ldj/WcfService1/BLL/lWmsGoods.cs

299 lines
8.3 KiB
C#
Raw Permalink Normal View History

2023-05-23 16:13:17 +08:00

/// <summary>
///LOGIC CLASS FOR TABLE t_wmsGoods
///By wm with codesmith.
///on 05/04/2017
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeiNiu.wms.Data.Model;
using System.Data;
using System.Transactions;
using DeiNiu.Data.BaseObject;
namespace DeiNiu.wms.Logical
{
[Serializable]
public class lWmsGoods :lbase
{
WmsGoods _obj;
public lWmsGoods()
{
initialize();
}
public lWmsGoods(int operId):base(operId)
{
initialize();
}
public WmsGoods getWmsGoods
{
get
{
if(_obj == null)
{
_obj = new WmsGoods();
}
2023-05-23 16:13:17 +08:00
return _obj;
}
}
/// <summary>
/// get all data
/// </summary>
public DataSet getAllData()
{
return _obj.Query();
}
/// <summary>
/// get all data
/// </summary>
public DataSet getAllActiveData()
{
return _obj.QueryActived();
}
/// <summary>
/// get a record by id
/// </summary>
public void initialize(int id)
{
_obj = id != 0 ? new WmsGoods(id) : new WmsGoods();
}
/// <summary>
/// get a record by id 0
/// </summary>
public void initialize()
{
initialize(0);
}
/// <summary>
/// get a record by id
/// </summary>
public void initialize(DataRow dr)
{
_obj = new WmsGoods(dr);
}
//begin cust db operation, query, excute sql etc.
/*
/// <summary>
/// query with like, return talbe and record cnt.
/// </summary>
public DataSet Query(string querystr, int rownumStart, int rownumEnd)
{
if (rownumEnd > rownumStart && rownumStart > 0)
{
_obj.rownumStart = rownumStart;
_obj.rownumEnd = rownumEnd;
}
//if (string.IsNullOrEmpty(querystr))
//{
// return _obj.Query();
//}
string condition = "";
string[] parameters = querystr.Split(";".ToCharArray());
foreach (string value in parameters)
{
if (string.IsNullOrEmpty(value))
{
continue;
}
string[] par = value.Split("#".ToCharArray());
condition += par.Length == 0 ? "" : " and ";
foreach (string p in par)
{
condition += p;
}
}
return _obj.Query(condition);
} */
/// <summary>
/// update in a transaction scrop
/// </summary>
public void update(List<WmsGoods> goods)
{
if (valid())
{
using (TransactionScope scope = new TransactionScope())
{
foreach (WmsGoods good in goods)
{
good.Update();
}
_obj = goods[goods.Count - 1];
scope.Complete();
}
}
}
private bool valid()
{
return true;
}
protected override BaseModel getModel()
{
return _obj;
}
internal DataTable QueryPacking(string goodsId)
{
return _obj.queryPacking(goodsId);
}
2023-11-21 19:18:23 +08:00
public void updatePackInfo(int id, string goodsId, string barcode, int packingQty, string manufacturer2, string spec, decimal chang, decimal kuan, decimal gao, decimal weight, int statckLayers, int stackLayNums, bool isDelete)
{
Erp_packing packing = new Erp_packing(id);
if (isDelete)
{
packing.Delete();
return;
}
2023-12-03 22:13:49 +08:00
DataTable dt = getWmsGoods.getGoodsDetailBybarcode(barcode);
if (dt.Rows.Count > 0)
{
string gdid= dt.Rows[0]["goodsId"].ToString().Trim();
if(!goodsId.Trim().ToUpper().Equals(gdid.Trim().ToUpper()))
throw new Exception("条码 " + barcode + " 已关联商品 " + dt.Rows[0]["goodsId"].ToString());
}
packing.barcode = barcode.Replace("\r\n", "").Replace("\n", "");
2023-11-21 19:18:23 +08:00
packing.goodsId = goodsId;
packing.weight = weight;
packing.chang = chang;
packing.kuan = kuan;
packing.gao = gao;
packing.weight = weight;
packing.spec = spec;
packing.manufacturer2 = manufacturer2;
packing.stackLayers = statckLayers;
packing.stackLayNums = stackLayNums;
packing.packingQty = packingQty;
ErpGoods eg = new ErpGoods(goodsId);
eg.bigCount = packingQty;
packing.packingUnit = eg.unit;
WmsGoods wg = new WmsGoods(goodsId);
wg.bigCount = packingQty;
log.Debug("update goods big count to " + packingQty);
using (TransactionScope scope = new TransactionScope())
{
if (id > 0)
{
packing.Update();
}
else
{
packing.Add();
}
eg.Update();
wg.Update();
scope.Complete();
}
}
2024-02-06 19:36:47 +08:00
internal void goodsMaintain(string goodsId,decimal fullMax, decimal bulkMax, decimal batch1Max, decimal batch2Max, decimal batch3Max, int ABC, int storeType, string barcode, int expiredDays, bool canSeedOut)
2023-11-21 19:18:23 +08:00
{
2023-12-03 22:13:49 +08:00
barcode= barcode.Replace("\r\n", "").Replace("\n", "");
2023-11-21 19:18:23 +08:00
WmsGoods goods = new WmsGoods(goodsId);
if (bulkMax > 0)
goods.bulkMax = bulkMax;
if (batch1Max > 0)
goods.batchMax1 = batch1Max;
if (batch2Max > 0)
goods.batchMax2 = batch2Max;
if (batch3Max > 0)
goods.batchMax3 = batch3Max;
2023-12-03 22:13:49 +08:00
if (fullMax > 0)
goods.full_max = fullMax;
2023-11-21 19:18:23 +08:00
if (ABC > 0)
goods.ABC = ABC;
if (storeType > 0)
goods.part = storeType;
// if (bigCount > 0)
// goods.bigCount = bigCount;
ErpGoods erpgd = new ErpGoods(goodsId);
using (TransactionScope scope = new TransactionScope())
{
2023-12-03 22:13:49 +08:00
if (erpgd.expiryDays != expiredDays)
2023-11-21 19:18:23 +08:00
{
erpgd.barCode = barcode;
erpgd.expiryDays = expiredDays;
erpgd.Update();
}
2023-12-03 22:13:49 +08:00
if (erpgd.barCode != barcode)
{
if (!string.IsNullOrEmpty(barcode))
{
DataTable dt = getWmsGoods.getGoodsDetailBybarcode(barcode);
if (dt.Rows.Count > 0)
{
string gdid = dt.Rows[0]["goodsId"].ToString().Trim();
if (!goodsId.Trim().ToUpper().Equals(gdid.Trim().ToUpper()))
throw new Exception("条码 " + barcode + " 已关联商品 " + dt.Rows[0]["goodsId"].ToString());
}
Erp_packing packing = new Erp_packing(barcode);
if (packing.ID == 0)
{
packing.barcode = barcode;
packing.goodsId = goodsId;
packing.packingQty = goods.bigCount;
packing.Add();
}
}
}
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
goods.canSeedOut = canSeedOut;
2023-12-03 22:13:49 +08:00
goods.barcode = barcode;
goods.expiryDays = expiredDays;
2023-11-21 19:18:23 +08:00
goods.Update();
scope.Complete();
}
}
internal DataTable queryByKeyWords(string keywords)
{
return getWmsGoods.queryByKeyWords(keywords);
}
2023-05-23 16:13:17 +08:00
}
}