ProductEdit.asp
资源名称:1.rar [点击查看]
上传用户:yrf020
上传日期:2007-07-24
资源大小:1287k
文件大小:17k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
HTML/CSS
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
- <% Option Explicit %>
- <HTML xmlns="http://www.w3.org/1999/xhtml">
- <HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
- <META NAME="copyright" CONTENT="Copyright 2006-2008 - Hokilly.com-STUDIO" />
- <META NAME="Author" CONTENT="红金羚软件,www.hokilly.com" />
- <META NAME="Keywords" CONTENT="" />
- <META NAME="Description" CONTENT="" />
- <TITLE>编辑产品</TITLE>
- <link rel="stylesheet" href="Images/CssAdmin.css">
- <script language="javascript" src="../Script/Admin.js"></script>
- <script language = "JavaScript" src = "../Script/file_js.js" type="text/javascript"></script>
- </HEAD>
- <!--#include file="../Include/Const.asp" -->
- <!--#include file="../Include/ConnSiteData.asp" -->
- <!--#include file="CheckAdmin.asp"-->
- <%
- Dim SERVER_NAME
- SERVER_NAME=trim(Request.ServerVariables("SERVER_NAME"))
- if (SERVER_NAME= ""&chr(119)&chr(119)&chr(119)&chr(46)&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME= ""&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&"")or(SERVER_NAME= ""&chr(108)&chr(111)&chr(99)&chr(97)&chr(108)&chr(104)&chr(111)&chr(115)&chr(116)&"")or(SERVER_NAME= ""&chr(49)&chr(50)&chr(55)&chr(46)&chr(48)&chr(46)&chr(48)&chr(46)&chr(49)&"") then
- if Instr(session("AdminPurview"),"|33,")=0 then
- response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
- response.end
- end if
- '========判断是否具有管理权限
- %>
- <BODY>
- <%
- dim Result
- Result=request.QueryString("Result")
- dim ID,ProductNameCh,ViewFlagCh,SortNameCh,SortID,SortPath
- dim ProductNo,ProductModel,N_Price,P_Price,Stock,UnitCh,MakerCh,CommendFlag,NewFlag,GroupID,GroupIdName,Exclusive
- dim BigPic,SmallPic,ContentCh,UploadFiles
- ID=request.QueryString("ID")
- call ProductEdit()
- %>
- <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
- <tr>
- <td height="24" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle"> <strong>产品检索及分类查看:添加,修改,删除产品信息</strong></font></td>
- </tr>
- <tr>
- <td height="24" align="center" nowrap bgcolor="#eafefe"><a href="ProductEdit.asp?Result=Add" onClick='changeAdminFlag("添加产品信息")'>添加产品信息</a><font color="#0000FF"> | </font><a href="ProductList.asp" onClick='changeAdminFlag("产品列表")'>查看所有产品信息</a></td>
- </tr>
- </table>
- <br>
- <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
- <form name="editForm" method="post" action="ProductEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
- <tr>
- <td height="24" nowrap bgcolor="#eafefe"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editProduct idth="100%">
- <tr>
- <td width="120" height="20" align="right"> </td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" align="right">名 称:</td>
- <td><input name="ProductNameCh" type="text" class="textfield" id="ProductNameCh" style="WIDTH: 240;" value="<%=ProductNameCh%>" maxlength="100"> 显示:<input name="ViewFlagCh" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlagCh then response.write ("checked")%>> *</td>
- </tr>
- <tr>
- <td height="20" align="right">所属类别:</td>
- <td><input name="SortNameCh" type="text" class="textfield" id="SortNameCh" value="<%=SortNameCh%>" style="WIDTH: 240;background-color:#eafefe;" readonly> <a href="javaScript:OpenScript('SelectSort.asp?Result=Products',500,500,'')"><img src="Images/Select.gif" width="30" height="16" border="0" align="absmiddle"></a></td>
- </tr>
- <tr>
- <td height="20" align="right">类别数字:</td>
- <td><input name="SortID" type="text" class="textfield" id="SortID" style="WIDTH: 40;background-color:#eafefe;" value="<%=SortID%>" readonly><input name="SortPath" type="text" class="textfield" id="SortPath" style="WIDTH: 200;background-color:#eafefe;" value="<%=SortPath%>" readonly> *</td>
- </tr>
- <tr>
- <td height="20" align="right">编 号:</td>
- <td><input name="ProductNo" type="text" class="textfield" id="ProductNo" style="WIDTH: 240;" value="<%=ProductNo%>" maxlength="100"> * 如果不明确请勿修改</td>
- </tr>
- <tr>
- <td height="20" align="right">型 号:</td>
- <td><input name="ProductModel" type="text" class="textfield" id="ProductModel" style="WIDTH: 240;" value="<%=ProductModel%>" maxlength="100"></td>
- </tr>
- <tr>
- <td height="20" align="right">标 准 价:</td>
- <td><input name="N_Price" type="text" class="textfield" id="N_Price" style="WIDTH: 240;" value="<%=N_Price%>" maxlength="100"> * </td>
- </tr>
- <tr>
- <td height="20" align="right">优 惠 价:</td>
- <td><input name="P_Price" type="text" class="textfield" id="P_Price" style="WIDTH: 240;" value="<%=P_Price%>" maxlength="100"> * </td>
- </tr>
- <tr>
- <td height="20" align="right">库存数量:</td>
- <td><input name="Stock" type="text" class="textfield" id="Stock" style="WIDTH: 240;" value="<%=Stock%>" maxlength="100"> *</td>
- </tr>
- <tr>
- <td height="20" align="right">计价单位:</td>
- <td><input name="UnitCh" type="text" class="textfield" id="UnitCh" style="WIDTH: 240;" value="<%=UnitCh%>" maxlength="100"> *</td>
- </tr>
- <tr>
- <td height="20" align="right">出品公司:</td>
- <td><input name="MakerCh" type="text" class="textfield" id="MakerCh" style="WIDTH: 240;" value="<%=MakerCh%>" maxlength="100"></td>
- </tr>
- <tr>
- <td height="20" align="right">状 态:</td>
- <td><input name="CommendFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if CommendFlag then response.write ("checked")%>> 推荐 <input name="NewFlag" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if NewFlag then response.write ("checked")%>> 最新</td>
- </tr>
- <tr>
- <td height="20" align="right">查看权限:</td>
- <td><select name="GroupID" class="textfield">
- <% call SelectGroup() %>
- </select>
- <input name="Exclusive" type="radio" value=">=" <%if Exclusive="" or Exclusive=">=" then response.write ("checked")%>> 隶属<input type="radio" <%if Exclusive="=" then response.write ("checked")%> name="Exclusive" value="=">专属(隶属:权限值≥可查看,专属:权限值=可查看)</td>
- </tr>
- <tr>
- <td height="20" align="right">产品主图:</td>
- <td><input name="BigPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=BigPic%>" maxlength="100" ID="magicfacepic(1)">
- <a href="javaScript:OpenScript('UpFileForm.asp?Result=BigPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a> <font onclick="lookmagic(1)" style="CURSOR:hand">选择已上传图片</font>
- <div id="magicframe(1)" style="visibility:hidden; position: absolute;width:10; left: 2px; top: 479px;">
- <iframe src="photoShow.asp?action=1" width="380" height="290" frameborder="0" scrolling="no"></iframe>
- </div></td>
- </tr>
- <tr>
- <td height="20" align="right">缩 略 图:</td>
- <td><input name="SmallPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=SmallPic%>" maxlength="100" id="magicfacepic(2)">
- <a href="javaScript:OpenScript('UpFileForm.asp?Result=SmallPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a> <font onclick="lookmagic(2)" style="CURSOR:hand">选择已上传图片</font>
- <div id="magicframe(2)" style="visibility:hidden; position: absolute;width:10; left: 2px; top: 479px;">
- <iframe src="photoShow.asp?action=2" width="380" height="290" frameborder="0" scrolling="no"></iframe>
- </div></td>
- </tr>
- <tr>
- <td height="20" align="right" valign="top">介 绍:<br>
- <td><textarea name="ContentCh" style="display:none"id="ContentCh" readonly><%=ContentCh%></textarea>
- <iframe id="eWebEditor1" src="../Editor/ewebeditor.asp?id=ContentCh&style=Editor&savepathfilename=UploadFiles" frameborder="0" scrolling="no" width="550" height="450"></iframe></td>
- </tr>
- <tr>
- <td height="30" align="right"> </td>
- <td valign="bottom"><input type="hidden" name="UploadFiles" value="<%=UploadFiles%>" onChange="doChange(this,document.editForm.DefaultPicList)">
- <input name="submitSaveEdit" type="submit" class="button" id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
- </tr>
- <tr>
- <td height="20" align="right"> </td>
- <td valign="bottom"> </td>
- </tr>
- </table></td>
- </tr>
- </form>
- </table>
- </body>
- </html>
- <%
- else
- response.write "<meta http-equiv=refresh content=0;URL="&chr(104)&chr(116)&chr(116)&chr(112)&chr(58)&chr(47)&chr(47)&chr(104)&chr(111)&chr(107)&chr(105)&chr(108)&chr(108)&chr(121)&chr(46)&chr(99)&chr(111)&chr(109)&chr(47)&chr(114)&chr(101)&chr(103)&chr(46)&chr(97)&chr(115)&chr(112)&">"
- response.end%>
- <%end if%>
- <%
- sub ProductEdit()
- dim Action,rsRepeat,rs,sql
- Action=request.QueryString("Action")
- if Action="SaveEdit" then '保存编辑产品信息
- set rs = server.createobject("adodb.recordset")
- if len(trim(request.Form("ProductNameCh")))<1 then
- response.write ("<script language=javascript> alert('名称为必填项目!');history.back(-1);</script>")
- response.end
- end if
- if len(trim(request.Form("UnitCh")))<1 then
- response.write ("<script language=javascript> alert('计价单位为必填项目!');history.back(-1);</script>")
- response.end
- end if
- if Result="Add" then '创建产品信息
- sql="select * from CompanyCMS_Products"
- rs.open sql,conn,1,3
- rs.addnew
- rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
- if Request.Form("ViewFlagCh")=1 then
- rs("ViewFlagCh")=Request.Form("ViewFlagCh")
- else
- rs("ViewFlagCh")=0
- end if
- if Request.Form("SortID")="" and Request.Form("SortPath")="" then
- response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
- response.end
- else
- rs("SortID")=Request.Form("SortID")
- rs("SortPath")=Request.Form("SortPath")
- end if
- set rsRepeat = conn.execute("select ProductNo from CompanyCMS_Products where ProductNo='" & trim(Request.Form("ProductNo")) & "'")
- if not (rsRepeat.bof and rsRepeat.eof) then '判断此产品编号是否存在
- response.write "<script language=javascript> alert('" & trim(Request.Form("ProductNo")) & "此产品编号已经存在,请换一个编号再试试!');history.back(-1);</script>"
- response.end
- else
- rs("ProductNo")=trim(Request.Form("ProductNo"))
- end if
- rs("ProductModel")=trim(Request.Form("ProductModel"))
- if (not IsNumeric(trim(request.Form("N_Price")))) or (not IsNumeric(trim(request.Form("P_Price"))))then
- response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
- response.end
- elseif trim(request.Form("N_Price"))<0 or trim(request.Form("P_Price"))<0then
- response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
- response.end
- else
- rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
- rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
- end if
- if (not IsNumeric(trim(request.Form("Stock")))) then
- response.write ("<script language=javascript> alert('库存数量必填且为数值!');history.back(-1);</script>")
- response.end
- else
- rs("Stock")=Round(trim(Request.Form("Stock")),2)
- end if
- rs("UnitCh")=trim(Request.Form("UnitCh"))
- rs("MakerCh")=trim(Request.Form("MakerCh"))
- if Request.Form("CommendFlag")=1 then
- rs("CommendFlag")=Request.Form("CommendFlag")
- else
- rs("CommendFlag")=0
- end if
- if Request.Form("NewFlag")=1 then
- rs("NewFlag")=Request.Form("NewFlag")
- else
- rs("NewFlag")=0
- end if
- GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
- rs("GroupID")=GroupIdName(0)
- rs("Exclusive")=trim(Request.Form("Exclusive"))
- rs("BigPic")=trim(Request.Form("BigPic"))
- rs("SmallPic")=trim(Request.Form("SmallPic"))
- rs("ContentCh")=Request.Form("ContentCh")
- rs("UploadFiles")=trim(Request.Form("UploadFiles"))
- rs("AddTime")=now()
- rs("UpdateTime")=now()
- end if
- if Result="Modify" then '修改产品信息
- sql="select * from CompanyCMS_Products where ID="&ID
- rs.open sql,conn,1,3
- rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
- if Request.Form("ViewFlagCh")=1 then
- rs("ViewFlagCh")=Request.Form("ViewFlagCh")
- else
- rs("ViewFlagCh")=0
- end if
- if Request.Form("SortID")<>"" and Request.Form("SortPath")<>"" then
- rs("SortID")=Request.Form("SortID")
- rs("SortPath")=Request.Form("SortPath")
- else
- response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
- response.end
- end if
- rs("ProductNo")=trim(Request.Form("ProductNo"))
- rs("ProductModel")=trim(Request.Form("ProductModel"))
- if (not IsNumeric(trim(request.Form("N_Price")))) or (not IsNumeric(trim(request.Form("P_Price"))))then
- response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
- response.end
- elseif trim(request.Form("N_Price"))<0 or trim(request.Form("P_Price"))<0then
- response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
- response.end
- else
- rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
- rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
- end if
- if (not IsNumeric(trim(request.Form("Stock")))) then
- response.write ("<script language=javascript> alert('库存数量必填且为数值!');history.back(-1);</script>")
- response.end
- else
- rs("Stock")=Round(trim(Request.Form("Stock")),2)
- end if
- rs("UnitCh")=trim(Request.Form("UnitCh"))
- rs("MakerCh")=trim(Request.Form("MakerCh"))
- if Request.Form("CommendFlag")=1 then
- rs("CommendFlag")=Request.Form("CommendFlag")
- else
- rs("CommendFlag")=0
- end if
- if Request.Form("NewFlag")=1 then
- rs("NewFlag")=Request.Form("NewFlag")
- else
- rs("NewFlag")=0
- end if
- GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
- rs("GroupID")=GroupIdName(0)
- rs("Exclusive")=trim(Request.Form("Exclusive"))
- rs("BigPic")=trim(Request.Form("BigPic"))
- rs("SmallPic")=trim(Request.Form("SmallPic"))
- rs("ContentCh")=Request.Form("ContentCh")
- rs("UploadFiles")=trim(Request.Form("UploadFiles"))
- rs("UpdateTime")=now()
- end if
- rs.update
- rs.close
- set rs=nothing
- response.write "<script language=javascript> alert('成功编辑产品信息!');changeAdminFlag('产品列表');location.replace('ProductList.asp');</script>"
- else '提取产品信息
- if Result="Modify" then
- set rs = server.createobject("adodb.recordset")
- sql="select * from CompanyCMS_Products where ID="& ID
- rs.open sql,conn,1,1
- if rs.bof and rs.eof then
- response.write ("数据库读取记录出错!")
- response.end
- end if
- ProductNameCh=rs("ProductNameCh")
- ViewFlagCh=rs("ViewFlagCh")
- SortNameCh=SortText(rs("SortID"))
- SortID=rs("SortID")
- SortPath=rs("SortPath")
- ProductNo=rs("ProductNo")
- ProductModel=rs("ProductModel")
- N_Price=rs("N_Price")
- P_Price=rs("P_Price")
- Stock=rs("Stock")
- UnitCh=rs("UnitCh")
- MakerCh=rs("MakerCh")
- CommendFlag=rs("CommendFlag")
- NewFlag=rs("NewFlag")
- GroupID=rs("GroupID")
- Exclusive=rs("Exclusive")
- BigPic=rs("BigPic")
- SmallPic=rs("SmallPic")
- ContentCh=rs("ContentCh")
- UploadFiles=rs("UploadFiles")
- rs.close
- set rs=nothing
- else
- randomize timer
- ProductNo=Hour(now)&Minute(now)&Second(now)&"-"&int(900*rnd)+100
- Stock=10000
- end if
- end if
- end sub
- %>
- <%
- sub SelectGroup()
- dim rs,sql
- set rs = server.createobject("adodb.recordset")
- sql="select GroupID,GroupNameCh from CompanyCMS_MemGroup"
- rs.open sql,conn,1,1
- if rs.bof and rs.eof then
- response.write("未设组别")
- end if
- while not rs.eof
- response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupNameCh")&"'")
- if GroupID=rs("GroupID") then response.write ("selected")
- response.write(">"&rs("GroupNameCh")&"</option>")
- rs.movenext
- wend
- rs.close
- set rs=nothing
- end sub
- %>
- <%
- '生成所属类别--------------------------
- Function SortText(ID)
- Dim rs,sql
- Set rs=server.CreateObject("adodb.recordset")
- sql="Select * From CompanyCMS_ProductSort where ID="&ID
- rs.open sql,conn,1,1
- SortText=rs("SortNameCh")
- rs.close
- set rs=nothing
- End Function
- %>
English
