ldj/WcfService1/BLL/lWmsPlate.cs

217 lines
5.8 KiB
C#
Raw Normal View History

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

/// <summary>
///LOGIC CLASS FOR TABLE t_WmsPlate
///By wm with codesmith.
///on 04/06/2020
/// </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.Utils;
namespace DeiNiu.wms.Logical
{
[Serializable]
public class lWmsPlate :lbase
{
WmsPlate _obj;
public lWmsPlate()
{
initialize();
}
public WmsPlate getWmsPlate
{
get
{
if (_obj == null)
{
_obj = new WmsPlate();
}
_obj.operater = operId;
return _obj;
}
}
public lWmsPlate(int operId)
: base(operId)
{
initialize();
}
/// <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 WmsPlate(id) : new WmsPlate();
}
/// <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 WmsPlate(dr);
}
protected override DeiNiu.Data.BaseObject.BaseModel getModel()
{
return _obj;
}
//begin cust db operation, query, excute sql etc.
internal int add(WmsPlate obj,int count)
{
for (int i = 0; i < count; i++)
{
obj.Add();
obj.plateId = Util.getBoxId(obj.type, obj.color, obj.ID);
obj.Update();
}
return 1;
}
/// <summary>
/// put goods into a plate
/// </summary>
public enumRegPlateResult inPlate(string plateId,enumPlateStatus type, string goodsId,string barcode,int skuId,decimal count,string orderNo)
{
if (valid( plateId, type, goodsId, skuId) == enumRegPlateResult.)
{
using (TransactionScope scope = new TransactionScope())
{
WmsPlate plate = new WmsPlate(plateId);
plate.type =(int)type;
WmsPlateStock_tmp pst = new WmsPlateStock_tmp(plateId,skuId);
if (pst.ID == 0)
{
pst.plateId = plateId;
pst.goodsId = goodsId;
pst.skuId = skuId;
pst.count = count;
pst.operater = operId;
pst.barcode = barcode;
pst.Add();
}
else
{
pst.count += count;
pst.operater = operId;
pst.Update();
}
switch (type)
{
// case enumPlateStatus.播种周转:
// plate.customerId = orderNo;
// break;
case enumPlateStatus.:
plate.locationId = orderNo;
break;
case enumPlateStatus.:
break;
case enumPlateStatus.:
plate.preInOrderNo = orderNo;
break;
case enumPlateStatus.:
plate.pickOrderNo = orderNo;
break;
case enumPlateStatus.:
plate.transNo = orderNo;
break;
}
plate.operater = operId;
plate.Update();
scope.Complete();
}
}
return enumRegPlateResult.;
}
private enumRegPlateResult valid(string plateId, enumPlateStatus type, string goodsId, int skuId)
{
if (enumPlateStatus. == type)
{
WmsPlateStock_tmp pst = new WmsPlateStock_tmp();
DataTable dt = pst.getPlateStockDetail(plateId);
if (dt.Rows.Count == 0)
{
return enumRegPlateResult.;
}
foreach (DataRow dr in dt.Rows)
{
if (dr["goodsId"].ToString() == goodsId)//存在goodsid
{
return enumRegPlateResult.;
}
}
WmsGoods wg = new WmsGoods(goodsId);
foreach (DataRow dr in dt.Rows)
{
if (Convert.ToInt16(dr["goodsType"].ToString()) == wg.goodsType)//存在goods type
{
return enumRegPlateResult.;
}
}
return enumRegPlateResult.使;
}
return enumRegPlateResult.;
}
}
}