コード例 #1
0
        public ActionResult Edit(string id)
        {
            PM_Contracts     form = null;
            List <ComboItem> Corp = null, Type = null, CustID = null, Region = null, Scan1 = null;

            using (var db = new SysContext())
            {
                Corp   = db.Database.SqlQuery <ComboItem>("select Text Text, Value Value from sys_code where " + string.Format("{0}", "/*TABLEALIAS*/CodeType='HtCorp'")).ToList();
                Type   = db.Database.SqlQuery <ComboItem>("select Text Text, Value Value from sys_code where " + string.Format("{0}", "/*TABLEALIAS*/CodeType='HtType'")).ToList();
                Region = db.Database.SqlQuery <ComboItem>("select Text Text, Value Value from sys_code where " + string.Format("{0}", "/*TABLEALIAS*/CodeType='Region'")).ToList();
                Scan1  = db.Database.SqlQuery <ComboItem>("select Text Text, Value Value from sys_code where " + string.Format("{0}", "/*TABLEALIAS*/CodeType='GCLB'")).ToList();
            }
            using (var db = new LUOLAI1401Context())
            {
                CustID = db.BD_Customers.Select(i => new ComboItem {
                    Text = i.Contact, Value = "" + i.FID
                }).ToList();
                form = db.PM_Contracts.Find(id);
            }
            ViewBag.RowState = 2;
            if (form == null)
            {
                ViewBag.RowState = 1;
                form             = new PM_Contracts
                {
                    Code   = id,
                    Type   = string.Format("{0}", "1"),
                    Region = string.Format("{0}", "1"),
                    Scan1  = string.Format("{0}", "n")
                };
            }
            return(View(new { form = form, dataSource = new { Corp, Type, CustID, Region, Scan1 } }));
        }
コード例 #2
0
ファイル: ContractController.cs プロジェクト: zhgl7688/-
        public ActionResult Edit3(PM_Contracts hr)
        {
            using (var db = new LUOLAI1401Context())
            {
                var oldhr = db.PM_Contracts.FirstOrDefault(s => s.Code == hr.Code);
                if (oldhr != null)
                {
                    oldhr.Scan1 = hr.Scan1;
                    oldhr.Scan2 = hr.Scan2;
                    oldhr.Scan3 = hr.Scan3;
                    oldhr.Scan4 = hr.Scan4;
                }
                db.SaveChanges();
            }

            return(Content("<script>alert('更新成功');window.close();</script>"));

            //return Content("<script>alert('更新成功');location='" + Url.Action("Practisecert", "Rols") + "'</script>");
        }