public IActionResult Index(PRESCRIPTIONS obj) { using var trn = db.Database.BeginTransaction(); try { db.PRESCRIPTIONS.Add(obj); db.SaveChanges(); if (obj.PRESCRIPTIONS_DRUGS != null) { int l = 1; foreach (var item in obj.PRESCRIPTIONS_DRUGS) { item.LINE_NO = l; db.PRESCRIPTIONS_DRUGS.Add(item); l++; } db.SaveChanges(); } if (obj.PRESCRIPTIONS_INVES != null) { db.PRESCRIPTIONS_INVES.AddRange(obj.PRESCRIPTIONS_INVES); db.SaveChanges(); } trn.Commit(); } catch (Exception ex) { string msg = ex.Message; trn.Rollback(); } return(View(obj)); }
///<summary> ///PRESCRIPTIONS /// </summary> public static void insert2Precription(PRESCRIPTIONS newPrescription) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); //Add new PRESCRIPTIONS to database db.PRESCRIPTIONS.InsertOnSubmit(newPrescription); //Save changes to Database. db.SubmitChanges(); }
public static void updatePrecription(string str_id, PRESCRIPTIONS updatePrescription) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); //Get PRESCRIPTIONS for update PRESCRIPTIONS oldPrescription = db.PRESCRIPTIONS.FirstOrDefault(e => e.id.Equals(str_id)); oldPrescription = updatePrescription; //Save changes to Database. db.SubmitChanges(); }
public static void deletePrecription(string str_id) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["LinqToSQLDBConnectionString"].ToString(); ECMSDataContext db = new ECMSDataContext(connectString); //Get PRESCRIPTIONS to Delete PRESCRIPTIONS deletePrecription = db.PRESCRIPTIONS.FirstOrDefault(e => e.id.Equals(str_id)); //Delete PRESCRIPTIONS db.PRESCRIPTIONS.DeleteOnSubmit(deletePrecription); //Save changes to Database. db.SubmitChanges(); }
public IActionResult Index() { PRESCRIPTIONS obj = new PRESCRIPTIONS(); return(View(obj)); }