Esempio n. 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ProductEntity entity)
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCT_CACHE, this.CompanyID);

            entity.InPrice  = entity.AvgPrice;
            entity.OutPrice = entity.AvgPrice;

            //处理类别
            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 : "";
            }

            entity.Include(a => new { a.ProductName, a.BarCode, a.FactoryNum, a.InCode, a.MinNum, a.MaxNum, a.UnitNum, a.UnitName, a.CateNum, a.CateName, a.Size, a.InPrice, a.OutPrice, a.AvgPrice, a.GrossWeight, a.NetWeight, a.StorageNum, a.DefaultLocal, a.CusNum, a.CusName, a.SupNum, a.SupName, a.Description, a.Display, a.Remark });
            entity.Where(a => a.SnNum == entity.SnNum)
            .And(a => a.CompanyID == this.CompanyID);
            int line = this.Product.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(Key);
            }
            return(line);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// 查询产品列表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <ProductEntity> GetList(ProductEntity entity, ref PageInfo pageInfo)
        {
            List <ProductEntity> listSource = GetList();

            if (listSource.IsNullOrEmpty())
            {
                return(listSource);
            }
            int rowCount = 0;
            List <ProductEntity> listResult = listSource;

            if (!entity.BarCode.IsEmpty())
            {
                listResult = listResult.Where(a => a.BarCode.Contains(entity.BarCode)).ToList();
            }
            if (!entity.ProductName.IsEmpty())
            {
                listResult = listResult.Where(a => a.ProductName.Contains(entity.ProductName)).ToList();
            }
            if (entity.FactoryNum.IsNotEmpty())
            {
                listResult = listResult.Where(a => a.FactoryNum.Contains(entity.FactoryNum)).ToList();
            }
            if (entity.InCode.IsNotEmpty())
            {
                listResult = listResult.Where(a => a.InCode.Contains(entity.InCode)).ToList();
            }
            if (!entity.Size.IsEmpty())
            {
                listResult = listResult.Where(a => a.Size.Contains(entity.Size)).ToList();
            }
            if (!entity.CateNum.IsEmpty())
            {
                ProductCategoryProvider      cateProvider = new ProductCategoryProvider(this.CompanyID);
                List <ProductCategoryEntity> listCate     = cateProvider.GetChildList(entity.CateNum);
                listCate   = listCate.IsNull() ? new List <ProductCategoryEntity>() : listCate;
                listResult = listResult.Where(a => listCate.Exists(item => item.SnNum == a.CateNum)).ToList();
            }
            if (entity.IsSingle > 0)
            {
                listResult = listResult.Where(a => a.IsSingle == entity.IsSingle).ToList();
            }
            rowCount          = listResult.Count;
            pageInfo.RowCount = rowCount;
            return(listResult.Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Take(pageInfo.PageSize).ToList());
        }
Esempio n. 4
0
        /// <summary>
        /// 所有仓库的正式库位和待入库位货品数量的总和
        /// 不区分仓库,不区分库位
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <V_LocalProductEntity> GetList(V_LocalProductEntity entity, ref PageInfo pageInfo)
        {
            V_LocalProductEntity Entity = new V_LocalProductEntity();

            Entity.IncludeAll();
            Entity.OrderBy(a => a.ID, EOrderBy.ASC);
            Entity.Where(a => a.CompanyID == this.CompanyID).And(item => item.Num > 0);

            if (entity.BarCode.IsNotEmpty())
            {
                Entity.Where("BarCode", ECondition.Like, "%" + entity.BarCode + "%");
            }
            if (entity.ProductName.IsNotEmpty())
            {
                Entity.Where("ProductName", ECondition.Like, "%" + entity.ProductName + "%");
            }
            if (entity.Size.IsNotEmpty())
            {
                Entity.Where("Size", ECondition.Like, "%" + entity.Size + "%");
            }
            if (entity.CateNum.IsNotEmpty())
            {
                ProductCategoryProvider      provider = new ProductCategoryProvider(this.CompanyID);
                List <ProductCategoryEntity> listCate = provider.GetChildList(entity.CateNum);
                string[] items = null;
                if (!listCate.IsNullOrEmpty())
                {
                    items = listCate.Select(item => item.SnNum).ToArray();
                }
                else
                {
                    items = new string[] { "" };
                }
                Entity.And("CateNum", ECondition.In, items);
            }

            int rowCount = 0;
            List <V_LocalProductEntity> listResult = this.V_LocalProduct.GetList <V_LocalProductEntity>(Entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            return(listResult);
        }