<!--#include file="top.jsp"-->
<!--#include file="../inc/page.jsp"-->
<table width="762" border="0" align="center" cellpadding="2" cellspacing="0" style='BORDER-COLLAPSE: collapse;MARGIN: 3px'>
  <tr> 
    <td height="15" colspan="2"></td>
  </tr>
  <tr> 
    <td width="180" valign="top">
<!--#include file="left.jsp"-->
    </td>
<td width="582" height="280" valign="middle">
<%Select case request("abc")
case "add2"%>
<div align="center"> 
  <p><br>
          <a href="?">&gt;&gt;返回送货清单主页面</a>&nbsp;&nbsp;<br>
  </p>
</div>
<table width="96%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr> 
    <td height="207" valign="top" width="10%"> <form name="ffm" method="POST" action=?abc=add2>
        <table bgcolor=#CCCCCC border=0 cellpadding=3 cellspacing=1 
        width="350" align="center" class="9bang">
          <tbody>
            <tr bgcolor="#f1f1f1"> 
              <td class="008c5e">&gt;&gt;新增送货信息<br>
                (只需输入订单号即可，如果是电话订单请选中<font color="#FF3333">电话</font>后的选框)</td>
            </tr>
            <tr> 
              <td height="18" bgcolor=#FFFFFF class="008c5e"> <div align="center"> 
                  订单号<font color="#FF0000"><b> 
                  <input name="id" type="hidden" id="id" value="<%=Request("id")%>">
                  </b></font> 
                  <input name="bh" type="text" class="wenbenkuang" id="bh" size="15" maxlength="14">
                  <font color="#FF3333">电话</font> 
                  <input name="lx" type="checkbox" id="lx" value="1">
                  <input name="Submit" type="submit" class="go-wenbenkuang" value="提交">
                </div>
                </td>
            </tr>
          </tbody>
        </table>
        <br>
<%if request("bh")<>"" then
	  if request("lx")<>"" then
	  lx=1
	 set rs = conn.execute("select * from telorder where spn='"&saferequest("bh")&"'")
'sql= "select * from telorder where spn="&saferequest("bh")&""
'response.write(sql)
	  if rs.eof then
	  Response.Write("<script>alert(""找不到该订单信息，请确认您输入的订单号是否正确！"");history.back();</script>")
	  else
	  conn.execute("Insert into sh(bh,lx,dz,name,tel,bz,sjid)values("&rs("id")&","&lx&",'"&rs("t_add")&"','"&rs("t_name")&"','"&rs("t_tel")&"','"&rs("telbeizhu")&"',"&saferequest("id")&")")
      end if
	  rs.close
	  else
	  set rs = conn.execute("select * from cart where bh='"&saferequest("bh")&"'")
	  if rs.eof then
	  Response.Write("<script>alert(""找不到该订单信息，请确认您输入的订单号是否正确！"");history.back();</script>")
	  else
	  conn.execute("Insert into sh(bh,dz,name,tel,bz,sjid)values('"&saferequest("bh")&"','"&rs("dz")&"','"&rs("name")&"','"&rs("tel")&"','"&rs("bz")&"',"&saferequest("id")&")")
      end if
	  rs.close
	  end if
end if
'添加完成,开始显示数据 
set rs = conn.execute("select * from sh where sjid="&saferequest("id")&"")
%>
              <table bgcolor=#CCCCCC border=0 cellpadding=3 cellspacing=1 
        width="570" align="center" class="9bang">
                <%set rs = conn.execute("select * from sh where sjid="&saferequest("id")&" order by id desc")
		  if not rs.eof then %>
          <tr bgcolor="#FFFFFF"> 
            <td colspan="5" class="008c5e"> <div align="center">本次送货清单列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                <a href="sh_print.jsp?id=<%=rs("sjid")%>" target="_blank">&gt;&gt;打印本次送货清单</a></div></td>
          </tr>
          <tbody>
            <tr bgcolor="#f1f1f1"> 
              <td width=100 class="008c5e"> 
                <div align="center">订单号</div></td>
              <td width=225 class="008c5e"> <div align="center">送货地址</div></td>
              <td width=75 class="008c5e"> <div align="center">收货人</div></td>
                    <td width=150 class="008c5e"> 
                      <div align="center">联系电话</div></td>
              <td width=35 align="center" class="008c5e">删除</td>
            </tr>
            <% While NOT rs.EOF %>
            <tr> 
              <td bgcolor=#FFFFFF width=100 height="18"> 
                <div align="center"> 
                  <%if rs("lx")=1 then Response.Write ("电话")%>
                  <%=rs("bh")%></div></td>
              <td bgcolor=#ffffff width=225 height="18"> <%=rs("dz")%></td>
              <td bgcolor=#ffffff width=75 height="18"> <div align="center"><%=rs("name")%></div></td>
              <td height="18" bgcolor=#FFFFFF> <%=rs("tel")%></td>
              <td width="35" rowspan="2" bgcolor=#ffffff> <div align="center"><a href=del.jsp?x=a&id=<%=rs("id")%>>删除</a></div></td>
            </tr>
            <tr> 
              <td bgcolor=#FFFFFF height="18">&nbsp;</td>
              <td height="18" colspan="3" bgcolor=#ffffff>备注：<%=rs("bz")%></td>
            </tr>
<%rs.MoveNext()
Wend
end if%>
          </tbody>
        </table>
        <input type="hidden" name="MM_insert" value="true">
      </form></td>
  </tr>
</table>
</body>
</html>
<%rs.Close:set rs=nothing
case "add"
if request("add")="yes" and saferequest("n")<>"" and saferequest("y")<>"" and saferequest("r")<>"" then
conn.execute("Insert into sh(n,y,r,name)values('"&saferequest("n")&"','"&saferequest("y")&"','"&saferequest("r")&"','"&username&"')")
Response.redirect "?abc=add2&id="&conn.execute("select id from sh_sj where n='"&saferequest("n")&"' and y='"&saferequest("y")&"' and r='"&saferequest("r")&"'")(0)&""
end if%>
  <form method="POST" action="?abc=add&add=yes">
        第一步：录入送货清单日期<br>
        <br>
        <table bgcolor=#CCCCCC border=0 cellpadding=3 cellspacing=1 
        width="400" align="center" class="9bang">
          <tbody>
            <tr> 
              <td bgcolor=#f1f1f1 class="008c5e" width="100" height="25" align="center"><font size="2">送货清单日期</font></td>
              <td width="300" height="25" bgcolor=#FFFFFF class="008c5e"> <font size="2"> 
                &nbsp;
                <input name="n" type="text" class="wenbenkuang" id="n" value="<%=year(date())%>" size="8" maxlength="4">
                年 
                <input name="y" type="text" class="wenbenkuang" id="y" value="<%=month(date())%>" size="4" maxlength="2">
                月
                <input name="r" type="text" class="wenbenkuang" id="r" value="<%=day(date())%>" size="4" maxlength="2">
                日 </font></td>
            </tr>
            <tr> 
              <td bgcolor=#f1f1f1 class="008c5e" width="100" height="25">&nbsp;</td>
              <td width="300" height="25" bgcolor=#ffffff class="008c5e"> <font size="2">&nbsp; 
                <input name="submit" type="submit" class="go-wenbenkuang" value="提交">
                <input name="Reset" type="reset" class="go-wenbenkuang" value="重填">
                <input name="Submit" type="button" class="go-wenbenkuang" onclick="javascript:window.history.go(-1)" value="返回">
                </font></td>
            </tr>
          </tbody>
        </table>
        </form>
<%case else
if request("del")="yes" then
conn.execute("Delete from sh where sjid="&saferequest("id")&"")
conn.execute("Delete from sh_sj where id="&saferequest("id")&"")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from sh where name='"&username&"' order by id desc "
rs.open sql,conn,3,1
if rs.eof then 
response.write "没有！"
end if 
page1("15")%>
</div>
<table width="500" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr align="center" valign="top"> 
      <td> <div align="center"></div>
        <a href="?abc=add">&gt;&gt;添加新送货清单</a></td>
    </tr>
</table>
<table width="500" border="0" align="center" bgcolor="#CCCCCC" cellpadding="0" cellspacing="1">
  <tr bgcolor="#f1f1f1" valign="middle" align="center"> 
    <td width="100" height="20"> 
      <div align="center">id</div></td>
    <td width="200" height="20"> 
      <div align="center">送货日期</div></td>
    <td width="100" height="20">修改</td>
    <td width="100">删除</td>
  </tr>
<%i=1
do while not rs.eof and i<=rs.pagesize%>
  <tr bgcolor="#FFFFFF" valign="middle" align="center"> 
      <td width="100" > <a href="sh_print.jsp?id=<%=rs("id")%>" target="_blank">
<% =rs("id")%></a>
      </td>
    <td width="200"> 
      <div align="center"> <%=rs("n")%>年<%=rs("y")%>月<%=rs("r")%>日</div></td>
    <td width="100"> <a href="?abc=add2&id=<% =rs("id")%>">修改</a></td>
    <td width="100"><a href="?del=yes&id=<% =rs("id")%>&page=<%= page %>">删除</a></td>
  </tr>
<%i=i+1
rs.MoveNext                                              
loop%>
  <tr bgcolor="#FFFFFF" valign="middle" align="center"> 
      <td height="30" colspan="4" >
<%page2("")
rs.close:set rs=nothing%> </td>
  </tr>
</table>
<%End Select%>
</td>
  </tr>
</table>
<!--#include file="../bottom.jsp"-->
