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 CheckIn_Load(object sender, EventArgs e) { // On load fill the res id combo box with the relevant check in options DataSet ds = new DataSet(); ds = Reservations.getCheckIns(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-In 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()); } } }