旧版报表、仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

84 lines
3.2 KiB

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
{
/// <summary>
/// 出货
/// </summary>
/// <param name="Container"></param>
/// <param name="Shipmentinfo"></param>
/// <param name="StockInfo"></param>
/// <returns></returns>
public bool ShipmentContainer(string Container, tcontainer Shipmentinfo, List<dynamic> 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<tstockoutlog> StockOutLog = new List<tstockoutlog>();
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;
}
}
}
}