/db/admin/store_add2.asp

https://github.com/semious/dynacomcorp · ASP · 120 lines · 101 code · 19 blank · 0 comment · 10 complexity · 3e13214c73dba3ee3abf801d25a391d0 MD5 · raw file

  1. <!--#include file="conn.asp" -->
  2. <!--#include file="IsAdmin.asp" -->
  3. <%
  4. dim rs1
  5. dim name,pic,address,tel,zone,address1,address2
  6. dim maxid
  7. dim edit,id
  8. edit=trim(cstr(request("action")))
  9. id=cstr(request("id"))
  10. name=trim(cstr(request("name")))
  11. pic=trim(cstr(request("pic")))
  12. address=trim(cstr(request("address")))
  13. address1=trim(cstr(request("address1")))
  14. address2=trim(cstr(request("address2")))
  15. tel=trim(cstr(request("tel")))
  16. zone=trim(cstr(request("zone")))
  17. set rs1=server.createobject("adodb.recordset")
  18. dim rs,sql,rs2
  19. set rs=server.createobject("adodb.recordset")
  20. set rs2=server.createobject("adodb.recordset")
  21. if name="" then
  22. response.Write("<script>alert('sorry£¬you must input name ');history.back(-1);</script>")
  23. response.End()
  24. end if
  25. if address="" then
  26. response.Write("<script>alert('sorry£¬you must input address ');history.back(-1);</script>")
  27. response.End()
  28. end if
  29. if pic="" then
  30. response.Write("<script>alert('sorry£¬you must input picture ');history.back(-1);</script>")
  31. response.End()
  32. end if
  33. if tel="" then
  34. response.Write("<script>alert('sorry£¬you must input telepone ');history.back(-1);</script>")
  35. response.End()
  36. end if
  37. if zone="" then
  38. response.Write("<script>alert('sorry£¬you must input zone ');history.back(-1);</script>")
  39. response.End()
  40. end if
  41. if edit = "editsave" then
  42. rs1.open "select * from product where name='"+name+"' and id <> '"+id+"'",conn
  43. if not rs1.eof then
  44. response.write"<script>alert('Sorry£¬the name has been used£¡Please choose another name£¡');history.back(-1);</script>"
  45. response.end
  46. end if
  47. rs1.close
  48. name=replace(name,"'","''")
  49. address=replace(address,"'","''")
  50. address1=replace(address1,"'","''")
  51. address2=replace(address2,"'","''")
  52. pic=replace(pic,"'","''")
  53. tel=replace(tel,"'","''")
  54. zone=replace(zone,"'","''")
  55. sql = "update distributor set "
  56. sql = sql + "name='" + name +"',"
  57. sql = sql + "address='" + address + "',"
  58. sql = sql + "pic='" + pic + "',"
  59. sql = sql + "address1='" + address1 + "',"
  60. sql = sql + "address2='" + address2 + "',"
  61. sql = sql + "tel='" + tel +"',"
  62. sql = sql + "[zone]='" + zone + "' "
  63. sql = sql + " where id = " & id
  64. conn.execute sql
  65. response.Write("<script>alert('Update Ok');location.href='store_edit.asp?action=edit&id="+id+"'</script>")
  66. response.end
  67. end if
  68. rs1.open "select * from distributor where name='"&name&"'",conn
  69. if not rs1.eof then
  70. response.write"<script>alert('sorry£¬the name has been used£¡Please choose another name£¡');history.back(-1);</script>"
  71. response.end
  72. end if
  73. rs1.close
  74. rs1.open "select max(id) as maxid from distributor",conn
  75. if not rs1.eof then
  76. maxid = trim(cstr(rs1("maxid")))+1
  77. else
  78. maxid = 1
  79. end if
  80. rs1.close
  81. sql="select top 1 * from distributor"
  82. rs.open sql,conn,1,3
  83. if not rs.eof then
  84. rs.addnew
  85. rs("id")=maxid
  86. rs("name")=name
  87. rs("address")=address
  88. rs("address1")=address1
  89. rs("address2")=address2
  90. rs("pic")=pic
  91. rs("tel")=tel
  92. rs("zone")=zone
  93. rs.update
  94. set rs1=nothing
  95. rs.close
  96. set rs=nothing
  97. conn.close
  98. set conn=nothing
  99. response.redirect"store_add_ok.asp"
  100. end if
  101. %>