Guest User

shopping cart

a guest
Jun 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. <%@ page contentType="text/html;charset=windows-1252"%>
  2. <jsp:useBean id="Util" scope="page" class="all.bean.Util" />
  3. <jsp:useBean id="db" scope="page" class="all.bean.Database" />
  4. <%@ page import="java.sql.*" %>
  5.  
  6. <html lang="en">
  7. <head>
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1">
  10. <title>Sigmaperkasa</title>
  11.  
  12. <!-- Google Fonts -->
  13. <link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,200,300,700,600' rel='stylesheet' type='text/css'>
  14. <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700,300' rel='stylesheet' type='text/css'>
  15. <link href='http://fonts.googleapis.com/css?family=Raleway:400,100' rel='stylesheet' type='text/css'>
  16.  
  17. <!-- Bootstrap -->
  18. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  19.  
  20. <!-- Font Awesome -->
  21. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  22.  
  23. <!-- Custom CSS -->
  24. <link rel="stylesheet" href="css/owl.carousel.css">
  25. <link rel="stylesheet" href="style.css">
  26. <link rel="stylesheet" href="css/responsive.css">
  27.  
  28. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  29. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  30. <!--[if lt IE 9]>
  31. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  32. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  33. <![endif]-->
  34. <script language="javascript">
  35. function getCookie(cname) {
  36. var name = cname + "=";
  37. var ca = document.cookie.split(';');
  38. for(var i=0; i<ca.length; i++) {
  39. var c = ca[i];
  40. while (c.charAt(0)==' ') {
  41. c = c.substring(1);
  42. }
  43. if (c.indexOf(name) == 0) {
  44. return c.substring(name.length, c.length);
  45. }
  46. }
  47. return "";
  48. }
  49.  
  50.  
  51. function setCookie(cname,cvalue,exdays) {
  52. var d = new Date();
  53. d.setTime(d.getTime() + (exdays*24*60*60*1000));
  54. var expires = "expires=" + d.toGMTString();
  55. document.cookie = cname+"="+cvalue+"; "+expires;
  56. }
  57.  
  58.  
  59. function AddCart(ProductID) {
  60.  
  61.  
  62. var strProductID = document.form.CartItem.value;
  63. var arrayCart = strProductID.split(",");
  64. var AddCart = true;
  65. var CartProductID = "";
  66.  
  67. var arrayLength = arrayCart.length;
  68. for (var i = 0; i < arrayLength; i++) {
  69. //alert(arrayCart[i]);
  70. if (arrayCart[i] == ProductID) {
  71. AddCart = false;
  72. }
  73.  
  74. }
  75.  
  76. if (AddCart==true) {
  77. if (document.form.CartItem.value == ""){
  78. CartProductID=ProductID;
  79. document.form.CartItem.value=ProductID;
  80. } else {
  81. CartProductID=document.form.CartItem.value + "," + ProductID;
  82. document.form.CartItem.value = document.form.CartItem.value + "," + ProductID;
  83. }
  84. }
  85.  
  86.  
  87. if (CartProductID !="") {
  88. setCookie("Cart_Product", CartProductID, 30);
  89. setCookie("CartCount", parseInt(document.form.CartCount.value) + 1, 30);
  90.  
  91.  
  92. }
  93.  
  94. document.form.CartCount.value = parseInt(document.form.CartCount.value) + 1;
  95.  
  96. var Test=getCookie("Cart_Product");
  97. var Test2=getCookie("CartCount");
  98. alert(Test);
  99. alert(Test2);
  100. }
  101.  
  102. </script>
  103. </head>
  104. <body>
  105. <form name="frm" method="post">
  106. <div class="header-area">
  107. <div class="container">
  108. <div class="row">
  109. <div class="col-md-8">
  110. <div class="user-menu">
  111. <ul>
  112. <li> <table><tr><td>Welcome,
  113. <%
  114. String strMemberName = (String)session.getAttribute("strMemberName");
  115. String strContactNumber = (String)session.getAttribute("strContactNumber");
  116. String strLoginID = (String)session.getAttribute("strLoginID");
  117.  
  118. if(strLoginID==null)
  119. strLoginID="";
  120. if(strContactNumber==null)
  121. strContactNumber="";
  122. if(strMemberName==null)
  123. strMemberName="";
  124.  
  125. if (strMemberName.equals("")) {
  126. out.println("Guest!");
  127. %>
  128. &nbsp;&nbsp;&nbsp;
  129. <li><a href="login_2.jsp">Login or Register</a></li>
  130. <%
  131. } else {
  132. out.println(strMemberName + "!");
  133. %>
  134. &nbsp;&nbsp;&nbsp;
  135. <li><a href="logoutsubmit.jsp">Logout</a> </li>
  136. <%
  137. }
  138. %>
  139. </li></td></tr></table>
  140. </ul>
  141. </div>
  142. </div>
  143.  
  144. <div class="col-md-4">
  145. <div class="header-right">
  146. <ul class="list-unstyled list-inline">
  147. <span class="key"></span><span class="value"></span>
  148. <ul class="dropdown-menu">
  149. </ul>
  150. </li>
  151.  
  152. <li class="dropdown dropdown-small">
  153. <span class="key"></span><span class="value"> </span>
  154. <ul class="dropdown-menu">
  155. </ul>
  156. </li>
  157. </ul>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div> <!-- End header area -->
  163.  
  164. <div class="site-branding-area">
  165. <div class="container">
  166. <div class="row">
  167. <div class="col-sm-6">
  168. <div class="logo">
  169. <h1><a href="index.jsp">SigmaPerkasa<span>.com</span></a></h1>
  170. </div>
  171. </div>
  172.  
  173. <div class="col-sm-6">
  174. <div class="shopping-item">
  175. <a href="cart.jsp"><span class="glyphicon glyphicon-shopping-cart"></span> My Cart</a>
  176. <input type="Text" Name="CartItem" Value="" size="50">
  177. <input type="Text" Name="CartCount" Value="0" size="2">
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div> <!-- End site branding area -->
  183.  
  184. <div class="mainmenu-area">
  185. <div class="container">
  186. <div class="row">
  187. <div class="navbar-header">
  188. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
  189. <span class="sr-only">Toggle navigation</span>
  190. <span class="icon-bar"></span>
  191. <span class="icon-bar"></span>
  192. <span class="icon-bar"></span>
  193. </button>
  194. </div>
  195. <div class="navbar-collapse collapse">
  196. <ul class="nav navbar-nav">
  197. <li><a href="index.jsp">Home</a></li>
  198. <li><a href="aboutus.jsp">About</a></li>
  199. <li><a href="product.jsp">Products</a></li>
  200. <li><a href="contact.jsp">Contact Person</a></li>
  201. </ul>
  202. </div>
  203. </div>
  204. </div>
  205. </div> <!-- End mainmenu area -->
  206.  
  207.  
  208. <%
  209. String url = "jdbc:mysql://localhost:3306/";
  210. String dbName = "project_db";
  211. String driver = "com.mysql.jdbc.Driver";
  212. String userName = "root";
  213. String password = "password";
  214.  
  215. try {
  216. //create database connection
  217. Class.forName(driver).newInstance();
  218. Connection conn = DriverManager.getConnection(url+dbName,userName,password);
  219. Statement statement = conn.createStatement();
  220.  
  221. //Create SQL to run 1
  222. String SQL = "SELECT CategoryID, CategoryName FROM t_category";
  223. ResultSet res = statement.executeQuery(SQL);
  224.  
  225.  
  226. //Statement statement = conn.createStatement();
  227. //statement.executeUpdate (strSQL);
  228. %>
  229. <table border="0" align="center" width="100%">
  230. <tr>
  231. <td align="center"></td>
  232. </tr>
  233. </table>
  234. <table border="0" align="center">
  235. <tr>
  236. <td>
  237. <table width=100% border="0">
  238. <tr>
  239. <td width=9%>&nbsp;&nbsp;&nbsp;</td>
  240. <td width="17%" valign="top"><br><h4>All Categories:</h4><br>
  241.  
  242. <%
  243. int Numbering =0;
  244. //Loop and retrieve records 1
  245. int number = 0;
  246. while (res.next()) {
  247. String strCategoryID= res.getString("CategoryID");
  248. String strCategoryName= res.getString("CategoryName");
  249. Numbering++;
  250. out.println("<h5><a href='product.jsp?FilterID="+strCategoryID+"'>"+strCategoryName+"</a></h5><br>");
  251.  
  252.  
  253. }
  254. %>
  255. </td>
  256. <td width="100%">
  257. <table border = "0">
  258. <tr><br>
  259.  
  260. <%
  261. String strCategoryID = "";
  262. String strCategoryName = "";
  263. String strProductName = "";
  264. String strDescription ="";
  265. String strProductID = "";
  266. String strBrand = "";
  267. String strPrice = "";
  268. String strImage = "";
  269. int intProductCounter = 0;
  270.  
  271. String strFilterID= Util.getValues(request, "FilterID");
  272. String strWC= "";
  273.  
  274. if (!strFilterID.equals("")){
  275. strWC="WHERE CategotyID="+strFilterID;
  276. }
  277.  
  278. //Create SQL to run 2
  279.  
  280. if (strFilterID.equals("")) {
  281. SQL = "SELECT ProductID, ProductName, Brand, Quantity, Price, Description, CategoryID, Image FROM t_product_detail ";
  282. } else {
  283. SQL = "SELECT ProductID, ProductName, Brand, Quantity, Price, Description, CategoryID, Image FROM t_product_detail WHERE CategoryID="+strFilterID+"";
  284. }
  285.  
  286.  
  287. ResultSet resProduct = statement.executeQuery(SQL);
  288. //Loop and retrieve records 2
  289. while (resProduct.next()){
  290. intProductCounter++;
  291.  
  292. strProductID = resProduct.getString("ProductID");
  293. strProductName = resProduct.getString("ProductName");
  294. strDescription = resProduct.getString("Description");
  295. strBrand = resProduct.getString("Brand");
  296. strPrice = resProduct.getString("Price");
  297. strImage = resProduct.getString("Image");
  298.  
  299. if (intProductCounter % 3 == 1){
  300. out.println("<tr height='140'>");
  301. }
  302. out.println("<td width=35% align='middle'><br><img src=img/"+strImage+" width='180'>");
  303. out.println("<br><br>"+strProductName+" ("+strBrand+")<br> "+strDescription+"");
  304. out.println("<br><br><font color='red'>RM "+strPrice+"</font>");
  305. out.println("<br><input type='submit' name='CartItem' value='Add to Cart'><A href='javascript:AddCart('"+strProductID+"');'></td></a>");
  306.  
  307. if (intProductCounter % 3 == 0){
  308. out.println("</tr>");
  309. }
  310. }
  311. %>
  312. </td>
  313. </tr>
  314.  
  315. <tr><td height=30> </td></tr>
  316. </table>
  317. </table>
  318. <%
  319. // Close database Connection
  320. statement.close();
  321. res.close();
  322. conn.close();
  323.  
  324. } catch(Exception e){
  325. e.printStackTrace();
  326. }
  327. %>
  328.  
  329.  
  330. <!--Sign In menuare -->
  331.  
  332.  
  333. <div class="footer-top-area">
  334. <div class="zigzag-bottom"></div>
  335. <div class="container">
  336. <div class="row">
  337. <div class="col-md-3 col-sm-6">
  338. <div class="footer-about-us">
  339. <div style="text-align: justify;">
  340. <h2></h2>
  341. <p></p>
  342. </div>
  343. </div>
  344. </div>
  345.  
  346. <div class="col-md-3 col-sm-6">
  347. <div class="footer-about-us">
  348. <div style="text-align: justify;">
  349. <h2>SigmaPerkasa<span>.com</span></h2>
  350. <p>Sigma Perkasa Sdn Bhd. Started in 1994 or 1995 in Pontianak, West Kalimantan. This shop exactly used for sell all the electric spare parts that for television, VCD machine, DVD machine such as like IC, LED, diodes, speakers, cables, accessories car etc. This shop is owned by Lim Kiam Hiong or called A Hiong.</p>
  351. <a href="aboutus.jsp" class="readmore">Read More</a>
  352. </div>
  353. </div>
  354. </div>
  355.  
  356. <div class="col-md-3 col-sm-6">
  357. <div class="footer-menu">
  358. <h2 class="footer-wid-title">Categories</h2>
  359. <ul>
  360. <li><a href="#">Speaker</a></li>
  361. <li><a href="#">Equalizer</a></li>
  362. <li><a href="#">LED</a></li>
  363. <li><a href="#">Elco</a></li>
  364. <li><a href="#">Accessories</a></li>
  365. </ul>
  366. </div>
  367. </div>
  368. </div>
  369. </div>
  370. </div> <!-- End footer top area -->
  371.  
  372. <div class="footer-bottom-area">
  373. <div class="container">
  374. <div class="row">
  375. <div class="col-md-8">
  376. <div class="copyright">
  377. <p>&copy; 2015 eElectronics. All Rights Reserved. Coded with <i class="fa fa-heart"></i> by <a href="http://wpexpand.com" target="_blank">WP Expand</a></p>
  378. </div>
  379. </div>
  380.  
  381. <div class="col-md-4">
  382. <div class="footer-card-icon">
  383. <i class="fa fa-cc-discover"></i>
  384. <i class="fa fa-cc-mastercard"></i>
  385. <i class="fa fa-cc-paypal"></i>
  386. <i class="fa fa-cc-visa"></i>
  387. </div>
  388. </div>
  389. </div>
  390. </div>
  391. </div> <!-- End footer bottom area -->
  392.  
  393. <!-- Latest jQuery form server -->
  394. <script src="https://code.jquery.com/jquery.min.js"></script>
  395.  
  396. <!-- Bootstrap JS form CDN -->
  397. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  398.  
  399. <!-- jQuery sticky menu -->
  400. <script src="js/owl.carousel.min.js"></script>
  401. <script src="js/jquery.sticky.js"></script>
  402.  
  403. <!-- jQuery easing -->
  404. <script src="js/jquery.easing.1.3.min.js"></script>
  405.  
  406. <!-- Main Script -->
  407. <script src="js/main.js"></script>
  408. </body>
  409. </html>
Add Comment
Please, Sign In to add comment