/// <summary>
 /// 添加产品类别
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Add(ProductCategoryEntity entity)
 {
     entity.IncludeAll();
     int line = this.ProductCategory.Add(entity);
     if (line > 0)
     {
         CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
     }
     return line;
 }
예제 #2
0
 public static ProductCategory_CE ToCE(ProductCategoryEntity item)
 {
     ProductCategory_CE target = new ProductCategory_CE();
     target.ID=item.ID;
     target.CateNum=item.CateNum;
     target.CateName=item.CateName;
     target.IsDelete=item.IsDelete;
     target.CreateTime=item.CreateTime;
     target.CreateUser=item.CreateUser;
     target.Remark=item.Remark;
     return target;
 }
 /// <summary>
 /// 批量删除产品类型
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public int DelBat(List<string> list)
 {
     using (TransactionScope ts = new TransactionScope())
     {
         int line = 0;
         foreach (string cateNum in list)
         {
             ProductCategoryEntity entity = new ProductCategoryEntity();
             entity.Where(a => a.CateNum == cateNum);
             entity.IsDelete = (int)EIsDelete.Deleted;
             entity.IncludeIsDelete(true);
             line += this.ProductCategory.Update(entity);
         }
         ts.Complete();
         if (line > 0)
         {
             CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
         }
         return line;
     }
 }
 /// <summary>
 /// 修改产品类别
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Update(ProductCategoryEntity entity)
 {
     entity.IncludeCateName(true).IncludeRemark(true)
         .Where(a => a.CateNum == entity.CateNum)
         ;
     int line = this.ProductCategory.Update(entity);
     if (line > 0)
     {
         CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
     }
     return line;
 }
 /// <summary>
 /// 查询产品类别分页
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="pageInfo"></param>
 /// <returns></returns>
 public List<ProductCategoryEntity> GetList(ProductCategoryEntity entity, ref PageInfo pageInfo)
 {
     entity.IncludeAll();
     entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
     entity.OrderBy(a => a.ID, EOrderBy.DESC);
     int rowCount = 0;
     List<ProductCategoryEntity> list = this.ProductCategory.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);
     pageInfo.RowCount = rowCount;
     if (!list.IsNullOrEmpty())
     {
         AdminProvider adminProvider = new AdminProvider();
         foreach (ProductCategoryEntity item in list)
         {
             if (!item.CreateUser.IsEmpty())
             {
                 AdminEntity admin = adminProvider.GetAdmin(item.CreateUser);
                 item.CreateUser = admin.IsNotNull() ? admin.UserName : item.CreateUser;
             }
         }
     }
     return list;
 }
 /// <summary>
 /// 查询所有的产品类别
 /// </summary>
 /// <returns></returns>
 public List<ProductCategoryEntity> GetList()
 {
     List<ProductCategoryEntity> list = CacheHelper.Get(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE) as List<ProductCategoryEntity>;
     if (!list.IsNullOrEmpty())
     {
         return list;
     }
     ProductCategoryEntity entity = new ProductCategoryEntity();
     entity.OrderBy(a => a.ID, EOrderBy.DESC);
     entity.IncludeAll();
     entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
     list = this.ProductCategory.GetList(entity);
     if (!list.IsNullOrEmpty())
     {
         CacheHelper.Insert(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, list);
     }
     return list;
 }
 /// <summary>
 /// 根据产品类别删除删除
 /// </summary>
 /// <param name="cateNum"></param>
 /// <returns></returns>
 public int Delete(string cateNum)
 {
     ProductCategoryEntity entity = new ProductCategoryEntity();
     entity.Where(a => a.CateNum == cateNum);
     entity.IsDelete = (int)EIsDelete.Deleted;
     entity.IncludeIsDelete(true);
     int line = this.ProductCategory.Update(entity);
     if (line > 0)
     {
         CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
     }
     return line;
 }
예제 #8
0
        private static void GetProCatInfo(System.Data.DataSet dataset, List<ProductEntity> list)
        {
            var rows = dataset.Tables[0].Rows;
            if (rows.Count > 2)
            {
                ProductCategoryProvider ProductCategory = new ProductCategoryProvider();
                for (var i = 2; i < rows.Count; i++)
                {
                    ProductEntity entity = new ProductEntity();
                    ProductCategoryEntity PCEntity = new ProductCategoryEntity();
                    var row = rows[i];
                    entity.SnNum = row[1].ToString();
                    if (string.IsNullOrEmpty(entity.SnNum)) continue;
                    entity.BarCode = row[2].ToString();
                    entity.ProductName = row[3].ToString();
                    entity.CateName = row[4].ToString();
                    PCEntity = ProductCategory.GetSingleCateName(entity.CateName);
                    if (PCEntity.IsNotNull())
                    {
                        entity.CateNum = PCEntity.CateNum;
                    }
                    else
                    {
                        entity.CateNum = "";
                    }
                    entity.Num = ConvertHelper.ToType<int>(row[5].ToString());
                    entity.MinNum = ConvertHelper.ToType<int>(row[6].ToString());
                    entity.MaxNum = ConvertHelper.ToType<int>(row[7].ToString());
                    entity.UnitName = row[8].ToString();
                    entity.UnitNum = entity.UnitNum;
                    entity.AvgPrice = ConvertHelper.ToType<double>(row[9].ToString());
                    entity.InPrice = ConvertHelper.ToType<double>(row[10].ToString());
                    entity.OutPrice = ConvertHelper.ToType<double>(row[11].ToString());
                    entity.NetWeight = ConvertHelper.ToType<double>(row[12].ToString());
                    entity.GrossWeight = ConvertHelper.ToType<double>(row[13].ToString());
                    entity.Remark = row[14].ToString();

                    entity.IsDelete = (int)EIsDelete.NotDelete;

                    entity.CreateTime = DateTime.Now;
                    list.Add(entity);
                }

            }
        }
예제 #9
0
 public ActionResult Edit()
 {
     string cateNum = WebUtil.GetFormValue<string>("num", string.Empty);
     string cateName = WebUtil.GetFormValue<string>("name", string.Empty);
     string remark = WebUtil.GetFormValue<string>("remark", string.Empty);
     if (cateNum.IsEmpty())
     {
         ProductCategoryEntity entity = new ProductCategoryEntity();
         entity.CateNum = SequenceProvider.GetSequence(typeof(ProductCategoryEntity));
         entity.CateName = cateName;
         entity.IsDelete = (int)EIsDelete.NotDelete;
         entity.CreateTime = DateTime.Now;
         entity.Remark = remark;
         entity.CreateUser = this.LoginUserCode;
         ProductCategoryProvider provider = new ProductCategoryProvider();
         int line = provider.Add(entity);
         if (line > 0)
         {
             this.ReturnJson.AddProperty("d", "success");
         }
     }
     else
     {
         ProductCategoryEntity entity = new ProductCategoryEntity();
         entity.CateNum = cateNum;
         entity.CateName = cateName;
         entity.Remark = remark;
         ProductCategoryProvider provider = new ProductCategoryProvider();
         int line = provider.Update(entity);
         if (line > 0)
         {
             this.ReturnJson.AddProperty("d", "success");
         }
     }
     return Content(this.ReturnJson.ToString());
 }
예제 #10
0
 public ActionResult CateList()
 {
     string cateName = WebUtil.GetFormValue<string>("cateName", string.Empty);
     int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
     int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
     ProductCategoryProvider provider = new ProductCategoryProvider();
     ProductCategoryEntity entity = new ProductCategoryEntity();
     if (!cateName.IsEmpty())
     {
         entity.Begin<ProductCategoryEntity>()
             .Where<ProductCategoryEntity>("CateNum", ECondition.Like, "%" + cateName + "%")
             .Or<ProductCategoryEntity>("CateName", ECondition.Like, "%" + cateName + "%")
             .End<ProductCategoryEntity>()
             ;
     }
     PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
     List<ProductCategoryEntity> list = provider.GetList(entity, ref pageInfo);
     list = list.IsNull() ? new List<ProductCategoryEntity>() : list;
     string json = ConvertJson.ListToJson<ProductCategoryEntity>(list, "data");
     JsonObject jsonObject = new JsonObject(json);
     this.ReturnJson.AddProperty("list", jsonObject);
     this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
     return Content(this.ReturnJson.ToString());
 }