Advertisement
Guest User

Untitled

a guest
May 7th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <%
  2. Enumeration en = request.getParameterNames();
  3. while(en.hasMoreElements()){
  4. String cid = (String) en.nextElement();
  5. String cid_val = request.getParameter(cid);
  6. System.out.println("cid: " + cid_val);
  7. String cnumber=(String)en.nextElement();
  8. String c_num=request.getParameter(cnumber);
  9. System.out.println("cnum: " + c_num);
  10. String roomNo = (String) en.nextElement();
  11. String hotelID = request.getParameter(roomNo);
  12. String InDate = (String) en.nextElement();
  13. String OutDate = request.getParameter(InDate);
  14. int roomNo2 = Integer.parseInt(roomNo);
  15. SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
  16.  
  17. java.util.Date dt = sdf.parse(InDate);
  18.  
  19. java.sql.Date sqlD = new Date(dt.getTime());
  20.  
  21. int NoOfDays=0;
  22.  
  23. SimpleDateFormat sdff = new SimpleDateFormat("MM/dd/yyyy");
  24.  
  25. java.util.Date dtt = sdff.parse(OutDate);
  26.  
  27. java.sql.Date sqlDD = new Date(dtt.getTime());
  28.  
  29. /* /* System.out.println("Days= "+daysBetween(cal1.getTime(),cal2.getTime())); */
  30.  
  31. Double x = Math.random() * 10000000;
  32. x = x% 1000000;
  33. x =Math.floor(x);
  34. String InvoiceNo = x.toString();
  35. InvoiceNo = InvoiceNo.substring(0, InvoiceNo.length()-2);
  36. //System.out.println(InvoiceNo);
  37. float totalAmt=5;
  38. try{
  39. //out.println("Hello "+user_name+", your booking could not be completed. Sorry for the inconvenience");
  40.  
  41. Class.forName("com.mysql.jdbc.Driver");
  42. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel","root","Micole614");
  43. Statement st= con.createStatement();
  44. String query_string2 = "insert into Make_Reservation values ('"+InvoiceNo+"','"+sqlD+"','"+totalAmt+"','"+c_num+"','"+cid_val+"')";
  45. out.println("hello");
  46. int xx = st.executeUpdate(query_string2);
  47.  
  48. String query_string = "insert into Reservation values ('"+roomNo2+"','"+hotelID+"','"+InvoiceNo+"','"+sqlDD+"','"+NoOfDays+"','"+sqlD+"')";
  49. int i=st.executeUpdate(query_string);
  50. PreparedStatement update=con.prepareStatement("Update Reservation Set NoOfDays=? Where Room_no= '"+roomNo2+"' and HotelID='"+hotelID+"'and InvoiceNo='"+InvoiceNo+"'");
  51. update.setString(1,"(datediff('"+sqlDD+"','"+sqlD+"'))");
  52. System.out.println(update.toString());
  53. update.executeUpdate();
  54. /* if (i > 0){
  55. out.println("Hello "+user_name+", your account has been created. Your Invoice Number is: "+InvoiceNo+"");
  56. }
  57. else{
  58. out.println("Hello "+user_name+", it didnt work sorry");
  59. }*/
  60. }
  61. catch(Exception e){
  62. e.printStackTrace();
  63. }
  64. }
  65. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement