コード例 #1
0
        public ActionResult SaveOrder(int mr, int cons, TBL_MPROC_DETAIL[] order)
        {
            string result = "Error! Order Is Not Complete!";

            if (mr != 0 && cons != 0)
            {
                //int cutomerId = Guid.NewGuid();
                TBL_MASTER_PROCEDURE model = new TBL_MASTER_PROCEDURE();
                model.MR           = mr;
                model.MP_CONS      = cons;
                model.MP_USER_ID   = Convert.ToInt32(Session["user_id"]);
                model.MP_USER_ORG  = Convert.ToInt32(Session["user_org"]);
                model.MP_USER_dATE = DateTime.Now;
                db.TBL_MASTER_PROCEDURE.Add(model);
                db.SaveChanges();
                int last_insert_id = model.MP_CODE;
                foreach (var item in order)
                {
                    //var orderId = Guid.NewGuid();
                    TBL_MPROC_DETAIL tmd = new TBL_MPROC_DETAIL();
                    //O.OrderId = orderId;
                    tmd.MP_CODE = last_insert_id;
                    tmd.pro_id  = item.pro_id;
                    tmd.PRICE   = item.PRICE;
                    db.TBL_MPROC_DETAIL.Add(tmd);
                }
                db.SaveChanges();
            }

            result = "Success! Order Is Complete!";

            return(Json(result, JsonRequestBehavior.AllowGet));
            //return RedirectToAction("reporting");
        }
コード例 #2
0
        public JsonResult InsertCustomers(List <TBL_MPROC_DETAIL> customers)
        {
            using (Pathology_dbEntities1 db = new Pathology_dbEntities1())
            {
                TBL_MASTER_PROCEDURE mp = new TBL_MASTER_PROCEDURE();
                //Truncate Table to delete all old records.
                db.Database.ExecuteSqlCommand("TRUNCATE TABLE [TBL_MPROC_DETAIL]");
                //Check for NULL.
                if (customers == null)
                {
                    customers = new List <TBL_MPROC_DETAIL>();
                }

                //Loop and insert records.
                foreach (TBL_MPROC_DETAIL customer in customers)
                {
                    db.TBL_MPROC_DETAIL.Add(customer);
                }
                int insertedRecords = db.SaveChanges();
                return(Json(insertedRecords));
            }
        }
コード例 #3
0
 public ActionResult Add_Departments(TBL_R_DEPT objdept)
 {
     db.TBL_R_DEPT.Add(objdept);
     db.SaveChanges();
     return(RedirectToAction("Departments"));
 }