private void RoomAnalysis_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ds = Reservations.getYear(ds); for (int i = 0; i < ds.Tables["Year"].Rows.Count; i++) { var val = ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0'); if (!cmbYear.Items.Contains(val)) { cmbYear.Items.Add(val); } } DataSet dst = new DataSet(); cboRoom_Type.Items.Clear(); ds = RoomRate.getRoomRate(dst); for (int i = 0; i < dst.Tables["ss"].Rows.Count; i++) { cboRoom_Type.Items.Add(dst.Tables[0].Rows[i][0].ToString()); } }
private void UpdateRoom_Load(object sender, EventArgs e) { //load combo with room No details. DataSet ds = new DataSet(); ds = Rooms.getRooms(ds); if (ds.Tables["ss"].Rows.Count == 0) { cmbRoomNo.Focus(); MessageBox.Show("There are no rooms availabe for update", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cmbRoomNo.TabStop = false; } for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cmbRoomNo.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0')); } // fills room type combo box with relevant rates from the rates table DataSet dsrt = new DataSet(); dsrt = RoomRate.getRoomRate(dsrt); for (int i = 0; i < dsrt.Tables["ss"].Rows.Count; i++) { cmbRoomType.Items.Add(dsrt.Tables[0].Rows[i][0].ToString().PadLeft(3, '0')); } }
private void MakeReservation_Load(object sender, EventArgs e) { //sets min date to today on load for both dtps dtpFrom.MinDate = DateTime.Now; dtpTo.MinDate = DateTime.Now; DataSet ds = new DataSet(); ds = RoomRate.getRoomRate(ds); // tests to make sure tere is a room available for rent if (ds.Tables["ss"].Rows.Count == 0) { cmbRoomNo.Focus(); MessageBox.Show("There are no rooms available for reservation", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cmbRoomNo.TabStop = false; } else { //load combo with roomrate details. // this will allow a user to select a rate from the the pre-existing rates found in database for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboTypes.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0')); } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //if resetting combo, ignore if (cmbRoomType.SelectedIndex == -1) { return; } //find Rate details RoomRate updRoomRate = new RoomRate(); updRoomRate.getRoomRate(cmbRoomType.Text.Substring(0, 3)); if (updRoomRate.getRoom_Type().Equals(0)) { MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbRoomType.Focus(); return; } //display Rate details txtdescription.Text = updRoomRate.getDescription(); txtRate.Text = updRoomRate.getRate().ToString(); //display details grpUpdateRoom.Visible = true; }
private void UpdateRoomRate_Load(object sender, EventArgs e) { //load combo with roomrate details. DataSet ds = new DataSet(); ds = RoomRate.getRoomRate(ds); if (ds.Tables["ss"].Rows.Count == 0) { // if a rate hasnt been added suitable error message is displayed cmbRoomType.Focus(); MessageBox.Show("There are no room rates available for update", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); cmbRoomType.TabStop = false; } else { //populate combo box for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cmbRoomType.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + ds.Tables[0].Rows[i][1].ToString()); } } }
private void AddRoom_Load_1(object sender, EventArgs e) { //load combo with roomrate details. DataSet ds = new DataSet(); ds = RoomRate.getRoomRate(ds); if (ds.Tables["ss"].Rows.Count == 0) { // if a rate hasnt been added suitable error message is displayed MessageBox.Show("A rate has not been entered please add a roomrate before adding a room", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cmbType.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0')); } } }
private void btnUpdate1_Click(object sender, EventArgs e) { if (txtdescription.Text == string.Empty) { //Checking if description has been entered correctly and putting cursor there if it isnt MessageBox.Show("Description must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtdescription.Focus(); return; } if (txtRate.Text == String.Empty) { //Checking if Rate has been entered correctly and putting cursor there if it isnt MessageBox.Show("Rate must be Entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtRate.Focus(); return; } if (txtdescription.Text.Any(Char.IsDigit)) { MessageBox.Show("Description can only contain letters"); txtdescription.Focus(); return; } Decimal number; if (!Decimal.TryParse(txtRate.Text, out number)) { //Checks to make sure that rate has been entered in decimal format MessageBox.Show("Rate must be a decimal number.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtRate.Focus(); return; } else { //validate data //instantiate RoomRate Object RoomRate myRoomRate = new RoomRate(); myRoomRate.setDescription(txtdescription.Text); myRoomRate.setRate(Convert.ToDecimal(txtRate.Text)); //INSERT RoomRate record into RoomRate table myRoomRate.updateRoomRate(cmbRoomType.Text.Substring(0, 3)); //Display Confirmation Message MessageBox.Show("Room Type " + cmbRoomType.Text + " Updated", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); //reset UI //resetting ui after successfully updateing room txtdescription.Clear(); txtRate.Clear(); cmbRoomType.SelectedIndex = -1; grpUpdateRoom.Visible = false; //clearinf the combo box so results arent duplicated cmbRoomType.Items.Clear(); //resetting the combo box with the updated details DataSet ds = new DataSet(); ds = RoomRate.getRoomRate(ds); for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cmbRoomType.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + ds.Tables[0].Rows[i][1].ToString()); } } }