public HashSet <PharmacySaleItemModel> GetPharmacySales() { string query = "SELECT pharmacy_sale.id, medicine.name, employee.first_name, employee.last_name," + "employee.middle_name, pharmacy_sale.quantity, pharmacy_sale.profit, pharmacy_sale.date " + "FROM pharmacy_sale " + "LEFT JOIN medicine ON medicine.id = pharmacy_sale.id_medicine " + "LEFT JOIN employee ON employee.id = pharmacy_sale.id_employee "; command = new MySqlCommand(query, connection); MySqlDataReader reader = command.ExecuteReader(); HashSet <PharmacySaleItemModel> items = new HashSet <PharmacySaleItemModel>(); PharmacySaleItemModel item; while (reader.Read()) { item = new PharmacySaleItemModel(); item.id = reader.GetValue(0).ToString(); item.name = reader.GetValue(1).ToString(); item.employee = reader.GetValue(2).ToString() + reader.GetValue(3).ToString() + reader.GetValue(4).ToString(); item.quantity = reader.GetValue(5).ToString(); item.profit = reader.GetValue(6).ToString(); item.date = reader.GetValue(7).ToString(); items.Add(item); } command.Dispose(); return(items); }
public PharmacySaleViewModel() { _selectedItem = null; GetDataFromDatabase(); }