Example #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        private bool Editr(hx_Contract_template p)
        {
            //string[] proNames;

            //proNames = new string[] { "contract_type_id", "contract_template_name", "contract_template_context", "usestate" };
            p = (hx_Contract_template)Utils.ValidateModelClass(p);

            //DbEntityEntry entry = ef.Entry<hx_Contract_template>(p);
            //entry.State = EntityState.Unchanged;

            //foreach (string ProName in proNames)
            //{
            //    entry.Property(ProName).IsModified = true;
            //}
            //int i = ef.SaveChanges();

            int i = ef.hx_Contract_template.Where(a => a.contract_template_id == p.contract_template_id).Update(a => new hx_Contract_template {
                contract_type_id = p.contract_type_id, contract_template_name = p.contract_template_name, contract_template_context = p.contract_template_context
            });

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public ActionResult DelTempliate(int id)
        {
            var controllerName = this.RouteData.Values["controller"].ToString();
            var actionName     = this.RouteData.Values["action"].ToString();

            var userid = Utils.GetAdmUserID();

            if (!new UserLimitByEF().CheckAdminLimit(userid, controllerName, actionName))
            {   //无权限
                return(Content(StringAlert.Alert("您没有操作权限!"), "text/html"));
            }
            if (id < 1)
            {
                return(Content(StringAlert.Alert("参数错误!"), "text/html"));
            }
            hx_Contract_template pDel = new hx_Contract_template()
            {
                contract_template_id = id
            };

            ef.hx_Contract_template.Attach(pDel);
            ef.hx_Contract_template.Remove(pDel);
            int i = ef.SaveChanges();

            if (i > 0)
            {
                return(Content(StringAlert.Alert("删除成功!", "/admin/ContractTemp/Index"), "text/html"));
            }
            else
            {
                return(Content(StringAlert.Alert("删除失败!"), "text/html"));
            }
        }
Example #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        private bool Add(hx_Contract_template t)
        {
            t = (hx_Contract_template)Utils.ValidateModelClass(t);
            ef.hx_Contract_template.Add(t);
            ef.SaveChanges();

            return(true);
        }
Example #4
0
        public ActionResult Template(int id = 0)
        {
            hx_Contract_template temp = new hx_Contract_template();

            if (id > 0)
            {
                temp = ef.hx_Contract_template.SingleOrDefault(p => p.contract_template_id == id);
            }
            IEnumerable <SelectListItem> list_ConType = ef.hx_contract_type.OrderByDescending(p => p.contract_type_id).Select(p => new SelectListItem {
                Value = p.contract_type_id.ToString(), Text = p.contract_type_name
            });

            ViewBag.list_ConType = list_ConType;
            ViewBag.id           = id;
            return(View(temp));
        }
Example #5
0
        public ActionResult TemplateEdit(int contract_template_id, int contract_type_id, string contract_template_name, string content1)
        {
            string str;
            hx_Contract_template p = new hx_Contract_template();

            if (contract_template_id == 0)
            {
                p.cretatetime = DateTime.Now;
                p.usestate    = 1;
            }
            else
            {
                p = (from a in ef.hx_Contract_template where a.contract_template_id == contract_template_id select a).FirstOrDefault();
            }
            p.contract_template_id      = contract_template_id;
            p.contract_template_context = content1;
            p.contract_type_id          = contract_type_id;
            p.contract_template_name    = contract_template_name;

            if (IsExist(contract_template_name, contract_template_id))
            {
                str = StringAlert.Alert("模板名称已经存在!");
            }
            else
            {
                bool result = false;
                if (contract_template_id == 0)
                {
                    result = Add(p);
                }
                else
                {
                    result = Editr(p);
                }

                if (result)
                {
                    str = StringAlert.Alert("操作成功!", "/admin/ContractTemp/Index");
                }
                else
                {
                    str = StringAlert.Alert("操作失败!", "/admin/ContractTemp/Template?id=" + contract_template_id);
                }
            }
            return(Content(str, "text/html"));
        }