ProductEdit.asp
上传用户:dbstep
上传日期:2022-08-06
资源大小:2803k
文件大小:12k
源码类别:

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

开发平台:

ASP/ASPX

  1. <HTML xmlns="http://www.w3.org/1999/xhtml">
  2. <HEAD>
  3. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
  4. <TITLE>编辑产品</TITLE>
  5. <link rel="stylesheet" href="Images/CssAdmin.css">
  6. <script language="javascript" src="../skweb/JS/Admin.js"></script>
  7. </HEAD>
  8. <!--#include file="../skweb/Const.asp" -->
  9. <!--#include file="../skweb/ConnSiteData.asp" -->
  10. <!-- #include file="../fckeditor/fckeditor.asp" -->
  11. <!--#include file="CheckAdmin.asp"-->
  12. <%
  13. if Instr(session("AdminPurview"),"|33,")=0 then 
  14.   response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
  15.   response.end
  16. end if
  17. '========判断是否具有管理权限
  18. %>
  19. <BODY>
  20. <% 
  21. dim Result
  22. Result=request.QueryString("Result")
  23. dim ID,ProductName,ViewFlag,SortName,SortID,SortPath
  24. dim ProductNo,ProductModel,Price,Maker,CommendFlag,NewFlag,GroupID,GroupIdName,Exclusive
  25. dim BigPic,SmallPic,Content
  26. ID=request.QueryString("ID")
  27. call ProductEdit() 
  28. %>
  29.  
  30. <table width="100%" border="0" cellpadding="3"  >
  31.   <form name="editForm" method="post" action="ProductEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
  32.   <tr>
  33.     <td height="24" nowrap bgcolor="#EBF2F9"><table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" id=editProduct idth="100%">
  34.    <tr>
  35.         <td height="29" colspan="2" background="Images/menutitle.gif" bgcolor="#FFFFFF"><table width="470" border="0" cellspacing="0" cellpadding="0">
  36.           <tr>
  37.             <td width="121"><strong><font color="#000000" size="2">产品管理</font></strong></td>
  38.             <td width="87"><a href="ProductEdit.asp?Result=Add"><img src="Images/x1.gif" width="52" height="17" border="0"></a></td>
  39.             <td width="87"><a href="ProductList.asp"><img src="Images/xlm.gif" width="52" height="17" border="0"></a></td>
  40.             <td width="87"><a href="ProductSort.asp"><img src="Images/xx.gif" width="52" height="17" border="0"></a></td>
  41.             <td width="88"><a href="OrderList.asp"><img src="Images/xdd.gif" width="52" height="17" border="0"></a></td>
  42.           </tr>
  43.         </table></td>
  44.       </tr>
  45.       <tr>
  46.         <td height="20" align="right" bgcolor="#FFFFFF">产品名称:</td>
  47.         <td bgcolor="#FFFFFF"><input name="ProductName" type="text" class="textfield" id="ProductName" style="WIDTH: 240;" value="<%=ProductName%>" maxlength="100">
  48.           &nbsp;*&nbsp;不少于3个字符 
  49.           <input name="ViewFlag" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" <%if ViewFlag then response.write ("checked")%>>
  50.           发布&nbsp;
  51.           <input name="CommendFlag" type="checkbox" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if CommendFlag then response.write ("checked")%>>
  52.           &nbsp;推荐&nbsp;
  53.           <input name="NewFlag" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if NewFlag then response.write ("checked")%>>
  54.           &nbsp;最新</td>
  55.       </tr>
  56.       <tr>
  57.         <td height="24" align="right" bgcolor="#FFFFFF">所属类别:</td>
  58.         <td bgcolor="#FFFFFF"><input name="SortID" type="text" class="textfield" id="SortID" style="WIDTH: 40;background-color:#EBF2F9;" value="<%=SortID%>" readonly>&nbsp;<input name="SortPath" type="text" class="textfield" id="SortPath" style="WIDTH: 80;background-color:#EBF2F9;" value="<%=SortPath%>" readonly>&nbsp;<input name="SortName" type="text" class="textfield" id="SortName" value="<%=SortName%>" style="WIDTH: 140;background-color:#EBF2F9;" 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>
  59.       </tr>
  60.       <tr>
  61.         <td height="20" align="right" bgcolor="#FFFFFF">编  号:</td>
  62.         <td bgcolor="#FFFFFF"><input name="ProductNo" type="text" class="textfield" id="ProductNo" style="WIDTH: 240;" value="<%=ProductNo%>" maxlength="100">&nbsp;*&nbsp;如果不明确请勿修改</td>
  63.       </tr>
  64.       <tr>
  65.         <td height="20" align="right" bgcolor="#FFFFFF">型  号:</td>
  66.         <td bgcolor="#FFFFFF"><input name="ProductModel" type="text" class="textfield" id="ProductModel" style="WIDTH: 240;" value="<%=ProductModel%>" maxlength="100"></td>
  67.       </tr>
  68.       <tr>
  69.         <td height="20" align="right" bgcolor="#FFFFFF">价  格:</td>
  70.         <td bgcolor="#FFFFFF"><input name="Price" type="text" class="textfield" id="Price" style="WIDTH: 240;" value="<%=Price%>" maxlength="100"></td>
  71.       </tr>   
  72.   <tr>
  73.         <td height="20" align="right" bgcolor="#FFFFFF">出品公司:</td>
  74.         <td bgcolor="#FFFFFF"><input name="Maker" type="text" class="textfield" id="Maker" style="WIDTH: 240;" value="<%=Maker%>" maxlength="100"></td>
  75.       </tr>
  76.       <tr>
  77.         <td height="20" align="right" bgcolor="#FFFFFF">查看权限:</td>
  78.         <td bgcolor="#FFFFFF"><select name="GroupID" class="textfield">
  79.           <% call SelectGroup() %>
  80.           </select>
  81.           <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="=">
  82.           专属 [隶属:权限值≥可查看,专属:权限值=可查看]</td>
  83.       </tr>
  84.       <tr>
  85.         <td height="20" align="right" bgcolor="#FFFFFF">产品主图:</td>
  86.         <td bgcolor="#FFFFFF"><input name="BigPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=BigPic%>" maxlength="100">&nbsp;<a href="javaScript:OpenScript('UpFileForm.asp?Result=BigPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a></td>
  87.       </tr>
  88.       <tr>
  89.         <td height="20" align="right" bgcolor="#FFFFFF">缩 略 图:</td>
  90.         <td bgcolor="#FFFFFF"><input name="SmallPic" type="text" class="textfield" style="WIDTH: 240;" value="<%=SmallPic%>" maxlength="100">&nbsp;<a href="javaScript:OpenScript('UpFileForm.asp?Result=SmallPic',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a></td>
  91.       </tr>
  92.       <tr>
  93.         <td height="20" align="right" valign="top" bgcolor="#FFFFFF">详细介绍:<br>
  94.         <td bgcolor="#FFFFFF"><%
  95. Dim oFCKeditor
  96. Set oFCKeditor = New FCKeditor
  97. oFCKeditor.BasePath = "../fckeditor/" 
  98. oFCKeditor.Width = "100%" 
  99. oFCKeditor.Height = "400" 
  100. oFCKeditor.Value = content
  101. oFCKeditor.Create "Content" 
  102. %></td>
  103.       </tr>
  104.       <tr>
  105.         <td height="30" align="right" bgcolor="#FFFFFF">&nbsp;</td>
  106.         <td valign="bottom" bgcolor="#FFFFFF"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
  107.       </tr>
  108.     </table></td>
  109.   </tr>
  110.   </form>
  111. </table>
  112. </BODY>
  113. </HTML>
  114. <%
  115. sub ProductEdit()
  116.   dim Action,rsRepeat,rs,sql
  117.   Action=request.QueryString("Action")
  118.   if Action="SaveEdit" then '保存编辑产品信息
  119.     set rs = server.createobject("adodb.recordset")
  120.     if len(trim(request.Form("ProductName")))<3 then
  121.       response.write ("<script language=javascript> alert('产品名称为必填项目!');history.back(-1);</script>")
  122.       response.end
  123.     end if
  124.     if Result="Add" then '创建产品信息
  125.   sql="select * from sk_Products"
  126.       rs.open sql,conn,1,3
  127.       rs.addnew
  128.       rs("ProductName")=trim(Request.Form("ProductName"))
  129.   if Request.Form("ViewFlag")=1 then
  130.         rs("ViewFlag")=Request.Form("ViewFlag")
  131.   else
  132.         rs("ViewFlag")=0
  133.   end if
  134.   if Request.Form("SortID")="" and Request.Form("SortPath")="" then
  135.         response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
  136.         response.end
  137.   else
  138.     rs("SortID")=Request.Form("SortID")
  139. rs("SortPath")=Request.Form("SortPath")
  140.   end if
  141.       set rsRepeat = conn.execute("select ProductNo from sk_Products where ProductNo='" & trim(Request.Form("ProductNo")) & "'")
  142.       if not (rsRepeat.bof and rsRepeat.eof) then '判断此产品编号是否存在
  143.         response.write "<script language=javascript> alert('" & trim(Request.Form("ProductNo")) & "此产品编号已经存在,请换一个编号再试试!');history.back(-1);</script>"
  144.         response.end
  145.       else
  146.     rs("ProductNo")=trim(Request.Form("ProductNo"))
  147.   end if
  148.   rs("ProductModel")=trim(Request.Form("ProductModel"))
  149.   rs("Price")=trim(Request.Form("Price"))
  150.   rs("Maker")=trim(Request.Form("Maker"))
  151.   if Request.Form("CommendFlag")=1 then
  152.         rs("CommendFlag")=Request.Form("CommendFlag")
  153.   else
  154.         rs("CommendFlag")=0
  155.   end if
  156.   if Request.Form("NewFlag")=1 then
  157.         rs("NewFlag")=Request.Form("NewFlag")
  158.   else
  159.         rs("NewFlag")=0
  160.   end if
  161.       GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
  162.   rs("GroupID")=GroupIdName(0)
  163.   rs("Exclusive")=trim(Request.Form("Exclusive"))
  164.   rs("BigPic")=trim(Request.Form("BigPic"))   
  165.   rs("SmallPic")=trim(Request.Form("SmallPic"))
  166.   rs("Content")=Request.Form("Content")
  167.   rs("AddTime")=now()
  168. end if  
  169. if Result="Modify" then '修改产品信息
  170.       sql="select * from sk_Products where ID="&ID
  171.       rs.open sql,conn,1,3
  172.       rs("ProductName")=trim(Request.Form("ProductName"))
  173.   if Request.Form("ViewFlag")=1 then
  174.         rs("ViewFlag")=Request.Form("ViewFlag")
  175.   else
  176.         rs("ViewFlag")=0
  177.   end if
  178.   if Request.Form("SortID")<>"" and Request.Form("SortPath")<>"" then
  179.     rs("SortID")=Request.Form("SortID")
  180. rs("SortPath")=Request.Form("SortPath")
  181.   else
  182.         response.write ("<script language=javascript> alert('请选择所属分类!');history.back(-1);</script>")
  183.         response.end
  184.   end if
  185.   rs("ProductNo")=trim(Request.Form("ProductNo"))
  186.   rs("ProductModel")=trim(Request.Form("ProductModel"))
  187.   rs("Price")=trim(Request.Form("Price"))
  188.   rs("Maker")=trim(Request.Form("Maker"))
  189.   if Request.Form("CommendFlag")=1 then
  190.         rs("CommendFlag")=Request.Form("CommendFlag")
  191.   else
  192.         rs("CommendFlag")=0
  193.   end if
  194.   if Request.Form("NewFlag")=1 then
  195.         rs("NewFlag")=Request.Form("NewFlag")
  196.   else
  197.         rs("NewFlag")=0
  198.   end if
  199.       GroupIdName=split(Request.Form("GroupID"),"┎╂┚")
  200.   rs("GroupID")=GroupIdName(0)
  201.   rs("Exclusive")=trim(Request.Form("Exclusive"))
  202.   rs("BigPic")=trim(Request.Form("BigPic"))   
  203.   rs("SmallPic")=trim(Request.Form("SmallPic"))
  204.   rs("Content")=Request.Form("Content")
  205. end if
  206. rs.update
  207. rs.close
  208.     set rs=nothing 
  209.      Response.Redirect("Tips/pro.asp")
  210.   else '提取产品信息
  211. if Result="Modify" then
  212.       set rs = server.createobject("adodb.recordset")
  213.       sql="select * from sk_Products where ID="& ID
  214.       rs.open sql,conn,1,1
  215.       if rs.bof and rs.eof then
  216.         response.write ("数据库读取记录出错!")
  217.         response.end
  218.       end if
  219.   ProductName=rs("ProductName")
  220.   ViewFlag=rs("ViewFlag")
  221.   SortName=SortText(rs("SortID"))
  222.   SortID=rs("SortID")
  223.   SortPath=rs("SortPath")
  224.   ProductNo=rs("ProductNo")
  225.       ProductModel=rs("ProductModel")
  226.   Price=rs("Price")
  227.   Maker=rs("Maker")
  228.   CommendFlag=rs("CommendFlag")
  229.   NewFlag=rs("NewFlag")
  230.   GroupID=rs("GroupID")
  231.   Exclusive=rs("Exclusive")
  232.   BigPic=rs("BigPic")
  233.   SmallPic=rs("SmallPic")
  234.       Content=rs("Content")
  235.   rs.close
  236.       set rs=nothing 
  237. else
  238.   ProductNo="Pro"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)
  239.     end if
  240.   end if
  241. end sub
  242. %>
  243. <% 
  244. sub SelectGroup()
  245.   dim rs,sql
  246.   set rs = server.createobject("adodb.recordset")
  247.   sql="select GroupID,GroupName from sk_MemGroup"
  248.   rs.open sql,conn,1,1
  249.   if rs.bof and rs.eof then
  250.     response.write("未设组别")
  251.   end if
  252.   while not rs.eof
  253.     response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupName")&"'")
  254.     if GroupID=rs("GroupID") then response.write ("selected")
  255.     response.write(">"&rs("GroupName")&"</option>")
  256.     rs.movenext
  257.   wend
  258.   rs.close
  259.   set rs=nothing
  260. end sub
  261. %>
  262. <%
  263. '生成所属类别--------------------------
  264. Function SortText(ID)
  265.   Dim rs,sql
  266.   Set rs=server.CreateObject("adodb.recordset")
  267.   sql="Select * From sk_ProductSort where ID="&ID
  268.   rs.open sql,conn,1,1
  269.   SortText=rs("SortName")
  270.   rs.close
  271.   set rs=nothing
  272. End Function
  273. %>