Exemplo n.º 1
0
        /// <summary>
        /// 获得单据详细信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override List <OutStoDetailEntity> GetOrderDetail(OutStoDetailEntity entity)
        {
            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.IncludeAll();
            detail.Where(a => a.OrderSnNum == entity.OrderSnNum)
            .And(a => a.CompanyID == this.CompanyID)
            ;
            ProductEntity product = new ProductEntity();

            product.Include(a => new { a.Size });
            detail.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });

            List <OutStoDetailEntity> list = this.OutStoDetail.GetList(detail);

            if (!list.IsNullOrEmpty())
            {
                List <LocationEntity> listLocation = new LocationProvider(this.CompanyID).GetList();
                listLocation = listLocation == null ? new List <LocationEntity>() : listLocation;
                foreach (OutStoDetailEntity item in list)
                {
                    LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.LocalNum);
                    item.LocalName   = location == null ? "" : location.LocalName;
                    item.StorageName = location == null ? "" : location.StorageName;
                }
            }
            return(list);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询库存预警列表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <V_StorageProductEntity> GetList(V_StorageProductEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.OrderBy(item => item.ID, EOrderBy.DESC);
            entity.And(item => item.CompanyID == this.CompanyID);

            if (entity.StorageNum.IsNotEmpty())
            {
                entity.And(item => item.StorageNum == entity.StorageNum);
            }

            if (entity.BarCode.IsNotEmpty())
            {
                entity.And("BarCode", ECondition.Like, "%" + entity.BarCode + "%");
            }
            if (entity.ProductName.IsNotEmpty())
            {
                entity.And("ProductName", ECondition.Like, "%" + entity.ProductName + "%");
            }

            ProductEntity Product = new ProductEntity();

            Product.Include(item => new { MinNum = item.MinNum, MaxNum = item.MaxNum });
            entity.Left <ProductEntity>(Product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });

            int rowCount = 0;
            List <V_StorageProductEntity> listResult = this.V_StorageProduct.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            return(listResult);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 在线库存报表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <LocalProductEntity> GetList(LocalProductEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            ProductEntity ProEntity = new ProductEntity();

            // ProEntity.Include(a => new { Size = a.Size, AvgPrice = a.AvgPrice, CateNum = a.CateNum, CateName = a.CateName, MinNum = a.MinNum, MaxNum = a.MaxNum });

            ProEntity.Include(a => new { AvgPrice = a.AvgPrice, CateNum = a.CateNum, CateName = a.CateName, MinNum = a.MinNum, MaxNum = a.MaxNum });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            int rowCount = 0;
            List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            List <ProductCategoryEntity> listCates = new ProductCategoryProvider().GetList();

            listCates = listCates.IsNull() ? new List <ProductCategoryEntity>() : listCates;
            if (!listResult.IsNullOrEmpty())
            {
                foreach (LocalProductEntity item in listResult)
                {
                    if (item.CateName.IsEmpty())
                    {
                        ProductCategoryEntity cate = listCates.FirstOrDefault(a => a.CateNum == item.CateNum);
                        item.CateName = cate == null ? "" : cate.CateName;
                    }
                }
            }
            return(listResult);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 查询盘点差异单
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public List <InventoryDifEntity> GetList(InventoryDifEntity entity)
        {
            entity.IncludeAll();
            entity.Where(item => item.CompanyID == entity.CompanyID);
            if (entity.OrderSnNum.IsNotEmpty())
            {
                entity.And(item => item.OrderSnNum == entity.OrderSnNum);
            }
            if (entity.OrderNum.IsNotEmpty())
            {
                entity.And("OrderNum", ECondition.Like, "%" + entity.OrderNum + "%");
            }
            if (entity.LocalNum.IsNotEmpty())
            {
                entity.And(item => item.LocalNum == entity.LocalNum);
            }
            if (entity.LocalName.IsNotEmpty())
            {
                entity.And("LocalName", ECondition.Like, "%" + entity.LocalName + "%");
            }
            if (entity.StorageNum.IsNotEmpty())
            {
                entity.And(item => item.StorageNum == entity.StorageNum);
            }
            if (entity.ProductNum.IsNotEmpty())
            {
                entity.And(item => item.ProductNum == entity.ProductNum);
            }
            if (entity.BarCode.IsNotEmpty())
            {
                entity.And("BarCode", ECondition.Like, "%" + entity.BarCode + "%");
            }
            if (entity.ProductName.IsNotEmpty())
            {
                entity.And("ProductName", ECondition.Like, "%" + entity.ProductName + "%");
            }
            if (entity.BatchNum.IsNotEmpty())
            {
                entity.And("BatchNum", ECondition.Like, "%" + entity.BatchNum + "%");
            }
            ProductEntity product = new ProductEntity();

            product.Include(a => new { Size = a.Size, CateName = a.CateName, UnitName = a.UnitName });
            entity.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });

            StorageEntity Storage = new StorageEntity();

            Storage.Include(a => new { StorageName = a.StorageName });
            entity.Left <StorageEntity>(Storage, new Params <string, string>()
            {
                Item1 = "StorageNum", Item2 = "SnNum"
            });

            List <InventoryDifEntity> listResult = this.InventoryDif.GetList(entity);

            return(listResult);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ProductEntity entity)
        {
            entity.InPrice  = entity.AvgPrice;
            entity.OutPrice = entity.AvgPrice;
            entity.Include(a => new { a.ProductName, a.BarCode, 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.Description, a.Count, a.Color });
            entity.Where(a => a.SnNum == entity.SnNum);
            int line = this.Product.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE);
            }
            return(line);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获得满足条件的所有产品的总价格
        /// </summary>
        /// <param name="localName"></param>
        /// <param name="localType"></param>
        /// <param name="searchKey"></param>
        /// <param name="storageNum"></param>
        /// <returns></returns>
        public double GetAllTotalPrice(string localName, string localType, string searchKey, string storageNum)
        {
            LocalProductEntity entity        = new LocalProductEntity();
            double             allTotalPrice = 0;

            if (!storageNum.IsEmpty())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (!localName.IsEmpty())
            {
                entity.Where("LocalName", ECondition.Like, "%" + localName + "%");
                entity.Or("LocalNum", ECondition.Like, "%" + localName + "%");
            }

            if (!searchKey.IsEmpty())
            {
                entity.Begin <LocalProductEntity>()
                .Where <LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                .Or <LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%")
                .Or <LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                .End <LocalProductEntity>();
            }
            entity.IncludeNum(true);

            ProductEntity ProEntity = new ProductEntity();

            ProEntity.Include(a => new { AvgPrice = a.AvgPrice });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.OrderBy(a => a.ID, EOrderBy.DESC);

            List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity);

            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice   = a.Num * a.AvgPrice;
                    allTotalPrice += a.TotalPrice;
                });
            }
            return(allTotalPrice);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 根据订单详细唯一编码号获取该订单详细信息以及产品信息
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        public OrderDetailEntity GetOrderDetailBySnNum(string snNum)
        {
            OrderDetailEntity entity = new OrderDetailEntity();

            entity.IncludeAll();
            ProductEntity ProEntity = new ProductEntity();

            ProEntity.Include(a => new { Size = a.Size });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.Where("SnNum", ECondition.Eth, snNum);
            entity = this.OrderDetail.GetSingle(entity);
            return(entity);
        }
Exemplo n.º 9
0
        /// <summary>
        ///     获得单据详细信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override List <OrderDetailEntity> GetOrderDetail(OrderDetailEntity entity)
        {
            var detail = new OrderDetailEntity();

            detail.IncludeAll();
            detail.Where(a => a.OrderNum == entity.OrderNum);
            var product = new ProductEntity();

            product.Include(a => new { a.Size, a.UnitName });
            detail.Left(product, new Params <string, string> {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            var list = OrderDetail.GetList(detail);

            return(list);
        }
Exemplo n.º 10
0
Arquivo: OrderBill.cs Projeto: op706/-
        /// <summary>
        /// 获得单据详细信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override List <OrderDetailEntity> GetOrderDetail(OrderDetailEntity entity)
        {
            OrderDetailEntity detail = new OrderDetailEntity();

            detail.IncludeAll();
            detail.Where(a => a.OrderNum == entity.OrderNum);
            ProductEntity product = new ProductEntity();

            product.Include(a => new { Size = a.Size, UnitName = a.UnitName });
            detail.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            List <OrderDetailEntity> list = this.OrderDetail.GetList(detail);

            return(list);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="barCode"></param>
        /// <param name="productName"></param>
        /// <param name="unit"></param>
        /// <param name="snNum"></param>
        /// <returns></returns>
        public int Update(string barCode, string productName, string unit, string snNum)
        {
            ProductEntity entity = new ProductEntity();

            entity.BarCode     = barCode;
            entity.ProductName = productName;
            entity.UnitNum     = unit;
            entity.Include(a => new { a.ProductName, a.BarCode, a.UnitNum });
            entity.Where(a => a.SnNum == snNum);
            int line = this.Product.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCT_CACHE);
            }
            return(line);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 根据产品条码或者产品编号或者产品名称搜索库存产品数量以及库存位置
        /// 主要用于选择产品的界面中搜索功能。在搜索到相应产品之后查询库存信息
        /// </summary>
        /// <returns></returns>
        public List <LocalProductEntity> GetList(string barCode)
        {
            LocalProductEntity entity = new LocalProductEntity();

            entity.IncludeAll();
            ProductEntity ProEntity = new ProductEntity();

            ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.Where(a => a.BarCode == barCode);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity);

            return(listResult);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 编辑产品信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int EditProduct(ProductEntity entity)
        {
            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.UnitNum, a.UnitName, a.CateNum, a.CateName, 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);

            return(line);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 根据库存唯一编码号获取该位置的库存信息以及产品信息
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        public LocalProductEntity GetLocalProductBySn(string sn, string productNum = null)
        {
            LocalProductEntity entity = new LocalProductEntity();

            entity.IncludeAll();
            ProductEntity ProEntity = new ProductEntity();

            ProEntity.Include(a => new { Size = a.Size, InPrice = a.InPrice });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.Where(a => a.Sn == sn);
            if (!productNum.IsEmpty())
            {
                entity.Where(a => a.ProductNum == productNum);
            }
            entity = this.LocalProduct.GetSingle(entity);
            return(entity);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 查询单据详细信息
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public override InStorDetailEntity GetDetail(string SnNum)
        {
            InStorDetailEntity entity = new InStorDetailEntity();

            entity.IncludeAll();
            entity.Where(item => item.SnNum == SnNum)
            .And(item => item.CompanyID == this.CompanyID)
            ;

            ProductEntity product = new ProductEntity();

            product.Include(item => new { Size = item.Size });
            entity.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });

            entity = this.InStorDetail.GetSingle(entity);
            return(entity);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 获得单据详细信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override List <InventoryDetailEntity> GetOrderDetail(InventoryDetailEntity entity)
        {
            InventoryDetailEntity detail = new InventoryDetailEntity();

            detail.IncludeAll();
            detail.Where(a => a.OrderSnNum == entity.OrderSnNum)
            .And(a => a.CompanyID == this.CompanyID)
            ;

            ProductEntity product = new ProductEntity();

            product.Include(a => new { a.ProductName, a.BarCode, a.UnitName, a.CateName, a.Size });

            detail.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "TargetNum", Item2 = "SnNum"
            });

            List <InventoryDetailEntity> list = this.InventoryDetail.GetList(detail);

            return(list);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 查询单据详细数据分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public override List <InStorDetailEntity> GetDetailList(InStorDetailEntity entity, ref PageInfo pageInfo)
        {
            InStorDetailEntity detail = new InStorDetailEntity();

            detail.IncludeAll();
            detail.OrderBy(a => a.ID, EOrderBy.DESC);
            detail.Where(a => a.CompanyID == this.CompanyID);

            if (!entity.BarCode.IsEmpty())
            {
                detail.And("BarCode", ECondition.Like, "%" + entity.BarCode + "%");
            }
            if (!entity.ProductName.IsEmpty())
            {
                detail.And("ProductName", ECondition.Like, "%" + entity.ProductName + "%");
            }
            if (!entity.StorageNum.IsEmpty())
            {
                detail.And(a => a.StorageNum == entity.StorageNum);
            }

            ProductEntity product = new ProductEntity();

            product.Include(item => new { Size = item.Size });
            detail.Left <ProductEntity>(product, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });

            InStorageEntity InOrder = new InStorageEntity();

            InOrder.Include(a => new { OrderNum = a.OrderNum, SupNum = a.SupNum, SupName = a.SupName, OrderTime = a.OrderTime, Status = a.Status, InType = a.InType, AuditeTime = a.AuditeTime });
            detail.Left <InStorageEntity>(InOrder, new Params <string, string>()
            {
                Item1 = "OrderSnNum", Item2 = "SnNum"
            });
            InOrder.And(a => a.IsDelete == (int)EIsDelete.NotDelete);
            if (!entity.SupNum.IsEmpty())
            {
                InOrder.AndBegin <InStorageEntity>()
                .And <InStorageEntity>("SupNum", ECondition.Like, "%" + entity.SupNum + "%")
                .Or <InStorageEntity>("SupName", ECondition.Like, "%" + entity.SupNum + "%")
                .End <InStorageEntity>()
                ;
            }
            if (!entity.SupName.IsEmpty())
            {
                InOrder.AndBegin <InStorageEntity>()
                .And <InStorageEntity>("SupNum", ECondition.Like, "%" + entity.SupName + "%")
                .Or <InStorageEntity>("SupName", ECondition.Like, "%" + entity.SupName + "%")
                .End <InStorageEntity>()
                ;
            }
            if (!entity.BeginTime.IsEmpty())
            {
                DateTime time = ConvertHelper.ToType <DateTime>(entity.BeginTime, DateTime.Now.Date.AddDays(-1));
                InOrder.And(a => a.CreateTime >= time);
            }
            if (!entity.EndTime.IsEmpty())
            {
                DateTime time = ConvertHelper.ToType <DateTime>(entity.EndTime, DateTime.Now.Date.AddDays(1));
                InOrder.And(a => a.CreateTime < time);
            }
            if (entity.Status > 0)
            {
                InOrder.And(item => item.Status == entity.Status);
            }
            if (entity.CreateUser.IsNotEmpty())
            {
                InOrder.And(item => item.CreateUser == entity.CreateUser);
            }
            if (entity.InType > 0)
            {
                InOrder.And(item => item.InType == entity.InType);
            }
            if (entity.OrderNum.IsNotEmpty())
            {
                InOrder.And("OrderNum", ECondition.Like, "%" + entity.OrderNum + "%");
            }
            if (entity.ContractOrder.IsNotEmpty())
            {
                InOrder.And("ContractOrder", ECondition.Like, "%" + entity.ContractOrder + "%");
            }
            AdminEntity admin = new AdminEntity();

            admin.Include(a => new { CreateUserName = a.UserName });
            InOrder.Left <AdminEntity>(admin, new Params <string, string>()
            {
                Item1 = "CreateUser", Item2 = "UserNum"
            });

            AdminEntity auditeUser = new AdminEntity();

            auditeUser.Include(a => new { AuditeUserName = a.UserName });
            InOrder.Left <AdminEntity>(auditeUser, new Params <string, string>()
            {
                Item1 = "AuditUser", Item2 = "UserNum"
            });

            int rowCount = 0;
            List <InStorDetailEntity> listResult = this.InStorDetail.GetList(detail, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;
            if (!listResult.IsNullOrEmpty())
            {
                List <LocationEntity> listLocation = new LocationProvider(this.CompanyID).GetList();
                listLocation = listLocation == null ? new List <LocationEntity>() : listLocation;
                foreach (InStorDetailEntity item in listResult)
                {
                    LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.LocalNum);
                    item.LocalName   = location == null ? "" : location.LocalName;
                    item.StorageName = location == null ? "" : location.StorageName;
                }
            }
            return(listResult);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 编辑带有SKU的产品
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="listSku"></param>
        /// <returns></returns>
        public int Edit(ProductEntity entity, List <ProductSkuEntity> listSku)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                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.UnitNum, a.UnitName, a.CateNum, a.CateName, 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 (!listSku.IsNullOrEmpty())
                {
                    ProductSkuEntity SkuEntity = new ProductSkuEntity();
                    SkuEntity.IncludeAll();
                    SkuEntity.Where(a => a.ProductNum == entity.SnNum)
                    .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
                    .And(a => a.CompanyID == this.CompanyID)
                    ;
                    List <ProductSkuEntity> listSource = this.ProductSku.GetList(SkuEntity);
                    listSource = listSource.IsNull() ? new List <ProductSkuEntity>() : listSource;

                    listSku = listSku.IsNull() ? new List <ProductSkuEntity>() : listSku;

                    foreach (ProductSkuEntity item in listSku)
                    {
                        item.SnNum = item.SnNum.IsEmpty() ? ConvertHelper.NewGuid() : item.SnNum;
                        if (listSource.Exists(a => a.SnNum == item.SnNum))
                        {
                            item.Include(b => new { b.Size, b.Color, b.NetWeight, b.GrossWeight, b.InPrice, b.AvgPrice, b.OutPrice });
                            item.Where(b => b.SnNum == item.SnNum).And(b => b.CompanyID == this.CompanyID);
                            line += this.ProductSku.Update(item);
                        }
                        else
                        {
                            item.IsDelete   = (int)EIsDelete.NotDelete;
                            item.CreateTime = DateTime.Now;
                            item.CompanyID  = this.CompanyID;
                            item.IncludeAll();
                            line += this.ProductSku.Add(item);
                        }
                    }

                    foreach (ProductSkuEntity item in listSource)
                    {
                        if (!listSku.Exists(a => a.SnNum == item.SnNum))
                        {
                            item.IsDelete = (int)EIsDelete.Deleted;
                            item.IncludeIsDelete(true);
                            item.Where(b => b.SnNum == item.SnNum).And(b => b.CompanyID == this.CompanyID);
                            line += this.ProductSku.Update(item);
                        }
                    }
                }
                ts.Complete();
                return(line);
            }
        }