Switch warehouse matching to use IDs
This commit is contained in:
@@ -29,16 +29,21 @@ namespace BLL
|
||||
var q = from x in db.Tw_MaterialStock
|
||||
join mat in db.HJGL_MaterialCodeLib on x.PipeLineMatCode equals mat.MaterialCode into mm
|
||||
from mat in mm.DefaultIfEmpty()
|
||||
join warehouse in db.Base_Warehouse on x.WarehouseId equals warehouse.WarehouseId into warehouses
|
||||
from warehouse in warehouses.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode)) &&
|
||||
(string.IsNullOrEmpty(table.WarehouseId) || x.WarehouseId == table.WarehouseId) &&
|
||||
(string.IsNullOrEmpty(table.WarehouseCode) || x.WarehouseCode.Contains(table.WarehouseCode) || x.WarehouseId.Contains(table.WarehouseCode)) &&
|
||||
(string.IsNullOrEmpty(table.PipeLineMatCode) || x.PipeLineMatCode.Contains(table.PipeLineMatCode)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialUnit) || mat.MaterialUnit.Contains(table.MaterialUnit)) &&
|
||||
(string.IsNullOrEmpty(table.ProjectId) || x.ProjectId.Contains(table.ProjectId))
|
||||
select new Model.Tw_MaterialStockOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
WarehouseCode = x.WarehouseCode,
|
||||
WarehouseId = x.WarehouseId,
|
||||
WarehouseCode = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName,
|
||||
WarehouseName = warehouse == null ? x.WarehouseCode : warehouse.WarehouseName,
|
||||
PipeLineMatCode = x.PipeLineMatCode,
|
||||
StockNum = x.StockNum,
|
||||
ProjectId = x.ProjectId,
|
||||
@@ -88,7 +93,8 @@ namespace BLL
|
||||
Model.Tw_MaterialStock table = new Model.Tw_MaterialStock
|
||||
{
|
||||
Id = newtable.Id,
|
||||
WarehouseCode = newtable.WarehouseCode,
|
||||
WarehouseId = newtable.WarehouseId,
|
||||
WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode,
|
||||
PipeLineMatCode = newtable.PipeLineMatCode,
|
||||
StockNum = newtable.StockNum,
|
||||
ProjectId = newtable.ProjectId,
|
||||
@@ -104,7 +110,8 @@ namespace BLL
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.WarehouseCode = newtable.WarehouseCode;
|
||||
table.WarehouseId = newtable.WarehouseId;
|
||||
table.WarehouseCode = Base_WarehouseService.GetWarehouseNameById(newtable.WarehouseId) ?? newtable.WarehouseCode;
|
||||
table.PipeLineMatCode = newtable.PipeLineMatCode;
|
||||
table.StockNum = newtable.StockNum;
|
||||
table.ProjectId = newtable.ProjectId;
|
||||
@@ -125,16 +132,16 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目编码,材料编码,仓库编码,数量增减库存
|
||||
/// 根据项目编码,材料编码,仓库主键,数量增减库存
|
||||
/// </summary>
|
||||
/// <param name="ProjectId"></param>
|
||||
/// <param name="MaterialCode"></param>
|
||||
/// <param name="WarehouseCode"></param>
|
||||
/// <param name="warehouseId"></param>
|
||||
/// <param name="inOutType"></param>
|
||||
/// <param name="StockNum"></param>
|
||||
public static void UpdateStockNum(string ProjectId, string MaterialCode, string WarehouseCode, TwConst.InOutType inOutType, decimal? StockNum)
|
||||
public static void UpdateStockNum(string ProjectId, string MaterialCode, string warehouseId, TwConst.InOutType inOutType, decimal? StockNum)
|
||||
{
|
||||
Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.ProjectId == ProjectId && x.PipeLineMatCode == MaterialCode && x.WarehouseCode == WarehouseCode);
|
||||
Model.Tw_MaterialStock table = Funs.DB.Tw_MaterialStock.FirstOrDefault(x => x.ProjectId == ProjectId && x.PipeLineMatCode == MaterialCode && x.WarehouseId == warehouseId);
|
||||
//如果是入库,则库存数量加上,如果是出库,则库存数量减去
|
||||
if (inOutType == TwConst.InOutType.出库)
|
||||
{
|
||||
@@ -153,7 +160,8 @@ namespace BLL
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ProjectId = ProjectId,
|
||||
PipeLineMatCode = MaterialCode,
|
||||
WarehouseCode = WarehouseCode,
|
||||
WarehouseId = warehouseId,
|
||||
WarehouseCode = Base_WarehouseService.GetWarehouseNameById(warehouseId),
|
||||
StockNum = StockNum ?? 0,
|
||||
};
|
||||
Funs.DB.Tw_MaterialStock.InsertOnSubmit(newtable);
|
||||
|
||||
Reference in New Issue
Block a user