public ActionResult AddGoodsCategory(GoodsCategoryModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IGoodsCategoryBLL goodsCategoryTypeBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); T_GoodsCategory goodsCategory = new T_GoodsCategory() { Name = model.Name, ShopId = GetCurrentShopId().Value }; // 保存 goodsCategoryTypeBll.Save(goodsCategory); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel EditGoodsCategory(GoodsCategoryInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IGoodsCategoryBLL goodsBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); if (goodsBLL.Exist(m => m.Name == model.Name && m.Id != model.Id && m.ShopId == model.ShopId)) { resultModel.Msg = "该商品类别已经存在"; } else { var goodsCategory = goodsBLL.GetEntity(g => g.Id == model.Id.Value); //修改商品分类 if (goodsCategory != null) { goodsCategory.Name = model.Name; goodsBLL.Update(goodsCategory); } else { resultModel.Msg = "不存在当前商品分类"; } } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ActionResult DeleteGoodsCategory(int id) { JsonModel jm = new JsonModel(); IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); //获取要删除的类别 T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == id); if (goodsCategory == null) { jm.Msg = "该类别不存在"; } else if (goodsCategory.ShopSales.Count() > 0) { jm.Msg = "已有该类型的商品,无法删除"; } else { if (goodsCategoryBll.Delete(goodsCategory)) { //操作日志 jm.Content = "删除商品类别 " + goodsCategory.Name; } else { jm.Msg = "删除失败"; } } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult EditGoodsCategory(GoodsCategoryModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == model.Id); if (goodsCategory != null) { goodsCategory.Name = model.Name; //保存到数据库 if (goodsCategoryBll.Update(goodsCategory)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该类别不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
private void FrmSaleLog_Load(object sender, EventArgs e) { BllFactory.DLLBasePath = Application.StartupPath; bll = BllFactory.GetReportBll(); logBll = BllFactory.GetSaleLogBll(); goodsBll = BllFactory.GetGoodsBll(); catBll = BllFactory.GetGoodsCategoryBll(); loadData(); }
public GoodsController(IGoodsBLL goodsBLL, ICategoryBLL categoryBLL, IGoodsCategoryBLL goodsCategoryBLL, IGoodsImagesBLL goodsImagesBLL, IReCommendBLL recommendBLL) { _goodsBLL = goodsBLL; _categoryBLL = categoryBLL; _goodsCategoryBLL = goodsCategoryBLL; _goodsImagesBLL = goodsImagesBLL; _recommendBLL = recommendBLL; }
public HomeController(ICategoryBLL categoryBLL, IGoodsBLL goodsBLL, IGoodsImagesBLL goodsImagesBLL, IGoodsCategoryBLL goodsCategoryBLL, IRulesBLL rulesBLL, IMemberBLL memberBLL) { _categoryBLL = categoryBLL; _goodsBLL = goodsBLL; _goodsImagesBLL = goodsImagesBLL; _goodsCategoryBLL = goodsCategoryBLL; _rulesBLL = rulesBLL; _memberBLL = memberBLL; }
/// <summary> /// 加载商品类目 /// </summary> private void LoadCategories() { if (catBll == null) { catBll = BLLLoader.GetGoodsCategoryBll(); } this.cmbCategory.DisplayMember = "Name"; this.cmbCategory.ValueMember = "Id"; this.cmbCategory.DataSource = catBll.GetAllCategories(); }
public ApiPageResultModel GetGoodsCategoryList([FromUri] GoodsCategorySearchModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); IGoodsCategoryBLL goodsBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); Expression <Func <T_GoodsCategory, bool> > where = g => g.ShopId == model.ShopId; // 获取商家的商品分类 var list = goodsBLL.GetPageList(where, model.PageIndex).Select( g => new { Id = g.Id, Name = g.Name, Count = g.ShopSales.Count() }).ToList(); resultModel.result = list; resultModel.Total = goodsBLL.Count(g => g.ShopId == model.ShopId); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
/// <summary> /// 获取当前门店商品分类列表 /// </summary> private List <SelectListItem> GetGoodsCategoryList(int ShopId) { IGoodsCategoryBLL goodsCategoryBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); var sortModel = this.SettingSorting("Id", true); var list = goodsCategoryBLL.GetList(u => u.ShopId == ShopId, sortModel.SortName, sortModel.IsAsc); //转换为下拉列表并返回 return(list.Select(m => new SelectListItem() { Text = m.Name, Value = m.Id.ToString(), Selected = false }).ToList()); }
public ActionResult GoodsCategoryList(GoodsCategoryModel model) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); var shopId = GetCurrentShopId().Value; Expression <Func <T_GoodsCategory, bool> > where = u => (string.IsNullOrEmpty(model.Name) ? true : u.Name.Contains(model.Name)) && u.ShopId == shopId; //查询条件 //排序 var sortModel = this.SettingSorting("Id", false); //将查询到的数据赋值传到页面 model.DataList = goodsCategoryBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_GoodsCategory>; return(View(model)); }
public ContentResult RemoteCheckExist(int Id, string Name) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); var ShopId = GetCurrentShopId().Value; if (goodsCategoryBll.Exist(m => m.Name == Name && m.Id != Id && m.ShopId == ShopId)) { // 校验不通过 return(Content("false")); } else { return(Content("true")); } }
public ApiResultModel GetGoodsCategoryList([FromUri] DetailSearchModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); //该门店的商品类别 Expression <Func <T_GoodsCategory, bool> > where = s => s.ShopId == model.Id; //获取指定门店的类别列表 IGoodsCategoryBLL categoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); resultModel.result = categoryBll.GetList(where).Select(s => new { CategoryId = s.Id, CategoryName = s.Name }); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ActionResult EditGoodsCategory(int id) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); var shopId = GetCurrentShopId().Value; //获取要编辑的物业账户 T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == id && m.ShopId == shopId); if (goodsCategory != null) { //初始化返回页面的模型 GoodsCategoryModel model = new GoodsCategoryModel() { Id = goodsCategory.Id, Name = goodsCategory.Name }; return(View(model)); } else { return(RedirectToAction("GoodsCategoryList")); } }
private void initBll() { BllFactory.DLLBasePath = Application.StartupPath; bll = BllFactory.GetGoodsBll(); catBll = BllFactory.GetGoodsCategoryBll(); }