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.
282 lines
15 KiB
282 lines
15 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 ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSLLDisposeInFoDAL
|
|
{
|
|
#region AddandEditList
|
|
// public static void AddandEditList(List<ICSLLDisposeInFo> ItemLotList, string Appconstr)
|
|
// {
|
|
// FramDataContext db = new FramDataContext(Appconstr);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
// foreach (ICSLLDisposeInFo lineNew in ItemLotList)
|
|
// {
|
|
// bool isNew = false;
|
|
// var line = db.ICSLLDisposeInFo.SingleOrDefault(a => a.LOTNO == lineNew.LOTNO && a.ItemCode == lineNew.ItemCode && a.DocNo == lineNew.DocNo && a.LineNo == lineNew.LineNo);
|
|
// if (line == null)
|
|
// {
|
|
// isNew = true;
|
|
// line = new ICSLLDisposeInFo();
|
|
// line.ID = AppConfig.GetGuid();
|
|
// }
|
|
// line.LOTNO = lineNew.LOTNO;
|
|
// line.ItemCode = lineNew.ItemCode;
|
|
// line.ItemName = lineNew.ItemName;
|
|
// line.BarCodeQty = lineNew.BarCodeQty;
|
|
// line.DisposeInQty = lineNew.DisposeInQty;
|
|
// line.SupplierName = lineNew.SupplierName;
|
|
// line.DocNo = lineNew.DocNo;
|
|
// line.LineNo = lineNew.LineNo;
|
|
// line.LineNo = lineNew.LineNo;
|
|
// line.CompleteInformation = lineNew.CompleteInformation;
|
|
// line.ReleaseStatus = lineNew.ReleaseStatus;
|
|
// line.MUSER = lineNew.MUSER;
|
|
// line.MUSERName = lineNew.MUSERName;
|
|
// line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
// line.WorkPoint = lineNew.WorkPoint;
|
|
|
|
// if (isNew) db.ICSLLDisposeInFo.InsertOnSubmit(line);
|
|
|
|
// db.SubmitChanges();
|
|
// }
|
|
// db.Transaction.Commit();
|
|
// UpdatePoLine(ItemLotList, Appconstr);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw new Exception(ex.Message);
|
|
// }
|
|
// }
|
|
|
|
// public static void UpdatePoLine(List<ICSLLDisposeInFo> ItemLotList, string dsconn)
|
|
// {
|
|
// try
|
|
// {
|
|
// foreach (ICSLLDisposeInFo lineNew in ItemLotList)
|
|
// {
|
|
// //根据物料条码和RCV行获取U8采购单行和RCV实际到货数量
|
|
// string sql = @"SELECT a.BarCodeNo ,--条码
|
|
// b.RcvDocNo ,--收货单号
|
|
// b.RcvLineNo ,--行号
|
|
// b.RcvLineStoreQty ,--实到数量
|
|
// b.RcvLineSrcPOSrcDocNo ,--源采购单号
|
|
// b.RcvLineSrcPOSrcDocLineNo --源采购单行
|
|
// FROM WM_BarCode a inner JOIN dbo.WM_RCVShip b ON a.RCVShipguid = b.guid
|
|
// and a.SrcType = 'WM_RCVShip'
|
|
// where 1=1
|
|
// AND b.RcvDocNo='{0}' AND b.RcvLineNo='{1}'";
|
|
// sql = string.Format(sql, lineNew.DocNo, lineNew.LineNo);
|
|
// DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
// if (dt != null && dt.Rows.Count > 0)
|
|
// {
|
|
// //判断 到货数量 等于(ReleaseStatus=1 and Completelnformation=1)的数量之和 + ReleaseStatus=0 的数量之和
|
|
// //回写 U9 PO行上 DescFlexSegments_PrivateDescSeg20=1
|
|
// //判断 到货数量 大于(ReleaseStatus=1 and Completelnformation=1)的数量之和 + ReleaseStatus=0 的数量之和
|
|
// //回写 U9 PO行上 DescFlexSegments_PrivateDescSeg20=0
|
|
// string sql1 = @"select SUM(ISNULL(DisposeInQty,0)) DisposeInQty, DocNo , [LineNo] from ICSLLDisposeInFo
|
|
// where DocNo = '{0}' AND [LineNo] = '{1}'
|
|
// AND ((ReleaseStatus=1 and CompleteInformation=1) OR ReleaseStatus=0)
|
|
// GROUP BY DocNo , [LineNo]";
|
|
// sql1 = string.Format(sql1, lineNew.DocNo, lineNew.LineNo);
|
|
// DataTable dt1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
|
|
// if (dt1 != null && dt1.Rows.Count > 0)
|
|
// {
|
|
// if (Convert.ToDecimal(dt.Rows[0]["RcvLineStoreQty"].ToString()) == Convert.ToDecimal(dt1.Rows[0]["DisposeInQty"].ToString()))
|
|
// {
|
|
// string sql2 = @"UPDATE a SET a.DescFlexSegments_PrivateDescSeg20=1
|
|
// FROM dbo.PM_POLine a
|
|
// LEFT JOIN dbo.PM_PurchaseOrder b ON a.PurchaseOrder=b.ID
|
|
// WHERE b.DocNo='{0}' AND a.DocLineNo='{1}'";
|
|
// sql2 = string.Format(sql2, dt.Rows[0]["RcvLineSrcPOSrcDocNo"].ToString(), dt.Rows[0]["RcvLineSrcPOSrcDocLineNo"].ToString());
|
|
// DBHelper.ExecuteNonQuery(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql2);
|
|
// }
|
|
// else if (Convert.ToDecimal(dt.Rows[0]["RcvLineStoreQty"].ToString()) > Convert.ToDecimal(dt1.Rows[0]["DisposeInQty"].ToString()))
|
|
// {
|
|
// string sql2 = @"UPDATE a SET a.DescFlexSegments_PrivateDescSeg20=0
|
|
// FROM dbo.PM_POLine a
|
|
// LEFT JOIN dbo.PM_PurchaseOrder b ON a.PurchaseOrder=b.ID
|
|
// WHERE b.DocNo='{0}' AND a.DocLineNo='{1}'";
|
|
// sql2 = string.Format(sql2, dt.Rows[0]["RcvLineSrcPOSrcDocNo"].ToString(), dt.Rows[0]["RcvLineSrcPOSrcDocLineNo"].ToString());
|
|
// DBHelper.ExecuteNonQuery(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql2);
|
|
// }
|
|
// }
|
|
// else//查询不到数据默认到货数量大,回写0
|
|
// {
|
|
// string sql2 = @"UPDATE a SET a.DescFlexSegments_PrivateDescSeg20=0
|
|
// FROM dbo.PM_POLine a
|
|
// LEFT JOIN dbo.PM_PurchaseOrder b ON a.PurchaseOrder=b.ID
|
|
// WHERE b.DocNo='{0}' AND a.DocLineNo='{1}'";
|
|
// sql2 = string.Format(sql2, dt.Rows[0]["RcvLineSrcPOSrcDocNo"].ToString(), dt.Rows[0]["RcvLineSrcPOSrcDocLineNo"].ToString());
|
|
// DBHelper.ExecuteNonQuery(AppConfig.GetDataBaseConnectStringByKey("[DB.ERP]"), CommandType.Text, sql2);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
// }
|
|
|
|
// private static DataTable SQlReturnData(SqlCommand cmd)
|
|
// {
|
|
// DataTable dt = new DataTable();
|
|
// SqlDataAdapter dr = new System.Data.SqlClient.SqlDataAdapter();
|
|
// dr.SelectCommand = cmd;
|
|
// dr.Fill(dt);
|
|
// return dt;
|
|
// }
|
|
#endregion
|
|
|
|
|
|
//public static void EditCompleteInformation(ICSLLDisposeInFo ItemLot, string Appconstr)
|
|
//{
|
|
// FramDataContext db = new FramDataContext(Appconstr);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
// bool isNew = false;
|
|
// var line = db.ICSLLDisposeInFo.SingleOrDefault(a => a.LOTNO == ItemLot.LOTNO && a.ItemCode == ItemLot.ItemCode && a.DocNo == ItemLot.DocNo && a.LineNo == ItemLot.LineNo);
|
|
// if (line == null)
|
|
// {
|
|
// isNew = true;
|
|
// line = new ICSLLDisposeInFo();
|
|
// line.ID = AppConfig.GetGuid();
|
|
// }
|
|
// line.CompleteInformation = ItemLot.CompleteInformation;
|
|
// line.MUSER = ItemLot.MUSER;
|
|
// line.MUSERName = ItemLot.MUSERName;
|
|
// line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
// if (isNew) db.ICSLLDisposeInFo.InsertOnSubmit(line);
|
|
|
|
// db.SubmitChanges();
|
|
// db.Transaction.Commit();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw new Exception(ex.Message);
|
|
// }
|
|
//}
|
|
//public static void LLDisposeAgainEdit(List<ICSLLDisposeInFoAgain> ItemLotList, string Appconstr)
|
|
//{
|
|
// FramDataContext db = new FramDataContext(Appconstr);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
// foreach (ICSLLDisposeInFoAgain lineNew in ItemLotList)
|
|
// {
|
|
// bool isNew = false;
|
|
// var line = db.ICSLLDisposeInFoAgain.SingleOrDefault(a => a.LOTNO == lineNew.LOTNO && a.ItemCode == lineNew.ItemCode);
|
|
// if (line == null)
|
|
// {
|
|
// isNew = true;
|
|
// line = new ICSLLDisposeInFoAgain();
|
|
// line.ID = AppConfig.GetGuid();
|
|
// }
|
|
// line.LOTNO = lineNew.LOTNO;
|
|
// line.ItemCode = lineNew.ItemCode;
|
|
// line.ItemName = lineNew.ItemName;
|
|
// line.BarCodeQty = lineNew.BarCodeQty;
|
|
// line.DisposeInQty = lineNew.DisposeInQty;
|
|
// line.SupplierName = lineNew.SupplierName;
|
|
// line.DocNo = lineNew.DocNo;
|
|
// line.LineNo = lineNew.LineNo;
|
|
// line.MUSER = lineNew.MUSER;
|
|
// line.MUSERName = lineNew.MUSERName;
|
|
// line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
// line.WorkPoint = lineNew.WorkPoint;
|
|
// line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
|
|
|
|
// if (isNew) db.ICSLLDisposeInFoAgain.InsertOnSubmit(line);
|
|
|
|
// db.SubmitChanges();
|
|
// }
|
|
// db.Transaction.Commit();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw new Exception(ex.Message);
|
|
// }
|
|
//}
|
|
|
|
public static void LLDisposeAgainEditByLOTNO(List<ICSLLDisposeInFoAgain> ItemLotList, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSLLDisposeInFoAgain lineNew in ItemLotList)
|
|
{
|
|
//判断是否存在自定义档案,不存在则自动生成一条确认数据
|
|
//if (!GetUserCodeIsTrue(lineNew.LOTNO, Appconstr))
|
|
//{
|
|
|
|
bool isNew = false;
|
|
var line = db.ICSLLDisposeInFoAgain.SingleOrDefault(a => a.LOTNO == lineNew.LOTNO && a.ItemCode == lineNew.ItemCode);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSLLDisposeInFoAgain();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
line.LOTNO = lineNew.LOTNO;
|
|
line.ItemCode = lineNew.ItemCode;
|
|
line.ItemName = lineNew.ItemName;
|
|
line.BarCodeQty = lineNew.BarCodeQty;
|
|
line.DisposeInQty = lineNew.DisposeInQty;
|
|
line.SupplierName = lineNew.SupplierName;
|
|
line.DocNo = lineNew.DocNo;
|
|
line.LineNo = lineNew.LineNo;
|
|
line.MUSER = lineNew.MUSER;
|
|
line.MUSERName = lineNew.MUSERName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
line.WorkPoint = lineNew.WorkPoint;
|
|
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
|
|
|
|
if (isNew) db.ICSLLDisposeInFoAgain.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
//}
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
private static bool GetUserCodeIsTrue(string LotNo, string Appconstr)
|
|
{
|
|
bool isTrue = false;
|
|
string sql = string.Format(@"SELECT *
|
|
FROM Sys_EnumValues
|
|
WHERE EnumKey='080'
|
|
AND EnumValue=(SELECT MUSERCode FROM WM_RCVShip
|
|
WHERE guid =(SELECT RCVShipguid FROM WM_BarCode WHERE BarCodeNo='{0}'))", LotNo);
|
|
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
isTrue = true;
|
|
}
|
|
return isTrue;
|
|
}
|
|
}
|
|
}
|