示例#1
0
        public ActionResult CreateSave(CustomField model, string returnUrl = "Index")
        {
            ViewBag.Path1 = "参数设置";
            if (ModelState.IsValid)
            {
                try
                {
                    db.CustomField.Add(model);
                    db.PPSave();
                    Common.RMOk(this, "记录:'" + model + "'新建成功!");
                    return Redirect(Url.Content(returnUrl));
                }
                catch (Exception e)
                {
                    if (e.InnerException.Message.Contains("Cannot insert duplicate key row"))
                    {
                        ModelState.AddModelError(string.Empty, "相同名称的记录已存在,保存失败!");
                    }
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            ViewBag.ReturnUrl = returnUrl;
            return View("Create", model);
        }
示例#2
0
        public ActionResult RestoreSave(CustomField record, string returnUrl = "Index")
        {
            ViewBag.Path1 = "参数设置";
            //检查记录在权限范围内
            var result = Common.GetHRAdminCustomFieldQuery(db, WebSecurity.CurrentUserId, true).Where(a => a.IsDeleted == true).Where(a => a.Id == record.Id).SingleOrDefault();
            if (result == null)
            {
                Common.RMError(this);
                return Redirect(Url.Content(returnUrl));
            }
            //end

            try
            {
                result.IsDeleted = false;
                db.PPSave();
                Common.RMOk(this, "记录:" + result + "恢复成功!");
                return Redirect(Url.Content(returnUrl));
            }
            catch (Exception e)
            {
                Common.RMOk(this, "记录" + result + "恢复失败!" + e.ToString());
            }
            return Redirect(Url.Content(returnUrl));
        }
示例#3
0
        public ActionResult EditSave(CustomField model, string returnUrl = "Index")
        {
            ViewBag.Path1 = "参数设置";
            //检查记录在权限范围内
            var result = Common.GetHRAdminCustomFieldQuery(db, WebSecurity.CurrentUserId).Where(a => a.Id == model.Id).SingleOrDefault();
            if (result == null)
            {
                Common.RMError(this);
                return Redirect(Url.Content(returnUrl));
            }
            //end

            if (ModelState.IsValid)
            {
                try
                {
                    result.BasicInfo1 = model.BasicInfo1;
                    result.BasicInfo2 = model.BasicInfo2;
                    result.BasicInfo3 = model.BasicInfo3;
                    result.BasicInfo4 = model.BasicInfo4;
                    result.BasicInfo5 = model.BasicInfo5;
                    result.BasicInfo6 = model.BasicInfo6;
                    result.BasicInfo7 = model.BasicInfo7;
                    result.BasicInfo8 = model.BasicInfo8;
                    result.BasicInfo9 = model.BasicInfo9;
                    result.BasicInfo10 = model.BasicInfo10;

                    result.PensionInfo1 = model.PensionInfo1;
                    result.PensionInfo2 = model.PensionInfo2;
                    result.PensionInfo3 = model.PensionInfo3;
                    result.PensionInfo4 = model.PensionInfo4;
                    result.PensionInfo5 = model.PensionInfo5;

                    result.HireInfo1 = model.HireInfo1;
                    result.HireInfo2 = model.HireInfo2;
                    result.HireInfo3 = model.HireInfo3;
                    result.HireInfo4 = model.HireInfo4;
                    result.HireInfo5 = model.HireInfo5;
                    result.HireInfo6 = model.HireInfo6;
                    result.HireInfo7 = model.HireInfo7;
                    result.HireInfo8 = model.HireInfo8;
                    result.HireInfo9 = model.HireInfo9;
                    result.HireInfo10 = model.HireInfo10;
                    result.HireInfo11 = model.HireInfo11;
                    result.HireInfo12 = model.HireInfo12;
                    result.HireInfo13 = model.HireInfo13;
                    result.HireInfo14 = model.HireInfo14;
                    result.HireInfo15 = model.HireInfo15;
                    result.HireInfo16 = model.HireInfo16;
                    result.HireInfo17 = model.HireInfo17;
                    result.HireInfo18 = model.HireInfo18;
                    result.HireInfo19 = model.HireInfo19;
                    result.HireInfo20 = model.HireInfo20;

                    db.PPSave();
                    Common.RMOk(this, "记录:" + model + "保存成功!");
                    return Redirect(Url.Content(returnUrl));
                }
                catch (Exception e)
                {
                    if (e.InnerException.Message.Contains("Cannot insert duplicate key row"))
                    {
                        ModelState.AddModelError(string.Empty, "相同名称的记录已存在,保存失败!");
                    }
                }
            }
            ViewBag.ReturnUrl = returnUrl;

            return View("Edit", model);
        }