/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonEdit_Click(object sender, EventArgs e) { HotelRoom room = new HotelRoom(_hotelRooms[listBox1.SelectedIndex].roomNumber, (int)numericUpDownRoomNumber.Value / 100, (RoomType)comboBoxRoomType.SelectedItem, checkBoxRiverView.Checked, numericUpDownRate.Value, checkBoxBooked.Checked); if (room.roomNumber != _hotelRooms[listBox1.SelectedIndex].roomNumber) { MessageBox.Show("Room Number was not upated as this is not allowed"); } _hotelRooms[listBox1.SelectedIndex] = room; updateStatus(); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { HotelRoom room = (HotelRoom)listBox1.SelectedItem; numericUpDownRoomNumber.Value = room.roomNumber; numericUpDownFloorNumber.Value = room.floor; comboBoxRoomType.SelectedItem = room.typeOfRoom; checkBoxRiverView.Checked = room.riverView; checkBoxBooked.Checked = room.booked; numericUpDownRate.Value = room.rate; } }
public Form1() { InitializeComponent(); _hotelRooms = new BindingList <HotelRoom>(); listBox1.DataSource = _hotelRooms; comboBoxRoomType.DataSource = Enum.GetValues(typeof(RoomType)); for (int i = 1; i <= ROOMS_PER_FLOOR * NUMBER_OF_FLOORS; i++) { HotelRoom room = new HotelRoom((((i - 1) / ROOMS_PER_FLOOR) * 100) + ((i - 1) % ROOMS_PER_FLOOR), ((i - 1) / ROOMS_PER_FLOOR), (RoomType)rand.Next(0, 5), rand.Next(0, 2) > 0, rand.Next(1, 100), rand.Next(0, 2) > 0); _hotelRooms.Add(room); } updateStatus(); }
private void buttonAdd_Click(object sender, EventArgs e) { int roomNumber = (int)numericUpDownRoomNumber.Value; // floorNumber = (int)numericUpDownFloorNumber.Value; RoomType roomType = (RoomType)comboBoxRoomType.SelectedItem; bool riverView = checkBoxRiverView.Checked; bool booked = checkBoxBooked.Checked; decimal rate = numericUpDownRate.Value; foreach (HotelRoom hotelRoom in _hotelRooms) { if (hotelRoom.roomNumber == roomNumber) { return; } } HotelRoom room = new HotelRoom(roomNumber, roomNumber / 100, roomType, riverView, rate, false); _hotelRooms.Add(room); updateStatus(); }