public DbResult <bool> Auditin(long userId, long stockOutId) { var flag = _client.Ado.UseTran(() => { //添加库存 如果有则修改 如果没有新增 添加库存明细 var stockOutDetailList = _client.Queryable <Wms_stockoutdetail>().Where(c => c.StockOutId == stockOutId).ToList(); var inventory = new Wms_inventory(); stockOutDetailList.ForEach(c => { var exist = _client.Queryable <Wms_inventory>().Where(i => i.MaterialId == c.MaterialId && i.StoragerackId == c.StoragerackId).First(); CheckNull.ArgumentIsNullException(exist, PubConst.StockOut1); if (exist.Qty < c.ActOutQty) { CheckNull.ArgumentIsNullException(PubConst.StockOut2); } //update exist.Qty = exist.Qty - c.ActOutQty; exist.ModifiedBy = userId; exist.ModifiedDate = DateTimeExt.DateTime; _client.Updateable(exist); }); //修改明细状态 2 _client.Updateable(new Wms_stockoutdetail { Status = StockInStatus.egis.ToByte(), AuditinId = userId, AuditinTime = DateTimeExt.DateTime, ModifiedBy = userId, ModifiedDate = DateTimeExt.DateTime }).UpdateColumns(c => new { c.Status, c.AuditinId, c.AuditinTime, c.ModifiedBy, c.ModifiedDate }).Where(c => c.StockOutId == stockOutId && c.IsDel == 1).ExecuteCommand(); //修改主表中的状态改为进行中 2 _client.Updateable(new Wms_stockout { StockOutId = stockOutId, StockOutStatus = StockInStatus.egis.ToByte(), ModifiedBy = userId, ModifiedDate = DateTimeExt.DateTime }).UpdateColumns(c => new { c.StockOutStatus, c.ModifiedBy, c.ModifiedDate }).ExecuteCommand(); }); return(flag); }
public bool Auditin(long UserId, long stockInId) { var flag = _client.Ado.UseTran(() => { //添加库存 如果有则修改 如果没有新增 添加库存明细 var stockInDetailList = _client.Queryable <Wms_stockindetail>().Where(c => c.StockInId == stockInId).ToList(); var inventoryListAdd = new List <Wms_inventory>(); var inventoryListUpdate = new List <Wms_inventory>(); var inventoryDetail = new List <Wms_inventoryrecord>(); var inventory = new Wms_inventory(); stockInDetailList.ForEach(c => { var exist = _client.Queryable <Wms_inventory>().Where(i => i.MaterialId == c.MaterialId && i.StoragerackId == c.StoragerackId).First(); if (exist.IsNullT()) { //add inventory.InventoryId = PubId.SnowflakeId; inventory.StoragerackId = c.StoragerackId; inventory.CreateBy = UserId; inventory.Qty = c.ActInQty; inventory.MaterialId = c.MaterialId; //inventoryListAdd.Add(exist); _client.Insertable(inventory).ExecuteCommand(); } else { //update exist.Qty = exist.Qty + c.ActInQty; exist.ModifiedBy = UserId; exist.ModifiedDate = DateTimeExt.DateTime; //inventoryListUpdate.Add(exist); _client.Updateable(exist).ExecuteCommand(); } inventoryDetail.Add(new Wms_inventoryrecord { InventoryrecordId = PubId.SnowflakeId, CreateBy = UserId, Qty = c.ActInQty, StockInDetailId = c.StockInDetailId, }); }); //_inventory.Insert(inventoryListAdd); //_inventory.Update(inventoryListUpdate); _client.Insertable(inventoryDetail).ExecuteCommand(); //修改明细状态 2 _client.Updateable(new Wms_stockindetail { Status = StockInStatus.egis.ToByte(), AuditinId = UserId, AuditinTime = DateTimeExt.DateTime, ModifiedBy = UserId, ModifiedDate = DateTimeExt.DateTime }).UpdateColumns(c => new { c.Status, c.AuditinId, c.AuditinTime, c.ModifiedBy, c.ModifiedDate }) .Where(c => c.StockInId == stockInId && c.IsDel == 1).ExecuteCommand(); //修改主表中的状态改为进行中 2 _client.Updateable(new Wms_stockin { StockInId = stockInId, StockInStatus = StockInStatus.egis.ToByte(), ModifiedBy = UserId, ModifiedDate = DateTimeExt.DateTime }).UpdateColumns(c => new { c.StockInStatus, c.ModifiedBy, c.ModifiedDate }).ExecuteCommand(); }).IsSuccess; return(flag); }