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.
396 lines
16 KiB
396 lines
16 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 ICSPOArriveDAL
|
|
{
|
|
#region 删除
|
|
public static void deleteSonInfo(string ID, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSPOArrive.Where(a => a.ID == ID);
|
|
db.ICSPOArrive.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static void deleteHeadInfo(string ReID, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSINVReceipt.Where(a => a.ID == ReID);
|
|
db.ICSINVReceipt.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable IsIncludingDetail(string LOT, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql1 = @"SELECT DISTINCT c.LotNO as 批次
|
|
FROM
|
|
ICSPOArrive b
|
|
LEFT JOIN dbo.ICSWareHouseLotInfoLog g ON g.TransNO=b.cCode and g.TransLine=b.irowno
|
|
INNER JOIN ICSWareHouseLotInfo c ON g.LotNO=c.LotNO WHERE g.TransType='到货' AND b.ID='{0}'";
|
|
sql1 = string.Format(sql1, LOT);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql1).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static DataTable ArriveDetail(string ReID, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
string sql1 = @"SELECT * FROM ICSPOArrive b WHERE b.ID='{0}'";
|
|
sql1 = string.Format(sql1, ReID);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql1).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#region 删除日志信息
|
|
public static void deleteLotInfo(string NO, string Line, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSWareHouseLotInfoLog.Where(a => a.TransNO == NO && a.TransLine == Line && a.TransType == "到货");
|
|
db.ICSWareHouseLotInfoLog.DeleteAllOnSubmit(lines);
|
|
//var linees = db.ICSITEMLot.Where(a => LOTList.Contains(a.LotNO) && a.TYPE=="采购到货");
|
|
//db.ICSITEMLot.DeleteAllOnSubmit(linees);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 更新条码信息
|
|
public static void UpItemLotInfo(string NO, string Line, string dsconn)
|
|
{
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection(dsconn);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
string sql = @" UPDATE b SET b.EATTRIBUTE3=NULL,b.EATTRIBUTE4 =NULL
|
|
FROM dbo.ICSWareHouseLotInfoLog a
|
|
INNER JOIN dbo.ICSITEMLot b ON a.LotNO= b.LotNO
|
|
where a.TransNO='{0}' and a.TransLine='{1}'and a.TransType='{2}'";
|
|
sql = string.Format(sql, NO, Convert.ToInt32(Line), "到货");
|
|
DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 新增内容
|
|
#region 删除
|
|
public static void deleteInfo(List<string> RIDList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSITEMLot.Where(a => RIDList.Contains(a.ID));
|
|
db.ICSITEMLot.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static FormICSRdrecord2LOTUIModelX Search_Info(string cCode, string irowno, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
#region
|
|
try
|
|
{
|
|
string RowNO = irowno.ToString();
|
|
FormICSRdrecord2LOTUIModelX info = new FormICSRdrecord2LOTUIModelX();
|
|
info.Arr = db.ICSPOArrive.SingleOrDefault(a => a.cCode == cCode && a.irowno == int.Parse(RowNO));
|
|
if (info.Arr != null)
|
|
info.inventory = db.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == info.Arr.cInvCode);
|
|
info.icsitems = db.ICSITEMLot.Where(a => a.ItemCode == info.Arr.cInvCode && a.TransNO == info.Arr.cCode && a.TransLine == info.Arr.irowno.ToString()).FirstOrDefault();
|
|
var infos = db.ICSITEMLot.Where(a => a.ItemCode == info.Arr.cInvCode);
|
|
info.SumQty = Convert.ToDecimal(info.Arr.iQuantity);
|
|
try
|
|
{
|
|
string sql = @"SELECT COUNT(C.ItemCode) AS NUM, C.ItemCode, C.LOTQTY FROM ICSPOArrive A
|
|
LEFT JOIN ICSITEMLot C ON A.cInvCode = C.ItemCode AND A.cCode = C.TransNO AND A.irowno = CONVERT(int, C.TransLine)
|
|
LEFT JOIN ICSWareHouseLotInfo D ON C.LotNO = D.LotNO WHERE A.cCode = '{0}' AND A.irowno = '{1}' AND C.ItemCode = '{2}'
|
|
GROUP BY C.ItemCode, C.LOTQTY ";
|
|
sql = string.Format(sql, cCode, irowno, info.Arr.cInvCode);
|
|
DataTable ds = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
if (ds.Rows.Count == 0 || ds == null)
|
|
{
|
|
info.SumNo = 0;
|
|
}
|
|
else
|
|
{
|
|
info.SumNo = 0;
|
|
for (int i = 0; i < ds.Rows.Count; i++)
|
|
{
|
|
info.SumNo += Int32.Parse(ds.Rows[i]["NUM"].ToString());
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
var infoMaxs = db.ICSITEMLot.Where(a => a.TransNO == info.Arr.Free2 && a.TransLine == info.Arr.irowno.ToString());
|
|
if (infoMaxs.Count() == 0)
|
|
info.MaxNo = 0;
|
|
else
|
|
{
|
|
string lotno = infoMaxs.OrderByDescending(a => a.LotNO).FirstOrDefault().LotNO;
|
|
info.MaxNo = Convert.ToInt32(lotno.Substring(lotno.Length - 5));
|
|
}
|
|
if (infos != null && infos.Count() > 0)
|
|
{
|
|
#region
|
|
//var VenderLotNO = infos.Where(a => a.PRODUCTDATE == AppConfig.GetSeverDateTime("yyyy-MM-dd")).Select(a => a.VenderLotNO).Distinct();
|
|
//if (VenderLotNO != null && VenderLotNO.Count() > 0)
|
|
//{
|
|
// info.VenderLotNO = VenderLotNO.ToList()[0];
|
|
// return info;
|
|
//}
|
|
#endregion
|
|
info.VenderLotNO = info.Arr.Batch;
|
|
return info;
|
|
}
|
|
var infoTodays = db.ICSITEMLot.Where(a => a.PRODUCTDATE == AppConfig.GetSeverDateTime("yyyy-MM-dd")).Select(a => a.TransNO);
|
|
info.TodayMOCount = infoTodays.Distinct().Count();
|
|
return info;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#region
|
|
public static DataSet SearchData(string cCode, string irowno, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT D.ID, CASE WHEN E.LOTNO IS NULL THEN 'Y' ELSE '' END AS isSelect, D.LotNO, D.LOTQTY, C.INVUOM, A.cCode,
|
|
A.irowno, D.VenderLotNO, D.PRODUCTDATE, D.MUSERName, CAST(CASE WHEN E.LotNO IS NOT NULL THEN '1' ELSE '0' END AS BIT) AS isInput,
|
|
D.VenBatch FROM ICSPOArrive A LEFT JOIN ICSINVENTORY C ON A.cInvCode = C.INVCODE
|
|
INNER JOIN ICSITEMLot D ON A.cInvCode = D.ItemCode AND A.cCode = D.TransNO AND A.irowno = CONVERT(int, D.TransLine)
|
|
LEFT JOIN ICSWareHouseLotInfo E ON D.LotNO = E.LotNO WHERE A.cCode = '{0}' AND A.irowno = '{1}' ORDER BY A.cCode, A.irowno ";
|
|
sql = string.Format(sql, cCode, irowno, AppConfig.WorkPointCode);
|
|
DataSet ds = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql);
|
|
return ds;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static DataTable GetBatch(string cInvCode, string WorkPoint, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT INVCODE, INVNAME, INVSTD, INVCLASS, INVCONTROLTYPE FROM ICSINVENTORY WHERE 1=1 AND INVCODE = '{0}' AND WorkPoint = '{1}' ";
|
|
sql = string.Format(sql, cInvCode, WorkPoint);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetVen(string cInvCode, string WorkPoint, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT INVCODE, INVNAME, INVSTD, INVCLASS, INVCONTROLTYPE FROM ICSINVENTORY A
|
|
INNER JOIN Sys_EnumValues B ON A.INVCLASS = B.EnumValue AND B.EnumKey = '00002'
|
|
WHERE 1=1 AND INVCODE = '{0}' AND WorkPoint = '{1}' ";
|
|
sql = string.Format(sql, cInvCode, WorkPoint);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetCheck(string cInvCode, string WorkPoint, string dsconn)
|
|
{
|
|
#region WMS
|
|
try
|
|
{
|
|
string sql = @"
|
|
SELECT INVCODE, INVNAME, INVSTD, INVCLASS, INVCONTROLTYPE FROM ICSINVENTORY A
|
|
INNER JOIN Sys_EnumValues B ON A.INVCLASS = B.EnumValue AND B.EnumKey = '00004'
|
|
WHERE 1=1 AND INVCODE = '{0}' AND WorkPoint = '{1}'";
|
|
sql = string.Format(sql, cInvCode, WorkPoint);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
#endregion
|
|
#region U8
|
|
//try
|
|
//{
|
|
// string sql = @"SELECT cInvCode, cInvName, cInvCCode FROM Inventory WHERE 1=1 AND cInvCode = '{0}' ";
|
|
// sql = string.Format(sql, cInvCode);
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql).Tables[0];
|
|
// return dt;
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// throw ex;
|
|
//}
|
|
#endregion
|
|
}
|
|
|
|
#region 新增和修改
|
|
public static void Add(List<ICSITEMLot> InfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSITEMLot info in InfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSITEMLot.SingleOrDefault(a => a.ID == info.ID && a.WorkPoint == AppConfig.WorkPointCode);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSITEMLot();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
line.LotNO = info.LotNO;
|
|
line.ItemCode = info.ItemCode;
|
|
line.TransNO = info.TransNO;
|
|
line.TransLine = info.TransLine;
|
|
line.VENDORITEMCODE = info.VENDORITEMCODE;
|
|
line.VENDORCODE = info.VENDORCODE;
|
|
line.VenderLotNO = info.VenderLotNO;
|
|
line.PRODUCTDATE = info.PRODUCTDATE;
|
|
line.LOTQTY = info.LOTQTY;
|
|
line.ACTIVE = info.ACTIVE;
|
|
line.Exdate = info.Exdate;
|
|
line.TYPE = info.TYPE;
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.EATTRIBUTE2 = info.EATTRIBUTE2;
|
|
line.EATTRIBUTE3 = info.EATTRIBUTE3;
|
|
line.EATTRIBUTE5 = info.EATTRIBUTE5;
|
|
line.VenBatch = info.VenBatch;
|
|
if (isNew)
|
|
{
|
|
db.ICSITEMLot.InsertOnSubmit(line);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static DataTable GetVenBatch(string INVCLASS, string WorkPoint, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT * FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00002' AND EnumValue = '{0}' ";
|
|
sql = string.Format(sql, INVCLASS, WorkPoint);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
//DataTable dt = DBHelper.ExecuteDataset(AppConfig.GetDataBaseConnectStringByKey("[DB.SYS]"), CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|