private void CheckOut_Load(object sender, EventArgs e) { //populate the combobox on load 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()); } } }
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; }