⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopcart.asp

📁 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会
💻 ASP
字号:
<%@ Language=VBScript%>
<%
Response.Buffer=true
Response.Expires=0
%>
<!-- #include file="dsn_root.asp" -->
<!-- #include file="func.inc.asp" -->

<%
set cn = Server.CreateObject("ADODB.Connection")
cn.Open(mycnstr)
set rs = Server.CreateObject("ADODB.Recordset")
set rs2 = Server.CreateObject("ADODB.Recordset")


prono = Request.QueryString("prono")
flag = Request.QueryString("flag")
delno = Request.QueryString("delno")
method = Request.QueryString("method")


tot = Request.Cookies("ordercount")
if tot = "" then tot = 0


if method="88" then

	sql = "select top 1 email from sys_dept order by flag desc"
	rs.Open sql,cn,0,1,1
	if not rs.EOF then
		sys_email=trim(rs("email"))
	end if
	rs.Close

	sql = "select max(keyno) from shopcart"
	rs.Open sql,cn,0,1,1
	if not rs.EOF and rs(0) > 0 then
		keyno = rs(0) + 1
	else
		keyno = 1
	end if
	rs.Close

	cn.BeginTrans
	username = fixedReplaceStr(Request.Form("username"), 10)
	corpname = fixedReplaceStr(Request.Form("corpname"), 50)
	address = fixedReplaceStr(Request.Form("address"), 60)
	email = fixedReplaceStr(Request.Form("email"), 60)
	phone = fixedReplaceStr(Request.Form("phone"), 20)
	content = fixedReplaceStr(Request.Form("content"), "")
	
	rs2.Open "shopdetail",cn,3,3
	sum_sl = 0
	for i = 1 to tot
		c = cstr(i)
		if Request.Cookies("prono")(c)<>"" then
			if Request.Cookies("amount")(c)>0 then
				rs2.AddNew
				rs2("cartno") = keyno
				rs2("prono") = Request.Cookies("prono")(c)
				rs2("title") = Request.Cookies("title")(c)
	   			if Request.Cookies("price")(c) = "" then dj = 0 else dj = Request.Cookies("price")(c)
				rs2("price") = dj
				rs2("amount") = Request.Cookies("amount")(c)

				sum_sl = sum_sl + Request.Cookies("amount")(c)
				orderdetail = orderdetail + Request.Cookies("title")(c) + "/" + Request.Cookies("amount")(c) + chr(13) + chr(10)
			end if
		end if	
	next
	if sum_sl > 0 then	
		rs.Open "shopcart",cn,3,3
		rs.AddNew
		rs("keyno")=keyno
		rs("username") = username
		rs("corpname") = corpname
		rs("address") = address
		rs("phone") = phone
		rs("email") = email
		rs("state") = "0"
		rs("content") = content
		rs("creadate") = now()
		rs("ipaddress") = Request.ServerVariables("Remote_HOST")
		rs("sysemail") = sys_email
		rs.Update
		rs2.UpdateBatch
		cn.CommitTrans
		rs.close
		rs2.Close
		 	

		txt="这个一封来自"+Request.ServerVariables("Http_HOST")+"的在线定购邮件!"
		mailstr=txt+ chr(13) + chr(10)
		mailstr=mailstr + "姓名:" + username + chr(13) + chr(10)
		mailstr=mailstr + "单位:" + corpname + chr(13) + chr(10)
		mailstr=mailstr + "电话:" + phone + chr(13) + chr(10)
		mailstr=mailstr + "地址:" + address + chr(13) + chr(10)
		mailstr=mailstr + "Email:" + email + chr(13) + chr(10)
		mailstr=mailstr + "IP地址:" + Request.ServerVariables("Remote_HOST") + chr(13) + chr(10)
		mailstr=mailstr + "说明:" + content + chr(13) + chr(10) + chr(13) + chr(10)
		mailstr=mailstr + "定购商品:" + chr(13) + chr(10) + orderdetail + chr(13) + chr(10)

		Set msg = Server.CreateObject("JMail.Message")
		msg.silent = true
		msg.Logging = true
		msg.Charset = "gb2312"
		msg.MailServerUserName = "public@ibw.com.cn"   '输入smtp服务器验证登陆名 
		msg.MailServerPassword = "wangxin108"          '输入smtp服务器验证密码   (用户Email帐号对应的密码)
		msg.From ="public@ibw.com.cn" 
		msg.FromName = myname							 '发件人姓名
		msg.AddRecipient sys_email						 '收件人Email
		'msg.AddRecipientBCC  "napoleon@ibw.com.cn"	  '密件传送'
		msg.Subject = Request.ServerVariables("Http_HOST")+"在线定购"&now()		  '信件主题
		msg.Body =mailstr						'正文
		msg.Send ("smtp.sina.net")               'smtp服务器地址(企业邮局地址)
		set msg = nothing
		
	else
		cn.RollbackTrans
	end if

	set rs = nothing
	set rs2 = nothing
	cn.Close
	set cn = nothing


	Response.Cookies("ordercount") = ""
	Response.Redirect("shopcart.asp?flag=1")
end if



if method = "0" then	'清空购物车
	Response.Cookies("ordercount") = ""
	Response.Redirect "shopcart.asp"
end if	


if delno <> "" then			'删除商品'
	for i = 1 to cint(tot)
		c = cstr(i)
		if delno = Request.Cookies("prono")(c) then
			Response.Cookies("prono")(c) = ""
			Response.Redirect "shopcart.asp"
		end if
	next
end if	


if method="99" then					'修改数量
	for i = 1 to tot
		c = cstr(i)
		if isnumeric(Request.Form("amount"+c)) then
			Response.Cookies("amount")(c) = Request.Form("amount"+c)
			Response.Redirect "shopcart.asp"
		end if	
	next
end if


if prono<>"" and isnumeric(prono) then			'新增商品'
	'首先查找商品的名称和价格
	sql = "select title,price from product where state='1' and prono=" & prono
	rs.Open sql,cn,0,1,1
	if not rs.EOF then
		title = rs("title")
		price = rs("price")
	else
		response.end
	end if
	rs.Close
	set rs = nothing
	set rs2 = nothing
	cn.Close
	set cn = nothing

	'检查此商品是否已经订购过了,如果是,增加已订购的数量,否则新增一条订购记录
	bz = 0
	for i = 1 to tot
		c = cstr(i)
		if prono = Request.Cookies("prono")(c) then
			Response.Cookies("amount")(c) = Request.Cookies("amount")(c)+1
			bz = 1
			exit for
		end if
	next

	if bz <> 1 then
		tot = tot + 1
		c = cstr(tot)
		Response.Cookies("ordercount") = tot
		Response.Cookies("prono")(c) = prono
		Response.Cookies("title")(c) = title
		Response.Cookies("amount")(c) = 1
		Response.Cookies("price")(c) = price
	end if


	Response.Redirect "shopcart.asp"
end if
%>

<!-- #include file="begin.asp" -->

<table width="1002" height="137" border="0" cellpadding="0" cellspacing="0" background="images/top_15.jpg">
  <tr> 
    <td width="779"><img src="images/o1.jpg" width="779" height="137"></td>
    <td width="223">&nbsp;</td>
  </tr>
</table>
<table width="1002" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="162" align="center" valign="top" bgcolor="#F4F4F4">
		<!-- #include file="inc_search.asp" //-->
		<!-- #include file="inc_contact.asp" //-->
	</td>
    <td width="617" valign="top" background="images/index4_15.jpg"> <table width="617" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="13" height="31" background="images/index4_11.jpg"><img src="images/list2.jpg" width="5" height="31"></td>
          <td width="604" valign="bottom" background="images/index4_11.jpg"> <table width="30%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="12%" height="17"><img src="images/list.gif" width="14" height="13"></td>
                <td width="88%">网上订购</td>
              </tr>
              <tr> 
                <td height="4" colspan="2"> </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td colspan="2" align="center" valign="top">
		    <table width="95%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="15"> </td>
              </tr>
            </table>
            <table width="95%" border="0" cellspacing="1" cellpadding="1">
			  <form name=form1 method=post action="shopcart.asp?method=99">
					
				<tr height=20 align="center" bgcolor="#056112"> 
				  <td width=35><font color="#FFFFFF">删除</font></td>
				  <td><font color="#FFFFFF">产品名称</font></td>
				  <td width="99"><font color="#FFFFFF"> 价格 </font></td>
				  <td width="50"><font color="#FFFFFF">数量</font></td>
				  <td width="60"><font color="#FFFFFF">新数量</font></td>
				  <td width="99"><font color="#FFFFFF">金额</font></td>
				</tr>
				  <%
					sum_je = 0
					for i = 1 to tot
						c = cstr(i)
						if Request.Cookies("prono")(c) <> "" then
							if Request.Cookies("amount")(c) = "" then sl = 0 else sl = Request.Cookies("amount")(c)
							if Request.Cookies("price")(c) = "" then dj = 0 else dj = Request.Cookies("price")(c)
							sum_je = sum_je + sl * dj		   			

							if (i mod 2) = 1 then
								Response.Write("<tr>")
							else
								Response.Write("<tr bgcolor='#F6FCEA'>")
							end if	
						%>
						<td width="35" align=right height=26>
							<div align=center><img onclick="delrec('<%=Request.Cookies("prono")(c)%>')" src="admin/images/delete.gif"></div>
						</td>
						<td align=left><%=Request.Cookies("title")(c)%></td>
						<td align="right"><%=dj%></td>
						<td align="right"><%=sl%></td>
						<td align="right"><input type=text value="<%=sl%>" size=4 maxlength=5 name="amount<%=c%>"></td>
						<td align="right"><%=sl*dj%></td>
						</tr>
						<%	
						end if					
					next

			if tot = 0 then
				if flag = 1 then
			%>
					<tr align="center"> 
					  <td colspan=6 height=10 align=right></td>
					</tr>
					<tr bgcolor="#ffffff" align="center"> 
					  <td colspan=6 height=40 align=center style="font-size:12px;color:#ff0000"><b>您的信息已发送成功!</b></a></td>
					</tr>
				</table>
           <%
				else
			%>
					<tr align="center"> 
						<td colspan=6 height=10 align=right></td>
					</tr>
					<tr bgcolor="#ffffff" align="center"> 
						<td colspan=6 height=30 align=center style="font-size:12px;color:#993300">暂无定购产品!</a></td>
					</tr>
				</table>
			<%
				end if
			else	
			%>
				<tr align="center"> 
				  <td colspan=6 height=10 align=right></td>
				</tr>
				<tr align="center"> 
					<td colspan=6 height=20 align=right><font color="#993300"><strong>合计总金额:<%=sum_je%></strong></font>&nbsp;</td>
				</tr>
				</table>
				<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
				  <tr> 
					<td height="60">&nbsp;</td>
					<td width="100"> 
					  <input type="submit" name="Submit4" value="修改数量">
					</td>
					<td width="100"> 
					  <input type="button" name="clearcart"  onclick="clearall()" value="清空购物车">
					</td>
					<td>&nbsp;</td>
				  </tr>
				  </form>             
				</table>
			<%
			end if
			%>


            <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" class="font2">
		     <form name=shopform method=post action="shopcart.asp?method=88" onsubmit="return checkshopform(shopform)">
              <tr> 
                <td colspan="2" height="30" align="center"><img src="images/jt.gif" width="23" height="11"><strong>提交订单</strong></td>
              </tr>
              <tr> 
                <td colspan="2" height="1" align="center" bgcolor="#CCCCCC"> </td>
              </tr>
              <tr> 
                <td colspan="2" height="5" align="center" bgcolor="#f5f5f5"> </td>
              </tr>
	          <tr height="25"> 
		        <td align="right">您的姓名:</td>
			    <td><input name="username" type="text" size="10" maxlength="10" style="border:1px solid #000000;"></td>
			  </tr>
	          <tr height="25"> 
				 <td align="right">单位名称:</td>
				 <td><input name="corpname" type="text" size="50" maxlength="60" style="border:1px solid #000000;"></td>
			  </tr>
	          <tr height="25"> 
				<td align="right">地址:</td>
				<td><input name="address" type="text" size="60" maxlength="20" style="border:1px solid #000000;"></td>
			  </tr>
	          <tr height="25"> 
				<td align="right">联系电话:</td>
				<td><input name="phone" type="text" size="20" maxlength="20" style="border:1px solid #000000;"></td>
			  </tr>
	          <tr height="25"> 
				<td align="right">电子信箱:</td>
				<td><input name="email" type="text" size="60" maxlength="60" style="border:1px solid #000000;"></td>
			  </tr>
	          <tr height="25"> 
				<td align="right">说明:</td>
				<td><textarea name="content" cols="60" rows="5"  style="border:1px solid #000000;"></textarea></td>
			  </tr>
			</table>  
            <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
              <tr> 
                <td height="60">&nbsp;</td>
                <td width="100"> 
                  <input type="submit" name="Submit32" value="我要定购">
                </td>
                <td width="100"> 
                  <input type="button" name="shopping" onclick="window.close()" value="继续购物">
                </td>
                <td>&nbsp;</td>
              </tr>
            </table>

		  </td>
        </tr>
      </table>
	</td>
    <td width="223" valign="top" background="images/list.jpg">
		<!-- #include file="inc_hot.asp" //-->
    </td>
  </tr>
</table>

<!-- #include file="end.asp" -->


<script language=Javascript>

	function clearall()
	{
	if (confirm('确认删除所有的定购产品吗?')==true) {
		window.location.href="shopcart.asp?method=0"
	 }
	}
	
	function delrec(code)
	{
		if (confirm('确认删除所选的产品吗?')==true) {
		window.location.href="shopcart.asp?delno="+code
	  }	
	}

	function checkshopform(form)
	{
		var flag=true;

		if(form("username").value==""){alert("请输入您的姓名!");form("username").focus();return false;}
		if(form("phone").value==""){alert("请输入您的电话!");form("phone").focus();return false;}
		if(form("email").value==""){alert("请输入您的电子信箱!");form("email").focus();return false;}
		return flag;
	}

</script>	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -