private void btnConfirm_Click(object sender, EventArgs e) { // deleting the reservation and resetting the ui Reservations cancel = new Reservations(); cancel.getRes_ID(); cancel.setRes_ID(Convert.ToInt32(txtResId.Text)); cancel.deleteReservation(); MessageBox.Show("A reservation has been successfully cancelled"); cboRes_ID.SelectedIndex = -1; grpDeleteRes.Visible = false; cboRes_ID.Items.Clear(); DataSet ds = new DataSet(); ds = Reservations.getValidReservationsForDeletion(ds); if (ds.Tables["ss"].Rows.Count == 0) { cboRes_ID.Focus(); MessageBox.Show("There are no reservations available to be cancelled", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cboRes_ID.TabStop = false; } else { for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString()); } } }
private void btnConfirm_Click(object sender, EventArgs e) { if (txtCustName.Text == String.Empty) { //Checking if customersname has been entered correctly and putting cursor there if it isnt MessageBox.Show("Customers Name must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCustName.Focus(); return; } if (txtEmail.Text == String.Empty) { //Checking if E-mail has been entered correctly and putting cursor there if it isnt MessageBox.Show("E-mail must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } if (txtCustName.Text.Any(Char.IsDigit)) { MessageBox.Show("CustName only accepts letters"); txtCustName.Focus(); return; } //Checking if RoomNo has been selected correctly and putting cursor there if it isnt if (cmbRoomNo.SelectedIndex == -1)//Nothing selected { MessageBox.Show("A Room No must be selected", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbRoomNo.Focus(); return; } else { //adding details to reservation and calculating total cost of stay Reservations makeRes = new Reservations(); makeRes.setRes_ID(Reservations.nextResId()); makeRes.setRoom_No(Convert.ToInt32(cmbRoomNo.Text)); makeRes.setCust_Name(txtCustName.Text.ToUpper()); makeRes.setE_Mail(txtEmail.Text.ToUpper()); makeRes.setDate_Arrive(dtpFrom.Value.ToString("yyyy-MM-dd")); makeRes.setDate_Depart(dtpTo.Value.ToString("yyyy-MM-dd")); makeRes.setTotal_Cost((Convert.ToDateTime(dtpTo.Text) - Convert.ToDateTime(dtpFrom.Text)).TotalDays * Reservations.findRate(makeRes.getRoom_No(Convert.ToInt32(cmbRoomNo.Text)))); makeRes.setCheck_In("A"); makeRes.setCheck_Out("A"); makeRes.setRes_Status("A"); makeRes.makeReservation(); //Clearing the ui MessageBox.Show("A Reservation has been successfully made"); txtCustName.Clear(); txtEmail.Clear(); cmbRoomNo.SelectedIndex = -1; cboTypes.SelectedIndex = -1; grpReservaion.Visible = false; } }
private void btnConfirm_Click(object sender, EventArgs e) { //if the radio button is checked if (rbCheckIn.Checked) { //get the res id Reservations checkin = new Reservations(); checkin.getRes_ID(); checkin.setRes_ID(Convert.ToInt32(txtResId.Text)); //invoke the checkin method checkin.checkIn(); //confirmation message and reset the ui MessageBox.Show("A Customer has succesfully checkedIn"); cboRes_ID.SelectedIndex = -1; rbCheckIn.Checked = false; grpCheckIn.Visible = false; // clear the res id box cboRes_ID.Items.Clear(); // create and fill a new dataset that will allow the system to update on the fly you wont have to go in and out of the function in order for it to update DataSet ds = new DataSet(); ds = Reservations.getCheckIns(ds, DateTime.Now.ToString("yyyy-MM-dd")); //if teres no check in display error message if (ds.Tables["ss"].Rows.Count == 0) { cboRes_ID.Focus(); MessageBox.Show("There are no rooms available for check-In today", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cboRes_ID.TabStop = false; } else { // if tere is populate the combo box for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString()); } } } // validation that ensure that you actual select the check in else { MessageBox.Show("CheckIn must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } rbCheckIn.Focus(); return; }
private void btnConfirm_Click(object sender, EventArgs e) { if (rbCheckOut.Checked) { // updateing db and resetting the ui Reservations checkOut = new Reservations(); checkOut.getRes_ID(); checkOut.setRes_ID(Convert.ToInt32(txtResID.Text)); checkOut.checkOut(); MessageBox.Show("A Customer has succesfully checkedOut"); cboRes_ID.SelectedIndex = -1; rbCheckOut.Checked = false; grpCheckOut.Visible = false; //clearing cbo box cboRes_ID.Items.Clear(); // repopulating the combobox with only relevant check outs. allows function to update while in the function DataSet ds = new DataSet(); ds = Reservations.getCheckOuts(ds, DateTime.Now.ToString("yyyy-MM-dd")); if (ds.Tables["ss"].Rows.Count == 0) { cboRes_ID.Focus(); MessageBox.Show("There are no rooms available for check-Out today", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cboRes_ID.TabStop = false; } else { for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboRes_ID.Items.Add(String.Format("{0:000000}", ds.Tables[0].Rows[i][0]) + " " + ds.Tables[0].Rows[i][2].ToString()); } } } else { MessageBox.Show("CheckOut must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } rbCheckOut.Focus(); return; }