<!--#include file="conn.asp"-->
<!--#include file="ProductList.asp"-->

<%
strCurrMenu=GetVariable("mnid")
%>
<%
if GetVariable("action")="save" then 
	'下订餐单
	if Session("ProductList")="" then
		Response.Write "<script language='javascript'>alert('Welcome you come to ，But you have not buy something！\n\nPlease return then choose shopping');</script>"
	end if

	strUser=GetFormVariable("txtuser")	
	strAddr=GetFormVariable("txtaddress")	
	strPhote=GetFormVariable("txtphote")	
	strEmail=GetFormVariable("txtemail")	
	strNote=GetFormVariable("txtnote")
	
	strProduct=""
	'输出商品列表
	ProductList = Session("ProductList")		'商品ID列表
	ProductCount=Session("ProductCount")		'商品数量列表
	PtCounts = Split(ProductCount, ",")
	strSQL="Select * From web_product Where id In (" & ProductList & "0)"
	Rs.open strSQL,conn,1,1
	money=0
	strProduct=strProduct & "<table width=100% border=0 cellspacing=1 cellpadding=0>" 
	strProduct=strProduct & "  <tr> " 
	strProduct=strProduct & "    <td width=11% align=center>No.</td>" 
	strProduct=strProduct & "    <td width=32% align=center>shopping name</td>" 
	strProduct=strProduct & "    <td width=21% align=right>Unit price</td>" 
	strProduct=strProduct & "    <td width=18% align=right>Amount</td>" 
	strProduct=strProduct & "    <td width=18% align=right>Total</td>" 
	strProduct=strProduct & "  </tr>" 
	For i=1 to rs.recordcount
		if rs.eof then exit for
		
		xj=Rs("p_price") * Cint(PtCounts(i-1))
		 money=money+xj
		strProduct=strProduct & "  <tr> " 
		strProduct=strProduct & "    <td align=center>" & i & "</td>" 
		strProduct=strProduct & "    <td align=center>" & trim(Rs("p_name")) & "</td>" 
		strProduct=strProduct & "    <td align=right>￥" & trim(Rs("p_price")) & "</td>" 
		strProduct=strProduct & "    <td align=right>" & PtCounts(i-1) & "</td>" 
		strProduct=strProduct & "    <td align=right>￥" & xj & "</td>" 
		strProduct=strProduct & "  </tr>" 
		rs.movenext
	next
	strProduct=strProduct & "<tr>     <td colspan=5><strong>Total：￥" & money & "</strong></td>  </tr></table>"

	
	strSQL="Insert Into web_product_order(m_id,mn_id,o_addr,o_phote,o_user,o_email,o_note,o_product,o_productList,o_productCount) Values("
	strSQL=strSQL & "0" & trim(Session("UserID")) & ","
	strSQL=strSQL & "0" & GetVariable("mnid") & ","
	strSQL=strSQL & "'" & strAddr & "',"
	strSQL=strSQL & "'" & strPhote & "',"
	strSQL=strSQL & "'" & strUser & "',"
	strSQL=strSQL & "'" & strEmail & "',"
	strSQL=strSQL & "'" & strNote & "',"
	strSQL=strSQL & "'" & strProduct & "',"	
	strSQL=strSQL & "'" & ProductList & "',"	
	strSQL=strSQL & "" & cint(ProductCount) & ")"	
	conn.execute strSQL,0,1
	Response.Write "<script language='javascript'>alert(' receive you order，Thank you!');</script>"
end if
%>

<%
'++++++++++++++++++++++++++++++购物车操作+++++++++++++++++++++++++++++++
'
'添加商品
if GetVariable("action")="add" then
	call AddProduct(GetVariable("spid"),CInt(GetVariable("PtCount")))
end if

'删除商品
if GetVariable("action")="modify" then
	call ModifyProduct(GetVariable("spid"),CInt(GetVariable("PtCount")))
end if

'清空购物车
if GetVariable("action")="clear" then
	call clearProduct()
end if

%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;">
<link rel="stylesheet" href="common/style.css" type="text/css">
<script language="JavaScript" src="common/JS_CheckForm.js"></script>
<script language="JavaScript">
function checkform(theform){
	if(!CheckEmpty(theform.txtuser, "Name")) return false;
	if(!CheckEmpty(theform.txtphote, "Telhone")) return false;
	if(!CheckEmpty(theform.txtaddress, "Address")) return false;
}

</script>
<script language="JavaScript">
	function PutWare(strID){
		Shopwin=window.open("shopping.asp?action=add&spid=" + strID+ "&PtCount=1&mnid=<%=strCurrMenu%>",'WareList','width=580,height=250,scrollbars=yes,resizable=yes');
		Shopwin.focus();
	}

</script>

</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" BodyBegin>
<!--#include file="top.asp"-->
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td colspan="2" height="2" valign="top"><img src="images/mega_1_047.gif" width="208" height="12"></td>
  </tr>
  <tr> 
    <td width="208" height="46" valign="top"> 
      <table width="208" border="0" cellspacing="0" cellpadding="0" height="100%">
        <tr> 
          <td width="198" height="44" bgcolor="f3f2f2" valign="top"> 
            <table width="198" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td> 
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="3" bgcolor="#CCCCCC">
                    <tr> 
                      <td bgcolor="#FFFFFF"></td>
                    </tr>
                  </table>
                  <table width="100%" border="0" cellspacing="1" cellpadding="0" height="5" bgcolor="#CCCCCC">
                    <tr> 
                      <td bgcolor="#FFFFFF"></td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr> 
                <td background="images/lin-bg.gif" height="33">
                  <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#FFFFFF">Productions 
                    Class</font></b></font></div>
                </td>
              </tr>
              <tr> 
                <td height="215"> 
                  <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr> 
                      <td height="168" valign="top">&nbsp; </td>
                    </tr>
                    <tr>
                      <td height="20"> 
                        <div align="center"> </div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <!--Link Begin-->
            <%
							isLink=GetKey("Enable",WebUserID,"link")
							if isLink="Yes" then
							%>
            <table width="198" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td> 
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="3" bgcolor="#CCCCCC">
                    <tr> 
                      <td bgcolor="#FFFFFF"></td>
                    </tr>
                  </table>
                  <table width="100%" border="0" cellspacing="1" cellpadding="0" height="5" bgcolor="#CCCCCC">
                    <tr> 
                      <td bgcolor="#FFFFFF"></td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr> 
                <td background="images/lin-bg.gif" height="33"> 
                  <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#FFFFFF">Links</font></b></font></div>
                </td>
              </tr>
              <tr> 
                <td height="215"> 
                  <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr> 
                      <td height="169" align="center"><script language="JavaScript" src="admin/link/link.asp"></script></td>
                    </tr>
                    <tr> 
                      <td height="20"> 
                        <div align="center"> </div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <%
							  end if
							  %>
            <!--Link End-->
          </td>
          <td width="9" height="44">&nbsp;</td>
        </tr>
      </table>
    </td>
    <td height="46" width="572" valign="top"> 
      <table width="96%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td height="21"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td background="images/lin-bg.gif" height="33" width="1%"><img src="images/left.gif" width="9" height="33"></td>
                <td background="images/lin-bg.gif" height="33" width="4%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#FFFFFF"><img src="images/ys-j2g.gif" width="14" height="14"></font></b></font></td>
                <td background="images/lin-bg.gif" height="33" width="91%"><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><b><font color="#FFFFFF">Order Form</font></b></font></td>
                <td background="images/lin-bg.gif" height="33" width="4%"> 
                  <div align="right"><img src="images/right.gif" width="10" height="33"></div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr> 
          <td height="18">&nbsp;</td>
        </tr>
        <tr> 
          <td> <table width="520" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="16">&nbsp;</td>
                <td width="490" height="300" valign="top"><table width="520" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="16">&nbsp;</td>
                      <td width="490" height="200" valign="top"> <table width="98%" height="267" border="0" cellpadding="0" cellspacing="1">
                          <tr> 
                            <td height="20" valign="top"> <table width="100%" height="20" border="0" cellpadding="0" cellspacing="1">
                                <tr> 
                                  <td height="27" bgcolor="#FFFFFF"><strong><font color="#FFFFFF">&nbsp;</font>You oredr the shooping list：</strong></td>
                                </tr>
                                <tr> 
                                  <td height="67" valign="top"> <table width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
                                      <tr> 
                                        <td width="42%" height="18" bgcolor="#EEEEEE"><strong>Name</strong></td>
                                        <td width="17%" align="center" bgcolor="#EEEEEE"><strong>Amount</strong></td>
                                        <td width="18%" align="center" bgcolor="#EEEEEE"><strong>Price</strong></td>
                                        <td width="23%" align="center" bgcolor="#EEEEEE"><strong>Delete 
                                          </strong></td>
                                      </tr>
                                      <SCRIPT language=javascript>
						<!--
							function SetCount(strID,strCount){
								if (CheckValue(strCount)){
									window.location="shopping.asp?action=modify" + "&spid=" + strID + "&PtCount=" + strCount;
								}
							}
							
							function DeleProduct(strID){
								window.location="?action=modify" + "&spid=" + strID + "&PtCount=0&mnid=<%=strCurrMenu%>";
							}
							
							function clearProduct(){
								window.location="shopping.asp?action=clear";
							}
							
							function buy(){
								window.open("dc.asp");
							}
							
						//-->
					  </SCRIPT>
                                      <%
				'输出商品列表
				ProductList = Session("ProductList")		'商品ID列表
				ProductCount=Session("ProductCount")		'商品数量列表
				PtCounts = Split(ProductCount, ",")
				
				strSQL="Select * From web_product Where id In (" & ProductList & "0)"
				set Rs=Server.CreateObject("ADODB.RecordSet")
				Rs.open strSQL,conn,1,1
				money=0
				if rs.recordcount=0 then 
					response.Write("<tr bgcolor=#FFFFFF><td colspan=4>Welcome you come to ，But you have not buy something！</td></tr>")
				end if
				For i=1 to rs.recordcount
					if rs.eof then exit for
				%>
                                      <tr> 
                                        <td height="18"><%=trim(Rs("p_name"))%></td>
                                        <td width="17%" align="center"><%=PtCounts(i-1)%> </td>
                                        <td width="18%" align="center"><%=trim(Rs("p_price"))%>/piece</td>
                                        <td width="23%" align="center"><a href="javascript:DeleProduct('<%=rs("id")%>')">Delete</a> 
                                          <%
				  xj=Rs("p_price") * Cint(PtCounts(i-1))
				  money=money+xj
				  %>
                                        </td>
                                      </tr>
                                      <%
					rs.movenext
				next
				%>
                                      <tr> 
                                        <td height="1" colspan="4" align="center" bgcolor="#EEEEEE"> 
                                          <table width="98%" border="0" cellspacing="0" cellpadding="0">
                                            <tr> 
                                              <td height="1" bgcolor="#666666"></td>
                                            </tr>
                                          </table></td>
                                      </tr>
                                      <tr> 
                                        <td colspan="2" bgcolor="F5F5F5"><a href="javascript:;" onClick="window.open('shopping.asp?mnid=<%=strCurrMenu%>','','width=580,height=250,scrollbars=yes,resizable=yes');">Look 
                                          Shooping bag<img src="images/buyprotect2.gif" border="0"></a></td>
                                        <td align="right" bgcolor="#EEEEEE">Total：</td>
                                        <td width="23%" align="center" bgcolor="#EEEEEE"><font color="#FF0000"><strong>$<%=money%></strong></font> </td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td valign="top"> <form name="orderform" method="post" onSubmit="return checkform(this)" action="?action=save&mnid=<%=strCurrMenu%>">
                                <table border="0" width="480" height="132" bordercolorlight="#000000" cellspacing="0" cellpadding="5" bordercolordark="#E8E8E8">
                                  <tr bgcolor="#CfCfCf"> 
                                    <td height="26" colspan="3"><strong>Input order form：</strong></td>
                                  </tr>
                                  <tr> 
                                    <td height="26" width="73" align="right">Name：</td>
                                    <td height="26" colspan="2"><input name="txtuser" type="text" id="txtuser3" size="18">
                                      *Must input!</td>
                                  </tr>
                                  <tr> 
                                    <td height="27"  align="right">Telephone：</td>
                                    <td height="27" colspan="2"><input name="txtphote" type="text" id="txtphote" size="18">
                                      *Must input </td>
                                  </tr>
                                  <tr> 
                                    <td height="26" width="73" align="right">E_mail：</td>
                                    <td height="26" colspan="2"><input type="text" name="txtemail" size="31"> 
                                    </td>
                                  </tr>
                                  <tr> 
                                    <td height="24" align="right">Address：</td>
                                    <td height="24" colspan="2"> <input type="text" name="txtaddress" size="31">
                                      *Must input</td>
                                  </tr>
                                  <tr> 
                                    <td height="1" align="right">Remark：</td>
                                    <td width="230" height="1"><textarea name="txtnote" cols="31" rows="4" id="txtnote" ></textarea></td>
                                    <td width="147" height="1">&nbsp;</td>
                                  </tr>
                                  <tr> 
                                    <td height="1" width="73" align="right">&nbsp;</td>
                                    <td height="1"><input type="submit" name="Submit" value="Submit"> 
                                      <input type="reset" name="Submit2" value="Reset"></td>
                                    <td height="1">&nbsp;</td>
                                  </tr>
                                </table>
                              </form></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
            </table> <br>
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="3" bgcolor="#CCCCCC">
  <tr> 
    <td bgcolor="#FFFFFF"></td>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="54" align="center" background="images/foot-bg.gif"> <font color="#FFFFFF">未设置<br></font><br>
      <script language="JavaScript" src="admin/count/counter.asp"></script></td>
  </tr>
</table>
<script language="JavaScript" src="common/init.js"></script>
</body>
</html>

