ProductEdit.asp
资源名称:1.rar [点击查看]
上传用户:yrf020
上传日期:2007-07-24
资源大小:1287k
文件大小:17k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <% Option Explicit %>
  3. <HTML xmlns="http://www.w3.org/1999/xhtml">
  4. <HEAD>
  5. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
  6. <META NAME="copyright" CONTENT="Copyright 2006-2008 - Hokilly.com-STUDIO" />
  7. <META NAME="Author" CONTENT="红金羚软件,www.hokilly.com" />
  8. <META NAME="Keywords" CONTENT="" />
  9. <META NAME="Description" CONTENT="" />
  10. <TITLE>编辑产品</TITLE>
  11. <link rel="stylesheet" href="Images/CssAdmin.css">
  12. <script language="javascript" src="../Script/Admin.js"></script>
  13. <script language = "JavaScript" src = "../Script/file_js.js" type="text/javascript"></script>
  14. </HEAD>
  15. <!--#include file="../Include/Const.asp" -->
  16. <!--#include file="../Include/ConnSiteData.asp" -->
  17. <!--#include file="CheckAdmin.asp"-->
  18. <%
  19. Dim SERVER_NAME
  20. SERVER_NAME=trim(Request.ServerVariables("SERVER_NAME"))
  21. 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
  22. if Instr(session("AdminPurview"),"|33,")=0 then 
  23.   response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
  24.   response.end
  25. end if
  26. '========判断是否具有管理权限
  27. %>
  28. <BODY>
  29. <% 
  30. dim Result
  31. Result=request.QueryString("Result")
  32. dim ID,ProductNameCh,ViewFlagCh,SortNameCh,SortID,SortPath
  33. dim ProductNo,ProductModel,N_Price,P_Price,Stock,UnitCh,MakerCh,CommendFlag,NewFlag,GroupID,GroupIdName,Exclusive
  34. dim BigPic,SmallPic,ContentCh,UploadFiles
  35. ID=request.QueryString("ID")
  36. call ProductEdit() 
  37. %>
  38. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  39.   <tr>
  40.     <td height="24" nowrap><font color="#FFFFFF"><img src="Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>产品检索及分类查看:添加,修改,删除产品信息</strong></font></td>
  41.   </tr>
  42.   <tr>
  43.     <td height="24" align="center" nowrap  bgcolor="#eafefe"><a href="ProductEdit.asp?Result=Add" onClick='changeAdminFlag("添加产品信息")'>添加产品信息</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="ProductList.asp" onClick='changeAdminFlag("产品列表")'>查看所有产品信息</a></td>
  44.   </tr>
  45. </table>
  46. <br>
  47. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6ab6b6">
  48.   <form name="editForm" method="post" action="ProductEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
  49.   <tr>
  50.     <td height="24" nowrap bgcolor="#eafefe"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editProduct idth="100%">
  51.       <tr>
  52.         <td width="120" height="20" align="right">&nbsp;</td>
  53.         <td>&nbsp;</td>
  54.       </tr>
  55.       <tr>
  56.         <td height="20" align="right">名  称:</td>
  57.         <td><input name="ProductNameCh" type="text" class="textfield" id="ProductNameCh" style="WIDTH: 240;" value="<%=ProductNameCh%>" maxlength="100">&nbsp;显示:<input name="ViewFlagCh" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlagCh then response.write ("checked")%>>&nbsp;*</td>
  58.       </tr>
  59.       <tr>
  60.         <td height="20" align="right">所属类别:</td>
  61.         <td><input name="SortNameCh" type="text" class="textfield" id="SortNameCh" value="<%=SortNameCh%>" style="WIDTH: 240;background-color:#eafefe;" readonly>&nbsp;<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>
  62.       </tr>
  63.       <tr>
  64.         <td height="20" align="right">类别数字:</td>
  65.         <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>&nbsp;*</td>
  66.       </tr>
  67.       <tr>
  68.         <td height="20" align="right">编  号:</td>
  69.         <td><input name="ProductNo" type="text" class="textfield" id="ProductNo" style="WIDTH: 240;" value="<%=ProductNo%>" maxlength="100">&nbsp;*&nbsp;如果不明确请勿修改</td>
  70.       </tr>
  71.       <tr>
  72.         <td height="20" align="right">型  号:</td>
  73.         <td><input name="ProductModel" type="text" class="textfield" id="ProductModel" style="WIDTH: 240;" value="<%=ProductModel%>" maxlength="100"></td>
  74.       </tr>
  75.       <tr>
  76.         <td height="20" align="right">标 准 价:</td>
  77.         <td><input name="N_Price" type="text" class="textfield" id="N_Price" style="WIDTH: 240;" value="<%=N_Price%>" maxlength="100">&nbsp;*&nbsp;</td>
  78.       </tr>   
  79.       <tr>
  80.         <td height="20" align="right">优 惠 价:</td>
  81.         <td><input name="P_Price" type="text" class="textfield" id="P_Price" style="WIDTH: 240;" value="<%=P_Price%>" maxlength="100">&nbsp;*&nbsp;</td>
  82.       </tr>
  83.       <tr>
  84.         <td height="20" align="right">库存数量:</td>
  85.         <td><input name="Stock" type="text" class="textfield" id="Stock" style="WIDTH: 240;" value="<%=Stock%>" maxlength="100">&nbsp;*</td>
  86.       </tr>   
  87.       <tr>
  88.         <td height="20" align="right">计价单位:</td>
  89.         <td><input name="UnitCh" type="text" class="textfield" id="UnitCh" style="WIDTH: 240;" value="<%=UnitCh%>" maxlength="100">&nbsp;*</td>
  90.       </tr>  
  91.   <tr>
  92.         <td height="20" align="right">出品公司:</td>
  93.         <td><input name="MakerCh" type="text" class="textfield" id="MakerCh" style="WIDTH: 240;" value="<%=MakerCh%>" maxlength="100"></td>
  94.       </tr>
  95.       <tr>
  96.         <td height="20" align="right">状  态:</td>
  97.         <td><input name="CommendFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if CommendFlag then response.write ("checked")%>>&nbsp;推荐&nbsp;<input name="NewFlag" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if NewFlag then response.write ("checked")%>>&nbsp;最新</td>
  98.       </tr>
  99.       <tr>
  100.         <td height="20" align="right">查看权限:</td>
  101.         <td><select name="GroupID" class="textfield">
  102.           <% call SelectGroup() %>
  103.           </select>
  104.           <input name="Exclusive" type="radio" value="&gt;="  <%if Exclusive="" or Exclusive=">=" then response.write ("checked")%>> 隶属<input type="radio"  <%if Exclusive="=" then response.write ("checked")%> name="Exclusive" value="=">专属(隶属:权限值≥可查看,专属:权限值=可查看)</td>
  105.       </tr>
  106.       <tr>
  107.         <td height="20" align="right">产品主图:</td>
  108.         <td><input name="BigPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=BigPic%>" maxlength="100" ID="magicfacepic(1)">
  109.             <a href="javaScript:OpenScript('UpFileForm.asp?Result=BigPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a>&nbsp;&nbsp;<font onclick="lookmagic(1)" style="CURSOR:hand">选择已上传图片</font>
  110.             <div id="magicframe(1)" style="visibility:hidden; position: absolute;width:10; left: 2px; top: 479px;">
  111.               <iframe src="photoShow.asp?action=1" width="380" height="290" frameborder="0" scrolling="no"></iframe>
  112.             </div></td>
  113.       </tr>
  114.       <tr>
  115.         <td height="20" align="right">缩 略 图:</td>
  116.         <td><input name="SmallPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=SmallPic%>" maxlength="100" id="magicfacepic(2)">
  117.           <a href="javaScript:OpenScript('UpFileForm.asp?Result=SmallPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a>&nbsp;&nbsp;<font onclick="lookmagic(2)" style="CURSOR:hand">选择已上传图片</font>
  118.           <div id="magicframe(2)" style="visibility:hidden; position: absolute;width:10; left: 2px; top: 479px;">
  119.             <iframe src="photoShow.asp?action=2" width="380" height="290" frameborder="0" scrolling="no"></iframe>
  120.           </div></td>
  121.       </tr>
  122.       
  123.       <tr>
  124.         <td height="20" align="right" valign="top">介  绍:<br>
  125.   
  126.         <td><textarea name="ContentCh" style="display:none"id="ContentCh" readonly><%=ContentCh%></textarea>
  127.           <iframe id="eWebEditor1" src="../Editor/ewebeditor.asp?id=ContentCh&style=Editor&savepathfilename=UploadFiles" frameborder="0" scrolling="no" width="550" height="450"></iframe></td>
  128.       </tr>
  129.       <tr>
  130.         <td height="30" align="right">&nbsp;</td>
  131.         <td valign="bottom"><input  type="hidden"  name="UploadFiles" value="<%=UploadFiles%>"  onChange="doChange(this,document.editForm.DefaultPicList)">
  132.         <input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
  133.       </tr>
  134.       <tr>
  135.         <td height="20" align="right">&nbsp;</td>
  136.         <td valign="bottom">&nbsp;</td>
  137.       </tr>
  138.     </table></td>
  139.   </tr>
  140.   </form>
  141. </table>
  142. </body>
  143. </html> 
  144. <%
  145. else
  146. 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)&">"
  147. response.end%>
  148. <%end if%>
  149. <%
  150. sub ProductEdit()
  151.   dim Action,rsRepeat,rs,sql
  152.   Action=request.QueryString("Action")
  153.   if Action="SaveEdit" then '保存编辑产品信息
  154.     set rs = server.createobject("adodb.recordset")
  155.     if len(trim(request.Form("ProductNameCh")))<1 then
  156.       response.write ("<script language=javascript> alert('名称为必填项目!');history.back(-1);</script>")
  157.       response.end
  158.     end if
  159. if len(trim(request.Form("UnitCh")))<1 then
  160.       response.write ("<script language=javascript> alert('计价单位为必填项目!');history.back(-1);</script>")
  161.       response.end
  162.     end if
  163.     if Result="Add" then '创建产品信息
  164.   sql="select * from CompanyCMS_Products"
  165.       rs.open sql,conn,1,3
  166.       rs.addnew
  167.       rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
  168.   if Request.Form("ViewFlagCh")=1 then
  169.         rs("ViewFlagCh")=Request.Form("ViewFlagCh")
  170.   else
  171.         rs("ViewFlagCh")=0
  172.   end if
  173.   if Request.Form("SortID")="" and Request.Form("SortPath")="" then
  174.         response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
  175.         response.end
  176.   else
  177.     rs("SortID")=Request.Form("SortID")
  178. rs("SortPath")=Request.Form("SortPath")
  179.   end if
  180.       set rsRepeat = conn.execute("select ProductNo from CompanyCMS_Products where ProductNo='" & trim(Request.Form("ProductNo")) & "'")
  181.       if not (rsRepeat.bof and rsRepeat.eof) then '判断此产品编号是否存在
  182.         response.write "<script language=javascript> alert('" & trim(Request.Form("ProductNo")) & "此产品编号已经存在,请换一个编号再试试!');history.back(-1);</script>"
  183.         response.end
  184.       else
  185.     rs("ProductNo")=trim(Request.Form("ProductNo"))
  186.   end if
  187.   rs("ProductModel")=trim(Request.Form("ProductModel"))
  188.   if (not IsNumeric(trim(request.Form("N_Price")))) or (not IsNumeric(trim(request.Form("P_Price"))))then
  189.         response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
  190.         response.end
  191.       elseif trim(request.Form("N_Price"))<0 or trim(request.Form("P_Price"))<0then
  192.         response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
  193.         response.end
  194.       else
  195.         rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
  196.     rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
  197.   end if
  198.   if (not IsNumeric(trim(request.Form("Stock"))))  then
  199.         response.write ("<script language=javascript> alert('库存数量必填且为数值!');history.back(-1);</script>")
  200.         response.end
  201.   else
  202. rs("Stock")=Round(trim(Request.Form("Stock")),2)
  203.   end if 
  204.   rs("UnitCh")=trim(Request.Form("UnitCh"))
  205.   rs("MakerCh")=trim(Request.Form("MakerCh"))
  206.   if Request.Form("CommendFlag")=1 then
  207.         rs("CommendFlag")=Request.Form("CommendFlag")
  208.   else
  209.         rs("CommendFlag")=0
  210.   end if
  211.   if Request.Form("NewFlag")=1 then
  212.         rs("NewFlag")=Request.Form("NewFlag")
  213.   else
  214.         rs("NewFlag")=0
  215.   end if
  216.       GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
  217.   rs("GroupID")=GroupIdName(0)
  218.   rs("Exclusive")=trim(Request.Form("Exclusive"))
  219.   rs("BigPic")=trim(Request.Form("BigPic"))   
  220.   rs("SmallPic")=trim(Request.Form("SmallPic"))
  221.   rs("ContentCh")=Request.Form("ContentCh")
  222.   rs("UploadFiles")=trim(Request.Form("UploadFiles"))
  223.   rs("AddTime")=now()
  224.   rs("UpdateTime")=now()
  225. end if  
  226. if Result="Modify" then '修改产品信息
  227.       sql="select * from CompanyCMS_Products where ID="&ID
  228.       rs.open sql,conn,1,3
  229.       rs("ProductNameCh")=trim(Request.Form("ProductNameCh"))
  230.   if Request.Form("ViewFlagCh")=1 then
  231.         rs("ViewFlagCh")=Request.Form("ViewFlagCh")
  232.   else
  233.         rs("ViewFlagCh")=0
  234.   end if
  235.   if Request.Form("SortID")<>"" and Request.Form("SortPath")<>"" then
  236.     rs("SortID")=Request.Form("SortID")
  237. rs("SortPath")=Request.Form("SortPath")
  238.   else
  239.         response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
  240.         response.end
  241.   end if
  242.   rs("ProductNo")=trim(Request.Form("ProductNo"))
  243.   rs("ProductModel")=trim(Request.Form("ProductModel"))
  244.   if (not IsNumeric(trim(request.Form("N_Price")))) or (not IsNumeric(trim(request.Form("P_Price"))))then
  245.         response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
  246.         response.end
  247.       elseif trim(request.Form("N_Price"))<0 or trim(request.Form("P_Price"))<0then
  248.         response.write ("<script language=javascript> alert('标准价和优惠价数据必填,且为正数!');history.back(-1);</script>")
  249.         response.end
  250.       else
  251.         rs("N_Price")=Round(trim(Request.Form("N_Price")),2)
  252.     rs("P_Price")=Round(trim(Request.Form("P_Price")),2)
  253.   end if
  254.   if (not IsNumeric(trim(request.Form("Stock"))))  then
  255.         response.write ("<script language=javascript> alert('库存数量必填且为数值!');history.back(-1);</script>")
  256.         response.end
  257.   else
  258. rs("Stock")=Round(trim(Request.Form("Stock")),2)
  259.   end if 
  260.   rs("UnitCh")=trim(Request.Form("UnitCh"))
  261.   rs("MakerCh")=trim(Request.Form("MakerCh"))
  262.   if Request.Form("CommendFlag")=1 then
  263.         rs("CommendFlag")=Request.Form("CommendFlag")
  264.   else
  265.         rs("CommendFlag")=0
  266.   end if
  267.   if Request.Form("NewFlag")=1 then
  268.         rs("NewFlag")=Request.Form("NewFlag")
  269.   else
  270.         rs("NewFlag")=0
  271.   end if
  272.       GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
  273.   rs("GroupID")=GroupIdName(0)
  274.   rs("Exclusive")=trim(Request.Form("Exclusive"))
  275.   rs("BigPic")=trim(Request.Form("BigPic"))   
  276.   rs("SmallPic")=trim(Request.Form("SmallPic"))
  277.   rs("ContentCh")=Request.Form("ContentCh")
  278.   rs("UploadFiles")=trim(Request.Form("UploadFiles"))
  279.   rs("UpdateTime")=now()
  280. end if
  281. rs.update
  282. rs.close
  283.     set rs=nothing 
  284.     response.write "<script language=javascript> alert('成功编辑产品信息!');changeAdminFlag('产品列表');location.replace('ProductList.asp');</script>"
  285.   else '提取产品信息
  286. if Result="Modify" then
  287.       set rs = server.createobject("adodb.recordset")
  288.       sql="select * from CompanyCMS_Products where ID="& ID
  289.       rs.open sql,conn,1,1
  290.       if rs.bof and rs.eof then
  291.         response.write ("数据库读取记录出错!")
  292.         response.end
  293.       end if
  294.   ProductNameCh=rs("ProductNameCh")
  295.   ViewFlagCh=rs("ViewFlagCh")
  296.   SortNameCh=SortText(rs("SortID"))
  297.   SortID=rs("SortID")
  298.   SortPath=rs("SortPath")
  299.   ProductNo=rs("ProductNo")
  300.       ProductModel=rs("ProductModel")
  301.   N_Price=rs("N_Price")
  302.   P_Price=rs("P_Price")
  303.   Stock=rs("Stock")
  304.   UnitCh=rs("UnitCh")
  305.   MakerCh=rs("MakerCh")
  306.   CommendFlag=rs("CommendFlag")
  307.   NewFlag=rs("NewFlag")
  308.   GroupID=rs("GroupID")
  309.   Exclusive=rs("Exclusive")
  310.   BigPic=rs("BigPic")
  311.   SmallPic=rs("SmallPic")
  312.       ContentCh=rs("ContentCh")
  313.   UploadFiles=rs("UploadFiles")
  314.   rs.close
  315.       set rs=nothing 
  316. else
  317.   randomize timer
  318.   ProductNo=Hour(now)&Minute(now)&Second(now)&"-"&int(900*rnd)+100
  319.   Stock=10000
  320.     end if
  321.   end if
  322. end sub
  323. %>
  324. <% 
  325. sub SelectGroup()
  326.   dim rs,sql
  327.   set rs = server.createobject("adodb.recordset")
  328.   sql="select GroupID,GroupNameCh from CompanyCMS_MemGroup"
  329.   rs.open sql,conn,1,1
  330.   if rs.bof and rs.eof then
  331.     response.write("未设组别")
  332.   end if
  333.   while not rs.eof
  334.     response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupNameCh")&"'")
  335.     if GroupID=rs("GroupID") then response.write ("selected")
  336.     response.write(">"&rs("GroupNameCh")&"</option>")
  337.     rs.movenext
  338.   wend
  339.   rs.close
  340.   set rs=nothing
  341. end sub
  342. %>
  343. <%
  344. '生成所属类别--------------------------
  345. Function SortText(ID)
  346.   Dim rs,sql
  347.   Set rs=server.CreateObject("adodb.recordset")
  348.   sql="Select * From CompanyCMS_ProductSort where ID="&ID
  349.   rs.open sql,conn,1,1
  350.   SortText=rs("SortNameCh")
  351.   rs.close
  352.   set rs=nothing
  353. End Function
  354. %>