private Boolean showBookingInformation() { lblBookingId.Text = EditBooking2.TBookingID; txtPhoneNo.Text = EditBooking2.TEmail; HotelReservationEntities3 h = new HotelReservationEntities3(); var book = from x in h.bookings where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail select x; booking b1 = book.FirstOrDefault(); if (book.FirstOrDefault() != null) { RegularExpressionValidator2.Visible = false; txtName.Text = b1.name; txtPassportNo.Text = b1.passportno; txtEmail.Text = b1.email; txtPhoneNo.Text = b1.Phone; txtCheckInDate.Text = b1.datecheckin.ToShortDateString(); txtCheckOutDate.Text = b1.datecheckout.ToShortDateString(); int range = b1.datecheckout.DayOfYear - b1.datecheckin.DayOfYear + 1; if (range >= 0) { lblDurantionOut.Text = range.ToString(); } else { lblDurantionOut.Text = "0"; } string roomType = ""; switch (b1.roomid) { case "s": roomType = "Single"; break; case "d": roomType = "Double"; break; case "du": roomType = "Deluxe"; break; case "su": roomType = "Superior"; break; } lblRoomType.Text = roomType; lblNumberOfRoom.Text = b1.roomno.ToString(); var room = from x in h.roomfacilities where x.roomid == b1.roomid select x; roomfacility rm = room.FirstOrDefault(); lblPrice.Text = "$" + rm.roomrent.ToString() + " per room"; lblTotal.Text = "$" + (rm.roomrent * range).ToString(); infoPanel.Visible = true; return(true); } else { return(false); } }
private void calculateCost(int range) { lblBookingId.Text = EditBooking2.TBookingID; HotelReservationEntities3 h = new HotelReservationEntities3(); var book = from x in h.bookings where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail select x; booking b1 = book.FirstOrDefault(); string roomType = ""; switch (lblRoomType.Text) { case "Single": roomType = "s"; break; case "Double": roomType = "d"; break; case "Deluxe": roomType = "du"; break; case "Superior": roomType = "su"; break; } b1.roomid = roomType; lblNumberOfRoom.Text = "1"; var room = from x in h.roomfacilities where x.roomid == b1.roomid select x; roomfacility rm = room.FirstOrDefault(); lblPrice.Text = "$" + rm.roomrent.ToString() + " per room"; lblTotal.Text = "$" + (rm.roomrent * range).ToString(); }
protected void Button1_Click(object sender, EventArgs e) { using (HotelReservationEntities3 hr = new HotelReservationEntities3()) { for (int i = 0; i < noofroom; i++) { if (noofroom < numgen) { var booking1 = (from a in hr.bookings select a).ToList(); int idgen = booking1.Count; booking bk = new booking(); int no = idgen; no++; bk.bookingid = "bk" + no; bk.name = TextBox3.Text; bk.Phone = TextBox6.Text; bk.passportno = TextBox4.Text; bk.email = TextBox5.Text; bk.datecheckin = Convert.ToDateTime(Checkin.Text); bk.datecheckout = Convert.ToDateTime(Checkout.Text); //bk.noofpeople = Convert.ToInt16(Noofpeople.Text); bk.roomid = Roomtype.Text; string type = Roomtype.Text; if (type.Equals("d")) { int temp1 = 60 - numgen; temp1++; bk.roomno = Roomtype.Text + temp1; hr.bookings.Add(bk); hr.SaveChanges(); numgen--; } else { int temp2 = 20 - numgen; temp2++; bk.roomno = Roomtype.Text + temp2; hr.bookings.Add(bk); hr.SaveChanges(); numgen--; } if (numgen == 0) { break; } } } } }
void Retrieve_Submit(object sender, EventArgs e) { HotelReservationEntities3 h = new HotelReservationEntities3(); var book = from x in h.bookings where x.bookingid == EditBooking1.TBookingID && x.email == EditBooking1.TEmail select x; if (book.FirstOrDefault() != null) { booking b = book.FirstOrDefault(); PanelInfo.Visible = true; labName.Text = b.name; labPss.Text = b.passportno; labEmail.Text = b.email; labTel.Text = b.Phone; labIN.Text = b.name; labOUT.Text = b.datecheckin.ToString("dd/MM/yyyy"); labIN.Text = b.datecheckout.ToString("dd/MM/yyyy"); labDuration.Text = (b.datecheckout.Date.Day - b.datecheckin.Date.Day).ToString(); if (b.roomid == "s") { labRoomT.Text = "Single room"; } else if (b.roomid == "d") { labRoomT.Text = "Double room"; } else if (b.roomid == "su") { labRoomT.Text = "Superior"; } else if (b.roomid == "du") { labRoomT.Text = "Deluxe"; } labRoomNo.Text = "1"; } else { EditBooking1.Message = "No Record has been found"; } }
private void changeBooking() { lblBookingId.Text = EditBooking2.TBookingID; HotelReservationEntities3 h = new HotelReservationEntities3(); var book = from x in h.bookings where x.bookingid == EditBooking2.TBookingID && x.email == EditBooking2.TEmail select x; booking b1 = book.FirstOrDefault(); string roomType = ""; switch (lblRoomType.Text) { case "Single": roomType = "s"; break; case "Double": roomType = "d"; break; case "Deluxe": roomType = "du"; break; case "Superior": roomType = "su"; break; } // int beforeRoomAmounts = Convert.ToInt32(lblNumberOfRoom.Text); var avail = from x in h.availablities where x.dateofavailablity >= b1.datecheckin && x.dateofavailablity <= b1.datecheckout && //&& x.roomsavailable >= beforeRoomAmounts x.roomid == roomType select x; foreach (availablity a in avail) { a.roomsavailable += 1; } b1.name = txtName.Text; b1.passportno = txtPassportNo.Text; b1.email = txtEmail.Text; b1.Phone = txtPhoneNo.Text; // lblAfterChange.Text = txtPhoneNo.Text; b1.datecheckin = Convert.ToDateTime(txtCheckInDate.Text); b1.datecheckout = Convert.ToDateTime(txtCheckOutDate.Text); b1.roomid = roomType; lblNumberOfRoom.Text = "1"; var room = from x in h.roomfacilities where x.roomid == b1.roomid select x; roomfacility rm = room.FirstOrDefault(); lblPrice.Text = "$" + rm.roomrent.ToString() + " per room"; lblTotal.Text = "$" + (rm.roomrent).ToString(); //int afterRoomAmounts = Convert.ToInt32(lblNumberOfRoom.Text); var avail2 = from x in h.availablities where x.dateofavailablity >= b1.datecheckin && x.dateofavailablity <= b1.datecheckout && //&& x.roomsavailable >= afterRoomAmounts x.roomid == roomType select x; foreach (availablity a in avail2) { a.roomsavailable -= 1; } h.SaveChanges(); }
protected void Button1_Click(object sender, EventArgs e) { using (HotelReservationEntities3 hr = new HotelReservationEntities3()) { for (int i = 0; i < noofroom; i++) { if (noofroom < numgen) { var booking1 = (from a in hr.bookings select a).ToList(); int idgen = booking1.Count; booking bk = new booking(); int no = idgen; //no++; //bk.bookingid = "bk" + no; var check = (from x in hr.bookings select x.bookingid).ToList(); List <int> listid = new List <int>(); foreach (String strbookingid in check) { int x = Convert.ToInt32(strbookingid.Substring(2)); listid.Add(x); } int maxid = listid.Max(); maxid++; bk.bookingid = "bk" + maxid; bk.name = TextBox3.Text; //bk.Phone = TextBox6.Text; bk.passportno = TextBox4.Text; bk.email = TextBox5.Text; bk.datecheckin = Convert.ToDateTime(Checkin.Text); bk.datecheckout = Convert.ToDateTime(Checkout.Text); //bk.noofpeople = Convert.ToInt16(Noofpeople.Text); bk.roomid = Roomtype.Text; string type = Roomtype.Text; if (type.Equals("d")) { int temp1 = 60 - numgen; temp1++; bk.roomno = Roomtype.Text + temp1; bk.noofpeople = 2; hr.bookings.Add(bk); hr.SaveChanges(); //updating availablity table avai[i] = numgen; numgen--; } else if (type.Equals("s")) { int temp2 = 20 - numgen; temp2++; bk.roomno = Roomtype.Text + temp2; bk.noofpeople = 1; hr.bookings.Add(bk); hr.SaveChanges(); avai[i] = numgen; numgen--; } else if (type.Equals("du")) { int temp2 = 20 - numgen; temp2++; bk.roomno = Roomtype.Text + temp2; bk.noofpeople = 3; hr.bookings.Add(bk); hr.SaveChanges(); avai[i] = numgen; numgen--; } else if (type.Equals("su")) { int temp2 = 20 - numgen; temp2++; bk.roomno = Roomtype.Text + temp2; bk.noofpeople = 5; hr.bookings.Add(bk); hr.SaveChanges(); avai[i] = numgen; numgen--; } else { } //Jade var avail2 = from x in hr.availablities where x.dateofavailablity >= bk.datecheckin && x.dateofavailablity <= bk.datecheckout && //&& x.roomsavailable >= afterRoomAmounts x.roomid == Roomtype.Text select x; foreach (availablity a in avail2) { a.roomsavailable -= 1; } hr.SaveChanges(); //Thiru //var availablity1 = (from a in hr.availablities // select a).ToList(); //int idgen1 = availablity1.Count; //int avgen = idgen1; //avgen++; //non = avai.Min(); //if (type.Equals("s")) //{ // availablity av = new availablity(); // av.roomsavailable = non; // av.availablityid = "av"+avgen; // av.dateofavailablity = Convert.ToDateTime(Checkin.Text); // av.roomid = "s"; // hr.availablities.Add(av); // hr.SaveChanges(); //} //else if (type.Equals("d")) //{ // availablity av = new availablity(); // av.roomsavailable = non; // av.availablityid = "av" + avgen; // av.dateofavailablity = Convert.ToDateTime(Checkin.Text); // av.roomid = "d"; // hr.availablities.Add(av); // hr.SaveChanges(); //} //else if (type.Equals("du")) //{ // availablity av = new availablity(); // av.roomsavailable = non; // av.availablityid = "av"+avgen; // av.dateofavailablity = Convert.ToDateTime(Checkin.Text); // av.roomid = "s"; // hr.availablities.Add(av); // hr.SaveChanges(); //} //else if (type.Equals("su")) //{ // availablity av = new availablity(); // av.roomsavailable = non; // av.availablityid = "av"+avgen; // av.dateofavailablity = Convert.ToDateTime(Checkin.Text); // av.roomid = "su"; // hr.availablities.Add(av); // hr.SaveChanges(); //} if (numgen == 0) { break; } String display = "Successfully Booked !!! Thank you for booking at our hotel. You will receive mail about the confirmation."; ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('" + display + "')", true); String toEmail = TextBox5.Text; String subject = "Booking Confirmation."; String body = "Successfully booked."; sendemail(toEmail, subject, body); } } } }