public ActionResult Para()
        {
            var gridModel = new ParaGridModel();

            SetupParaGridModel(gridModel.ParasGrid);
            return(View(gridModel));
        }
        public ActionResult Para_RequestData(Guid?id)
        {
            List <DXInfo.Models.NameCode> ncs = null;

            if (id.HasValue)
            {
                ncs = db.NameCode.Where(w => w.ID == id).ToList();
            }
            else
            {
                ncs = db.NameCode.ToList();
            }
            var gridModel = new ParaGridModel();

            SetupParaGridModel(gridModel.ParasGrid);
            return(gridModel.ParasGrid.DataBind(ncs.AsQueryable()));
        }
        public ActionResult Para_EditData(DXInfo.Models.NameCode nc)
        {
            var gridModel = new ParaGridModel();

            SetupParaGridModel(gridModel.ParasGrid);
            if (gridModel.ParasGrid.AjaxCallBackMode == AjaxCallBackMode.AddRow)
            {
                using (var context = db)
                {
                    nc.ID = Guid.NewGuid();

                    if (nc.Type == "DeptCodeLength")
                    {
                        //DeptCodeLength
                        var n = context.NameCode.Where(w => w.Type == "DeptCodeLength").FirstOrDefault();
                        if (n != null)
                        {
                            return(gridModel.ParasGrid.ShowEditValidationMessage("部门编码长度记录只能有一条"));
                        }
                    }
                    context.NameCode.Add(nc);
                    context.SaveChanges();
                }
            }
            if (gridModel.ParasGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow)
            {
                using (var context = db)
                {
                    var oldnc = context.NameCode.Where(w => w.ID == nc.ID).FirstOrDefault();
                    oldnc.Code    = nc.Code;
                    oldnc.Name    = nc.Name;
                    oldnc.Value   = nc.Value;
                    oldnc.Comment = nc.Comment;
                    context.SaveChanges();
                }
            }
            return(RedirectToAction("Para"));
        }