private void deleteRoomButton_Click(object sender, EventArgs e) { Room room; int roomId; string employeeItem = managementRoomListBox.SelectedItem.ToString(); int employeeId = Convert.ToInt32(employeeItem.Substring(0, employeeItem.IndexOf(' '))); roomId = employeeId; room = new Room(roomId, 0, null, 0, null, false); this.hms.DeleteRoom(room); string employeeItems = managementHotelListBox.SelectedItem.ToString(); int employeeIds = Convert.ToInt32(employeeItems.Substring(0, employeeItems.IndexOf(' '))); int HotelId = employeeIds; Dictionary <int, Room> rooms = hms.getRoomsByHotelId(HotelId); managementRoomListBox.Items.Clear(); roomListBox.Items.Clear(); // Clear the current list of items foreach (var pair in rooms) { managementRoomListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getType()} - ${pair.Value.getPrice()}"); roomListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getType()} - ${pair.Value.getPrice()}"); } managementRoomListBox.Update(); roomListBox.Update(); ExceptionInterface excep = new ExceptionInterface("Successfully deleted room"); excep.Show(); }
private void createNewRoomButton_Click(object sender, EventArgs e) { hms = new HotelManagementSystem(); hotels = new Dictionary <int, Hotel>(); Room room; string employeeItem = managementHotelListBox.SelectedItem.ToString(); int employeeId = Convert.ToInt32(employeeItem.Substring(0, employeeItem.IndexOf(' '))); int HotelId = employeeId; string type = this.roomTypeTextbox.Text; string RoomPrice = roomPriceTextbox.Text; float price = (float)Convert.ToDouble(RoomPrice); room = new Room(1, HotelId, type, price, null, false); this.hms.AddRoom(room); Dictionary <int, Room> rooms = hms.getRoomsByHotelId(HotelId); managementRoomListBox.Items.Clear(); roomListBox.Items.Clear(); // Clear the current list of items foreach (var pair in rooms) { managementRoomListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getType()} - ${pair.Value.getPrice()}"); } managementRoomListBox.Update(); roomListBox.Update(); ExceptionInterface excep = new ExceptionInterface("Successfully created new room"); excep.Show(); }