public string UpdatePatient(int patientId, Patient patient) { try { DispenseryEntities db = new DispenseryEntities(); //fetch object from db Patient p = db.Patients.Find(patientId); p.PatientName = patient.PatientName; p.PatientSurname = patient.PatientSurname; p.PatientAddress = patient.PatientAddress; p.PatientTown = patient.PatientTown; p.PatientCounty = patient.PatientCounty; p.PatientEirecode = patient.PatientEirecode; p.PatientPhoneNum = patient.PatientPhoneNum; p.PatientEmail = patient.PatientEmail; p.PatientMedication = patient.PatientMedication; p.PatientCountry = patient.PatientCountry; p.PatientMedicalCondition = patient.PatientMedicalCondition; db.SaveChanges(); return(patient.PatientName + " " + patient.PatientSurname + " was succesfully updated."); } catch (Exception ex) { return("Error: " + ex); } }
public string UpdateHerbStock(int herbStockID, HerbStock herbStock) { try { DispenseryEntities db = new DispenseryEntities(); //fetch object from db HerbStock hs = db.HerbStocks.Find(herbStockID); hs.HerbRefNum = herbStock.HerbRefNum; hs.BatchNum = herbStock.BatchNum; hs.BuyPrice = herbStock.BuyPrice; hs.ExpiryDate = herbStock.ExpiryDate; hs.Quantity = herbStock.Quantity; hs.SupplierID = herbStock.SupplierID; hs.HerbRawToGranRatio = herbStock.HerbRawToGranRatio; hs.DateReceived = herbStock.DateReceived; hs.DateToDispensery = herbStock.DateToDispensery; hs.HerbForm = herbStock.HerbForm; hs.DateLastChanged = herbStock.DateLastChanged; db.SaveChanges(); return("Herb ref.: " + herbStock.HerbRefNum + ", batch : " + herbStock.BatchNum + " was succesfully inserted."); } catch (Exception ex) { return("Error: " + ex); } }
public AllHerb GetAllHerb(string allHerbID) { try { using (DispenseryEntities db = new DispenseryEntities()) { AllHerb ah = db.AllHerbs.Find(allHerbID); return(ah); } } catch (Exception) { return(null); } }
public AllHerb GetHerbByName(string HerbName) { try { using (DispenseryEntities db = new DispenseryEntities()) { AllHerb ah = db.AllHerbs.SingleOrDefault(AllHerb => AllHerb.HerbName == HerbName); return(ah); } } catch (Exception) { return(null); } }
public Patient GetPatient(int patientId) { try { using (DispenseryEntities db = new DispenseryEntities()) { Patient p = db.Patients.Find(patientId); return(p); } } catch (Exception) { return(null); } }
//public string DeletePatient(int patientId) //{ // try // { // DispenseryEntities db = new DispenseryEntities(); // HerbStock hs = db.Patients.Find(patientId); // db.Patients.Attach(hs); // db.Patients.Remove(hs); // db.SaveChanges(); // return hs.PatientName + " " + hs.PatientSurname + " was succesfully removed."; // } // catch (Exception ex) // { // return "Error: " + ex; // } //} public HerbStock GetHerbStock(int herbStockID) { try { using (DispenseryEntities db = new DispenseryEntities()) { HerbStock hs = db.HerbStocks.Find(herbStockID); return(hs); } } catch (Exception) { return(null); } }
public string InsertHerb(AllHerb allHerbs) { try { DispenseryEntities db = new DispenseryEntities(); db.AllHerbs.Add(allHerbs); db.SaveChanges(); return(allHerbs.HerbName + " was succesfully inserted."); } catch (Exception ex) { return("Error: " + ex); } }
public List <Patient> GetAllPatients() { try { using (DispenseryEntities db = new DispenseryEntities()) { List <Patient> patients = (from x in db.Patients select x).ToList(); return(patients); } } catch (Exception) { return(null); } }
public string InsertPatient(Patient patient) { try { DispenseryEntities db = new DispenseryEntities(); db.Patients.Add(patient); db.SaveChanges(); return(patient.PatientName + " " + patient.PatientSurname + " was succesfully inserted."); } catch (Exception ex) { return("Error: " + ex); } }
public List <HerbStock> GetAllHerbStock() { try { using (DispenseryEntities db = new DispenseryEntities()) { List <HerbStock> herbStocks = (from x in db.HerbStocks select x).ToList(); return(herbStocks); } } catch (Exception) { return(null); } }
public string InsertHerbToStock(HerbStock herbStock) { try { DispenseryEntities db = new DispenseryEntities(); db.HerbStocks.Add(herbStock); db.SaveChanges(); return("Herb ref.: " + herbStock.HerbRefNum + ", batch : " + herbStock.BatchNum + " was succesfully inserted."); } catch (Exception ex) { return("Error: " + ex); } }
public string DeleteHerb(string refNum) { try { DispenseryEntities db = new DispenseryEntities(); AllHerb aH = db.AllHerbs.Find(refNum); db.AllHerbs.Attach(aH); db.AllHerbs.Remove(aH); db.SaveChanges(); return(aH.HerbName + " was succesfully removed."); } catch (Exception ex) { return("Error: " + ex); } }
public string DeletePatient(int patientId) { try { DispenseryEntities db = new DispenseryEntities(); Patient p = db.Patients.Find(patientId); db.Patients.Attach(p); db.Patients.Remove(p); db.SaveChanges(); return(p.PatientName + " " + p.PatientSurname + " was succesfully removed."); } catch (Exception ex) { return("Error: " + ex); } }
public string UpdateHerb(string refNum, AllHerb allHerb) { try { DispenseryEntities db = new DispenseryEntities(); //fetch object from db AllHerb aH = db.AllHerbs.Find(refNum); aH.Active = allHerb.Active; aH.Description = allHerb.Description; aH.EnglishName = allHerb.EnglishName; aH.HerbName = allHerb.HerbName; aH.HerbNameChinese = allHerb.HerbNameChinese; aH.PharmaName = allHerb.PharmaName; aH.Temperature = allHerb.Temperature; db.SaveChanges(); return(allHerb.HerbName + " was succesfully updated."); } catch (Exception ex) { return("Error: " + ex); } }