<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
else
if request.cookies("timesshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
end if
end if
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权添加修改商品信息！');history.go(-1);</script>"
response.End
end if
%>
<title>送货方式</title>
<%dim action,deliveryid
deliveryid=SafeRequest("id",1)
action=FormatSQL(SafeRequest("action",0))
set rs=server.CreateObject("adodb.recordset")

select case action

case "deliverysave"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权更改送货方式！');history.go(-1);</script>"
response.End
end if
rs.open "select * from delivery where deliveryid="&deliveryid,conn,1,3
rs("subject")=trim(request.form("subject"))
rs("deliveryidorder")=request.form("deliveryidorder")
rs("fee")=request.form("fee")
rs("methord")=0
rs("payfee")=request.form("payfee")
rs.update
rs.close
response.write "<script language=javascript>alert('成功修改了送货方式！');history.go(-1);</script>"
response.End

case "deliveryadd"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权添加送货方式！');history.go(-1);</script>"
response.End
end if
rs.open "select * from delivery",conn,1,3
rs.addnew
rs("subject")=trim(request.form("subject"))
rs("deliveryidorder")=request.form("deliveryidorder")
rs("fee")=request.form("fee")
rs("methord")=0
rs("payfee")=request.form("payfee")
rs.update
rs.close
response.write "<script language=javascript>alert('成功添加了新的送货方式！');history.go(-1);</script>"
response.End

case "deliverydel"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权删除送货方式！');history.go(-1);</script>"
response.End
end if
conn.execute "delete from delivery where deliveryid="&deliveryid
response.redirect "methord.asp?action=delivery"

case "zhifudel"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权删除支付方式！');history.go(-1);</script>"
response.End
end if
conn.execute "delete from delivery where deliveryid="&deliveryid
response.redirect "methord.asp?action=zhifu"

case "zhifusave"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权更改支付方式！');history.go(-1);</script>"
response.End
end if
rs.open "select * from delivery where deliveryid="&deliveryid,conn,1,3
rs("subject")=trim(request.form("subject2"))
rs("deliveryidorder")=request.form("deliveryidorder")
rs("methord")=1
rs.update
rs.close
response.redirect "methord.asp?action=zhifu"
response.End

case "zhifuadd"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权增加支付方式！');history.go(-1);</script>"
response.End
end if
rs.open "select * from delivery",conn,1,3
rs.addnew
rs("subject")=trim(request.form("subject2"))
rs("deliveryidorder")=request.form("deliveryidorder")
rs("methord")=1
rs.update
rs.close
response.redirect "methord.asp?action=zhifu"
response.End
end select
set rs=nothing
%>
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6699cc">
  <tr align="center" bgcolor="#6699cc" height="20"> 
    <td><a href="methord.asp?action=delivery"><font color="#FFFFFF">编辑送货方式</font></a></td>
    <td><a href="methord.asp?action=zhifu"><font color="#FFFFFF">编辑支付方式</font></a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td height="100" colspan="2"> <br> 
      <%select case action
	case "delivery"%>
      <table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="#6699cc" align="center" height="20"> 
          <td width="30%"><font color="#FFFFFF">送货方式</font></td>
          <td width="12%"><font color="#FFFFFF">送货费用</font></td>
          <td width="13%"><font color="#FFFFFF">加收百分比</font></td>
          <td width="20%"><font color="#FFFFFF">排 序</font></td>
          <td width="25%"><font color="#FFFFFF">操 作 </font></td>
        </tr>
        <%dim i,j
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from delivery where methord=0 order by deliveryidorder",conn,1,1
		i=rs.recordcount
		do while not rs.eof%>
        <tr align="center" bgcolor="#FFFFFF"> 
          <form name="form1" method="post" action="methord.asp?action=deliverysave&id=<%=rs("deliveryid")%>">
            <td><input name="subject" type="text" id="subject" size="14" value=<%=trim(rs("subject"))%>></td>
            <td><input name="fee" type="text" id="fee" size="4" value=<%=rs("fee")%> onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
              元</td>
            <td><input name="payfee" type="text" id="payfee" size="4" value=<%=rs("payfee")%> onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input name="deliveryidorder" type="text" id="deliveryidorder" size="2" value=<%=rs("deliveryidorder")%> onKeyPress	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
		onpaste		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input type="submit" name="Submit" value="修 改"> &nbsp;<a href="methord.asp?action=deliverydel&id=<%=rs("deliveryid")%>" onClick="return confirm('您确定进行删除操作吗？')"><font color="#FF6600">删除</font></a> 
            </td>
          </form>
        </tr>
        <%rs.movenext
		loop
		rs.close
		set rs=nothing%>
        <br>
        <tr> 
          <td height="20" bgcolor="#6699cc" colspan="5" align="center"><font color="#FFFFFF">增加送货方式</font></td>
        </tr>
        <tr align="center" bgcolor="#FFFFFF"> 
          <form name="form2" method="post" action="methord.asp?action=deliveryadd">
            <td><input name="subject" type="text" id="subject" size="14"></td>
            <td><input name="fee" type="text" id="fee" size="4" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
              元</td>
            <td><input name="payfee" type="text" id="payfee" size="4" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" 
		onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input name="deliveryidorder" type="text" id="deliveryidorder" value=<%=i+1%> size="2" onKeyPress	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
		onpaste		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input type="submit" name="Submit3" value="添 加"></td>
          </form>
        </tr>
      </table>
      <%case "zhifu"%>
      <table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr bgcolor="#6699cc" align="center" height="20"> 
          <td width="40%"><font color="#FFFFFF">支付方式</font></td>
          <td width="30%"><font color="#FFFFFF">排 序</font></td>
          <td width="30%"><font color="#FFFFFF">操作</font></td>
        </tr>
        <%set rs=server.CreateObject("adodb.recordset")
		  rs.open "select * from delivery where methord=1 order by deliveryidorder",conn,1,1
		  j=rs.recordcount
		  do while not rs.eof%>
        <tr align="center" bgcolor="#FFFFFF"> 
          <form name="form1" method="post" action="methord.asp?action=zhifusave&id=<%=rs("deliveryid")%>">
            <td><input name="subject2" type="text" id="subject2" size="14" value=<%=trim(rs("subject"))%>></td>
            <td><input name="deliveryidorder" type="text" id="deliveryidorder" size="2" value=<%=rs("deliveryidorder")%> onKeyPress	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
		onpaste		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input type="submit" name="Submit2" value="确 认">
                &nbsp;<a href="methord.asp?action=zhifudel&id=<%=rs("deliveryid")%>" onClick="return confirm('您确定进行删除操作吗？')"><font color="#FF6600">删除</font></a> 
             </td>
          </form>
          <%rs.movenext
		  loop
		  rs.close
		  set rs=nothing%>
        </tr>
		<tr><td height="20" bgcolor="#6699cc" colspan="4" align="center"><font color="#FFFFFF">增加支付方式</font></td></tr>
        <tr bgcolor="#FFFFFF" align="center"> 
          <form name="form1" method="post" action="methord.asp?action=zhifuadd">
            <td><input name="subject2" type="text" id="subject2" size="14"></td>
            <td><input name="deliveryidorder" type="text" id="deliveryidorder" value=<%=j+1%> size="2" onKeyPress	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
		onpaste		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
		ondrop		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))"></td>
            <td><input type="submit" name="Submit32" value="添 加"></td>
          </form>
        </tr>
      </table>
      <%end select%>
      </td>
  </tr>
</table>
<br>
<!--#include file="footer.asp"-->
<script>
	function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
</script>