/// <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); }
/// <summary> /// 根据唯一编号删除盘点差异单 /// </summary> /// <param name="SnNum"></param> /// <returns></returns> public int DeleteDif(string SnNum) { InventoryDifEntity entity = new InventoryDifEntity(); entity.Where(item => item.SnNum == SnNum).And(item => item.CompanyID == this.CompanyID); int line = this.InventoryDif.Delete(entity); return(line); }
/// <summary> /// 新增盘差数据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int AddDif(InventoryDifEntity entity) { int line = 0; //检查是否库位存在该产品 InventoryDifEntity check = new InventoryDifEntity(); check.Where(a => a.ProductNum == entity.ProductNum) .And(a => a.LocalNum == entity.LocalNum) .And(a => a.BatchNum == entity.BatchNum) .And(a => a.CompanyID == this.CompanyID) ; check.IncludeAll(); check = this.InventoryDif.GetSingle(check); if (check.IsNotNull()) { check.FirstQty = entity.FirstQty; check.IncludeFirstQty(true); check.Where(a => a.SnNum == check.SnNum); line = this.InventoryDif.Update(check); } else { LocationProvider provider = new LocationProvider(this.CompanyID); LocationEntity Location = provider.GetSingleByNum(entity.LocalNum); if (Location != null) { entity.LocalName = Location.LocalName; } entity.DifQty = entity.FirstQty - entity.LocalQty; entity.SnNum = ConvertHelper.NewGuid(); entity.CreateTime = DateTime.Now; entity.CompanyID = this.CompanyID; entity.IncludeAll(); line = this.InventoryDif.Add(entity); } return(line); }
/// <summary> /// 保存盘点差异单 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int SaveDif(InventoryDifEntity entity) { entity.DifQty = entity.FirstQty - entity.LocalQty; LocationProvider provider = new LocationProvider(this.CompanyID); LocationEntity Location = provider.GetSingleByNum(entity.LocalNum); if (Location != null) { entity.LocalName = Location.LocalName; } entity.Include(a => new { a.BatchNum, a.LocalNum, a.LocalName, a.FirstQty, a.DifQty }); entity.Where(a => a.SnNum == entity.SnNum) .And(a => a.CompanyID == this.CompanyID) ; int line = this.InventoryDif.Update(entity); return(line); }