// Load data from guest, billing_item and folio_item tables into listboxes private void LoadDataFolio() { // Fetch dataset for guestlist 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 for billingitems DataSet billingitemListDS = DBGetData.GetBillingItemList(); if (billingitemListDS != null) { // No tables fetched if (billingitemListDS.Tables.Count == 0) { MessageBox.Show("No billing_item datatable found, contact administrator."); return; } // No rows fetched else if (billingitemListDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No datarows found in billing_item table."); return; } // Set the dataset as source for listbox listBoxBillingItem.ValueMember = "billing_itemid"; listBoxBillingItem.DisplayMember = "billing_itemname"; listBoxBillingItem.DataSource = billingitemListDS.Tables[0]; } // Set value and display member for listBoxFolioItem listBoxFolioItem.ValueMember = "billing_itemid"; listBoxFolioItem.DisplayMember = "billing_itemname"; // Highlight existing values MySqlDataReader getValues = DBGetData.GetFolioData(folioid); if (getValues.Read()) { listBoxGuest.SelectedValue = Convert.ToInt32(getValues[0]); } getValues.Dispose(); }