Пример #1
0
        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));
        }
Пример #2
0
        ///<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();
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
        }
Пример #5
0
        public IActionResult Index()
        {
            PRESCRIPTIONS obj = new PRESCRIPTIONS();

            return(View(obj));
        }