Exemplo n.º 1
0
        /// <summary>
        /// 获取门店列表
        /// </summary>
        public string GetDefaultStoreListData()
        {
            var    service = new StoreBLL(CurrentUserInfo);
            string content = string.Empty;

            string key = string.Empty;

            if (Request("StoreID") != null && Request("StoreID") != string.Empty)
            {
                key = Request("StoreID").ToString().Trim();
            }

            var queryEntity = new StoreEntity();

            queryEntity.StoreID = key;
            int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1;

            var data           = service.GetList(queryEntity, pageIndex, 1000);
            var dataTotalCount = service.GetListCount(queryEntity);

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    data.ToJSON(),
                                    dataTotalCount);
            return(content);
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            StoreInfo info = StoreBLL.GetList(p => p.ID == id).FirstOrDefault();


            return(View(info));
        }
Exemplo n.º 3
0
        public ActionResult Index(int page = 1)
        {
            var list = StoreBLL.GetList(p => true);

            list = list.OrderByDescending(p => p.ID);
            var result = list.ToPagedList(page, PageSize);

            return(View(result));
        }
Exemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            var info = StoreBLL.GetList(p => p.ID == id).FirstOrDefault();

            if (null == info)
            {
                return(Json(new APIJson(-1, "删除失败,参数有误")));
            }
            if (StoreBLL.Delete(info))
            {
                return(Json(new APIJson(0, "删除成功")));
            }
            return(Json(new APIJson(-1, "删除失败,请重试")));
        }
Exemplo n.º 5
0
        public ActionResult Edit(StoreInfo info)
        {
            StoreInfo infoExist = StoreBLL.GetList(p => p.Name == info.Name && p.ID != info.ID).FirstOrDefault();

            if (infoExist != null)
            {
                return(Json(new APIJson(-1, "名称已存在")));
            }
            if (string.IsNullOrEmpty(info.Name))
            {
                return(Json(new APIJson(-1, "名称未填写")));
            }
            if (string.IsNullOrEmpty(info.Name.Trim()))
            {
                return(Json(new APIJson(-1, "名称不能是空格,请正确填写")));
            }
            if (null == info.IP)
            {
                info.IP = string.Empty;
            }
            infoExist = StoreBLL.GetList(p => p.ID == info.ID).FirstOrDefault();
            if (null == infoExist)
            {
                return(Json(new APIJson(-1, "parms error")));
            }
            if (!string.IsNullOrEmpty(info.Password))
            {
                bool IsPassWordValidate = ValidatePassWord(info);
                if (!IsPassWordValidate || info.Password.Length < 8 || info.Password.Length > 16)
                {
                    return(Json(new APIJson("密码必需包含数字、字母,并且长度在8到16位")));
                }
                infoExist.Password = Tool.Md5Helper.Md5(info.Password);
            }

            infoExist.Name = info.Name;
            infoExist.Code = info.Code;
            infoExist.IP   = info.IP;
            if (StoreBLL.Edit(infoExist))
            {
                return(Json(new APIJson(0, "提交成功")));
            }
            return(Json(new APIJson(-1, "提交失败")));
        }
Exemplo n.º 6
0
        public ActionResult Create(StoreInfo info)
        {
            info.CreateDate = DateTime.Now;
            info.IP         = string.Empty;
            StoreInfo infoExist = StoreBLL.GetList(p => p.Name == info.Name).FirstOrDefault();

            if (null != infoExist)
            {
                return(Json(new APIJson(-1, "名称已存在")));
            }
            if (string.IsNullOrEmpty(info.Name))
            {
                return(Json(new APIJson(-1, "名称未填写")));
            }
            if (string.IsNullOrEmpty(info.Name.Trim()))
            {
                return(Json(new APIJson(-1, "名称不能是空格,请正确填写")));
            }
            if (string.IsNullOrEmpty(info.Code))
            {
                info.Code = info.Name;
            }
            if (!string.IsNullOrEmpty(info.Password))
            {
                bool IsPassWordValidate = ValidatePassWord(info);
                if (!IsPassWordValidate || info.Password.Length < 8 || info.Password.Length > 16)
                {
                    return(Json(new APIJson("密码必需包含数字、字母,并且长度在8到16位")));
                }
            }
            else
            {
                info.Password = "******";
            }
            info.Password = Tool.Md5Helper.Md5(info.Password);
            StoreBLL.Create(info);
            if (info.ID > 0)
            {
                return(Json(new APIJson(0, "添加成功", new { info.ID, info.Name })));
            }
            return(Json(new APIJson(-1, "添加失败")));
        }