private void btnReserve_Click(object sender, EventArgs e) { //declaring variables used in the reservation form string guestName; string roomNum; string rType; string checkInDate; string checkOutDate; string noDays; string noOfPeople; DateTime currentDate = DateTime.Now; //initialising the variable2s used in the reservation form guestName = tbGuestName.Text; roomNum = tbRoomNum.Text.ToString(); rType = tbRoomType.Text; checkInDate = dtpCheckIn.Text; checkOutDate = dtpCheckOut.Text; noDays = tbNoDays.Text.ToString(); noOfPeople = numAdults.Text.ToString(); //subTotal = Convert.ToInt32(tbSubTotal.Text); subTotal = 0; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Check whether text box fields have values entered. if ((epGuestName.GetError(this.tbGuestName).Length > 0) || ((epRoomNum.GetError(this.tbRoomNum).Length > 0))) { MessageBox.Show("Please attend to any errors", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Create a new instance of the UseDatabase case. UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb"); useDb.ConnectToDatabase(); string b = useDb.Reservation(guestName, roomNum, checkInDate, checkOutDate, noOfPeople, noDays, subTotal.ToString()); if (b == "success") { MessageBox.Show("Reservation successfull", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); File.AppendAllText("..\\..\\App_Data\\LogFiles\\Check-In.txt", "Guest : " + guestName + " Has made a reservation ,on : " + currentDate + Environment.NewLine); this.Close(); } else { MessageBox.Show("Fail"); } useDb.DisconnectDatabase(); } }
private void btnSave_Click(object sender, EventArgs e) { //Declaring variables for use in the guest form. string sName = txtName.Text; string sSurname = txtSurname.Text; string sAddress = txtAddress.Text; string sNum = txtNum.Text; string sGender = cbGender.Text; string sEmail = txtEmail.Text; string sStatus = ""; DateTime currentDate = DateTime.Now; //Validates if all the fields are entered and that there are no error messages before saving the data to the database. if ((txtName.Text == "") || (txtSurname.Text == "") || (txtAddress.Text == "") || (txtNum.Text == "") || (txtEmail.Text == "")) { //Message box to inform the user of errors. MessageBox.Show("Please ensure all fields have values entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if ((epContact.GetError(this.txtNum).Length > 0) || (epEmail.GetError(this.txtEmail).Length > 0)) { //Message box to inform the user of errors. MessageBox.Show("Please attend to any error messages", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Calls methods form the UseDatabase case to add a new quest. UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb"); useDb.ConnectToDatabase(); string b = useDb.addGuest(sName, sSurname, sAddress, sNum, sGender, sEmail, sStatus); useDb.DisconnectDatabase(); //Informs the user if the database was updated if (b == "success") { MessageBox.Show("A guest has been successfully added", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Information); //Appends details to a log file. File.AppendAllText("..\\..\\App_Data\\LogFiles\\Guest.txt", "Guest : " + sName + " Has been added :" + currentDate + Environment.NewLine); } else { MessageBox.Show("There was a problem with inserting into the database", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); } } }
private void btnCheckout_Click(object sender, EventArgs e) { //Checks if all text boxes are filled if (txtGuestName.Text == "" || txtRoomNo.Text == "") { MessageBox.Show("Please enter all required fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { //Checks if any error messages are active before proceeding. if ((epGuest.GetError(this.txtGuestName).Length > 0) || (epRoomNo.GetError(this.txtRoomNo).Length > 0)) { MessageBox.Show("Please attend to any errors", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Initiates variables string guestName = txtGuestName.Text; string checkOutDate = txtCheckOut.Text = DateTime.Now.ToString(); string roomNo = txtRoomNo.Text; //Create a new instance of the UseDatabase case. UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb"); useDb.ConnectToDatabase(); string b = useDb.CheckOut(guestName, roomNo, checkOutDate); //Informs user of success or failure of database entry. if (b == "success") { MessageBox.Show("User has been checked out successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); File.AppendAllText("..\\..\\App_Data\\LogFiles\\Check-In.txt", "Guest : " + guestName + " Has been Checked-out ,on : " + checkOutDate + Environment.NewLine); } else { MessageBox.Show("Failed to check out user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } useDb.DisconnectDatabase(); } } }
private void btnSave_Click(object sender, EventArgs e) { //Declaring variables used in the new room form string roomNum; string roomType; string roomRate; DateTime currentDate = DateTime.Now; //Initialising variables used in new room form roomNum = txtRoomNumber.Text; roomType = txtRoomType.Text; roomRate = txtRoomRate.Text.ToString(); if ((txtRoomNumber.Text == "") || (txtRoomType.Text == "") || (txtRoomRate.Text == "")) { //Message box to inform the user of errors. MessageBox.Show("Please ensure all fields have values entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //creates new instance of the Usedatabase case. UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb"); useDb.ConnectToDatabase(); //Runs the method to add a room and returns a string as result. string b = useDb.addRoom(roomNum, roomType, roomRate); useDb.DisconnectDatabase(); //Informs the user if the room was added or if there was an error. if (b == "success") { MessageBox.Show("A Room has been successfully added", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Information); File.AppendAllText("..\\..\\App_Data\\LogFiles\\Room.txt", "Room : " + roomNum + " Has been added :" + currentDate + Environment.NewLine); this.Close(); } else { MessageBox.Show("There was a problem with inserting into the database", "Caption", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//When the Check-In button is clicked. private void btnCheckIn_Click(object sender, EventArgs e) { //Declaring variables used in the check form. string guestName = txtGuestName.Text; string roomNum = txtRoomNumber.Text; string roomType = txtRoomType.Text; string numPeople = (numAdults.Value).ToString(); DateTime currentDate = DateTime.Now; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Checks whether text box fields have values entered. if ((epGuestName.GetError(this.txtGuestName).Length > 0) || (epRoomNo.GetError(this.txtRoomNumber).Length > 0) || (epNumPeople.GetError(this.numAdults).Length > 0)) { MessageBox.Show("Please attend to any errors", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Create a new instance of the UseDatabase case. UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb"); useDb.ConnectToDatabase(); string b = useDb.CheckIn(guestName, d1.ToString(), roomNum, txtNoDays.Text, numPeople, subTotal); //Informs user of success or failure of database entry. if (b == "success") { MessageBox.Show("User has been checked in", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); File.AppendAllText("..\\..\\App_Data\\LogFiles\\Check-In.txt", "Guest : " + guestName + " Has been Checked-in ,on : " + currentDate + Environment.NewLine); this.Close(); } else { MessageBox.Show("Failed to check-in", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error); } useDb.DisconnectDatabase(); } }