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

📄 addpro.asp

📁 一个网上销售电器的超市购物系统
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'/*----------------------------------------------
'项目名:     网上商品超市(ASP课程设计)
'开始日期:   2004年3月1日
'完成日期:  
'最后修改:  -
'制作地点:  湖南科技大学
'程序制作:  邓宁  刘颖佳
'联系方式:   
'           Email:skydenny@163.com
'                 lyj0805@163.com                  
'       
'-----------------------------------------------*/

%><!--#include file="inc/config.asp"-->
<!--#include file="inc/conn.asp"--> 
<!--#include file="inc/chk.asp"--> 
<%
if session("rank")>2 then
	call Msgbox("你的权限不够!","Back","None")
	response.End
end if
%>

<%

'添加产品
If NOT IsEmpty (request("AddProSubmit")) then
	dim productdate,discount
	discount=round(request("price2")/request("price1"),2)
	if request("productdateyear")<>"" then
		productdate=trim(request("productdateyear"))&"年"&trim(request("productdatemonth"))&"月"
	else
		productdate=""
	end if
	
	set rs=server.CreateObject("adodb.recordset")
	rs.Open "select * from product",conn,1,3
	rs.AddNew
	
	rs("productdate")=productdate 
	rs("discount")=discount 
	
	rs("name")=trim(request("name")) 
	
	rs("format")=request("format")
	
	if request("pronum")<>"" then
		rs("pronum")=int(request("pronum"))
	else
		rs("pronum")=0
	end if
	
	if request("protimes")<>"" then
		rs("protimes")=int(request("protimes"))
	else
		rs("protimes")=0
	end if

	rs("author")=trim(request("author"))
	
	rs("mark")=trim(request("mark"))
	rs("introduce")=trim(request("introduce")) 
	
	rs("price1")=trim(request("price1"))  
	rs("price2")=trim(request("price2"))  
	rs("vipprice")=trim(request("vipprice"))  
	
	rs("pic")=trim(request("pic")) 
	rs("categoryid")=int(request("categoryid"))
	rs("sortsid")=int(request("sortsid")) 
	
	rs("score")=request("score") 
	
	rs("type")=trim(request("type"))
	
	rs("solded")=0 
	rs("viewnum")=0 
	rs("adddate")=now() 
	rs("rank")=0  
	rs("ranknum")=0
	if request("detail")<>"" then
		rs("detail")=htmlencode2(request("detail"))
	end if

	if request("content")<>"" then
		rs("content")=htmlencode2(request("content"))
	end if

	if request("detail")<>"" then
		rs("desc")=htmlencode2(strvalue(request("detail") ,100))
	end if

	'是否推荐产品
	if request("recommend")=1 then  
		rs("recommend")=1
	else
		rs("recommend")=0
	end if
	rs.Update
	rs.Close
	set rs=nothing
	call MsgBox("添加成功!","GoUrl","addpro.asp")
	response.End
end if
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上商品超市</title>
<link href="../style.css" rel="stylesheet" type="text/css">


</head>

<body>
<!--#include file="head.htm"-->

<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="219" height="697" align="left" valign="top"><br>
      <!--#include file="menu.htm"-->

        <br></td><td width="561" align="left" valign="top">      <script language = "JavaScript">

var onecount;
onecount=0;
subcat = new Array();
<%
'读取分类字段赋给JS数组
dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from sorts order by sortsorder ",conn,1,1
count = 0
do while not rs.eof 
%>
subcat[<%=count%>] = new Array("<%= trim(rs("sorts"))%>","<%= rs("categoryid")%>","<%= rs("sortsid")%>");
<%
        count = count + 1
        rs.movenext
        loop
        rs.close
%>
		
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.sortsid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
             document.myform.sortsid.options[document.myform.sortsid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
      </script>      <br>      <table border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="18"><img src="../images/w.gif" width="18" height="18"></td>
          <td width="66" style="color:#415373">添加商品</td>
        </tr>
      </table>      
      <br>      <form action="" method="post" name="myform" id="myform">
        <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>选择分类:</div></td>
            <td colspan="2"> 
              <%
rs.open "select * from category order by categoryorder",conn,1,1
if rs.eof and rs.bof then
	call MsgBox("请先添加分类!","Back","None")
	response.end
else
%>
              <select name="categoryid" size="1" id="select2" onChange="changelocation(document.myform.categoryid.options[document.myform.categoryid.selectedIndex].value)">
                <option selected value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
                <%      
 dim selclass
 selclass=rs("categoryid")
 rs.movenext
 do while not rs.eof
%>
                <option value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
                <%
 rs.movenext
 loop
end if
rs.close
%>
              </select>
              小类: 
              <select name="sortsid">
                <%
rs.open "select * from sorts where categoryid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
                <option value="<%=rs("sortsid")%>" selected><%=rs("sorts")%></option>
                <% rs.movenext
do while not rs.eof
%>
                <option value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
                <%
rs.movenext
loop
end if
        rs.close
        set rs = nothing
        conn.Close
        set conn = nothing
%>
              </select> <strong>(带</strong> <span class="redfont">* <font color="#000000"><strong>的为必须填写的</strong>)</font></span></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>商品名:</div></td>
            <td colspan="2"> 
              <input name="name" type="text" id="name" size="30"> 
            </td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>品牌:</div></td>
            <td colspan="2"> 
              <input name="author" type="text" id="author" size="20"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>出厂地址: </div></td>
            <td colspan="2"> 
              <input name="mark" type="text" id="mark" size="30" ></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right">包装:</div></td>
            <td colspan="2"> 
              <input name="introduce" type="text" id="introduce" size="30" ></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>出厂日期:</div></td>
            <td colspan="2"> 
              <select name="productdateyear" id="productdateyear">
                <%dim i
for i=year(now) to 1900 step -1
response.write "<option value="&i&">"&i&"</option>"
next
%>
              </select>
              <select name="productdatemonth" id="productdatemonth">
                <%for i=1 to 12
response.write "<option value="&i&">"&i&"</option>"
next%>
              </select>
              月</td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>价格: </div></td>
            <td colspan="2">市场价: 
              <input name="price1" type="text" id="price1" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" VALUE="0" size="6" 
onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
              元, 会员价: 
              <input name="price2" type="text" id="price2" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" value="0" size="6" 
onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
              元, VIP价: 
              <INPUT NAME="vipprice" TYPE="text" ID="vipprice" ONKEYPRESS	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" value="0" SIZE="6" 
ONPASTE		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
ONDROP		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))">
              元<br>
              赠送积分: 
              <INPUT NAME="score" VALUE="0" SIZE="4" TYPE="text" ONKEYPRESS	= "return regInput(this,	/^[0-9]*$/,		String.fromCharCode(event.keyCode))"
ONPASTE		= "return regInput(this,	/^[0-9]*$/,		window.clipboardData.getData('Text'))"
ONDROP		= "return regInput(this,	/^[0-9]*$/,		event.dataTransfer.getData('Text'))">
              分</td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right">重 量:</div></td>
            <td colspan="2"> 
              <input name="format" type="text" id="format" size="10"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right">批 次:</div></td>
            <td colspan="2"> 
              <input name="protimes" type="text" id="protimes" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" size="6" 
onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right">件 数: </div></td>
            <td colspan="2"> 
              <input name="pronum" type="text" id="pronum" onKeyPress	= "return regInput(this,	/^\d*\.?\d{0,2}$/,		String.fromCharCode(event.keyCode))" size="10" 
onpaste		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		window.clipboardData.getData('Text'))"
ondrop		= "return regInput(this,	/^\d*\.?\d{0,2}$/,		event.dataTransfer.getData('Text'))"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>商品编码:</div></td>
            <td colspan="2"> 
              <input name="type" type="text" id="type2" size="30"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right"><span class="redfont">*</span>商品图片: </div></td>
            <td colspan="2"> 
              <input name="pic" type="text" id="pic" size="30" VALUE=""> 
              &nbsp; <input type="button" name="Submit2" value="上 传" onClick="javascript:window.open('upfile.asp','','width=580,height=160,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=no');return false;"></td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td> 
              <div align="right">详细说明:</div></td>
            <td colspan="2"> 
              <textarea name="detail" cols="46" rows="8" id="detail"></textarea> 
            </td>
          </tr>
          <tr bgcolor="#F1F7FE"> 
            <td height="128" valign="top"> 
              <div align="right">
                <p>&nbsp;</p>
                <p>&nbsp;</p>
                <p>目录:</p>
                </div></td>
            <td colspan="2"> 
              <TEXTAREA NAME="content" COLS="46" ROWS="8" ID="content"></TEXTAREA> 
            </td>
          </tr>
          <tr align="center" bgcolor="#F1F7FE"> 
            <td colspan="3"> 
              <input name="recommend" type="checkbox" id="recommend" value="1">
              推荐此商品 
              <input name="AddProSubmit" type="submit" id="AddProSubmit" onClick="return checkpro();" value="添加"> 
              <script language="JavaScript">
<!--
function checkpro()
{
    if(checkspace(document.myform.name.value)) {
	document.myform.name.focus();
    alert("请输入商品名!");
	return false;
  }

	if(checkspace(document.myform.author.value)) {
	document.myform.author.focus();
    alert("请输入品牌!");
	return false;
  }
	if(checkspace(document.myform.mark.value)) {
	document.myform.mark.focus();
    alert("请输入出厂地址!");
	return false;
  }

	if(checkspace(document.myform.type.value)) {
	document.myform.type.focus();
    alert("请输入商品编码!");
	return false;
  }

    if(checkspace(document.myform.price1.value)||document.myform.price1.value==0) {
	document.myform.price1.focus();
    alert("请输入市场价!");
	return false;
  }
    if(checkspace(document.myform.price2.value)||document.myform.price2.value==0) {
	document.myform.price2.focus();
    alert("请输入会员价!");
	return false;
  }
    if(checkspace(document.myform.vipprice.value)||document.myform.vipprice.value==0) {
	document.myform.vipprice.focus();
    alert("请输入VIP价!");
	return false;
  }


     if(checkspace(document.myform.price1.value)) {
	document.myform.price1.focus();
    alert("请输入商品市场价格!");
	return false;
  }
     if(checkspace(document.myform.price2.value)) {
	document.myform.price2.focus();
    alert("请输入商品会员价格!");
	return false;
  }
      if(checkspace(document.myform.vipprice.value)) {
	document.myform.vipprice.focus();
    alert("请输入VIP月会员商品价格!");
	return false;
  }
 
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
//-->
                          
</script></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<!--#include file="foot.htm"-->
</body>
</html>

⌨️ 快捷键说明

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