Exemplo n.º 1
0
        public ActionResult Save(Product_Pattern model)
        {
            string patternName = RequestString("patternname");
            string patternCode = RequestString("patterncode");

            if (string.IsNullOrEmpty(patternName))
            {
                return(LayerAlertErrorAndReturn("请填写名称!"));
            }
            if (string.IsNullOrEmpty(patternCode))
            {
                return(LayerAlertErrorAndReturn("请填写编号!"));
            }
            string firstPic = string.Empty;
            string pics     = GetPics("pic", ref firstPic);

            if (model.Id > 0)
            {
                model = Bll.BllProduct_Pattern.First(o => o.Id == model.Id);
                if (model == null)
                {
                    return(Response404());
                }
            }
            else
            {
                model = new Product_Pattern();
            }

            if ((model.Id == 0 || model.PatternCode != patternCode) && Bll.BllProduct_Pattern.CheckCode(patternCode))
            {
                return(LayerAlertErrorAndReturn("编码重复!"));
            }

            model.IsShow      = RequestBool("isshow");
            model.PatternName = patternName;
            model.PatternCode = patternCode;
            model.FirstPic    = firstPic;
            model.Pics        = pics;
            model.AddTime     = DateTime.Now;
            model.AdminId     = MyInfo.Id;

            if ((model.Id > 0 ? Bll.BllProduct_Pattern.Update(model) : Bll.BllProduct_Pattern.Insert(model)) > 0)
            {
                return(LayerAlertSuccessAndRefresh((model.Id > 0 ? "修改" : "添加") + "成功"));
            }
            else
            {
                return(LayerAlertErrorAndReturn((model.Id > 0 ? "修改" : "添加") + "失败"));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 产品编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id = 0)
        {
            Product_Pattern model = null;

            if (id == 0)
            {
                model = new Product_Pattern();
            }
            else
            {
                model = Bll.BllProduct_Pattern.First(o => o.Id == id);
                if (model == null)
                {
                    return(LayerAlertErrorAndClose("记录不存在!"));
                }
            }
            return(View(model));
        }