using System; using System.Collections.Generic; using System.Linq; using System.Web; //using Warehouse.Models; using Warehouse.Models.whMS; using Z.EntityFramework.Plus; namespace Warehouse.DAL.Shipment { public class ShipmentMSDal { /// /// 出货 /// /// /// /// /// public bool ShipmentContainer(string Container, tcontainer Shipmentinfo, List StockInfo) { using (var context = new whMSModel()) { var container = context.tcontainers.Where(a => a.containerno == Container); if (container == null) { return false; } tcontainer t1 = container.FirstOrDefault(); t1.customno = Shipmentinfo.customno; t1.driver = Shipmentinfo.driver; t1.driverphone = Shipmentinfo.driverphone; t1.drivertype = Shipmentinfo.drivertype; t1.materialcompany = Shipmentinfo.materialcompany; t1.plateno = Shipmentinfo.plateno; t1.shipmentuser = Shipmentinfo.shipmentuser; t1.driveno = Shipmentinfo.driveno; t1.shipmenttime = System.DateTime.Now; //发货箱号和提单号 add by xue lei on 2019-9-10 t1.billlading = Shipmentinfo.billlading; t1.shipmentcarton = Shipmentinfo.shipmentcarton; string stockids = ""; string SqlShipmentPalletBindStockinId = ""; string UserId = System.Web.HttpContext.Current.Request.Cookies["userid"].Value.ToString(); List StockOutLog = new List(); foreach (var item in StockInfo) { //SqlShipmentPalletBindStockinId += "update wh.dbo.tcontainerpallet set stockloginid =" + item.stockid + ",shipmenttime = getdate(),shipmentuser='"+ UserId +"' where palletno = '"+item.palletno+"';"; stockids += item.stockid + ","; StockOutLog.Add(new tstockoutlog { palletno = item.palletno, createtime = System.DateTime.Now, createuser = System.Web.HttpContext.Current.Request.Cookies["userid"].Value, stockinlogid = item.stockid, stockouttype = 1,//出货出库 storagelocationid = item.storagelocationid }); } context.Configuration.AutoDetectChangesEnabled = false; context.tstockoutlogs.AddRange(StockOutLog); stockids = stockids.Remove(stockids.Length - 1, 1); string sql = "update wh.dbo.tstockinlog set status =3 where id in(" + stockids + ");"; string AllSql = SqlShipmentPalletBindStockinId + sql; context.Database.ExecuteSqlCommand(AllSql); context.SaveChanges(); // add by xue lei on 2019-12-11 清除库位条件 int? LocationId = StockOutLog.FirstOrDefault().storagelocationid; if (context.tstockinlogs.Where(a => a.storagelocationid == LocationId && (a.status == 2 || a.status==4) ).Count() == 0) { context.tlocationconditions.Where(a => a.storagelocationid == LocationId).Update(x => new tlocationcondition() { status = "N" }); } return true; } } } }