public void UpdateMedicinePrice(int adapterSelector) { IMedicinePriceAdapter medicinPriceAdapter; if (adapterSelector == 1) { medicinPriceAdapter = new MedicinePriceAdapter1(); } else { medicinPriceAdapter = new MedicinePriceAdapter2(); } DateTime UpdateTime = GetLastUpdate(); List <MedicinePrice> medicinePrices = medicinPriceAdapter.GetMedicinePrice(); if (medicinePrices[0].date > UpdateTime) { for (int i = 0; i < medicinePrices.Count; i++) { MedicinePrice medicinePrice = medicinePrices[i]; string query = Utility.ReadSQLQueryFromFile("UpdateMedicinCostPrice.txt"); SQLQuery sQLQuery = new SQLQuery(query); sQLQuery.AddParameter("@name", medicinePrice.name.ToString(), SqlDbType.VarChar); sQLQuery.AddParameter("@costprice", medicinePrice.price.ToString(), SqlDbType.Decimal); SQLQueryResult sQLQueryResult = SQLDatabaseConnector.QueryDatabase(sQLQuery); } UpdateMedicinePriceDate(medicinePrices[0]); } }
public string UpdateMedicinePriceDate(MedicinePrice medicinePrice) { string query = Utility.ReadSQLQueryFromFile("UpdateMedicinPriceDate.txt"); SQLQuery sQLQuery = new SQLQuery(query); sQLQuery.AddParameter("@newdate", medicinePrice.date.ToString(), SqlDbType.DateTime); SQLQueryResult sQLQueryResult = SQLDatabaseConnector.QueryDatabase(sQLQuery); if (sQLQueryResult.code == 0) { return("ok"); } else { throw new DateNotUpdated("", sQLQueryResult.exception); } }
public List <MedicinePrice> GetMedicinePrice() { List <MedicinePrice> list = new List <MedicinePrice>(); string file = Path.GetDirectoryName(Application.ExecutablePath) + "/Medicine/medicin1.txt"; string[] MedicinPrices = File.ReadAllLines(file); DateTime date = Convert.ToDateTime(MedicinPrices[0]); for (int i = 2; i < MedicinPrices.Length; i++) { string[] MedicinList = MedicinPrices[i].Split('_'); decimal price = Convert.ToDecimal(MedicinList[1], new System.Globalization.CultureInfo("da-DK")); string name = MedicinList[0]; MedicinePrice medicinPrice = MedicinPriceFactory.Instance().CreateMedicinPrice(name, price, date); list.Add(medicinPrice); } return(list); }