PageRenderTime 35ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/db/admin/product_edit.asp

https://github.com/semious/dynacomcorp
ASP | 503 lines | 493 code | 9 blank | 1 comment | 39 complexity | 85fe0a60ff1b58593317d698f843b942 MD5 | raw file
  1. <!--#include file="conn.asp"-->
  2. <!--#include file="IsAdmin.asp" -->
  3. <html>
  4. <head>
  5. <meta http-equiv="content-type" content="text/html">
  6. <title>Edit Product page</title>
  7. <link rel="stylesheet" href="css/style.css">
  8. </head>
  9. <body>
  10. <%
  11. Response.Buffer = True
  12. Response.ExpiresAbsolute = Now() - 1
  13. Response.Expires = 0
  14. Response.CacheControl = no-cache
  15. dim edit,id,sql
  16. dim rs
  17. dim flag
  18. flag=0
  19. set rs =server.createobject("adodb.recordset")
  20. edit=trim(request("action"))
  21. id=trim(cstr(request("id")))
  22. 'delete item
  23. if edit = "delete" then
  24. rs.open "select * from cat where p_id like '%|"+id+"|%'",conn
  25. if not rs.eof then
  26. response.Write("<script>alert('sorry!a menu named "+trim(cstr(rs("name")))+" has this product which you want to delete,so you must remove this product from this menu first!');history.back(-1);</script>")
  27. response.End()
  28. else
  29. sql = "delete from product where id = " & id
  30. conn.execute sql
  31. response.Write("<div style='margin:50px 0 0 200px;font-weight:bold;'>Product has been deleted.</div>")
  32. response.End()
  33. end if
  34. rs.close
  35. end if
  36. %>
  37. <script language="javascript">
  38. function confirmDel(id,page){
  39. if (confirm("Are you sure?")){
  40. window.location.href = "product_edit.asp?action=delete&id=" + id+ "&page="+page ;
  41. }
  42. }
  43. function checkdata() {
  44. if (document.DocForm.name.value.length ==0 ) {
  45. alert("part_num should not be left blank!")
  46. document.DocForm.name.focus()
  47. return false;
  48. }
  49. if (document.DocForm.des.value.length ==0) {
  50. alert("description should not be left blank!")
  51. document.DocForm.des.focus()
  52. return false;
  53. }
  54. if (document.DocForm.pic1.value.length ==0 ) {
  55. alert("You must have a picture at least!")
  56. document.DocForm.pic1.focus()
  57. return false;
  58. }
  59. if (document.DocForm.pdf.value.length ==0) {
  60. alert("Lack of a pdf file!")
  61. document.DocForm.pdf.focus()
  62. return false;
  63. }
  64. return true;
  65. }
  66. //window.onload = function(){
  67. //// document.forms[0]["des"].value = unescape(document.forms[0]["des"].value);
  68. //}
  69. </script>
  70. <div align="center">
  71. <p><font size="4"><b>Product Information</b></font></p>
  72. </div>
  73. <div>
  74. <%
  75. if edit="edit" then
  76. sql="select * from product where id = " + id + " "
  77. else
  78. sql="select top 1 * from product"
  79. end if
  80. rs.open sql,conn,1,3
  81. if rs.eof and rs.bof then
  82. response.write "No product"
  83. response.End()
  84. else
  85. %>
  86. <table border="1px" cellspacing="0" width="696" bordercolor="#000000" cellpadding="0" align="left" style="margin:0 0 0 10px; font-size:14px;">
  87. <tr>
  88. <td width="100" align="center" bgcolor="#FEEC85" style="border:1px #000000 solid">
  89. <strong>Part_Num</strong></td>
  90. <td width="436" align="center" bgcolor="#FEEC85" style="border:1px #000000 solid">
  91. <strong>Description</strong></td>
  92. <td width="50" align="center" bgcolor="#FEEC85" style="border:1px #000000 solid">
  93. <b>Del</b></td>
  94. <td width="48" align="center" bgcolor="#FEEC85" style="border:1px #000000 solid">
  95. <b>View</b></td>
  96. </tr>
  97. <%
  98. dim curpage,i
  99. if request("page")="" then
  100. curpage = 1
  101. else
  102. curpage = cint(request("page"))
  103. end if
  104. rs.pagesize = 12
  105. rs.absolutepage = curpage
  106. for i = 1 to rs.pagesize
  107. %>
  108. <tr>
  109. <td bgcolor="#FFFCD9" style="border:1px #000000 solid">
  110. <p align="center" bgcolor="#E8E8E8"><%=rs("name")%>
  111. </td>
  112. <td bgcolor="#FFFCD9" style="border:1px #000000 solid">
  113. <p align="center"><a href="product_edit.asp?action=edit&id=<%=rs("id")%>"><%=unescape(rs("des"))%></a>
  114. </td>
  115. <td bgcolor="#FFFCD9" style="border:1px #000000 solid">
  116. <p align="center"><a href='javascript:confirmDel(<%= rs("id")%>,<%=cstr(curpage)%>)'>Del</a>
  117. </td>
  118. <td bgcolor="#FFFCD9" style="border:1px #000000 solid">
  119. <p align="center"><a href="../product.asp?pid=<%=rs("id")%>" target="_blank">View</a>
  120. </td>
  121. </tr>
  122. <%
  123. rs.movenext
  124. if rs.eof then
  125. i = i + 1
  126. exit for
  127. end if
  128. next
  129. %>
  130. </table>
  131. </div>
  132. <p>
  133. <%
  134. rs.close
  135. end if
  136. if edit="edit" then
  137. set fs=server.createobject("adodb.recordset")
  138. sql="select * from product where id = "+ id +""
  139. fs.open sql,conn,1,3
  140. %>
  141. </p>
  142. <p>&nbsp;</p>
  143. <p>&nbsp;</p>
  144. <form onSubmit="return checkdata()" name="DocForm" action="product_add2.asp">
  145. <table border="1" cellspacing="0" width="668" bordercolor="#000000" cellpadding="1" style="margin:0 0 0 20px;font-size:14px;">
  146. <tr>
  147. <td width="15%"></td>
  148. <td width="35%"></td>
  149. <td width="15%"></td>
  150. <td width="35%"></td>
  151. </tr>
  152. <tr align="center">
  153. <td colspan="4" height="20" style="border:1px solid #000000; background-color:#FEEC85">
  154. <div align="center"><font color="#FF0000"><b>Detail Information</b></font></div>
  155. </td>
  156. </tr>
  157. <tr align="center">
  158. <td width="110" style="border:1px solid #000000">
  159. <div align="right">Part_Number:</div>
  160. </td>
  161. <td colspan="3" style="border:1px solid #000000;padding:0 0 0 10px;">
  162. <div align="left"><input name="name" value="<%=fs("name")%>" size="60" maxlength="50" /></div>
  163. </td>
  164. </tr>
  165. <tr>
  166. <td width="94" style="border:1px solid #000000">
  167. <div align="right">Description:</div>
  168. </td>
  169. <td style="border:1 solid #000000;padding:0 0 0 10px;" colspan="3" align="left">
  170. <div align="left"><textarea name="des" cols="60" rows="1"><%=unescape(fs("des"))%></textarea></div>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td width="94" style="border:1px solid #000000">
  175. <div align="right">Short Desc.:</div>
  176. </td>
  177. <td style="border:1 solid #000000;padding:0 0 0 10px;" colspan="3" align="left">
  178. <div align="left"><textarea name="s_des" cols="60" rows="1"><%=fs("s_des")%></textarea></div>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td width="110" style="border:1px solid #000000">
  183. <div align="right">Picture1:</div>
  184. </td>
  185. <td width="210" style="border:1px solid #000000;padding:0 0 0 10px;">
  186. <div align="left"><input name="pic1" value="<%=fs("pic1")%>" size="20" maxlength="50" /></div>
  187. </td>
  188. <td width="94" style="border:1px solid #000000">
  189. <div align="right">Picture2:</div>
  190. </td>
  191. <td width="244" style="border:1px solid #000000;padding:0 0 0 10px;">
  192. <div align="left"><input name="pic2" value="<%=fs("pic2")%>" size="20" maxlength="50" /></div>
  193. </td>
  194. </tr>
  195. <tr>
  196. <td width="110" style="border:1px solid #000000">
  197. <div align="right">Picture3:</div>
  198. </td>
  199. <td width="210" style="border:1px solid #000000;padding:0 0 0 10px;">
  200. <div align="left"><input name="pic3" value="<%=fs("pic3")%>" size="20" maxlength="50" /></div>
  201. </td>
  202. <td width="94" style="border:1px solid #000000">
  203. <div align="right">Picture4:</div>
  204. </td>
  205. <td width="244" style="border:1px solid #000000;padding:0 0 0 10px;">
  206. <div align="left"><input name="pic4" value="<%=fs("pic4")%>" size="20" maxlength="50" /></div>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td width="110" style="border:1px solid #000000">
  211. <div align="right">Picture5:</div>
  212. </td>
  213. <td width="210" style="border:1px solid #000000;padding:0 0 0 10px;">
  214. <div align="left"><input name="pic5" value="<%=fs("pic5")%>" size="20" maxlength="50" /></div>
  215. </td>
  216. <td width="94" style="border:1px solid #000000">
  217. <div align="right">Picture6:</div>
  218. </td>
  219. <td width="244" style="border:1px solid #000000;padding:0 0 0 10px;">
  220. <div align="left"><input name="pic6" value="<%=fs("pic6")%>" size="20" maxlength="50" /></div>
  221. </td>
  222. </tr>
  223. <tr>
  224. <td width="110" style="border:1px solid #000000">
  225. <div align="right">Introduction:</div>
  226. </td>
  227. <td width="210" style="border:1px solid #000000;padding:0 0 0 10px;" colspan="3">
  228. <%dim intro
  229. intro=replace(fs("intro"),"<pre>","")
  230. intro=replace(intro,"</pre>","")
  231. %>
  232. <div align="left"><textarea rows="10" id="intro" cols="60" name="intro"><%=intro%></textarea></div>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td width="110" style="border:1px solid #000000">
  237. <div align="right">Video:</div>
  238. </td>
  239. <td style="border:1px solid #000000;padding:0 0 0 10px;">
  240. <div align="left"><input name="video" value="<%=fs("video")%>" size="20" maxlength="100"/></div>
  241. </td>
  242. <td style="border:1px solid #000000">
  243. <div align="right">Specification:</div>
  244. </td>
  245. <td style="border:1px solid #000000;padding:0 0 0 10px;">
  246. <div align="left"><input name="pdf" value="<%=fs("pdf")%>" size="20" maxlength="50" /></div>
  247. </td>
  248. </tr>
  249. <tr>
  250. <td style="border:1px solid #000000">
  251. <div align="right">Menu1:</div>
  252. </td>
  253. <td style="border:1px solid #000000;padding:0 0 0 10px;">
  254. <div align="left">
  255. <%
  256. rs.open "select * from cat where rank = '2'",conn
  257. if not rs.eof then
  258. %>
  259. <select disabled="disabled" name="menu1" style="width:150px;">
  260. <option value=" "></option>
  261. <%
  262. while not rs.eof
  263. if cstr(rs("id"))=cstr(fs("menu1")) then
  264. %>
  265. <option value="<%=trim(cstr(rs("id")))%>" selected="selected"><%=rs("name")%></option>
  266. <%
  267. else
  268. %>
  269. <option value="<%=trim(cstr(rs("id")))%>"><%=rs("name")%></option>
  270. <%
  271. end if
  272. rs.movenext
  273. wend
  274. %>
  275. </select>
  276. <span style="color: red">disabled</span>
  277. <%
  278. end if
  279. rs.close
  280. %>
  281. </div>
  282. </td>
  283. <td style="border:1px solid #000000">
  284. <div align="right">Menu2:</div>
  285. </td>
  286. <td style="border:1px solid #000000;padding:0 0 0 10px;">
  287. <div align="left">
  288. <%
  289. rs.open "select * from cat where rank = '2'",conn
  290. if not rs.eof then
  291. %>
  292. <select disabled="disabled" name="menu2" style="width:150px;"><option value=" "> </option><%
  293. while not rs.eof
  294. if cstr(rs("id"))=cstr(fs("menu2")) then
  295. %><option value="<%=trim(cstr(rs("id")))%>" selected="selected"><%=rs("name")%></option><%
  296. else
  297. %><option value="<%=trim(cstr(rs("id")))%>"><%=rs("name")%></option><%
  298. end if
  299. rs.movenext
  300. wend
  301. %>
  302. </select>
  303. <span style="color: red">disabled</span>
  304. <%
  305. end if
  306. rs.close
  307. %>
  308. </div>
  309. </td>
  310. </tr>
  311. <tr>
  312. <td style="border:1px solid #000000">
  313. <div align="right">Product1:</div>
  314. </td>
  315. <td style="border:1px solid #000;padding:0 0 0 10px;">
  316. <div align="left">
  317. <%
  318. rs.open "select * from product order by name",conn
  319. if not rs.eof then
  320. %>
  321. <select name="menu3" style="width:150px;">
  322. <option value=" "> </option>
  323. <%
  324. while not rs.eof
  325. if cstr(rs("id"))=cstr(fs("menu3")) then
  326. %><option value="<%=trim(cstr(rs("id")))%>" selected="selected"><%=rs("name")%></option><%
  327. else
  328. %><option value="<%=trim(cstr(rs("id")))%>"><%=rs("name")%></option><%
  329. end if
  330. rs.movenext
  331. wend
  332. %>
  333. </select>
  334. <%
  335. end if
  336. rs.close
  337. %>
  338. </div>
  339. </td>
  340. <td style="border:1px solid #000000">
  341. <div align="right">Menu4:</div>
  342. </td>
  343. <td style="border:1px solid #000000;padding:0 0 0 10px;">
  344. <div align="left">
  345. <%
  346. rs.open "select * from product order by name",conn
  347. if not rs.eof then
  348. %>
  349. <select name="menu4" style="width:150px;">
  350. <option value=" "> </option>
  351. <%
  352. while not rs.eof
  353. if cstr(rs("id"))=cstr(fs("menu4")) then
  354. %><option value="<%=trim(cstr(rs("id")))%>" selected="selected"><%=rs("name")%></option><%
  355. else
  356. %><option value="<%=trim(cstr(rs("id")))%>"><%=rs("name")%></option><%
  357. end if
  358. rs.movenext
  359. wend
  360. %>
  361. </select>
  362. <%
  363. end if
  364. rs.close
  365. %>
  366. </div>
  367. </td>
  368. </tr>
  369. <tr>
  370. <td style="border:1px solid #000000">
  371. <div align="right">Avail. Color:</div>
  372. </td>
  373. <td colspan="3" style="border:1px solid #000000;padding:0 0 0 10px;">
  374. <div align="left">
  375. <%
  376. if InStr(fs("color"),"BK") >0 then
  377. %>
  378. <input type="checkbox" name="bk" id="bk" value="BK" checked="checked">BK
  379. <%
  380. else
  381. %>
  382. <input type="checkbox" name="bk" id="bk" value="BK">BK
  383. <%
  384. end if
  385. if InStr(fs("color"),"WH") >0 then
  386. %>
  387. <input type="checkbox" name="wh" id="wh" value="WH" checked="checked">WH
  388. <%
  389. else
  390. %>
  391. <input type="checkbox" name="wh" id="wh" value="WH">WH
  392. <%
  393. end if
  394. if InStr(fs("color"),"PR") >0 then
  395. %>
  396. <input type="checkbox" name="pr" id="pr" value="PR" checked="checked">PR
  397. <%
  398. else
  399. %>
  400. <input type="checkbox" name="pr" id="pr" value="PR">PR
  401. <%
  402. end if
  403. if InStr(fs("color"),"BL") >0 then
  404. %>
  405. <input type="checkbox" name="bl" id="bl" value="BL" checked="checked">BL
  406. <%
  407. else
  408. %>
  409. <input type="checkbox" name="bl" id="bl" value="BL">BL
  410. <%
  411. end if
  412. if InStr(fs("color"),"AL") >0 then
  413. %>
  414. <input type="checkbox" name="al" id="al" value="AL" checked="checked">AL
  415. <%
  416. else
  417. %>
  418. <input type="checkbox" name="al" id="al" value="AL">AL
  419. <%
  420. end if
  421. if InStr(fs("color"),"GN") >0 then
  422. %>
  423. <input type="checkbox" name="gn" id="gn" value="GN" checked="checked">GN
  424. <%
  425. else
  426. %>
  427. <input type="checkbox" name="gn" id="gn" value="GN">GN
  428. <%
  429. end if
  430. if InStr(fs("color"),"GY") >0 then
  431. %>
  432. <input type="checkbox" name="gy" id="gy" value="GY" checked="checked">GY
  433. <%
  434. else
  435. %>
  436. <input type="checkbox" name="gy" id="gy" value="GY">GY
  437. <%
  438. end if
  439. if InStr(fs("color"),"IV") >0 then
  440. %>
  441. <input type="checkbox" name="iv" id="iv" value="IV" checked="checked">IV
  442. <%
  443. else
  444. %>
  445. <input type="checkbox" name="iv" id="iv" value="IY">IV
  446. <%
  447. end if
  448. if InStr(fs("color"),"OR") >0 then
  449. %>
  450. <input type="checkbox" name="orange" id="or" value="OR" checked="checked">OR
  451. <%
  452. else
  453. %>
  454. <input type="checkbox" name="oragne" id="or" value="OR">OR
  455. <%
  456. end if
  457. if InStr(fs("color"),"RD") >0 then
  458. %>
  459. <input type="checkbox" name="rd" id="rd" value="RD" checked="checked">RD
  460. <%
  461. else
  462. %>
  463. <input type="checkbox" name="rd" id="rd" value="RD">RD
  464. <%
  465. end if
  466. if InStr(fs("color"),"YL") >0 then
  467. %>
  468. <input type="checkbox" name="yl" id="yl" value="YL" checked="checked">YL
  469. <%
  470. else
  471. %>
  472. <input type="checkbox" name="yl" id="yl" value="YL">YL
  473. <%
  474. end if
  475. %>
  476. </div>
  477. </td>
  478. </tr>
  479. <tr>
  480. <td colspan="4" width="664">
  481. <div align="center">
  482. <input type="hidden" name="action" value="editsave">
  483. <input type="hidden" name="id" value=<%=id%>>
  484. <input type="hidden" name="page" value="<%=curpage%>">
  485. <input type="submit" name="Submit" value=" Done">
  486. </div>
  487. </td>
  488. </tr>
  489. </table>
  490. </form>
  491. </div>
  492. <%end if%>
  493. </body>
  494. </html>