<!--#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('欢迎您来到，您尚未点订购任何商品！\n\n请您先到产品展示区选择您想要的商品');</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>序号</td>" 
	strProduct=strProduct & "    <td width=32% align=center>商品名</td>" 
	strProduct=strProduct & "    <td width=21% align=right>单价</td>" 
	strProduct=strProduct & "    <td width=18% align=right>数量</td>" 
	strProduct=strProduct & "    <td width=18% align=right>小计</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>总计：￥" & 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('已经接收您的订单，谢谢您惠顾!');</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 xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="images/css.css" rel="stylesheet" type="text/css" />
<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.key, "关键字")) return false;
	if(!CheckInteger(theform.price1, "最低价格")) return false;
	if(!CheckInteger(theform.price2, "最高价格")) return false;
}
</script>

<script language="JavaScript">
function checkform(theform){
	if(!CheckEmpty(theform.txtuser, "联系人")) return false;
	if(!CheckEmpty(theform.txtphote, "联系电话")) return false;
	if(!CheckEmpty(theform.txtaddress, "详细地址")) return false;
}
</script>

<style type="text/css">
<!--
.t4 {font-family: "宋体";
	font-size: 12px;
	font-weight: bold;
	color: #000000;
	text-decoration: none;
}
.t11 {font-family: "宋体";
	font-size: 12px;
	font-weight: normal;
	color: #FFFF00;
	text-decoration: none;
	line-height: 18px;
}
-->
</style>
</head>

<body>
<!--#include file="top.asp" -->

<table width="782" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="205" valign="top" background="images/n000_09.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="29" background="images/eo_07.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="13%">&nbsp;</td>
                  <td width="87%" class="t1">友情链接</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr align="center">
                  <td width="100%" scope="row"><table width="76%" border="0" align="center" cellpadding="7" cellspacing="0">
                      <tr>
                        <td height="107" align="center"  valign="top" class="t1"> 　 <span class="cn"><br>
                              <script language="JavaScript" src="admin/link/link.asp"></script>
                        </span></td>
                      </tr>
                    </table>
                      <span class="t1">
                      <%
							  end if
							  %>
                      <!--Link End-->
                    </span></td>
                </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="581" valign="top"><table width="577" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="29" background="images/n000_08.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="7%">&nbsp;</td>
            <td width="93%" class="t2">订购商品</td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#EFEFEF">
        <tr>
          <td valign="top" bgcolor="#FFFFFF"><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" class="cn"><strong><font color="#FFFFFF">&nbsp;</font>您预订的商品清单：</strong></td>
                  </tr>
                  <tr>
                    <td height="67" valign="top"><table width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
                        <tr>
                          <td width="43%" height="18" bgcolor="#EEEEEE" class="cn"><strong>商品名称</strong></td>
                          <td width="16%" align="center" bgcolor="#EEEEEE" class="cn"><strong>数量</strong></td>
                          <td width="18%" align="center" bgcolor="#EEEEEE" class="cn"><strong>价格</strong></td>
                          <td width="23%" align="center" bgcolor="#EEEEEE" class="cn"><strong>删除 </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>欢迎您来到，您尚先购任何商品！</td></tr>")
				end if
				For i=1 to rs.recordcount
					if rs.eof then exit for
				%>
                        <tr>
                          <td height="18" class="cn"><%=trim(Rs("p_name"))%></td>
                          <td width="16%" align="center" class="cn"><%=PtCounts(i-1)%>件</td>
                          <td width="18%" align="center" class="cn"><%=trim(Rs("p_price"))%>/件</td>
                          <td width="23%" align="center" class="cn"><a href="javascript:DeleProduct('<%=rs("id")%>')"><img src="images/shanchu.gif" width="36" height="15" border="0"></a>
                              <%
				  xj=Rs("p_price") * Cint(PtCounts(i-1))
				  money=money+xj
				  %>
                          </td>
                        </tr>
                        <%
					rs.movenext
				next
				%>
                        <tr class="t1">
                          <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" class="cn"><a href="javascript:;" onClick="window.open('shopping.asp?mnid=<%=strCurrMenu%>','','width=580,height=250,scrollbars=yes,resizable=yes');">查看购物车<img src="images/buy.gif" alt="" width=60 height=20 border="0" align="absmiddle"></a></td>
                          <td align="right" bgcolor="#EEEEEE" class="cn">合计：</td>
                          <td width="23%" align="center" bgcolor="#EEEEEE" class="cn"><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" class="t1"><strong class="cn">填写订单：</strong></td>
                    </tr>
                    <tr class="cn">
                      <td width="73" height="26" align="right" class="t1">联系人：</td>
                      <td height="26" colspan="2" class="t1"><input name="txtuser" type="text" id="txtuser3" size="18">
                        *必填</td>
                    </tr>
                    <tr class="cn">
                      <td height="27"  align="right" class="t1">联系电话：</td>
                      <td height="27" colspan="2" class="t1"><input name="txtphote" type="text" id="txtphote" size="18">
                        *必填 </td>
                    </tr>
                    <tr class="cn">
                      <td width="73" height="26" align="right" class="t1">E_mail：</td>
                      <td height="26" colspan="2" class="t1"><input type="text" name="txtemail" size="31">
                      </td>
                    </tr>
                    <tr class="cn">
                      <td height="24" align="right" class="t1">详细地址：</td>
                      <td height="24" colspan="2" class="t1"><input type="text" name="txtaddress" size="31">
                        *必填，尽量详细</td>
                    </tr>
                    <tr>
                      <td height="1" align="right" class="cn">订购备注：</td>
                      <td width="230" height="1" class="cn"><textarea name="txtnote" cols="31" rows="4" id="txtnote" ></textarea></td>
                      <td width="147" height="1" class="t1">&nbsp;</td>
                    </tr>
                    <tr>
                      <td width="73" height="1" align="right" class="cn">&nbsp;</td>
                      <td height="1" class="cn"><input type="submit" name="Submit" value="提交">
                          <input type="reset" name="Submit2" value="重置"></td>
                      <td height="1" class="t1">&nbsp;</td>
                    </tr>
                  </table>
              </form></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<!--#include file="end.asp" -->
<script language="JavaScript" src="common/init.js"></script>
<script language=Javascript src="common/tranbig5.Js"></script>
</body>
</html>


