Beispiel #1
0
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(ProductEntity entity)
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCT_CACHE, this.CompanyID);

            entity.IncludeAll();
            entity.InPrice  = entity.AvgPrice;
            entity.OutPrice = entity.AvgPrice;
            entity.SnNum    = ConvertHelper.NewGuid();
            entity.BarCode  = entity.BarCode.IsEmpty() ? new TNumProvider(CompanyID).GetSwiftNum(typeof(ProductEntity), 6) : entity.BarCode;

            //处理类别
            if (!entity.CateNum.IsEmpty())
            {
                ProductCategoryEntity category = new ProductCategoryProvider(this.CompanyID).GetSingle(entity.CateNum);
                entity.CateName = category != null ? category.CateName : "";
            }
            if (!entity.UnitNum.IsEmpty())
            {
                MeasureEntity meaure = new MeasureProvider(this.CompanyID).GetMeasure(entity.UnitNum);
                entity.UnitName = meaure != null ? meaure.MeasureName : "";
            }
            int line = this.Product.Add(entity);

            if (line > 0)
            {
                CacheHelper.Remove(Key);
            }
            return(line);
        }
Beispiel #2
0
        public List <ProductEntity> GetAllList()
        {
            List <ProductEntity> list = new List <ProductEntity>();

            ProductEntity entity = new ProductEntity();

            entity.IncludeAll();
            entity.Where(a => true);
            list = this.Product.GetList(entity);
            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(ProductEntity entity)
        {
            entity.IncludeAll();
            entity.InPrice  = entity.AvgPrice;
            entity.OutPrice = entity.AvgPrice;
            int line = this.Product.Add(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE);
            }
            return(line);
        }
Beispiel #4
0
        /// <summary>
        /// 获得产品的缓存数据
        /// </summary>
        /// <returns></returns>
        public List <ProductEntity> GetList()
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCT_CACHE, this.CompanyID);
            List <ProductEntity> list = CacheHelper.Get(Key) as List <ProductEntity>;

            if (!list.IsNullOrEmpty())
            {
                return(list);
            }
            ProductEntity entity = new ProductEntity();

            entity.IncludeAll();
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            list = this.Product.GetList(entity);

            if (!list.IsNullOrEmpty())
            {
                StorageProvider      storageProvider = new StorageProvider(this.CompanyID);
                List <StorageEntity> listStorage     = storageProvider.GetList();
                listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage;

                LocationProvider      locationProvider = new LocationProvider(this.CompanyID);
                List <LocationEntity> listLocation     = locationProvider.GetList();
                listLocation = listLocation.IsNull() ? new List <LocationEntity>() : listLocation;

                foreach (ProductEntity item in list)
                {
                    if (!item.StorageNum.IsEmpty())
                    {
                        StorageEntity storage = listStorage.FirstOrDefault(a => a.SnNum == item.StorageNum);
                        item.StorageName = storage.IsNull() ? string.Empty : storage.StorageName;
                    }

                    if (!item.DefaultLocal.IsEmpty())
                    {
                        LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.DefaultLocal);
                        item.LocalName = location.IsNull() ? string.Empty : location.LocalName;
                    }
                }
            }
            if (!list.IsNullOrEmpty())
            {
                CacheHelper.Insert(Key, list);
            }
            return(list);
        }
Beispiel #5
0
        /// <summary>
        /// 获得产品的缓存数据
        /// </summary>
        /// <returns></returns>
        public List <ProductEntity> GetListByCache()
        {
            List <ProductEntity> list = CacheHelper.Get(CacheKey.JOOSHOW_PRODUCT_CACHE) as List <ProductEntity>;

            if (!list.IsNullOrEmpty())
            {
                return(list);
            }
            ProductEntity entity = new ProductEntity();

            entity.IncludeAll();
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            list = this.Product.GetList(entity);
            if (!list.IsNullOrEmpty())
            {
                CacheHelper.Insert(CacheKey.JOOSHOW_PRODUCT_CACHE, list);
            }
            return(list);
        }
        /// <summary>
        /// 新增带SKU的产品
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(ProductEntity entity, List <ProductSkuEntity> listSku)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                entity.IncludeAll();
                entity.InPrice  = entity.AvgPrice;
                entity.OutPrice = entity.AvgPrice;
                entity.SnNum    = ConvertHelper.NewGuid();
                entity.BarCode  = entity.BarCode.IsEmpty() ? new TNumProvider(CompanyID).GetSwiftNum(typeof(ProductEntity), 6) : entity.BarCode;

                //处理类别
                if (!entity.CateNum.IsEmpty())
                {
                    ProductCategoryEntity category = new ProductCategoryProvider(this.CompanyID).GetSingle(entity.CateNum);
                    entity.CateName = category != null ? category.CateName : "";
                }
                if (!entity.UnitNum.IsEmpty())
                {
                    MeasureEntity meaure = new MeasureProvider(this.CompanyID).GetMeasure(entity.UnitNum);
                    entity.UnitName = meaure != null ? meaure.MeasureName : "";
                }
                int line = this.Product.Add(entity);

                if (!listSku.IsNullOrEmpty())
                {
                    foreach (ProductSkuEntity item in listSku)
                    {
                        item.SnNum      = ConvertHelper.NewGuid();
                        item.ProductNum = entity.SnNum;
                        item.BarCode    = entity.BarCode + "-" + new TNumProvider(CompanyID).GetSwiftNum(entity.SnNum, 3);
                        item.IsDelete   = (int)EIsDelete.NotDelete;
                        item.CreateTime = DateTime.Now;
                        item.CompanyID  = this.CompanyID;
                        item.IncludeAll();
                        line += this.ProductSku.Add(item);
                    }
                }

                ts.Complete();
                return(line);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 查询产品列表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <ProductEntity> GetList(ProductEntity 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 <ProductEntity> list = this.Product.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            if (!list.IsNullOrEmpty())
            {
                List <ProductCategoryEntity> listCate = new ProductCategoryProvider().GetList();
                listCate = listCate.IsNull() ? new List <ProductCategoryEntity>() : listCate;
                foreach (ProductEntity item in list)
                {
                    if (listCate.Exists(a => a.CateNum == item.CateNum))
                    {
                        item.CateName = listCate.First(a => a.CateNum == item.CateNum).CateName;
                    }
                }
            }
            pageInfo.RowCount = rowCount;
            return(list);
        }
Beispiel #8
0
        /// <summary>
        /// 存储过程查询在线产品库存
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <param name="ProductName"></param>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public List <ProductEntity> GetList(ProductEntity entity, ref PageInfo pageInfo, string searchKey, string begin, string end)
        {
            entity.IncludeAll();
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            int rowCount = 0;
            List <ProductEntity> list       = this.Product.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);
            List <ProductEntity> listResult = new List <ProductEntity>();

            pageInfo.RowCount = rowCount;
            DateTime beginTime = ConvertHelper.ToType <DateTime>(begin, DateTime.Now.AddDays(-1));
            DateTime endTime   = ConvertHelper.ToType <DateTime>(end, DateTime.Now);
            Proc_ProductReportEntity prEntity = new Proc_ProductReportEntity();

            prEntity.SearchKey = searchKey;
            prEntity.BeginTime = beginTime;
            prEntity.EndTime   = endTime;
            if (!begin.IsEmpty() && !end.IsEmpty())
            {
                prEntity.IsTime = 1;//加上时间条件
            }
            else
            {
                prEntity.IsTime = 0;
            }
            if (!list.IsNullOrEmpty())
            {
                List <ProductCategoryEntity> listCates = new ProductCategoryProvider().GetList();
                listCates = listCates.IsNull() ? new List <ProductCategoryEntity>() : listCates;
                foreach (ProductEntity item in list)
                {
                    if (item.CateName.IsEmpty())
                    {
                        ProductCategoryEntity cate = listCates.FirstOrDefault(a => a.CateNum == item.CateNum);
                        item.CateName = cate == null ? "" : cate.CateName;
                    }
                    prEntity.ProductNum = item.SnNum;
                    prEntity.IsDelete   = (int)EIsDelete.NotDelete;
                    prEntity.Status     = (int)EAudite.Pass;
                    int line = this.Proc_ProductReport.ExecuteNonQuery(prEntity);
                    item.LocalProductNum      = prEntity.LocalProductNum;
                    item.InStorageNum         = prEntity.InStorageNum;
                    item.OutStorageNum        = prEntity.OutStorageNum;
                    item.BadReportNum         = prEntity.BadReportNum;
                    item.TotalLocalProductNum = prEntity.TotalLocalProductNum;
                    item.TotalInStorageNum    = prEntity.TotalInStorageNum;
                    item.TotalOutStorageNum   = prEntity.TotalOutStorageNum;
                    item.TotalBadReportNum    = prEntity.TotalBadReportNum;
                    if (item.InStorageNum > 0 && item.TotalInStorageNum > 0)
                    {
                        item.InStorageNumPCT = (item.InStorageNum * 100.00f) / item.TotalInStorageNum;
                    }
                    if (item.OutStorageNum > 0 && item.TotalOutStorageNum > 0)
                    {
                        item.OutStorageNumPCT = (item.OutStorageNum * 100.00f) / item.TotalOutStorageNum;
                    }
                    listResult.Add(item);
                }
            }
            return(listResult);
        }