/// <summary> /// add person button will check if name or lastname is empty or not. if they both are valid it will add this to room object. then it will take dates and other details. /// </summary> private void addpersonbutton_Click(object sender, EventArgs e) { if (costumerslistbox.SelectedIndex != -1) { MessageBox.Show("Error. You choose someone from the listbox then clicked add. You cannot do that."); return; } if (checkinputinformation()) { if (m_roomdetail.CurrentNumOfCostumers() < m_roomdetail.Capacity) { m_roomdetail.AddPerson(costumernametextbox.Text, costumerlastnametextbox.Text); m_roomdetail.Checkindate = checkindatetimepicker.Value; m_roomdetail.Checkoutdate = checkoutdatetimepicker.Value; } else { MessageBox.Show("This room has reached its limit please check your execution."); } UpdateGUI(); } }
/// <summary> /// when you choose a room from allroomslistbox it will put its information into form. then tries to find it from list2 is found selects it. if not keeps it empty. /// </summary> private void allroomslistbox_SelectedIndexChanged(object sender, EventArgs e) { if (allroomslistbox.SelectedIndex >= 0) { if (roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex) != null) { currRoomdetail = roomMngr.GetroomdetailAt(allroomslistbox.SelectedIndex); roomtypecombobox.SelectedIndex = (int)currRoomdetail.Roomtype; } int test = qualifiedroomslistbox.FindString(allroomslistbox.SelectedItem.ToString(), -1); if (test >= 0) { qualifiedroomslistbox.SelectedIndex = test; } else { qualifiedroomslistbox.SelectedIndex = -1; } } //this part is for buttons enable disable options. I do not want the user to be able to click addroom when some room is chosen or delete when nothing is chosen. if (allroomslistbox.SelectedIndex == -1) { reserveroombutton.Enabled = false; cancelreservationbutton.Enabled = false; if (roomtypecombobox.SelectedIndex != -1) { changeroomtypebutton.Enabled = false; deleteroombutton.Enabled = false; } } else { changeroomtypebutton.Enabled = true; deleteroombutton.Enabled = true; reserveroombutton.Enabled = true; if (currRoomdetail.CurrentNumOfCostumers() != 0) { reserveroombutton.Text = "Edit Room"; cancelreservationbutton.Enabled = true; } else { reserveroombutton.Text = "Reserve Room"; cancelreservationbutton.Enabled = false; } } }