<%
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0
%>
<!--#include file="conn2.asp"-->
<!--#include file="check2.asp"-->
<%
strtime=request.querystring("strtime")
if len(strtime)>10 and isdate(strtime) then
	sql=" insert into sh_peishou_backup(diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime) select diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime from sh_peishou "
	conn.execute(sql)

	conn.execute("delete * from sh_peishou")
	
	sql=" insert into sh_peishou(diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime) select diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime from sh_peishou_backup where backuptime=#"&strtime&"# "
	conn.execute(sql)
	
	conn.execute("delete * from sh_peishou_backup where backuptime=#"&strtime&"# ")
	
	response.write "<script language=JavaScript>" & "alert('成功还原之前（"&strtime&"）的收费标准！');" & "window.location.href='peishou.asp';" & "</script>"
	conn.close
	response.end
end if



ok=request.form("ok")
if ok="ok" then
	sql=" insert into sh_peishou_backup(diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime) select diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,self1,self2,self3,self4,backuptime from sh_peishou "
	conn.execute(sql)
	
	conn.execute("delete * from sh_peishou")
	
	b_time=now()
	for i=1 to request.form("maxi")
		diquid=trim(request.form("diquid"&i))
		sendkindid=trim(request.form("sendkindid"&i))
		
		qibuweight=trim(request.form("qibuweight"&i))
		qibuprice=trim(request.form("qibuprice"&i))
		chaoweight=trim(request.form("chaoweight"&i))
		chaoprice=trim(request.form("chaoprice"&i))
		freemoney=trim(request.form("freemoney"&i))

		if qibuweight="" then qibuweight="0"
		if qibuprice="" then qibuprice="0"
		if chaoweight="" then chaoweight="0"
		if chaoprice="" then chaoprice="0"
		if freemoney="" then freemoney="0"

		if qibuweight<>"0" then
		sql="insert into sh_peishou(diquid,sendkindid,qibuweight,qibuprice,chaoweight,chaoprice,freemoney,backuptime) values('"&diquid&"','"&sendkindid&"','"&qibuweight&"','"&qibuprice&"','"&chaoweight&"','"&chaoprice&"','"&freemoney&"','"&b_time&"')"
		conn.execute(sql)
		end if
	next
	response.write "<script language=JavaScript>" & "alert('成功保存设置！');" & "window.location.href='peishou.asp';" & "</script>"
	conn.close
	response.end
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
td{font-size:9pt}
body {
	margin-top: 5px;margin-left: 2px;
}
.style3 {color: #A84E22; font-weight: bold; }
#admin{
	BORDER-COLLAPSE: collapse;
	border-top-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-left-style: solid;
	border-top-color: #dddddd;
	border-left-color: #dddddd;
}#admin td {
	line-height: 24px;
	padding-left: 10px;
	padding-top: 2px;
	padding-bottom: 2px;
	color: #333333;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-right-style: solid;
	border-bottom-style: solid;
	border-right-color: #dddddd;
	border-bottom-color: #dddddd;
}
-->
</style>
</head>
<BODY bgcolor="#fcfcfc">
<table height="5"><tr><td></td></tr></table>
<TABLE width=93% border=0 align="center" cellPadding=0 cellSpacing=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" >
  <TBODY>
    <TR>
      <TD  height="30" bgColor=#dddddd>&nbsp;已选择了“按商品重量计算运费方式”，请按下面3步完成设置：
	  <B><a href='diqu.asp'>1、设置配送省份/地区</a>&nbsp;&nbsp;&nbsp;&nbsp;
	  <a href='sendkind2.asp'>2、设置送货方式</a>&nbsp;&nbsp;&nbsp;&nbsp;
	  <a href='peishou.asp'>3、设置配送收费标准</a></B></TD>
    </TR>
  </TBODY>
</TABLE>

<TABLE width=93% border=0 align="center" cellPadding=0 cellSpacing=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" >
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;3、设置配送收费标准</font></B></font> (在这里会按前面2步所设置的进行组合 | 如果该地区没有相应送货方式，留空即可。)</TD>
      <TD bgColor=#f4f5fd height=25>&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
		  


<table width="93%"  border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#b1bfee">
  <form action="peishou.asp" method="post" name="theForm" onSubmit="return Juge()">
    <%
	i=1
	sql="select * from sh_diqu order by id"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	if rs.bof or rs.eof then
	else

		do while not rs.eof
		diquid=rs("id")
		diqu=rs("diqu")

%>
    <tr bgcolor="#FFFFFF" > 
      <td width="10%" valign="middle" align="center"><b><%=diqu%></b></td>
      <td width="90%" valign="middle">
		<%
		sql2="select * from sh_sendkind order by id"
		set rs2=server.createobject("adodb.recordset")
		rs2.open sql2,conn,1,1
		if rs2.bof or rs2.eof then
		else
			do while not rs2.eof
				sendkindid=rs2("id")
				sendkind=rs2("sendkind")
				response.write "<font color='#0000ff'>"&sendkind&"：</font><br>"
				
					sql3="select * from sh_peishou where diquid="&diquid&"  and sendkindid="&sendkindid&" "
					set rs3=server.createobject("adodb.recordset")
					rs3.open sql3,conn,1,1
					if rs3.bof or rs3.eof then
						qibuweight=""
						qibuprice=""
						chaoweight=""
						chaoprice=""
						freemoney=""
						%>
						<input type='hidden' name='diquid<%=i%>' value='<%=diquid%>'>
						<input type='hidden' name='sendkindid<%=i%>' value='<%=sendkindid%>'>
						<font color='#777777'>
						起步重量:<input type='text' name='qibuweight<%=i%>' value='<%=qibuweight%>' size='7'>克&nbsp;&nbsp;起步价格:<input type='text' name='qibuprice<%=i%>' value='<%=qibuprice%>' size='6'>元&nbsp;&nbsp;&nbsp;&nbsp;
						每超重量:<input type='text' name='chaoweight<%=i%>' value='<%=chaoweight%>' size='7'>克&nbsp;&nbsp;超重价格:<input type='text' name='chaoprice<%=i%>' value='<%=chaoprice%>' size='6'>元</font><br>
						<font color='#ff7777'>购满金额:<input type='text' name='freemoney<%=i%>' value='<%=freemoney%>' size='7'>元免运费</font>
						<%
					else
						qibuweight=rs3("qibuweight")
						qibuprice=rs3("qibuprice")
						chaoweight=rs3("chaoweight")
						chaoprice=rs3("chaoprice")
						freemoney=rs3("freemoney")
						now_backuptime=rs3("backuptime")
						%>
						<input type='hidden' name='diquid<%=i%>' value='<%=diquid%>'>
						<input type='hidden' name='sendkindid<%=i%>' value='<%=sendkindid%>'>
						<font color='#333333'>
						起步重量:<input type='text' name='qibuweight<%=i%>' value='<%=qibuweight%>' size='7'>克&nbsp;&nbsp;起步价格:<input type='text' name='qibuprice<%=i%>' value='<%=qibuprice%>' size='6'>元&nbsp;&nbsp;&nbsp;&nbsp;
						每超重量:<input type='text' name='chaoweight<%=i%>' value='<%=chaoweight%>' size='7'>克&nbsp;&nbsp;超重价格:<input type='text' name='chaoprice<%=i%>' value='<%=chaoprice%>' size='6'>元</font><br>
						<font color='#ff7777'>购满金额:<input type='text' name='freemoney<%=i%>' value='<%=freemoney%>' size='7'>元免运费</font>
						<%
					end if
					rs3.close
					set rs3=nothing
					
				response.write "<br><br>"
			
			i=i+1
			rs2.movenext
			loop
		end if	
		rs2.close
		set rs2=nothing
		%>
      </td>
    </tr>
    <%
	    rs.movenext
		loop
	end if
	rs.close
	set rs=nothing
%>

    <tr>
      <td height="45" bgcolor="#FFFFFF" >&nbsp;</td>
      <td bgcolor="#FFFFFF" ><input name="maxi" type="hidden" value="<%=i%>"> 
        <input name="ok" type="hidden" value="ok"> &nbsp;<input name=action type="submit" value="保存设置">
        </td>
    </tr>
  </form>
</table>
</td></tr>
</table> </td></tr> </table> 
         
<table width="93%" border="0" align="center">
  <tr> 
    <td height="60" valign="top" style="line-height:180%;">之前几次设置的收费标准：(可以点击下面相应时间的链接来还原之前的收费标准。上面显示的是“<%=now_backuptime%>”保存的) <br>
<%
sql="select top 8 backuptime from sh_peishou_backup group by backuptime order by backuptime desc"
set rs=conn.execute(sql)
if rs.bof or rs.eof then
	response.write "没有记录。"
else
	do while not rs.eof
		backuptime=rs("backuptime")
		response.write "<a href='peishou.asp?strtime="&Server.URLEncode(backuptime)&"' onclick=""return confirm('还原 "&backuptime&" 的吗?')"">"&backuptime&"保存的</a><br>"
	rs.movenext
	loop
end if
rs.close
%>	
	</td>
  </tr>
</table>

<script language="JavaScript">
<!--
function Juge()
{

<%for i=1 to i-1%>
  if (isNaN(theForm.qibuweight<%=i%>.value))
  {
    alert("起步重量要为数字!");
    theForm.qibuweight<%=i%>.focus();
    return (false);
  }
  if (isNaN(theForm.qibuprice<%=i%>.value))
  {
    alert("起步价要为数字!");
    theForm.qibuprice<%=i%>.focus();
    return (false);
  }
  if (isNaN(theForm.chaoweight<%=i%>.value))
  {
    alert("超重量要为数字!");
    theForm.chaoweight<%=i%>.focus();
    return (false);
  }
  if (isNaN(theForm.chaoprice<%=i%>.value))
  {
    alert("超重量价要为数字!");
    theForm.chaoprice<%=i%>.focus();
    return (false);
  }
  if (isNaN(theForm.freemoney<%=i%>.value))
  {
    alert("购满金额要为数字!");
    theForm.freemoney<%=i%>.focus();
    return (false);
  }
<%next%>


   if(confirm("确认要提交保存设置吗?"))
      return true
   else
      return false;
}
//-->
</script>
<br><br><br><br>
</body></html>
