コード例 #1
0
        public ActionResult Edit(UpdateParmShop model)
        {
            var res = HandleResult(() =>
            {
                //Hashtable param = base.GetParameters();
                //ParamVessel pv=new ParamVessel();
                //pv.Add("parmvalue",String.Empty,HandleType.ReturnMsg);
                //pv.Add("id_shops", String.Empty, HandleType.ReturnMsg);
                //pv.Add("id", String.Empty, HandleType.ReturnMsg);
                //pv.Add("validation_type", String.Empty, HandleType.ReturnMsg);
                ////model.id_masteruser = id_user_master;
                //param = param.Trim(pv);
                //param.Add("id_masteruser", id_user_master);
                model.id_masteruser  = id_user_master;
                model.id_shop        = id_shop;
                model.id_shop_master = id_shop_master;
                return(BusinessFactory.Ts_Parm_Shop.Update(model));
            });

            return(JsonString(res, 1));
        }
コード例 #2
0
ファイル: Ts_Parm_ShopBLL.cs プロジェクト: 17/YunPos
        public override BaseResult Update(dynamic entity)
        {
            BaseResult res = new BaseResult()
            {
                Success = true
            };
            UpdateParmShop model = entity as UpdateParmShop;

            if (model == null ||
                string.IsNullOrEmpty(model.id_masteruser) ||
                string.IsNullOrEmpty(model.id))
            {
                res.Success = false;
                res.Message.Add("参数有误!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.parmvalue))
            {
                res.Success = false;
                res.Message.Add("参数值不能为空!");
                return(res);
            }
            if (string.IsNullOrEmpty(model.id_shop) || string.IsNullOrEmpty(model.id_shop_master))
            {
                res.Success = false;
                res.Message.Add("操作失败!");
                return(res);
            }

            var id_shop       = model.id_shop;
            var parmvalue     = model.parmvalue;
            var id_masteruser = model.id_masteruser;
            var id            = model.id;

            Hashtable ht = new Hashtable();

            ht.Add("id_masteruser", id_masteruser);
            ht.Add("id", id);
            var oldModel = DAL.GetItem <Ts_Parm_Shop>(typeof(Ts_Parm_Shop), ht);

            if (oldModel == null)
            {
                res.Success = false;
                res.Message.Add("数据已不存在!");
                return(res);
            }
            if (!ParmValidation.Valid(oldModel.regex, parmvalue, res) && oldModel.flag_editstyle != 1)
            {
                return(res);
            }
            if (ParmValidation.NeedValidParmCode(oldModel.parmcode) && oldModel.flag_editstyle != 1)
            {
                if (!ParmValidation.ValidDigit(parmvalue, oldModel.parmvalue, res))
                {
                    return(res);
                }
            }
            Hashtable param = new Hashtable();

            if (model.id_shop == oldModel.id_shop && model.id_shop == model.id_shop_master)
            {
                param.Clear();
                param.Add("id_masteruser", model.id_masteruser);
                param.Add("id", model.id);
                param.Add("new_parmvalue", model.parmvalue);
                DAL.UpdatePart(typeof(Ts_Parm_Shop), param);
            }
            else
            {
                param.Clear();
                param.Add("id_masteruser", model.id_masteruser);
                param.Add("id_shop", id_shop);
                param.Add("parmcode", oldModel.parmcode);
                var count = DAL.GetCount(typeof(Ts_Parm_Shop), param);
                if (count == 1)
                {
                    param.Add("new_parmvalue", model.parmvalue);
                    DAL.UpdatePart(typeof(Ts_Parm_Shop), param);
                }
                else if (count == 0)
                {
                    Ts_Parm_Shop parmShop = new Ts_Parm_Shop()
                    {
                        id             = GetGuid,
                        flag_editstyle = oldModel.flag_editstyle,
                        id_masteruser  = id_masteruser,
                        id_shop        = id_shop,
                        parmcode       = oldModel.parmcode,
                        parmvalue      = model.parmvalue,
                        parmdescribe   = oldModel.parmdescribe,
                        regex          = oldModel.regex,
                        sort_id        = oldModel.sort_id,
                        version        = oldModel.version,
                        parmname       = oldModel.parmname
                    };
                    DAL.Add(parmShop);
                }
                else
                {
                    res.Success = false;
                    res.Message.Add("数据有误,请联系管理员!");
                    return(res);
                }
            }
            DataCache.Remove(id_masteruser + "_" + id_shop + "_GetShopParm");
            return(res);
        }