/// <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); }
/// <summary> /// 查询库存清单数据 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <LocalProductEntity> GetList(LocalProductEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.Where(item => item.CompanyID == this.CompanyID).And(item => item.Num > 0); entity.OrderBy(item => item.ID, EOrderBy.DESC); if (entity.StorageNum.IsNotEmpty()) { entity.And(item => item.StorageNum == entity.StorageNum); } if (entity.LocalType > 0) { entity.And(item => item.LocalType == entity.LocalType); } if (entity.LocalNum.IsNotEmpty()) { entity.And(item => item.LocalNum == entity.LocalNum); } 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 + "%"); } int rowCount = 0; List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; if (!listResult.IsNullOrEmpty()) { ProductProvider productProvider = new ProductProvider(this.CompanyID); foreach (LocalProductEntity item in listResult) { ProductEntity product = productProvider.GetProduct(item.ProductNum); if (product != null) { item.Size = product.Size; item.CateNum = product.CateNum; item.CateName = product.CateName; item.AvgPrice = product.AvgPrice; item.MinNum = product.MinNum; item.MaxNum = product.MaxNum; item.UnitNum = product.UnitNum; item.UnitName = product.UnitName; } } } return(listResult); }
/// <summary> /// 获得产品的当前库存信息 /// </summary> /// <param name="localNum"></param> /// <param name="productNum"></param> /// <returns></returns> public LocalProductEntity GetSingle(string localNum, string productNum) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeAll(); entity.Where(a => a.LocalNum == localNum).And(a => a.ProductNum == productNum) .And(a => a.LocalType == (int)ELocalType.Normal); entity = this.LocalProduct.GetSingle(entity); return(entity); }
/// <summary> /// 移库管理获得库存信息 /// /// </summary> /// <param name="barCode"></param> /// <returns></returns> public List <LocalProductEntity> GetList(string barCode) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.BarCode == barCode).Or(a => a.ProductNum == barCode); List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity); return(listResult); }
/// <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); }
/// <summary> /// 获得满足条件的所有产品的库存 /// </summary> /// <param name="localName"></param> /// <param name="localType"></param> /// <param name="searchKey"></param> /// <param name="storageNum"></param> /// <returns></returns> public int GetAllNum(string localName, string localType, string searchKey, string storageNum) { LocalProductEntity entity = new LocalProductEntity(); 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); int allNum = 0; try { allNum = this.LocalProduct.Sum <int>(entity); } catch (Exception e) { allNum = 0; log.Info(e.Message); } return(allNum); }
/// <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); }
/// <summary> /// 获得产品的当前库存 /// </summary> /// <param name="storageNum"></param> /// <param name="productNum"></param> /// <returns></returns> public double GetLocalNum(string storageNum, string productNum) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeNum(true); entity.Where(a => a.StorageNum == storageNum).And(a => a.ProductNum == productNum) .And(a => a.LocalType == (int)ELocalType.Normal); try { double sum = this.LocalProduct.Sum <double>(entity); return(sum); } catch (Exception e) { log.Info(e.Message); } return(0); }
/// <summary> /// 获得库存信息 /// </summary> /// <param name="barCode"></param> /// <returns></returns> public List <LocalProductEntity> GetList(string barCode) { LocalProductEntity entity = new LocalProductEntity(); entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.BarCode == barCode).Or(a => a.ProductNum == barCode); LocationEntity location = new LocationEntity(); entity.Left <LocationEntity>(location, new Params <string, string>() { Item1 = "LocalNum", Item2 = "LocalNum" }); location.Where(a => a.LocalType == (int)ELocalType.Normal); List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity); return(listResult); }