コード例 #1
0
ファイル: DatabaseModel.cs プロジェクト: Gector911/Coursework
        public HashSet <ReceivingPharmacyItemModel> GetPharmacyReceiving()
        {
            string query = "SELECT receiving_pharmacy.id, medicine.name, receiving_pharmacy.quantity, receiving_pharmacy.cost, receiving_pharmacy.date " +
                           "FROM receiving_pharmacy " +
                           "LEFT JOIN medicine ON medicine.id = receiving_pharmacy.id_medicine ";

            command = new MySqlCommand(query, connection);

            MySqlDataReader reader = command.ExecuteReader();
            HashSet <ReceivingPharmacyItemModel> items = new HashSet <ReceivingPharmacyItemModel>();
            ReceivingPharmacyItemModel           item;

            while (reader.Read())
            {
                item          = new ReceivingPharmacyItemModel();
                item.id       = reader.GetValue(0).ToString();
                item.name     = reader.GetValue(1).ToString();
                item.quantity = reader.GetValue(2).ToString();
                item.cost     = reader.GetValue(3).ToString();
                item.date     = reader.GetValue(4).ToString();

                items.Add(item);
            }
            command.Dispose();
            return(items);
        }
コード例 #2
0
 public ReceivingWarehouseViewModel()
 {
     _selectedItem = null;
     GetDataFromDatabase();
 }