// Loading data from database into listBoxGuest and comboBoxRoomType private void LoadDataBooking() { // Fetch dataset DataSet guestListDS = DBGetData.GetGuestList(); if (guestListDS != null) { // No tables fetched if (guestListDS.Tables.Count == 0) { MessageBox.Show("No guest datatable found, contact administrator."); return; } // No rows fetched else if (guestListDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No datarows found in guest table."); return; } // Set the dataset as source for listbox listBoxGuest.ValueMember = "guestid"; listBoxGuest.DisplayMember = "guest_name"; listBoxGuest.DataSource = guestListDS.Tables[0]; } // Fetch dataset DataSet roomtypeListDS = DBGetData.GetRoomtypeList(); if (roomtypeListDS != null) { // No tables fetched if (roomtypeListDS.Tables.Count == 0) { MessageBox.Show("No roomtype datatable found, contact administrator."); return; } // No rows fetched else if (roomtypeListDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No datarows found in roomtype table."); return; } // Set the dataset as source for combobox comboBoxRoomType.ValueMember = "room_typeid"; comboBoxRoomType.DisplayMember = "name"; comboBoxRoomType.DataSource = roomtypeListDS.Tables[0]; } // Highlight existing values MySqlDataReader getValues = DBGetData.GetRoomreservationData(reservationid); if (getValues.Read()) { listBoxGuest.SelectedValue = getValues.GetInt32(0); comboBoxRoomType.SelectedValue = getValues.GetInt32(1); datePickerArrival.Value = getValues.GetDateTime(2); datePickerDeparture.Value = getValues.GetDateTime(3); if (!getValues.IsDBNull(4)) { textBoxRemark.Text = getValues.GetString(4); } } getValues.Dispose(); }