<!--#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)"
	Set rs=Server.CreateObject("ADODB.RecordSet")
	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
		dblPrice=Rs("p_price")
		if Session("m_UserID")<>"" then
			dblPrice=Rs("p_price1")
		End if
		
		xj=dblPrice * 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(dblPrice) & "</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>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="common/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="admin/common/JS_CheckForm.js"></script>
<script language="JavaScript">
function checkform(theform){
	if(!CheckEmpty(theform.key, "关键字")) return false;
}
</script>


<script language="JavaScript">
function checkorder(theform){
	if(!CheckEmpty(theform.txtuser, "联系人")) return false;
	if(!CheckEmpty(theform.txtphote, "联系电话")) return false;
	if(!CheckEmpty(theform.txtaddress, "详细地址")) return false;
}
</script>
</head>
<body bgcolor="#D4D0C8" leftmargin="0" topmargin="0" BodyBegin>
<!--#include file="top.asp" -->
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td colspan="5" rowspan="3"><table width="760" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="183" valign="top" background="images/index_r4_c1.gif"><table width="100%" height="421" border="0" cellpadding="0" cellspacing="0" background="images/index_r3_c1.gif" style="background-repeat:No-repeat";>
              <tr> 
                <td height="58" valign="top"><img src="images/dl.gif" width="183" height="49"></td>
              </tr>
              <tr> 
                <td height="59" align=center>
				<!--#include file="login.asp" --></td>
              </tr>
              <tr> 
                <td height="158" align="center"> <form action="pruduct.asp" method="post" name="search" id="search" onSubmit="return checkform(this)">
                    <TABLE cellSpacing=2 cellPadding=2 width="100%" align=center border=0>
                      <TR align="center"> 
                        <TD colspan="2" style="PADDING-LEFT: 6px"><strong><font style="color:white;font-size:16px">商品搜索</font></strong> 
                        </TD>
                      </TR>
                      <TBODY>
                        <TR> 
                          <TD align="right" style="PADDING-LEFT: 6px"><font color="#FFFFFF">关键字:</font></TD>
                          <TD style="PADDING-LEFT: 6px"><INPUT 
                  name=key id=searchkey2 size="13"> </TD>
                        </TR>
                        <TR> 
                          <TD width="31%" align="right" style="PADDING-LEFT: 6px"><font color="#FFFFFF">内 
                            容:</font></TD>
                          <TD style="PADDING-LEFT: 6px" width="69%"> <TABLE cellSpacing=0 cellPadding=0 border=0>
                              <TBODY>
                                <TR> 
                                  <TD><SELECT name=type>
                                      <OPTION value=1 selected>商品名称</OPTION>
                                      <OPTION value=2>内容简介</OPTION>
                                    </SELECT></TD>
                                  <TD> <TABLE id=T_select style="DISPLAY: none" cellSpacing=0 
                        cellPadding=0 border=0>
                                      <TBODY>
                                        <TR> 
                                          <TD></TD>
                                        </TR>
                                      </TBODY>
                                    </TABLE></TD>
                                </TR>
                              </TBODY>
                            </TABLE></TD>
                        </TR>
                        <TR> 
                          <TD width="31%" align="right" style="PADDING-LEFT: 6px"> 
                            <font color="#FFFFFF"> 价 格:</font></TD>
                          <TD style="PADDING-LEFT: 6px" width="69%">
						  <SELECT name=price>
                              <option value="20">20元以下</option>
                              <option value="30">30元以下</option>
                              <option value="50" selected>50元以下</option>
                              <option value="100">100元以下</option>
                              <option value="200">200元以下</option>
                              <option value="300">300元以下</option>
                              <option value="500">500元以下</option>
                              <option value="1000">1000元以下</option>
                              <option value="2000">2000元以下</option>
                              <option value="3000">3000元以下</option>
                            </SELECT>
							</TD>
                        </TR>
                        <TR> 
                          <TD width="31%" height=18 align="right" style="PADDING-LEFT: 6px"><font color="#FFFFFF">分 
                            类:</font></TD>
                          <TD style="PADDING-LEFT: 6px" width="69%"> <select name="class" style="width:90px">
                              <option value="">所有产品</option>
                              <%
								'开始输出分类
								strSQL="Select * From web_product_class Where c_parent=0 And mn_id=" & strCurrMenu & " Order by c_index"
								Set rsClass=Server.CreateObject("ADODB.RecordSet")
								rsClass.open strSQL,conn,1,1
								for i=1 to rsClass.recordcount
								%>
                              <option value="<%=rsClass("id")%>"><%=trim(rsClass("c_name"))%></option>
                              <%
									rsClass.movenext
								next
								rsClass.close
								%>
                            </select> </TD>
                        </TR>
                        <TR> 
                          <TD style="PADDING-LEFT: 6px" colSpan=2 height=18> <DIV align=center> 
                              <input type="submit" name="Submit3" value="搜 索">
                              <input type="reset" name="Submit4" value="重 置">
                              <br>
                            </DIV></TD>
                        </TR>
                    </TABLE>
                  </form></td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table></td>
          <td width="577" colspan="4" valign="top" bgcolor="#FFFFFF">
<TABLE cellSpacing=0 cellPadding=0 width=98% align=center border=0>
              <TBODY>
                <TR> 
                  <TD width="509"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr> 
                        <td width="44%">&nbsp;</td>
                        <td width="54%" align="right"><a href="javascript:;" onClick="window.open('shopping.asp?mnid=<%=strCurrMenu%>','','width=580,height=250,scrollbars=yes,resizable=yes');"><img src="images/buycar.gif" width="101" height="22" border="0"></a></td>
                        <td width="2%">&nbsp;</td>
                      </tr>
                    </table></TD>
                </TR>
                <TR> 
                  <TD bgColor=#ffffff><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>您预订的商品清单：</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"><strong>商品名称</strong></td>
                                                <td width="16%" align="center" bgcolor="#EEEEEE"><strong>数量</strong></td>
                                                <td width="18%" align="center" bgcolor="#EEEEEE"><strong>价格</strong></td>
                                                <td width="23%" align="center" bgcolor="#EEEEEE"><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
					dblPrice=Rs("p_price")
					if Session("m_UserID")<>"" then
						dblPrice=Rs("p_price1")
					End if
				%>
                                              <tr> 
                                                <td height="18"><%=trim(Rs("p_name"))%></td>
                                                <td width="16%" align="center"><%=PtCounts(i-1)%>件</td>
                                                <td width="18%" align="center"><%=dblPrice%>/件</td>
                                                <td width="23%" align="center"><a href="javascript:DeleProduct('<%=rs("id")%>')"><img src="images/shanchu.gif" width="36" height="15" border="0"></a> 
                                                  <%
				  xj=dblPrice * 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');">查看购物车<img src="images/buy.gif" alt="" width=60 height=20 border="0" align="absmiddle"></a></td>
                                                <td align="right" bgcolor="#EEEEEE">合计：</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 checkorder(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>填写订单：</strong></td>
                                          </tr>
                                          <tr> 
                                            <td height="26" width="73" align="right">联系人：</td>
                                            <td height="26" colspan="2"><input name="txtuser" type="text" id="txtuser3" value="<%=Session("m_RealName")%>" size="18">
                                              *必填</td>
                                          </tr>
                                          <tr> 
                                            <td height="27"  align="right">联系电话：</td>
                                            <td height="27" colspan="2"><input name="txtphote" type="text" id="txtphote" value="<%=Session("m_Tel")%>" size="18">
                                              *必填 </td>
                                          </tr>
                                          <tr> 
                                            <td height="26" width="73" align="right">E_mail：</td>
                                            <td height="26" colspan="2"><input name="txtemail" type="text" value="<%=Session("m_Email")%>" size="31"> 
                                            </td>
                                          </tr>
                                          <tr> 
                                            <td height="24" align="right">详细地址：</td>
                                            <td height="24" colspan="2"> <input name="txtaddress" type="text" value="<%=Session("m_Address")%>" size="31">
                                              *必填，尽量详细</td>
                                          </tr>
                                          <tr> 
                                            <td height="1" align="right">订购备注：</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="Submit5" value="提交"> 
                                              <input type="reset" name="Submit22" value="重置"></td>
                                            <td height="1">&nbsp;</td>
                                          </tr>
                                        </table>
                                      </form></td>
                                  </tr>
                                </table></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table></TD>
                </TR>
              </TBODY>
            </TABLE>
            
          </td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td><img src="images/spacer.gif" width="1" height="15" border="0" alt=""></td>
  </tr>
  <tr> 
    <td><img src="images/spacer.gif" width="1" height="210" border="0" alt=""></td>
  </tr>
  <tr> 
    <td colspan="5"><img name="index_r6_c1" src="images/index_r10_c1.gif" width="760" height="30" border="0" alt=""></td>
    <td><img src="images/spacer.gif" width="1" height="30" border="0" alt=""></td>
  </tr>
  <tr> 
    <td colspan="5" valign="top" bgcolor="#EF3A75"> <div align="center"> 
        <TABLE width=98% height="41" 
border=0 cellPadding=4 cellSpacing=5>
          <TBODY>
            <TR> 
              <TD height=19 align=center background="images/bg.gif"><FONT 
      color=#ffffff> &nbsp;购物流程:</FONT><FONT 
      color=#ffffff>选购-&gt;加入购物车-&gt;去收银台-&gt;确认收货人信息-&gt;选配送方式-&gt;确定下订单-&gt;下单后汇款-&gt;汇款确认-&gt;发货-&gt;完成</FONT></TD>
            </TR>
          </TBODY>
        </TABLE>
        公司地址：未知电话： <BR>E-Mail:test@test.com<BR>Copyright&copy;2004-2005 test All Rights Reserved.<br>ICP<br>
        <font color="#FFFFFF">您是本站第 
        <script language="JavaScript" src="admin/count/counter.asp"></script>
        位访问者</font></div></td>
    <td><img src="images/spacer.gif" width="1" height="135" border="0" alt=""></td>
  </tr>
</table>
<script language="JavaScript" src="common/init.js"></script>

</body>
</html>

