private void button1_Click(object sender, EventArgs e) { ArrayList list = RoomDBManager.GetAllRoom(); ArrayList list1 = BookingDBManager.GetAllBooking(); Room rm = new Room(); rm = RoomDBManager.GetRoomByDate(dtpStartDate.Text); Book bk = new Book(); bk = BookingDBManager.GetbookingByID(rm.bookingid); string output = ""; int roomcount = 0; int occupiedroomcount = 0; decimal total = 0; DateTime StartDate = dtpStartDate.Value; DateTime EndDate = StartDate.AddDays(7); foreach (Book booking in list1) { foreach (Room room in list) { char[] dateFmt = booking.check_in_date.ToCharArray(); string fmtYear = dateFmt[4].ToString() + dateFmt[5].ToString() + dateFmt[6].ToString() + dateFmt[7].ToString(); string fmtMonth = dateFmt[2].ToString() + dateFmt[3].ToString(); string fmtDay = dateFmt[0].ToString() + dateFmt[1].ToString(); DateTime dd = new DateTime(Convert.ToInt32(fmtYear), Convert.ToInt32(fmtMonth), Convert.ToInt32(fmtDay)); char[] dateFmt1 = booking.check_out_date.ToCharArray(); string fmtYear1 = dateFmt1[4].ToString() + dateFmt1[5].ToString() + dateFmt1[6].ToString() + dateFmt1[7].ToString(); string fmtMonth1 = dateFmt1[2].ToString() + dateFmt1[3].ToString(); string fmtDay1 = dateFmt1[0].ToString() + dateFmt1[1].ToString(); DateTime dd1 = new DateTime(Convert.ToInt32(fmtYear1), Convert.ToInt32(fmtMonth1), Convert.ToInt32(fmtDay1)); if (StartDate >= dd) { roomcount = +booking.no_of_rooms; } if (room.status == "Occupied") { occupiedroomcount++; } total = +(occupiedroomcount / roomcount) * 100; } } output += "Statistics: " + Environment.NewLine; output += "Percentage of the rooms that are occupied over the total number of rooms: " + total + Environment.NewLine; rt.overrideHTML(output); wbOutput.DocumentText = rt.generateHTML(false); }
private void button1_Click(object sender, EventArgs e) { ArrayList list = BookingDBManager.GetAllBooking(); string output = ""; int adultcount = 0; int childrencount = 0; int totalcount = 0; DateTime StartDate = dtpStartDate.Value; int totalNumberOfGuestInHotel = 0; int totalNumberOfChild = 0; int totalNumberOfAdult = 0; foreach (Book booking in list) { char[] dateFmt = booking.check_in_date.ToCharArray(); string fmtYear = dateFmt[4].ToString() + dateFmt[5].ToString() + dateFmt[6].ToString() + dateFmt[7].ToString(); string fmtMonth = dateFmt[2].ToString() + dateFmt[3].ToString(); string fmtDay = dateFmt[0].ToString() + dateFmt[1].ToString(); DateTime dd = new DateTime(Convert.ToInt32(fmtYear), Convert.ToInt32(fmtMonth), Convert.ToInt32(fmtDay)); char[] dateFmt1 = booking.check_out_date.ToCharArray(); string fmtYear1 = dateFmt1[4].ToString() + dateFmt1[5].ToString() + dateFmt1[6].ToString() + dateFmt1[7].ToString(); string fmtMonth1 = dateFmt1[2].ToString() + dateFmt1[3].ToString(); string fmtDay1 = dateFmt1[0].ToString() + dateFmt1[1].ToString(); DateTime dd1 = new DateTime(Convert.ToInt32(fmtYear1), Convert.ToInt32(fmtMonth1), Convert.ToInt32(fmtDay1)); if (StartDate >= dd) { adultcount = +booking.no_of_adults; childrencount = +booking.no_of_children; totalcount = +booking.no_of_adults + booking.no_of_children; totalNumberOfGuestInHotel += totalcount; totalNumberOfChild += childrencount; totalNumberOfAdult += adultcount; output += "Guest ID: " + booking.guestid + Environment.NewLine; output += "Number of adults: " + adultcount + Environment.NewLine; output += "Number of children: " + childrencount + Environment.NewLine + Environment.NewLine; } } output += "In Summary: " + Environment.NewLine; output += "Total number of adults in hotel: " + totalNumberOfAdult + Environment.NewLine; output += "Total number of children in hotel: " + totalNumberOfChild + Environment.NewLine; output += "Total number of guests in hotel: " + totalNumberOfGuestInHotel + Environment.NewLine; rt.overrideHTML(output); wbOutput.DocumentText = rt.generateHTML(false); }
protected void ddlBookingNo_SelectedIndexChanged(object sender, EventArgs e) { lblSelectedBkgNo.Text = ddlBookingNo.SelectedItem.Text; ArrayList userlist = BookingDBManager.GetAllBookings(); //ArrayList userlist = BookingDBManager.GetBookingByBkgNo(ddlBookingNo.SelectedItem.Text);//, (string)Session["username"]); DataList1.DataSource = userlist; DataList1.DataBind(); }
protected void btnLogin_Click(object sender, EventArgs e) { string i_bkgNo = tbxUsername.Text; string i_contactNo = tbxPassword.Text; if (BookingDBManager.Login(i_bkgNo, i_contactNo) == true) { Session["username"] = i_bkgNo; Response.Redirect("ListBooking.aspx"); } else { lblStatus.Text = "Login unsuccessful"; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string bkgNo = (string)Session["username"]; //string bkgNo = Request.QueryString["bkgNo"]; Booking b = BookingDBManager.GetBookingByBkgNo(bkgNo); lblBookingNo.Text = bkgNo; lblCIDate.Text = b.CIDate; lblCODate.Text = b.CODate; lblRoomType.Text = b.roomType; lblQty.Text = b.quantity; lblFirstName.Text = b.firstName; lblLastName.Text = b.lastName; lblEmail.Text = b.email; lblContactNo.Text = b.contactNo; } }
protected void btnCreate_Click(object sender, EventArgs e) { string bkgNo = tbxBkgNo.Text; string CIDate = tbxCIDate.Text; string CODate = tbxCODate.Text; string roomType = tbxRoomType.Text; string quantity = tbxQty.Text; string firstName = tbxFirstName.Text; string lastName = tbxLastName.Text; string email = tbxEmail.Text; string contactNo = tbxContactNo.Text; string querystring = "bkgNo=" + bkgNo; querystring += "&" + "CIDate=" + CIDate; querystring += "&" + "CODate=" + CODate; querystring += "&" + "roomType=" + roomType; querystring += "&" + "quantity=" + quantity; querystring += "&" + "firstName=" + firstName; querystring += "&" + "lastName=" + lastName; querystring += "&" + "email=" + email; querystring += "&" + "contactNo=" + contactNo; Booking b = new Booking(); b.bkgNo = tbxBkgNo.Text; b.CIDate = tbxCIDate.Text; b.CODate = tbxCODate.Text; b.roomType = tbxRoomType.Text; b.quantity = tbxQty.Text; b.firstName = tbxFirstName.Text; b.lastName = tbxLastName.Text; b.email = tbxEmail.Text; b.contactNo = tbxContactNo.Text; if (BookingDBManager.InsertBooking(b) == 1) { Server.Transfer("BookingDetails.aspx?" + querystring); } else { lblStatus.Text = "Booking Unsuccessful"; } }
protected void Page_Load(object sender, EventArgs e) { string bkgNo = (string)Session["username"]; if (!Page.IsPostBack) { Booking b = BookingDBManager.GetBookingByBkgNo(bkgNo); lblBookingNo.Text = bkgNo; tbxCIDate.Text = b.CIDate; tbxCODate.Text = b.CODate; tbxRoomType.Text = b.roomType; tbxQty.Text = b.quantity; tbxFirstName.Text = b.firstName; tbxLastName.Text = b.lastName; tbxEmail.Text = b.email; tbxContactNo.Text = b.contactNo; } HyperLink1.NavigateUrl = "BookingDetails.aspx?bkg_no=" + bkgNo; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //retrieve all booking from the database ArrayList bookinglist = BookingDBManager.GetAllBookings(); ddlBookingNo.DataSource = bookinglist; ddlBookingNo.DataBind(); lblSelectedBkgNo.Text = ddlBookingNo.SelectedItem.Text; //retrieve music that belongs to john from database //Booking userlist = BookingDBManager.GetBookingByBkgNo(ddlBookingNo.SelectedItem.Text); ArrayList userlist = BookingDBManager.GetAllBookings(); DataList1.DataSource = userlist; DataList1.DataBind(); } //display username from querystring to label lblUsername.Text = (string)Session["username"]; }
private void btnPreview_Click(object sender, EventArgs e) { Room rm = new Room(); rm = RoomDBManager.getRoomByRn(tbxRoomNoSearch.Text); Book bk = new Book(); bk = BookingDBManager.GetbookingByID(rm.bookingid); Guest g = new Guest(); g = GuestDBManager.GetGuestByID(bk.guestid); string output = ""; char[] cd = Convert.ToString(bk.check_in_date).ToCharArray(); string checkInDateFormatted = cd[0].ToString() + cd[1].ToString() + "-" + cd[2].ToString() + cd[3].ToString() + "-" + cd[4].ToString() + cd[5].ToString() + cd[6].ToString() + cd[7].ToString(); char[] cd1 = Convert.ToString(bk.check_out_date).ToCharArray(); string checkOutDateFormatted = cd1[0].ToString() + cd1[1].ToString() + "-" + cd1[2].ToString() + cd1[3].ToString() + "-" + cd1[4].ToString() + cd1[5].ToString() + cd1[6].ToString() + cd1[7].ToString(); output += "Booking ID: " + Convert.ToString(bk.bookingid) + Environment.NewLine; output += "Guest ID: " + Convert.ToString(bk.guestid) + Environment.NewLine; output += "Name: " + g.name + Environment.NewLine; output += "Phone number: " + Convert.ToString(g.phone) + Environment.NewLine; output += "Email: " + g.email + Environment.NewLine; output += "Address: " + g.address + Environment.NewLine; output += "Postal Code: " + Convert.ToString(g.postalcode) + Environment.NewLine; output += "Country: " + g.country + Environment.NewLine; output += "Check in date: " + checkInDateFormatted + Environment.NewLine; output += "Check out date: " + checkOutDateFormatted + Environment.NewLine; output += "Number of adults: " + Convert.ToString(bk.no_of_adults) + Environment.NewLine; output += "Number of children: " + Convert.ToString(bk.no_of_children) + Environment.NewLine; output += "Payment Type: " + g.paymenttype + Environment.NewLine; rt.overrideHTML(output); wbOutput.DocumentText = rt.generateHTML(false); }
protected void btnUpdate_Click(object sender, EventArgs e) { Booking editbooking = new Booking(); editbooking.bkgNo = lblBookingNo.Text; editbooking.CIDate = tbxCIDate.Text; editbooking.CODate = tbxCODate.Text; editbooking.roomType = tbxRoomType.Text; editbooking.quantity = tbxQty.Text; editbooking.firstName = tbxFirstName.Text; editbooking.lastName = tbxLastName.Text; editbooking.email = tbxEmail.Text; editbooking.contactNo = tbxContactNo.Text; if (BookingDBManager.UpdateBooking(editbooking) == 1) { lblStatus.Text = "Booking Updated!"; } else { lblStatus.Text = "Error! Booking not updated."; } }
protected void btnYes_Click(object sender, EventArgs e) { lblBookingNo.Text = (string)Session["username"]; BookingDBManager.DeleteBooking(lblBookingNo.Text); Response.Redirect("BookingDeleted.aspx"); }