Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%
- Enumeration en = request.getParameterNames();
- while(en.hasMoreElements()){
- String cid = (String) en.nextElement();
- String cid_val = request.getParameter(cid);
- System.out.println("cid: " + cid_val);
- String cnumber=(String)en.nextElement();
- String c_num=request.getParameter(cnumber);
- System.out.println("cnum: " + c_num);
- String roomNo = (String) en.nextElement();
- String hotelID = request.getParameter(roomNo);
- String InDate = (String) en.nextElement();
- String OutDate = request.getParameter(InDate);
- int roomNo2 = Integer.parseInt(roomNo);
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
- java.util.Date dt = sdf.parse(InDate);
- java.sql.Date sqlD = new Date(dt.getTime());
- int NoOfDays=0;
- SimpleDateFormat sdff = new SimpleDateFormat("MM/dd/yyyy");
- java.util.Date dtt = sdff.parse(OutDate);
- java.sql.Date sqlDD = new Date(dtt.getTime());
- /* /* System.out.println("Days= "+daysBetween(cal1.getTime(),cal2.getTime())); */
- Double x = Math.random() * 10000000;
- x = x% 1000000;
- x =Math.floor(x);
- String InvoiceNo = x.toString();
- InvoiceNo = InvoiceNo.substring(0, InvoiceNo.length()-2);
- //System.out.println(InvoiceNo);
- float totalAmt=5;
- try{
- //out.println("Hello "+user_name+", your booking could not be completed. Sorry for the inconvenience");
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel","root","Micole614");
- Statement st= con.createStatement();
- String query_string2 = "insert into Make_Reservation values ('"+InvoiceNo+"','"+sqlD+"','"+totalAmt+"','"+c_num+"','"+cid_val+"')";
- out.println("hello");
- int xx = st.executeUpdate(query_string2);
- String query_string = "insert into Reservation values ('"+roomNo2+"','"+hotelID+"','"+InvoiceNo+"','"+sqlDD+"','"+NoOfDays+"','"+sqlD+"')";
- int i=st.executeUpdate(query_string);
- PreparedStatement update=con.prepareStatement("Update Reservation Set NoOfDays=? Where Room_no= '"+roomNo2+"' and HotelID='"+hotelID+"'and InvoiceNo='"+InvoiceNo+"'");
- update.setString(1,"(datediff('"+sqlDD+"','"+sqlD+"'))");
- System.out.println(update.toString());
- update.executeUpdate();
- /* if (i > 0){
- out.println("Hello "+user_name+", your account has been created. Your Invoice Number is: "+InvoiceNo+"");
- }
- else{
- out.println("Hello "+user_name+", it didnt work sorry");
- }*/
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement