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.
666 lines
25 KiB
666 lines
25 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using System.Data;
|
|
using System.Data.Sql;
|
|
using System.Data.Linq;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSPalletDAL
|
|
{
|
|
|
|
public static List<FormICSPalletModel> SearchItemInfoList(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
List<FormICSPalletModel> returntype = new List<FormICSPalletModel>();
|
|
string sql = @"select [ID],[PalletCode],[MuserCode],[Mtime],[WorkPoint]
|
|
from [ICSPallet]
|
|
where 1=1";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSPalletModel itemmodel = new FormICSPalletModel();
|
|
itemmodel.ID = dr["ID"].ToString();
|
|
itemmodel.PalletCode = dr["PalletCode"].ToString();
|
|
itemmodel.MUSER = dr["MUSER"].ToString();
|
|
itemmodel.MTIME = DateTime.Now;
|
|
itemmodel.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
if (!returntype.Contains(itemmodel))
|
|
returntype.Add(itemmodel);
|
|
}
|
|
return returntype;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#region 关联批次
|
|
public static void AddandEdit(DataTable dt,string PalletCode, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
int seq = 0;
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
seq++;
|
|
ICSPalletLotNO lines = new ICSPalletLotNO();
|
|
lines.PalletCode = PalletCode;
|
|
lines.LotNO = dt.Rows[i]["产品批次"].ToString();
|
|
lines.Free1 = dt.Rows[i]["存货编码"].ToString();
|
|
lines.MuserCode = AppConfig.UserCode;
|
|
lines.MuserName = AppConfig.UserName;
|
|
lines.WorkPoint = AppConfig.WorkPointCode;
|
|
lines.Mtime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.ICSPalletLotNO.InsertOnSubmit(lines);
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSPalletModel> ITEM2ROUTEInfoList, string dsconn)
|
|
{
|
|
string str = "";
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
foreach (FormICSPalletModel info in ITEM2ROUTEInfoList)
|
|
{
|
|
|
|
var line = db.ICSPallet.SingleOrDefault(a => a.PalletCode == info.PalletCode);
|
|
if (line != null)
|
|
{
|
|
throw new Exception("箱号:" + info.PalletCode + " 已存在!\n");
|
|
}
|
|
else
|
|
{
|
|
line = new ICSPallet();
|
|
}
|
|
|
|
//var lineone = db.ICSPalletLotNO.Where(a => a.ID == info.ID);
|
|
//db.ICSPalletLotNO.DeleteAllOnSubmit(lineone);
|
|
|
|
line.PalletCode = info.PalletCode;
|
|
line.MuserCode = AppConfig.UserId;
|
|
line.MuserName = AppConfig.UserName;
|
|
line.Mtime = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
db.ICSPallet.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
|
|
//db.Transaction.Commit();
|
|
//Addop(ITEM2ROUTEInfoList, dsconn);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 代码是否存在
|
|
public static bool IsIncluding(string PalletCode, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSPallet.SingleOrDefault(a => a.PalletCode == PalletCode);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 根据存货编码查找id
|
|
public static string SearchIDbyItemcode(string itemCODE, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.Base_Inventory.SingleOrDefault(a => a.ItemCode == itemCODE);
|
|
if (line != null)
|
|
{
|
|
return line.guid;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static void deleteInfo(List<ICSPallet> item2routeList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSPallet item2route in item2routeList)
|
|
{
|
|
var lines = db.ICSPallet.Where(a => a.PalletCode == item2route.PalletCode);
|
|
db.ICSPallet.DeleteAllOnSubmit(lines);
|
|
|
|
var lineone = db.ICSPalletLotNO.Where(a => a.PalletCode == item2route.PalletCode);
|
|
db.ICSPalletLotNO.DeleteAllOnSubmit(lineone);
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 分批
|
|
public static void Fenpi(List<FormICSWareHouseLotInfoUIModel> lotInfoList, decimal number, string newlotno, string dsconn)
|
|
{
|
|
string transNO = "";
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSWareHouseLotInfoUIModel lotInfo in lotInfoList)
|
|
{
|
|
string strtime = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"SELECT CONVERT(INT,RIGHT(MAX(A.TransNO),3)) AS MAXLOT FROM ICSWareHouseLotInfoLog A WHERE A.TransNO LIKE '{0}%'";
|
|
sql = string.Format(sql, strtime);//取已存的transNo后三位
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
{
|
|
transNO = strtime + "001";
|
|
}
|
|
else if (dt.Rows[0][0] == null || dt.Rows[0][0].ToString() == "")
|
|
{
|
|
transNO = strtime + "001";
|
|
}
|
|
else
|
|
{
|
|
transNO = strtime + (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString().PadLeft(3, '0');//自动生成transNo
|
|
}
|
|
Addone(lotInfo, transNO, number, newlotno, dsconn);
|
|
var line = db.ICSWareHouseLotInfo.SingleOrDefault(a => a.ID == lotInfo.ID);
|
|
FenpiLog(db, transNO, "分批前", line, lotInfo.LotQty, line.LotNO, dsconn);
|
|
line.LotQty = lotInfo.LotQty - number;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
db.SubmitChanges();
|
|
FenpiLog(db, transNO, "分批后", line, line.LotQty, line.LotNO, dsconn);
|
|
|
|
var line1 = db.ICSITEMLot.SingleOrDefault(a => a.LotNO == lotInfo.LotNO);
|
|
line1.LOTQTY = lotInfo.LotQty;
|
|
line1.WorkPoint = AppConfig.WorkPointCode;
|
|
line1.MUSER = AppConfig.UserCode;
|
|
line1.MUSERName = AppConfig.UserName;
|
|
line1.MTIME = DateTime.Now;
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static void FenpiLog(FramDataContext db, string transNO, string BusinessCode, ICSWareHouseLotInfo lotInfo, decimal number, string newlotno, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
ICSWareHouseLotInfoLog infolog = new ICSWareHouseLotInfoLog();
|
|
infolog.ID = AppConfig.GetGuid();
|
|
infolog.EATTRIBUTE1 = lotInfo.ID;//新批次ID
|
|
infolog.TransNO = transNO;
|
|
infolog.LotNO = newlotno;
|
|
infolog.TransQTY = number;
|
|
infolog.FRMStorageCODE = lotInfo.WHCode;
|
|
infolog.TransType = "分批";
|
|
infolog.FRMStackCODE = lotInfo.BinCode;
|
|
infolog.TOStorageCODE = "";
|
|
infolog.BusinessCode = BusinessCode;
|
|
infolog.TOStackCODE = "";
|
|
infolog.ITEMCODE = lotInfo.INVCode;
|
|
infolog.WorkPoint = AppConfig.WorkPointCode;
|
|
infolog.MUSER = AppConfig.UserCode;
|
|
infolog.MUSERName = AppConfig.UserName;
|
|
infolog.MTIME = Convert.ToDateTime(lotInfo.MTIME); //DateTime.Now;
|
|
db.ICSWareHouseLotInfoLog.InsertOnSubmit(infolog);
|
|
db.SubmitChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static void hepiLog(FramDataContext db, string transNO, string BusinessCode, ICSWareHouseLotInfo lotInfo, decimal number, string newlotno, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
ICSWareHouseLotInfoLog infolog = new ICSWareHouseLotInfoLog();
|
|
infolog.ID = AppConfig.GetGuid();
|
|
infolog.EATTRIBUTE1 = lotInfo.ID;//新批次ID
|
|
infolog.TransNO = transNO;
|
|
infolog.LotNO = newlotno;
|
|
infolog.TransQTY = number;
|
|
infolog.FRMStorageCODE = lotInfo.WHCode;
|
|
infolog.TransType = "合批";
|
|
infolog.FRMStackCODE = lotInfo.BinCode;
|
|
infolog.TOStorageCODE = "";
|
|
infolog.BusinessCode = BusinessCode;
|
|
infolog.TOStackCODE = "";
|
|
infolog.ITEMCODE = lotInfo.INVCode;
|
|
infolog.WorkPoint = AppConfig.WorkPointCode;
|
|
infolog.MUSER = AppConfig.UserCode;
|
|
infolog.MUSERName = AppConfig.UserName;
|
|
infolog.MTIME = Convert.ToDateTime(lotInfo.MTIME); //DateTime.Now;
|
|
db.ICSWareHouseLotInfoLog.InsertOnSubmit(infolog);
|
|
db.SubmitChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}//////////////////////////////////////////////////////////////////////
|
|
|
|
public static void Addone(FormICSWareHouseLotInfoUIModel lotInfo, string transNO, decimal number, string newlotno, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
ICSWareHouseLotInfo line = new ICSWareHouseLotInfo();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.LotNO = newlotno;
|
|
line.LotQty = number;
|
|
line.ReceiveDate = Convert.ToDateTime(lotInfo.ReceiveDate);
|
|
line.WHGUID = lotInfo.WHGUID;
|
|
line.WHCode = lotInfo.WHCode;
|
|
line.BinGUID = lotInfo.BinGUID;
|
|
line.BinCode = lotInfo.BinCode;
|
|
line.INVGUID = lotInfo.INVGUID;
|
|
line.INVCode = lotInfo.INVCode;
|
|
line.EATTRIBUTE1 = "FP";
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = Convert.ToDateTime(lotInfo.MTIME); //DateTime.Now;
|
|
db.ICSWareHouseLotInfo.InsertOnSubmit(line);
|
|
|
|
FenpiLog(db, transNO, "分批后", line, number, newlotno, dsconn);
|
|
|
|
var line1 = db.ICSITEMLot.SingleOrDefault(a => a.LotNO == lotInfo.LotNO);
|
|
if (line1 == null)
|
|
{
|
|
throw new Exception("条码不存在!!");
|
|
}
|
|
ICSITEMLot itemLot = new ICSITEMLot();
|
|
itemLot.ID = AppConfig.GetGuid();
|
|
itemLot.LotNO = newlotno;
|
|
itemLot.ItemCode = line1.ItemCode;
|
|
itemLot.TransNO = line1.TransNO;
|
|
itemLot.TransLine = line1.TransLine;
|
|
itemLot.EATTRIBUTE2 = "FP";
|
|
itemLot.VENDORITEMCODE = line1.VENDORITEMCODE;
|
|
itemLot.VENDORCODE = line1.VENDORCODE;
|
|
itemLot.VenderLotNO = line1.VenderLotNO;
|
|
itemLot.PRODUCTDATE = line1.PRODUCTDATE;
|
|
itemLot.LOTQTY = number;
|
|
itemLot.ACTIVE = line1.ACTIVE;
|
|
itemLot.Exdate = line1.Exdate;
|
|
itemLot.TYPE = line1.TYPE;
|
|
itemLot.EATTRIBUTE3 = line1.EATTRIBUTE3;
|
|
itemLot.WorkPoint = AppConfig.WorkPointCode;
|
|
itemLot.MUSER = AppConfig.UserCode;
|
|
itemLot.MUSERName = AppConfig.UserName;
|
|
itemLot.MTIME = DateTime.Now;
|
|
db.ICSITEMLot.InsertOnSubmit(itemLot);
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion///////////////////////////////////////////////////////////////
|
|
|
|
#region 合批
|
|
public static void Hepi(List<FormICSWareHouseLotInfoUIModel> lotInfoList, string nolot, string dsconn)
|
|
{
|
|
string TransNos = "";
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
decimal sumqty = 0.00M;
|
|
List<string> nolotlist = new List<string>();
|
|
string strtime = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"SELECT CONVERT(INT,RIGHT(MAX(A.TransNO),3)) AS MAXLOT FROM ICSWareHouseLotInfoLog A WHERE A.TransNO LIKE '{0}%'";
|
|
sql = string.Format(sql, strtime);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
{
|
|
TransNos = strtime + "001";
|
|
}
|
|
else if (dt.Rows[0][0] == null || dt.Rows[0][0].ToString() == "")
|
|
{
|
|
TransNos = strtime + "001";
|
|
}
|
|
else
|
|
{
|
|
TransNos = strtime + (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString().PadLeft(3, '0');
|
|
}
|
|
foreach (FormICSWareHouseLotInfoUIModel lotInfo in lotInfoList)
|
|
{
|
|
var lines = db.ICSWareHouseLotInfo.SingleOrDefault(a => a.LotNO == nolot);
|
|
hepiLog(db, TransNos, "合批前", lines, lotInfo.LotQty, lotInfo.LotNO, dsconn);
|
|
sumqty = lotInfo.LotQty + sumqty;
|
|
if (!lotInfo.LotNO.Equals(nolot))
|
|
nolotlist.Add(lotInfo.LotNO);
|
|
}
|
|
var line = db.ICSWareHouseLotInfo.SingleOrDefault(a => a.LotNO == nolot);
|
|
line.LotQty = sumqty;
|
|
hepiLog(db, TransNos, "合批后", line, line.LotQty, nolot, dsconn);
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
//line.MTIME = DateTime.Now;
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
DeleteList(nolotlist, dsconn);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
//#region 合批后删除
|
|
//public static void DeleteList(List<string> nolotlist, string dsconn)
|
|
//{
|
|
// FramDataContext db = new FramDataContext(dsconn);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
|
|
// var lines = db.ICSWareHouseLotInfo.Where(a => nolotlist.Contains(a.LotNO));
|
|
// db.ICSWareHouseLotInfo.DeleteAllOnSubmit(lines);
|
|
// db.SubmitChanges();
|
|
// db.Transaction.Commit();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw ex;
|
|
// }
|
|
//}
|
|
|
|
//#endregion
|
|
|
|
public static void DeleteList(List<string> nolotlist, string dsconn)
|
|
{
|
|
|
|
try
|
|
{
|
|
foreach (string lotInfo in nolotlist)
|
|
{
|
|
string sql1 = @" UPDATE ICSWareHouseLotInfo SET LotQty=0 WHERE LotNO='{0}'";
|
|
sql1 = string.Format(sql1, lotInfo);
|
|
DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql1);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 批次删除
|
|
public static void Lotdelete(List<String> LOTList)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSWareHouseLotInfo.Where(a => LOTList.Contains(a.ID));
|
|
db.ICSWareHouseLotInfo.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 更新
|
|
public static void UpItemLotInfo(List<String> LOTList, string dsconn)
|
|
{
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection(dsconn);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (string lotInfo in LOTList)
|
|
{
|
|
string sql = @" UPDATE b SET b.qty = b.qty-a.LotQty
|
|
FROM (SELECT lotno,INVCode,WHCode,BinCode,SUM(lotqty) AS LotQty FROM dbo.ICSWareHouseLotInfo GROUP BY LotNO,INVCode,WHCode,BinCode) a
|
|
LEFT JOIN dbo.ICSWareHouseInfo b ON a.INVCode= b.INVCode AND b.WHCode=a.WHCode AND a.BinCode=b.BinCode
|
|
WHERE a.lotno ='{0}'";
|
|
sql = string.Format(sql, lotInfo);
|
|
DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查询
|
|
public static ICSWareHouseLotInfo select(String guid, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSWareHouseLotInfo.SingleOrDefault(a => a.ID == guid);
|
|
return (ICSWareHouseLotInfo)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static ICSWareHouseLotInfo Wereselect(String LotNO, String INVCode, String WHCode, String BinCode, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSWareHouseLotInfo.SingleOrDefault(a => a.LotNO == LotNO && a.INVCode == INVCode && a.WHCode == WHCode && a.BinCode == BinCode);
|
|
return (ICSWareHouseLotInfo)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新条码信息
|
|
public static void updatalot(string id, Decimal sum, string dsconn)
|
|
{
|
|
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection(dsconn);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
string sql = @" UPDATE ICSWareHouseLotInfo SET LotQty='{0}' WHERE ID='{1}'";
|
|
sql = string.Format(sql, sum, id);
|
|
DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 更新库存信息
|
|
public static void updatawerelot(Decimal lsum, string invcode, string whcode, string bincode, string dsconn)
|
|
{
|
|
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection(dsconn);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
string sql = @"UPDATE ICSWareHouseInfo SET QTY= isnull(QTY,0) +{0} where INVCode='{1}' and WHCode='{2}'and BinCode='{3}'";
|
|
sql = string.Format(sql, lsum, invcode, whcode, bincode);
|
|
DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 更新日志
|
|
public static void BLOGAdd(List<ICSWareHouseLotInfoLog> LotInfoLogList, Decimal lsum, string edit, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSWareHouseLotInfoLog info in LotInfoLogList)
|
|
{
|
|
var line = new ICSWareHouseLotInfoLog();
|
|
|
|
line.ID = AppConfig.GetGuid();
|
|
line.TransNO = info.TransNO;
|
|
line.TransLine = info.TransLine;
|
|
line.ITEMCODE = info.ITEMCODE;
|
|
line.LotNO = info.LotNO;
|
|
line.FRMStorageCODE = info.FRMStorageCODE;
|
|
line.FRMStackCODE = info.FRMStackCODE;
|
|
line.TOStorageCODE = info.TOStorageCODE;
|
|
line.TOStackCODE = info.TOStackCODE;
|
|
line.TransQTY = lsum;
|
|
line.TransType ="修改";
|
|
line.BusinessCode = edit;
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
db.ICSWareHouseLotInfoLog.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|