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 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 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 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); } }