华恒Mes鼎捷代码
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.

4425 lines
170 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSSoft.Frame.Data.Entity;
using ICSSoft.Base.Config.DBHelper;
using System.Data;
using System.Data.SqlClient;
using ICSSoft.Base.Config.AppConfig;
namespace ICSSoft.Frame.Data.DAL
{
public class ICSNCRDocDAL
{
#region 增加修改
public static void AddPicture(ICSNCRDocPicture info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocPicture.SingleOrDefault(a => a.PicturePath == info.PicturePath && a.SecDocNO == info.SecDocNO);
if (line != null)
{
return;
}
isNew = true;
line = new ICSNCRDocPicture();
line.ID = AppConfig.GetGuid();
line.SecDocNO = info.SecDocNO;
line.PicturenName = info.PicturenName;
line.PicturePath = info.PicturePath;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
if (isNew)
db.ICSNCRDocPicture.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static ICSNCRDocRectify AddEditRectify(ICSNCRDocRectify info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
if (string.IsNullOrEmpty(info.SecDocNO))
{
throw new Exception("纠正数据异常,请刷新。");
}
var line = db.ICSNCRDocRectify.SingleOrDefault(a => a.SecDocNO == info.SecDocNO);
if (line == null)
{
isNew = true;
line = new ICSNCRDocRectify();
line.ID = AppConfig.GetGuid();
}
var codes = db.ICSNCRDocRectify.Where(a => a.SecDocNO == info.SecDocNO && a.ID != line.ID);
if (codes.ToList().Count > 0)
{
throw new Exception("已存在纠正数据");
}
line.SecDocNO = info.SecDocNO;
line.RectifyContect = info.RectifyContect;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
line.Confirm = info.Confirm;
line.ConfirmPerson = info.ConfirmPerson;
line.ConfirmTime = info.ConfirmTime;
if (isNew)
{
db.ICSNCRDocRectify.InsertOnSubmit(line);
var NCR = db.ICSNCRDoc.SingleOrDefault(a => a.SecDocNO == info.SecDocNO);
NCR.Rectify = line.ID;
}
db.SubmitChanges();
db.Transaction.Commit();
return (ICSNCRDocRectify)line;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static ICSNCRDocPrevention AddEditPrevention(ICSNCRDocPrevention info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
if (string.IsNullOrEmpty(info.SecDocNO))
{
throw new Exception("数据异常,请刷新");
}
var line = db.ICSNCRDocPrevention.SingleOrDefault(a => a.SecDocNO == info.SecDocNO);
if (line == null)
{
isNew = true;
line = new ICSNCRDocPrevention();
line.ID = AppConfig.GetGuid();
}
var codes = db.ICSNCRDocPrevention.Where(a => a.SecDocNO == info.SecDocNO && a.ID != line.ID);
if (codes.ToList().Count > 0)
{
throw new Exception("已存在预防数据");
}
line.SecDocNO = info.SecDocNO;
line.PreventionContect = info.PreventionContect;
line.PlanComTime = info.PlanComTime;
line.ActComTime = info.ActComTime;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
line.ManagerConfirm = info.ManagerConfirm;
line.Confirm = info.Confirm;
line.ConfirmPerson = info.ConfirmPerson;
line.ConfirmTime = info.ConfirmTime;
if (isNew)
{
db.ICSNCRDocPrevention.InsertOnSubmit(line);
var NCR = db.ICSNCRDoc.SingleOrDefault(a => a.SecDocNO == info.SecDocNO);
NCR.Prevention = line.ID;
}
db.SubmitChanges();
db.Transaction.Commit();
return (ICSNCRDocPrevention)line;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static void EditPreventionActComTime(ICSNCRDocPrevention info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocPrevention.SingleOrDefault(a => a.ID == info.ID);
if (line == null)
{
throw new Exception("预防数据不存在");
}
line.ActComTime = info.ActComTime;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static void AddRectifyProcessLog(ICSNCRDocRectifyProcessLog info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var isNew = true;
var line = new ICSNCRDocRectifyProcessLog();
line.ID = AppConfig.GetGuid();
line.SecDocNO = info.SecDocNO;
line.DoType = info.DoType;
line.RectifyID = info.RectifyID;
line.SubmitDep = info.SubmitDep;
line.SubmitPerson = info.SubmitPerson;
line.CKStatus = info.CKStatus;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
if (isNew)
db.ICSNCRDocRectifyProcessLog.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static void AddRectifyProcessLog_Type(string SecdocNo, string DoType, int seq, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var isNew = true;
var line = new ICSNCRDocRectifyProcessLog();
line.ID = AppConfig.GetGuid();
var info = db.ICSNCRDocRectifyProcess.SingleOrDefault(a => a.Seq == seq && a.SecDocNO == SecdocNo);
if (info != null)
{
line.SecDocNO = info.SecDocNO;
line.DoType = DoType;
line.RectifyID = info.ID;
line.SubmitDep = info.SubmitDep;
line.SubmitPerson = info.SubmitPerson;
line.CKStatus = info.CKStatus;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
if (isNew)
db.ICSNCRDocRectifyProcessLog.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static void AddPreventionProcessLog(ICSNCRDocPreventionProcessLog info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var isNew = true;
var line = new ICSNCRDocPreventionProcessLog();
line.ID = AppConfig.GetGuid();
line.SecDocNO = info.SecDocNO;
line.DoType = info.DoType;
line.PreventionID = info.PreventionID;
line.SubmitDep = info.SubmitDep;
line.SubmitPerson = info.SubmitPerson;
line.PendingDepartment = info.PendingDepartment;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
if (isNew)
db.ICSNCRDocPreventionProcessLog.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static String CreateNCR(ICSNCRDoc lineNew, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
#region ICSNCRDoc
bool isNew = true;
var line = new ICSNCRDoc(); ;
line.ID = AppConfig.GetGuid();
var codes = db.ICSNCRDoc.Where(a => a.SecDocNO == lineNew.SecDocNO);
if (codes.ToList().Count > 0)
{
throw new Exception("此参数类型已存在");
}
// var codesLOT = db.ICSNCRDoc.Where(a => a.SrcDocInfo == lineNew.SrcDocInfo);
// if (codesLOT.ToList().Count > 0)
// {
// throw new Exception("此批号已申请NCR");
// }
line.OPCode = lineNew.OPCode;
line.SecDocNO = lineNew.SecDocNO;
if (string.IsNullOrEmpty(lineNew.SecDocCreateDep))
{
line.SecDocCreateDep = selectDepByUserCode(lineNew.SecDocCreateUser, Appconstr);
}
else
{
line.SecDocCreateDep = lineNew.SecDocCreateDep;
}
line.SecDocCreateTime = lineNew.SecDocCreateTime;
line.SecDocCreateUser = lineNew.SecDocCreateUser;
line.SecDocCreateUserName = lineNew.SecDocCreateUserName;
line.SecDocNO = lineNew.SecDocNO;
line.SecDocOKTime = lineNew.SecDocOKTime;
line.SecDocSeq = lineNew.SecDocSeq;
line.SecDocStatus = lineNew.SecDocStatus;
line.SecDocType = lineNew.SecDocType;
line.SrcDocInfo = lineNew.SrcDocInfo;
line.TimeLimit = lineNew.TimeLimit;
line.ToPostList = lineNew.ToPostList;
line.ToUserList = lineNew.ToUserList;
line.TreatResult = lineNew.TreatResult;
line.TreatWay = lineNew.TreatWay;
line.VendorDesc = lineNew.VendorDesc;
line.VendorState = lineNew.VendorState;
line.DefectType = lineNew.DefectType;
line.BadReason = lineNew.BadReason;
line.CCPostList = lineNew.CCPostList;
line.CCUserList = lineNew.CCUserList;
line.ContentDesc = lineNew.ContentDesc;
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
line.EATTRIBUTE2 = lineNew.EATTRIBUTE2;
line.EATTRIBUTE3 = lineNew.EATTRIBUTE3;
line.EATTRIBUTE4 = lineNew.EATTRIBUTE4;
line.EQPCode = lineNew.EQPCode;
line.ErrorType = lineNew.ErrorType;
line.IsNeedPrevention = lineNew.IsNeedPrevention;
line.TreatCost = lineNew.TreatCost;
line.ItemCode = lineNew.ItemCode;
line.LOTNO = lineNew.LOTNO;
line.OKUserList = lineNew.OKUserList;
line.OPCode = lineNew.OPCode;
line.Urgent = "一般";
line.IsCPIR = lineNew.IsCPIR;
line.CPIRItemType = lineNew.CPIRItemType;
//部件:物料描述取'-'之前的
//Base_Inventory item = ICSBase_InventoryDAL.select(lineNew.ItemCode, Appconstr);
//if (item != null && string.IsNullOrEmpty(lineNew.Partment))
//{
// string[] desc = item.ItemName.Split('-');
// if (desc != null && desc.Count() > 0)
// {
// line.Partment = desc[0];
// }
// else
// {
// line.Partment = lineNew.Partment;
// }
//}
//else
//{
// line.Partment = lineNew.Partment;
//}
if (string.IsNullOrEmpty(lineNew.Point))
{
line.Point = SelectPoint(line.SrcDocInfo);
}
else
{
line.Point = lineNew.Point;
}
line.Prevention = lineNew.Prevention;
if (!string.IsNullOrEmpty(lineNew.ProjectCode))
{
line.ProjectCode = lineNew.ProjectCode;
}
else
{
if (!string.IsNullOrEmpty(line.SrcDocInfo))
{
string Pro = GetAPSProjectCode(line.SrcDocInfo, Appconstr);//抓取派工表 项目号
if (string.IsNullOrEmpty(Pro))
{
line.ProjectCode = "NA";
}
else
{
line.ProjectCode = Pro;
}
}
else
{
line.ProjectCode = "NA";
}
}
line.Qty = lineNew.Qty;
line.ReadUserList = lineNew.ReadUserList;
line.RealCauseAnalysis = lineNew.RealCauseAnalysis;
line.ReasonDesc = lineNew.ReasonDesc;
line.Rectify = lineNew.Rectify;
line.OPCode = lineNew.OPCode;
if (line.Qty < 1)
{
throw new Exception("NCR数量不能小于1");
}
if (string.IsNullOrEmpty(line.ItemCode) && string.IsNullOrEmpty(line.LOTNO) && string.IsNullOrEmpty(line.ContentDesc) && string.IsNullOrEmpty(line.SrcDocInfo))
{
throw new Exception("无内容,无法申请NCR");
}
//炉号
//if (string.IsNullOrEmpty(lineNew.Furnace) && !string.IsNullOrEmpty(line.SrcDocInfo))
//{
// line.Furnace = GetInvLotFurnaceStrNew(line.SrcDocInfo, Appconstr, "炉号");
//}
//else
//{
// line.Furnace = lineNew.Furnace;
//}
line.PZLJMOCode = lineNew.PZLJMOCode;
line.GongShiFei = lineNew.GongShiFei;
line.CaiLiaoFei = lineNew.CaiLiaoFei;
line.IsWX = lineNew.IsWX;
try
{
if (string.IsNullOrEmpty(lineNew.EATTRIBUTE5))
{
//供应商编码
line.EATTRIBUTE5 = GetInvLotFurnaceStrNew(line.SrcDocInfo, Appconstr, "供应商编码");
}
else
{
string Supply_Item = GetInvLotFurnaceStrNew(line.SrcDocInfo, Appconstr, "供应商编码");
if (!string.IsNullOrEmpty(Supply_Item))
{
List<string> SSI = new List<string>(Supply_Item.Split(','));
List<string> SSWX = new List<string>(lineNew.EATTRIBUTE5.Split(','));
List<string> Supply_List = SSI.Union(SSWX).ToList<string>();
line.EATTRIBUTE5 = string.Join(",", Supply_List);
}
else
{
line.EATTRIBUTE5 = lineNew.EATTRIBUTE5;
}
}
}
catch (Exception ex)
{
}
//暂停lot
ZanTingLot(line.SrcDocInfo, line.OPCode,Appconstr);
line.EATTRIBUTE6 = lineNew.EATTRIBUTE6;
line.EATTRIBUTE7 = lineNew.EATTRIBUTE7;
line.EATTRIBUTE8 = lineNew.EATTRIBUTE8;
line.IsTuiLiao = lineNew.IsTuiLiao;
if (lineNew.NGQty == null)
{
line.NGQty = lineNew.Qty;
}
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew)
db.ICSNCRDoc.InsertOnSubmit(line);
db.SubmitChanges();
#endregion
//#region ICSNCRDocDoDetail
//linedoNew.SecDocID = line.ID;
//linedoNew.SecDocNO = line.SecDocNO;
//linedoNew.SecDocSeq = line.SecDocSeq;
//linedoNew.DoUser = line.SecDocCreateUser;
//linedoNew.DoUserName = line.SecDocCreateUserName;
//linedoNew.DoTIME = line.SecDocCreateTime;
//linedoNew.ReadUsers = "";
//AddandEditICSNCRDocDoDetail(linedoNew, db);
//#endregion
db.Transaction.Commit();
return line.ID;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//0913生产报工_批次判退回NCR
public static String CreateNCRS(ICSNCRDoc lineNew, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
#region ICSNCRDoc
bool isNew = true;
var line = new ICSNCRDoc(); ;
line.ID = AppConfig.GetGuid();
var codes = db.ICSNCRDoc.Where(a => a.SecDocNO == lineNew.SecDocNO);
if (codes.ToList().Count > 0)
{
throw new Exception("此参数类型已存在");
}
// var codesLOT = db.ICSNCRDoc.Where(a => a.SrcDocInfo == lineNew.SrcDocInfo);
// if (codesLOT.ToList().Count > 0)
// {
// throw new Exception("此批号已申请NCR");
// }
line.OPCode = lineNew.OPCode;
line.SecDocNO = lineNew.SecDocNO;
if (string.IsNullOrEmpty(lineNew.SecDocCreateDep))
{
line.SecDocCreateDep = selectDepByUserCode(lineNew.SecDocCreateUser, Appconstr);
}
else
{
line.SecDocCreateDep = lineNew.SecDocCreateDep;
}
line.SecDocCreateTime = lineNew.SecDocCreateTime;
line.SecDocCreateUser = lineNew.SecDocCreateUser;
line.SecDocCreateUserName = lineNew.SecDocCreateUserName;
line.SecDocNO = lineNew.SecDocNO;
line.SecDocOKTime = lineNew.SecDocOKTime;
line.SecDocSeq = lineNew.SecDocSeq;
line.SecDocStatus = lineNew.SecDocStatus;
line.SecDocType = lineNew.SecDocType;
line.SrcDocInfo = lineNew.SrcDocInfo;
line.TimeLimit = lineNew.TimeLimit;
line.ToPostList = lineNew.ToPostList;
line.ToUserList = lineNew.ToUserList;
line.TreatResult = lineNew.TreatResult;
line.TreatWay = lineNew.TreatWay;
line.VendorDesc = lineNew.VendorDesc;
line.VendorState = lineNew.VendorState;
line.DefectType = lineNew.DefectType;
line.BadReason = lineNew.BadReason;
line.CCPostList = lineNew.CCPostList;
line.CCUserList = lineNew.CCUserList;
line.ContentDesc = lineNew.ContentDesc;
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
line.EATTRIBUTE2 = lineNew.EATTRIBUTE2;
line.EATTRIBUTE3 = lineNew.EATTRIBUTE3;
line.EATTRIBUTE4 = lineNew.EATTRIBUTE4;
line.EQPCode = lineNew.EQPCode;
line.ErrorType = lineNew.ErrorType;
line.IsNeedPrevention = lineNew.IsNeedPrevention;
line.TreatCost = lineNew.TreatCost;
line.ItemCode = lineNew.ItemCode;
line.LOTNO = lineNew.LOTNO;
line.OKUserList = lineNew.OKUserList;
line.OPCode = lineNew.OPCode;
line.Urgent = "一般";
line.IsCPIR = lineNew.IsCPIR;
line.CPIRItemType = lineNew.CPIRItemType;
if (string.IsNullOrEmpty(lineNew.Point))
{
line.Point = SelectPoint(line.SrcDocInfo);
}
else
{
line.Point = lineNew.Point;
}
line.Prevention = lineNew.Prevention;
if (!string.IsNullOrEmpty(lineNew.ProjectCode))
{
line.ProjectCode = lineNew.ProjectCode;
}
else
{
if (!string.IsNullOrEmpty(line.SrcDocInfo))
{
string Pro = GetAPSProjectCode(line.SrcDocInfo, Appconstr);//抓取派工表 项目号
if (string.IsNullOrEmpty(Pro))
{
line.ProjectCode = "NA";
}
else
{
line.ProjectCode = Pro;
}
}
else
{
line.ProjectCode = "NA";
}
}
line.Qty = lineNew.Qty;
line.ReadUserList = lineNew.ReadUserList;
line.RealCauseAnalysis = lineNew.RealCauseAnalysis;
line.ReasonDesc = lineNew.ReasonDesc;
line.Rectify = lineNew.Rectify;
line.OPCode = lineNew.OPCode;
if (line.Qty < 1)
{
throw new Exception("NCR数量不能小于1");
}
if (string.IsNullOrEmpty(line.ItemCode) && string.IsNullOrEmpty(line.LOTNO) && string.IsNullOrEmpty(line.ContentDesc) && string.IsNullOrEmpty(line.SrcDocInfo))
{
throw new Exception("无内容,无法申请NCR");
}
line.PZLJMOCode = lineNew.PZLJMOCode;
line.GongShiFei = lineNew.GongShiFei;
line.CaiLiaoFei = lineNew.CaiLiaoFei;
line.IsWX = lineNew.IsWX;
try
{
if (string.IsNullOrEmpty(lineNew.EATTRIBUTE5))
{
//供应商编码
line.EATTRIBUTE5 = GetInvLotFurnaceStrNew(line.SrcDocInfo, Appconstr, "供应商编码");
}
else
{
string Supply_Item = GetInvLotFurnaceStrNew(line.SrcDocInfo, Appconstr, "供应商编码");
if (!string.IsNullOrEmpty(Supply_Item))
{
List<string> SSI = new List<string>(Supply_Item.Split(','));
List<string> SSWX = new List<string>(lineNew.EATTRIBUTE5.Split(','));
List<string> Supply_List = SSI.Union(SSWX).ToList<string>();
line.EATTRIBUTE5 = string.Join(",", Supply_List);
}
else
{
line.EATTRIBUTE5 = lineNew.EATTRIBUTE5;
}
}
}
catch (Exception ex)
{
}
//暂停lot
// ZanTingLot(line.SrcDocInfo, line.OPCode, Appconstr);
line.EATTRIBUTE6 = lineNew.EATTRIBUTE6;
line.EATTRIBUTE7 = lineNew.EATTRIBUTE7;
line.EATTRIBUTE8 = lineNew.EATTRIBUTE8;
line.IsTuiLiao = lineNew.IsTuiLiao;
if (lineNew.NGQty == null)
{
line.NGQty = lineNew.Qty;
}
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew)
db.ICSNCRDoc.InsertOnSubmit(line);
db.SubmitChanges();
#endregion
//#region ICSNCRDocDoDetail
//linedoNew.SecDocID = line.ID;
//linedoNew.SecDocNO = line.SecDocNO;
//linedoNew.SecDocSeq = line.SecDocSeq;
//linedoNew.DoUser = line.SecDocCreateUser;
//linedoNew.DoUserName = line.SecDocCreateUserName;
//linedoNew.DoTIME = line.SecDocCreateTime;
//linedoNew.ReadUsers = "";
//AddandEditICSNCRDocDoDetail(linedoNew, db);
//#endregion
db.Transaction.Commit();
return line.ID;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//public static void AddandEditICSNCRDocDoDetail(ICSNCRDocDoDetail lineNew, FramDataContext db)
//{
// bool isNew = false;
// var line = db.ICSNCRDocDoDetail.SingleOrDefault(a => a.ID == lineNew.ID);
// if (line == null)
// {
// isNew = true;
// line = new ICSNCRDocDoDetail();
// line.ID = AppConfig.GetGuid();
// }
// line.SecDocID = lineNew.SecDocID;
// line.SecDocNO = lineNew.SecDocNO;
// line.SecDocSeq = lineNew.SecDocSeq;
// line.DepCode = lineNew.DepCode;
// line.DoUser = lineNew.DoUser;
// line.DoUserName = lineNew.DoUserName;
// line.DoTIME = lineNew.DoTIME;
// line.ReadUsers = lineNew.ReadUsers;
// line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
// line.MUSER = AppConfig.UserCode;
// line.MUSERName = AppConfig.UserName;
// line.MTIME = DateTime.Now;
// line.WorkPoint = AppConfig.WorkPointCode;
// if (isNew)
// db.ICSNCRDocDoDetail.InsertOnSubmit(line);
// db.SubmitChanges();
//}
public static string AddEditNCR(ICSNCRDoc lineNew, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDoc.SingleOrDefault(a => a.ID == lineNew.ID);
if (line == null)
{
line = new ICSNCRDoc(); ;
line.ID = AppConfig.GetGuid();
}
var codes = db.ICSNCRDoc.Where(a => a.SecDocNO == lineNew.SecDocNO && a.ID != line.ID);
if (codes.ToList().Count > 0)
{
throw new Exception("此参数类型已存在");
}
line.SecDocNO = lineNew.SecDocNO;
if (isNew)
{
if (string.IsNullOrEmpty(lineNew.SecDocCreateDep))
{
line.SecDocCreateDep = selectDepByUserCode(lineNew.SecDocCreateUser, Appconstr);
}
else
{
line.SecDocCreateDep = lineNew.SecDocCreateDep;
}
line.SecDocCreateTime = DateTime.Now;
line.SecDocCreateUser = AppConfig.UserCode;
line.SecDocCreateUserName = AppConfig.UserName;
}
line.SecDocNO = lineNew.SecDocNO;
line.SecDocOKTime = lineNew.SecDocOKTime;
line.SecDocSeq = lineNew.SecDocSeq;
line.SecDocStatus = lineNew.SecDocStatus;
line.SecDocType = lineNew.SecDocType;
line.SrcDocInfo = lineNew.SrcDocInfo;
line.TimeLimit = lineNew.TimeLimit;
line.ToPostList = lineNew.ToPostList;
line.ToUserList = lineNew.ToUserList;
line.TreatResult = lineNew.TreatResult;
line.TreatWay = lineNew.TreatWay;
line.VendorDesc = lineNew.VendorDesc;
line.VendorState = lineNew.VendorState;
line.DefectType = lineNew.DefectType;
line.BadReason = lineNew.BadReason;
line.CCPostList = lineNew.CCPostList;
line.CCUserList = lineNew.CCUserList;
line.ContentDesc = lineNew.ContentDesc;
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
line.EATTRIBUTE2 = lineNew.EATTRIBUTE2;
line.EATTRIBUTE3 = lineNew.EATTRIBUTE3;
line.EATTRIBUTE4 = lineNew.EATTRIBUTE4;
line.EQPCode = lineNew.EQPCode;
line.ErrorType = lineNew.ErrorType;
line.IsNeedPrevention = lineNew.IsNeedPrevention;
line.TreatCost = lineNew.TreatCost;
line.ItemCode = lineNew.ItemCode;
line.LOTNO = lineNew.LOTNO;
line.OKUserList = lineNew.OKUserList;
line.OPCode = lineNew.OPCode;
line.Urgent = lineNew.Urgent;
//line.Partment = lineNew.Partment;
line.CPIRItemType = lineNew.CPIRItemType;
line.IsCPIR = lineNew.IsCPIR;
if (isNew)
{
//部件:物料描述取'-'之前的
//Base_Inventory item = ICSBase_InventoryDAL.select(lineNew.ItemCode, Appconstr);
//if (item != null && string.IsNullOrEmpty(lineNew.Partment))
//{
// string[] desc = item.ItemName.Split('-');
// if (desc != null && desc.Count() > 0)
// {
// line.Partment = desc[0];
// }
// else
// {
// line.Partment = lineNew.Partment;
// }
//}
//else
//{
// line.Partment = lineNew.Partment;
//}
}
else
{
line.Partment = lineNew.Partment;
}
if (isNew && string.IsNullOrEmpty(lineNew.Point))
{
line.Point = SelectPoint(line.SrcDocInfo);
}
else { line.Point = lineNew.Point; }
line.Prevention = lineNew.Prevention;
if (isNew)
{
if (!string.IsNullOrEmpty(lineNew.ProjectCode))
{
line.ProjectCode = lineNew.ProjectCode;
}
else
{
line.ProjectCode = "NA";
}
}
else
{
line.ProjectCode = lineNew.ProjectCode;
}
line.Qty = lineNew.Qty;
line.ReadUserList = lineNew.ReadUserList;
line.RealCauseAnalysis = lineNew.RealCauseAnalysis;
line.ReasonDesc = lineNew.ReasonDesc;
line.Rectify = lineNew.Rectify;
line.ManagerConfirm = lineNew.ManagerConfirm;
//炉号
line.Furnace = lineNew.Furnace;
line.PZLJMOCode = lineNew.PZLJMOCode;
line.GongShiFei = lineNew.GongShiFei;
line.CaiLiaoFei = lineNew.CaiLiaoFei;
line.IsWX = lineNew.IsWX;
line.EATTRIBUTE5 = lineNew.EATTRIBUTE5;
line.EATTRIBUTE6 = lineNew.EATTRIBUTE6;
line.EATTRIBUTE7 = lineNew.EATTRIBUTE7;
line.EATTRIBUTE8 = lineNew.EATTRIBUTE8;
line.IsTuiLiao = lineNew.IsTuiLiao;
line.NGQty = lineNew.NGQty;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew)
db.ICSNCRDoc.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
return line.ID;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void Edit_ICSNCRDocRectifyProcess(ICSNCRDocRectifyProcess Info, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocRectifyProcess.SingleOrDefault(a => a.ID == Info.ID);
if (line == null)
{
return;
}
line.SubmitTime = Info.SubmitTime;
line.SubmitDep = Info.SubmitDep;
line.SubmitPerson = Info.SubmitPerson;
line.SubmitStatus = Info.SubmitStatus;
line.LimitTime = Info.LimitTime;
line.ConfirmStatus = Info.ConfirmStatus;
line.CKStatus = Info.CKStatus;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
if (isNew) db.ICSNCRDocRectifyProcess.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void Edit_ICSNCRDocPreventionProcess(ICSNCRDocPreventionProcess Info, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocPreventionProcess.SingleOrDefault(a => a.ID == Info.ID);
if (line == null)
{
return;
}
line.SubmitTime = Info.SubmitTime;
line.SubmitDep = Info.SubmitDep;
line.SubmitPerson = Info.SubmitPerson;
line.SubmitStatus = Info.SubmitStatus;
line.LimitTime = Info.LimitTime;
line.PendingDepartment = Info.PendingDepartment;
line.ConfirmStatus = Info.ConfirmStatus;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
if (isNew) db.ICSNCRDocPreventionProcess.InsertOnSubmit(line);
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void UpdateRectifyProcessDate(DateTime DD, string SecDocNO, int seq, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocRectifyProcess.SingleOrDefault(a => a.SecDocNO == SecDocNO && a.Seq == seq);
if (line == null)
{
return;
}
line.LimitTime = DD;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void UpdatePreventionProcessDate(DateTime DD, string SecDocNO, int seq, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocPreventionProcess.SingleOrDefault(a => a.SecDocNO == SecDocNO && a.Seq == seq);
if (line == null)
{
return;
}
line.LimitTime = DD;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static ICSNCRDocRectifyBonusPenalty AddEditRectifyBonusPenalty(ICSNCRDocRectifyBonusPenalty info, string dsconn)
{
FramDataContext db = new FramDataContext(dsconn);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
bool isNew = false;
var line = db.ICSNCRDocRectifyBonusPenalty.SingleOrDefault(a => a.ID == info.ID);
if (line == null)
{
isNew = true;
line = new ICSNCRDocRectifyBonusPenalty();
line.ID = AppConfig.GetGuid();
}
var codes = db.ICSNCRDocRectifyBonusPenalty.Where(a => a.SecDocNO == info.SecDocNO &&
a.Type == info.Type && a.ResponsibleDep == info.ResponsibleDep &&
a.ResponsiblePerson == info.ResponsiblePerson && a.ResponsibleAmount == info.ResponsibleAmount &&
a.ID != line.ID);
if (codes.ToList().Count > 0)
{
throw new Exception("已存在纠正奖惩数据");
}
line.SecDocNO = info.SecDocNO;
line.ResponsibleAmount = info.ResponsibleAmount;
line.ResponsibleDep = info.ResponsibleDep;
line.ResponsiblePerson = info.ResponsiblePerson;
line.Type = info.Type;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
line.EATTRIBUTE1 = info.EATTRIBUTE1;
line.EATTRIBUTE2 = info.EATTRIBUTE2;
if (isNew)
{
db.ICSNCRDocRectifyBonusPenalty.InsertOnSubmit(line);
}
db.SubmitChanges();
db.Transaction.Commit();
return (ICSNCRDocRectifyBonusPenalty)line;
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw ex;
}
}
public static void UpdateNCR_ToUserList(string ID, string ToUserList, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.SingleOrDefault(a => a.ID == ID);
if (line == null)
{
throw new Exception("无该NCR数据;");
}
line.ToUserList = ToUserList;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void UpdateNCR_DoPerson(string SecDocNo, string DoPerson, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (DoPerson != "demo")
{
var line = db.ICSNCRDoc.SingleOrDefault(a => a.SecDocNO == SecDocNo);
if (line == null)
{
throw new Exception("无该NCR数据;");
}
if (string.IsNullOrEmpty(line.EATTRIBUTE3) && !line.ToUserList.Contains(DoPerson))
{
if (string.IsNullOrEmpty(line.EATTRIBUTE3))
{
line.EATTRIBUTE3 = DoPerson;
}
else
{
line.EATTRIBUTE3 = line.EATTRIBUTE3 + "," + DoPerson;
}
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
}
db.SubmitChanges();
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//报废 lot
public static void BaoFeiLot(string LotnoList, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (!string.IsNullOrEmpty(LotnoList))
{
string[] lots = LotnoList.Split(',');
for (int i = 0; i < lots.Length; i++)
{
if (!string.IsNullOrEmpty(lots[i]))
{
//var molot = db.ICSMO2Lot.FirstOrDefault(a => a.LOTNO == lots[i]);
//if (molot != null )
//{
// molot.LOTStatus = "报废";
// db.SubmitChanges();
//}
}
}
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//恢复 新增 lot
public static void HuiFuLot(string LotnoList, String Appconstr)
{
List<string> LotList = new List<string>();
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (!string.IsNullOrEmpty(LotnoList))
{
string[] lots = LotnoList.Split(',');
for (int i = 0; i < lots.Length; i++)
{
if (!string.IsNullOrEmpty(lots[i]))
{
//var molot = db.ICSMO2Lot.FirstOrDefault(a => a.LOTNO == lots[i]);
//if (molot != null )
//{
// molot.LOTStatus = "新增";
// db.SubmitChanges();
// LotList.Add(molot.LOTNO);
// // 对应的整机lot也要恢复新增
// string mocode = molot.MOCODE;
// //裸阀工单
// var mo = db.ICSMO.FirstOrDefault(a => a.MOCODE == mocode && a.ITEMCODE.Length == 10 && a.ITEMCODE.Substring(0, 2) == "11");
// if (mo != null && !string.IsNullOrEmpty(mo.ProjectCode))
// {
// //整机工单
// var moZJ = db.ICSMO.Where(a => a.ProjectCode == mo.ProjectCode && a.ITEMCODE.Length == 10 && a.ITEMCODE.Substring(0, 2) == "10");
// if (moZJ != null && moZJ.Count() > 0)
// {
// foreach (ICSMO mm in moZJ)
// {
// string ZJLot = mm.MOCODE + lots[i].Substring(lots[i].Length - 4, 4);
// var ZJLot_entity = db.ICSMO2Lot.SingleOrDefault(a => a.LOTNO == ZJLot);
// if (ZJLot_entity != null)
// {
// ZJLot_entity.LOTStatus = "新增";
// db.SubmitChanges();
// LotList.Add(ZJLot_entity.LOTNO);
// }
// }
// }
// }
//}
}
}
db.Transaction.Commit();
InsertZTLOTLog(LotList, "新增", Appconstr);
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//暂停 lot
public static void ZanTingLot(string LotnoList, string OPCodeList,String Appconstr)
{
List<string> LotList = new List<string>();
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (!string.IsNullOrEmpty(LotnoList))
{
string[] lots = LotnoList.Split(',');
string[] OPs = OPCodeList.Split(',');
for (int i = 0; i < lots.Length; i++)
{
if (!string.IsNullOrEmpty(lots[i]))
{
//var molot = db.ICSMO2Lot.FirstOrDefault(a => a.LotNO == lots[i]);
var molot = db.ICSLOTSIMULATION.FirstOrDefault(a => a.LOTNO == lots[i]&&a.OPCODE==OPs[i]);
//SELECT TOP 10 LOTStatus FROM ICSLOTSIMULATION WHERE LOTNO='' AND OPCODE='';
if (molot != null)
{
molot.LOTStatus = "暂停";
db.SubmitChanges();
LotList.Add(molot.LOTNO);
// 对应的整机lot也要暂停
//string mocode = molot.TransNO;
//裸阀工单
//var mo = db.ICSMO.FirstOrDefault(a => a.MOCODE == mocode && a.ITEMCODE.Length == 10 && a.ITEMCODE.Substring(0, 2) == "11");
//var mo = db.ICSMO.FirstOrDefault(a => a.MOCODE == mocode && a.MOSEQ==molot.TransLine);
//if (mo != null && !string.IsNullOrEmpty(mo.ProjectCode))
//{
// //整机工单
// //var moZJ = db.ICSMO.Where(a => a.ProjectCode == mo.ProjectCode && a.ITEMCODE.Length == 10 && a.ITEMCODE.Substring(0, 2) == "10");
// var moZJ = db.ICSMO.Where(a => a.ProjectCode == mo.ProjectCode && a.ITEMCODE.Length == 10 && a.ITEMCODE.Substring(0, 2) == "10");
// if (moZJ != null && moZJ.Count() > 0)
// {
// foreach (ICSMO mm in moZJ)
// {
// string ZJLot = mm.MOCODE + lots[i].Substring(lots[i].Length - 4, 4);
// //var ZJLot_entity = db.ICSMO2Lot.SingleOrDefault(a => a.LOTNO == ZJLot);
// var ZJLot_entity = db.ICSITEMLot.SingleOrDefault(a => a.LotNO == ZJLot);
// if (ZJLot_entity != null)
// {
// //ZJLot_entity.LOTStatus = "暂停";
// //db.SubmitChanges();
// //LotList.Add(ZJLot_entity.LOTNO);
// }
// }
// }
//}
}
}
}
db.Transaction.Commit();
InsertZTLOTLog(LotList,"暂停",Appconstr);
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
private static void InsertZTLOTLog(List<string> LotList, string Type,string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (LotList != null && LotList.Count > 0)
{
foreach (string lotno in LotList)
{
ICSZanTingLotLog line = new ICSZanTingLotLog();
line.ID = AppConfig.GetGuid();
line.LotNo = lotno;
line.EATTRIBUTE1 = Type;
line.MUSER = AppConfig.UserCode;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
db.ICSZanTingLotLog.InsertOnSubmit(line);
db.SubmitChanges();
}
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//更新是否需要对外单,五大类栏位
public static void UpdateNCR_CPIR(string SecDocNo, string IsCPIR, string ItemType, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.SingleOrDefault(a => a.SecDocNO == SecDocNo);
if (line == null)
{
throw new Exception("无该NCR数据;");
}
line.IsCPIR = IsCPIR;
line.CPIRItemType = ItemType;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void UPDatePZLJMOCode(string MOCode,string SecDocNo, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.SingleOrDefault(a => a.SecDocNO == SecDocNo);
if (line == null)
{
throw new Exception("无该NCR数据;");
}
line.PZLJMOCode = MOCode;
db.SubmitChanges();
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
//lotno 减去NGQTY
public static void SetLotNGQTY(string LotnoList, decimal NGQty, string opcode, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (!string.IsNullOrEmpty(LotnoList))
{
int NG = Convert.ToInt32(Convert.ToDouble(NGQty));
string[] lots = LotnoList.Split(',');
lots = lots.Distinct().ToArray();//去重
for (int i = 0; i < lots.Length; i++)
{
if (!string.IsNullOrEmpty(lots[i]) && lots[i].StartsWith("MO") && !string.IsNullOrEmpty(opcode))
{
var molot = db.ICSLOTSIMULATION.FirstOrDefault(a => a.LOTNO == lots[i]);
if (molot != null)
{
if (molot.GOODQTY >= NG)
{
molot.GOODQTY = molot.GOODQTY - NG;
molot.NGQTY = molot.LOTQTY - molot.GOODQTY;
}
else
{
molot.GOODQTY = 0;
molot.NGQTY = molot.LOTQTY;
}
db.SubmitChanges();
}
string[] oplist = opcode.Split(',');
oplist = oplist.Distinct().ToArray();//去重
for (int j = 0; j < oplist.Count(); j++)
{
string Str_OPCODE = oplist[i];
var mowip = db.ICSLOTONWIP.Where(a => a.LOTNO == lots[i] && a.OPCODE == Str_OPCODE);
if (mowip != null)
{
foreach (ICSLOTONWIP ww in mowip)
{
if (ww.GOODQTY >= NG)
{
ww.GOODQTY = ww.GOODQTY - NG;
ww.NGQTY = (int)ww.LOTQTY - ww.GOODQTY;
}
else
{
ww.GOODQTY = 0;
ww.NGQTY = (int)ww.LOTQTY;
}
}
}
db.SubmitChanges();
}
}
}
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
#endregion
#region 查询
public static ICSNCRDoc select(String ID, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.SingleOrDefault(a => a.ID == ID);
return (ICSNCRDoc)line;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static ICSNCRDoc selectBySrcDocInfo(String SrcDocInfo, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.Where(a => a.SrcDocInfo == SrcDocInfo);
if (line != null && line.Count() > 0)
{
return (ICSNCRDoc)line.First();
}
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static FormICSNCRDataUIModel select_FormICSNCRDataUIModel(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
FormICSNCRDataUIModel model = new FormICSNCRDataUIModel();
model.Entity_ICSNCRDoc = selectBySecDocNO(SecDocNO, Appconstr);
if (model.Entity_ICSNCRDoc != null)
{
model.NCRNumber = model.Entity_ICSNCRDoc.SecDocNO;
}
else
{ model.NCRNumber = ""; }
// model.Entity_DoDetail = selectDoDetailBySecDocNO(SecDocNO, db);
model.Entity_Rectify = SelectRectifyBySecDocNO(SecDocNO, db);
model.Entity_RectifyBonusPenaltylist = SelectRectifyBonusPenaltyBySecDocNO(SecDocNO, db);
model.Entity_RectifyProcesslist = SelectRectifyProcessBySecDocNO(SecDocNO, db);
model.Entity_Prevention = SelectPreventionBySecDocNO(SecDocNO, db);
model.Entity_PreventionProcesslist = SelectPreventionProcessBySecDocNO(SecDocNO, db);
model.Entity_Picturelist = SelectPictureBySecDocNO(SecDocNO, db);
model.PreventionProNamelist = SelectPreventionProName(SecDocNO, Appconstr);
model.RectifyProNamelist = SelectRectifyProName(SecDocNO, Appconstr);
return model;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static ICSNCRDoc selectBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return (ICSNCRDoc)line.First();
else
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static string selectDepByUserCode(String userCode, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
//var Dep = db.ICSUserInfo.SingleOrDefault(a => a.WorkNo == userCode);
//if (Dep != null)
//{
// return Dep.DeptNO;
//}
//else
return "";
}
catch (Exception ex)
{
return "";
}
}
//public static ICSNCRDocDoDetail selectDoDetailBySecDocNO(String SecDocNO, String Appconstr)
//{
// FramDataContext db = new FramDataContext(Appconstr);
// db.Connection.Open();
// db.Transaction = db.Connection.BeginTransaction();
// try
// {
// var line = db.ICSNCRDocDoDetail.Where(a => a.SecDocNO == SecDocNO);
// if (line != null && line.Count() > 0)
// return (ICSNCRDocDoDetail)line.First();
// else
// return null;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
//public static ICSNCRDocDoDetail selectDoDetailBySecDocNO(String SecDocNO, FramDataContext db)
//{
// try
// {
// var line = db.ICSNCRDocDoDetail.Where(a => a.SecDocNO == SecDocNO);
// if (line != null && line.Count() > 0)
// return (ICSNCRDocDoDetail)line.First();
// else
// return null;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
public static ICSNCRDocRectify SelectRectifyBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocRectify.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return (ICSNCRDocRectify)line.First();
else
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static ICSNCRDocRectify SelectRectifyBySecDocNO(String SecDocNO, FramDataContext db)
{
try
{
var line = db.ICSNCRDocRectify.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return (ICSNCRDocRectify)line.First();
else
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<NCRDocRectifyProcessModel> SelectRectifyProcessBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<NCRDocRectifyProcessModel> entitylist = new List<NCRDocRectifyProcessModel>();
try
{
var line = db.ICSNCRDocRectifyProcess.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.Seq);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRDocRectifyProcessModel Model = new NCRDocRectifyProcessModel();
Model.Entity_RectifyProcess = (ICSNCRDocRectifyProcess)item;
string User = "";
var vv = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == Model.Entity_RectifyProcess.ProcessName);
if (vv != null)
{
User = vv.Define1 + "," + vv.Define5;
}
Model.RectifyUser = User;
entitylist.Add(Model);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<NCRDocRectifyProcessModel> SelectRectifyProcessBySecDocNO(String SecDocNO, FramDataContext db)
{
List<NCRDocRectifyProcessModel> entitylist = new List<NCRDocRectifyProcessModel>();
try
{
var line = db.ICSNCRDocRectifyProcess.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.Seq);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRDocRectifyProcessModel Model = new NCRDocRectifyProcessModel();
Model.Entity_RectifyProcess = (ICSNCRDocRectifyProcess)item;
string User = "";
var vv = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == Model.Entity_RectifyProcess.ProcessName);
if (vv != null)
{
User = vv.Define1 + "," + vv.Define5;
}
Model.RectifyUser = User;
entitylist.Add(Model);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<ICSNCRDocRectifyBonusPenalty> SelectRectifyBonusPenaltyBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<ICSNCRDocRectifyBonusPenalty> entitylist = new List<ICSNCRDocRectifyBonusPenalty>();
try
{
var line = db.ICSNCRDocRectifyBonusPenalty.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.MTIME);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
entitylist.Add((ICSNCRDocRectifyBonusPenalty)item);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<ICSNCRDocRectifyBonusPenalty> SelectRectifyBonusPenaltyBySecDocNO(String SecDocNO, FramDataContext db)
{
List<ICSNCRDocRectifyBonusPenalty> entitylist = new List<ICSNCRDocRectifyBonusPenalty>();
try
{
var line = db.ICSNCRDocRectifyBonusPenalty.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.MTIME);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
entitylist.Add((ICSNCRDocRectifyBonusPenalty)item);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static ICSNCRDocPrevention SelectPreventionBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocPrevention.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return (ICSNCRDocPrevention)line.First();
else
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static ICSNCRDocPrevention SelectPreventionBySecDocNO(String SecDocNO, FramDataContext db)
{
try
{
var line = db.ICSNCRDocPrevention.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return (ICSNCRDocPrevention)line.First();
else
return null;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<NCRDocPreventionProcessModel> SelectPreventionProcessBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<NCRDocPreventionProcessModel> entitylist = new List<NCRDocPreventionProcessModel>();
try
{
var line = db.ICSNCRDocPreventionProcess.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.Seq);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRDocPreventionProcessModel Model = new NCRDocPreventionProcessModel();
Model.Entity_PreventionProcess = (ICSNCRDocPreventionProcess)item;
string user = "";
var vv = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == Model.Entity_PreventionProcess.ProcessName);
if (vv != null)
{
user = vv.Define1 + "," + vv.Define5;
}
Model.PreventionUser = user;
entitylist.Add(Model);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<NCRDocPreventionProcessModel> SelectPreventionProcessBySecDocNO(String SecDocNO, FramDataContext db)
{
List<NCRDocPreventionProcessModel> entitylist = new List<NCRDocPreventionProcessModel>();
try
{
var line = db.ICSNCRDocPreventionProcess.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.Seq);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRDocPreventionProcessModel Model = new NCRDocPreventionProcessModel();
Model.Entity_PreventionProcess = (ICSNCRDocPreventionProcess)item;
string user = "";
var vv = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == Model.Entity_PreventionProcess.ProcessName);
if (vv != null)
{
user = vv.Define1 + "," + vv.Define5;
}
Model.PreventionUser = user;
entitylist.Add(Model);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<ICSNCRDocPicture> SelectPictureBySecDocNO(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<ICSNCRDocPicture> entitylist = new List<ICSNCRDocPicture>();
try
{
var line = db.ICSNCRDocPicture.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.MTIME);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
entitylist.Add((ICSNCRDocPicture)item);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<ICSNCRDocPicture> SelectPictureBySecDocNO(String SecDocNO, FramDataContext db)
{
List<ICSNCRDocPicture> entitylist = new List<ICSNCRDocPicture>();
try
{
var line = db.ICSNCRDocPicture.Where(a => a.SecDocNO == SecDocNO).OrderBy(a => a.MTIME);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
entitylist.Add((ICSNCRDocPicture)item);
}
return entitylist;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsExistRectifyLog(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocRectifyProcessLog.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return true;
else
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsExistPreventionLog(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocPreventionProcessLog.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
return true;
else
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsOPBefore(String LotNo, String OP, String OP_CURRENT, String Appconstr)
{
try
{
string sql = @"SELECT mo.ITEMCODE, lot.LOTQTY ,OP.OPSEQ OPSEQ,OP2.OPSEQ OP_C_SEQ
FROM ICSMO2Lot lot Left Join ICSMO mo on lot.MoCode = mo.MoCode
left join ICSMO2ROUTE route on mo.mocode=route.mocode
left join icsitemroute2op op on route.ROUTECODE=op.routecode and op.itemcode=mo.itemcode and op.opcode='{1}'
left join icsitemroute2op op2 on route.ROUTECODE=op2.routecode and op2.itemcode=mo.itemcode and op2.opcode='{2}'
WHERE LOT.LOTNO='{0}'
";
sql = string.Format(sql, LotNo, OP, OP_CURRENT);
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(dt.Rows[0]["OPSEQ"].ToString()) && !string.IsNullOrEmpty(dt.Rows[0]["OP_C_SEQ"].ToString()))
{
if (dt.Rows[0]["ITEMCODE"].ToString().Substring(0, 2) == "11")
{
int seq = Convert.ToInt32(dt.Rows[0]["OPSEQ"].ToString());
int seq_c = Convert.ToInt32(dt.Rows[0]["OP_C_SEQ"].ToString());
if (seq >= seq_c)
{
return true;
}
}
}
}
return false;
}
catch (Exception ex)
{
return false;
}
}
public static String QualityEngineer(string type, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
string usercode = "";
List<string> Users = new List<string>();
var line = db.Sys_EnumValues.Where(a => a.EnumKey == "083" && a.EnumValue == type && a.StartFlag == true);
if (line != null && line.Count() > 0)
{
foreach (Sys_EnumValues item in line)
{
if (!(Users.Contains(item.EnumText)))
{
Users.Add(item.EnumText);
}
}
for (int j = 0; j < Users.Count; j++)
{
usercode += Users[j] + ",";
}
usercode = usercode.TrimEnd(',');
return usercode;
}
else
return "";
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsConfirmAllRectify(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocRectifyProcess.Where(a => a.SecDocNO == SecDocNO).OrderByDescending(a => a.Seq);
if (line != null && line.Count() > 0)
{
string confirmStatus = line.FirstOrDefault().ConfirmStatus;
if (confirmStatus == "关闭")
{
return true;
}
else
{ return false; }
}
else { return false; }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsSubmitAllRectify(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDocRectifyProcess.Where(a => a.SecDocNO == SecDocNO).OrderByDescending(a => a.Seq);
if (line != null && line.Count() > 0)
{
string SubmitStatus = line.FirstOrDefault().SubmitStatus;
if (SubmitStatus == "已提交")
{
return true;
}
else
{ return false; }
}
else { return false; }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsConfirmAllPrevention(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
ICSNCRDoc SecDoc = selectBySecDocNO(SecDocNO, Appconstr);
if (SecDoc != null && SecDoc.IsNeedPrevention == "是")
{
var line = db.ICSNCRDocPreventionProcess.Where(a => a.SecDocNO == SecDocNO).OrderByDescending(a => a.Seq);
if (line != null && line.Count() > 0)
{
string confirmStatus = line.FirstOrDefault().ConfirmStatus;
if (confirmStatus == "同意关闭")
{
return true;
}
}
}
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static bool IsSubmitAllPrevention(String SecDocNO, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
ICSNCRDoc SecDoc = selectBySecDocNO(SecDocNO, Appconstr);
if (SecDoc != null && SecDoc.IsNeedPrevention == "是")
{
var line = db.ICSNCRDocPreventionProcess.Where(a => a.SecDocNO == SecDocNO).OrderByDescending(a => a.Seq);
if (line != null && line.Count() > 0)
{
string SubmitStatus = line.FirstOrDefault().SubmitStatus;
if (SubmitStatus == "已提交")
{
return true;
}
}
}
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static List<Sys_EnumValues> SelectRoute(String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<Sys_EnumValues> list = new List<Sys_EnumValues>();
try
{
var line = db.Sys_EnumValues.Where(a => a.EnumKey == "076").OrderBy(a => a.Define2);
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
list.Add((Sys_EnumValues)item);
}
return list;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static Sys_EnumValues SelectPreventionMail(List<NCRDocPreventionProcessModel> list, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (list != null && list.Count() > 0)
{
foreach (NCRDocPreventionProcessModel item in list)
{
if (string.IsNullOrEmpty(item.Entity_PreventionProcess.SubmitStatus))
{
var line = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == item.Entity_PreventionProcess.ProcessName);
if (line != null)
{ return line; }
}
}
return null;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static Sys_EnumValues SelectRectifyMail(List<NCRDocRectifyProcessModel> list, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (list != null && list.Count() > 0)
{
foreach (NCRDocRectifyProcessModel item in list)
{
if (string.IsNullOrEmpty(item.Entity_RectifyProcess.SubmitStatus))
{
var line = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == item.Entity_RectifyProcess.ProcessName);
if (line != null)
{ return line; }
}
}
return null;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static Sys_EnumValues SelectPreventionMail_Final(String ProcessName, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == ProcessName);
if (line != null)
{ return line; }
}
catch (Exception ex)
{
return null;
}
return null;
}
public static Sys_EnumValues SelectRectifyMail_Final(String ProcessName, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_EnumValues.SingleOrDefault(a => a.EnumKey == "076" && a.EnumText == ProcessName);
if (line != null)
{ return line; }
}
catch (Exception ex)
{
return null;
}
return null;
}
public static string SelectPoint(string Lotno)
{
string Point = "";
try
{
if (Lotno.Substring(0, 2) == "MO")
{
string sql = @" select EQP.Address from ICSLOTSIMULATION lots
left join ICSEquipment EQP on lots.EQPCODE=EQP.EQPCODE
where lotno = '" + Lotno + "' ";
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
Point = dt.Rows[0]["Address"].ToString();
}
}
else
{
string sql = @" select b.RcvLineSrcPOSrcDocNo
from dbo.WM_BarCode a
left join WM_RCVShip b on a.RCVShipguid=b.guid
where a.BarCodeNo ='" + Lotno + "' ";
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
Point = dt.Rows[0]["RcvLineSrcPOSrcDocNo"].ToString();
}
}
return Point;
}
catch (Exception ex)
{
return "";
}
}
public static string GetQualityEngineerType(string DocTypeID, string OPCode, string itemcode, string LOTNO, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSSecDocType.SingleOrDefault(a => a.guid == DocTypeID);
if (line != null)
{
if (line.DocTypeCode.Contains("JJ"))
{
return "机加";
}
if (line.DocTypeCode.Contains("ZP"))
{
if (itemcode.Substring(0, 2) == "11")
{
if (!string.IsNullOrEmpty(LOTNO) && !string.IsNullOrEmpty(OPCode))
{
if (ICSNCRDocDAL.IsOPBefore(LOTNO, "SY", OPCode, Appconstr))
{
return "阀门试压工序前";
}
else
{ return "阀门试压工序后"; }
}
else
{
return "装配";
}
}
else
{
return "阀门试压工序后";
}
}
if (line.DocTypeCode.Contains("CK"))
{
return "仓库";
}
}
return "";
}
catch (Exception ex)
{
return "";
}
}
public static List<String> SelectPreventionProName(String SecDocNO, String Appconstr)
{
try
{
List<string> namelist = new List<string>();
string sql = @" SELECT VV.Define1 name
from ICSNCRDocPreventionProcess pro
inner join Sys_EnumValues vv on pro.ProcessName=vv.EnumText and EnumKey='076'
where 1=1
and pro.SecDocNO='{0}'
and VV.Define1!=''
union
SELECT VV.Define5 name
from ICSNCRDocPreventionProcess pro
inner join Sys_EnumValues vv on pro.ProcessName=vv.EnumText and EnumKey='076'
where 1=1
and pro.SecDocNO='{0}'
and VV.Define5!='' ";
sql = string.Format(sql, SecDocNO);
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
namelist.Add(dr["name"].ToString());
}
return namelist;
}
return null;
}
catch (Exception ex)
{
return null;
}
}
public static List<String> SelectRectifyProName(String SecDocNO, String Appconstr)
{
try
{
List<string> namelist = new List<string>();
string sql = @" SELECT VV.Define1 name
from ICSNCRDocRectifyProcess pro
inner join Sys_EnumValues vv on pro.ProcessName=vv.EnumText and EnumKey='076'
where 1=1
and pro.SecDocNO='{0}'
and VV.Define1!=''
union
SELECT VV.Define5 name
from ICSNCRDocRectifyProcess pro
inner join Sys_EnumValues vv on pro.ProcessName=vv.EnumText and EnumKey='076'
where 1=1
and pro.SecDocNO='{0}'
and VV.Define5!='' ";
sql = string.Format(sql, SecDocNO);
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
namelist.Add(dr["name"].ToString());
}
return namelist;
}
return null;
}
catch (Exception ex)
{
return null;
}
}
public static DataTable GetReCheck(string LotList, DateTime Mtime, String Appconstr)
{
try
{
string Str_Where = "";
if (!string.IsNullOrEmpty(LotList))
{
LotList = LotList.Replace(",", "','");
}
else
{
throw new Exception("无Lot");
}
if (Mtime != null)
{
Str_Where += @" and ckDateTime >'" + Mtime.ToString("yyyy-MM-dd HH:mm:ss") + @"' ";
}
Str_Where += @" and LOTNO in ('" + LotList + @"') ";
string sql = @"
DECLARE @WG NVARCHAR ( 20 ),@CJ NVARCHAR ( 20 )
SET @WG = '{0}'
SET @CJ = '{1}'
select result.*
,case when ISNULL( Result ,'')='' then (cast(DATEDIFF(mi, GETDATE(), DATEADD( hh, 4, MTIME )) /60 as NVARCHAR) +':'+
RIGHT('00'+CAST(ABS(DATEDIFF(mi, GETDATE(), DATEADD( hh, 4, MTIME )) %60 )AS nvarchar(50) ),2) ) else '' end remainingTime,'' AS participant from (
SELECT DISTINCT CAST
( 0 AS BIT ) AS isSelect,c.ID,
a.LOTNO,
a.LOTSEQ,
a.MOCODE,
d.ProjectCode,
e.ItemCode,
e.ItemName,
e.ItemStd,
b.MTIME,
f.[Address],
CASE
c.CKResult
WHEN '1' THEN
'合格'
WHEN '0' THEN
'不合格'
END AS Result,
CASE
WHEN c.LOTNO IS NOT NULL THEN
@WG ELSE @CJ
END AS Status,
a.LOTQTY ,ck.EATTRIBUTE1 AS ISOk
--,h.SecDocNO,h.ID SecDocID,g.DocTypeCode,h.SecDocSeq,g.DocTypePath
,CASE WHEN c.CKResult='1' THEN null else ISNULL(ff.SecDocNo, h.SecDocNO) end SecDocNO
,ISNULL(ff.ID, h.ID) SecDocID,ISNULL(gg.DocTypeCode, g.DocTypeCode) DocTypeCode
,ISNULL(ff.SecDocSeq, h.SecDocSeq) SecDocSeq,ISNULL(gg.DocTypePath, g.DocTypePath) DocTypePath
,case when ff.SecDocNo is not null and ff.SecDocNo!='' then '1' when h.SecDocNo is not null and h.SecDocNo!='' then '0' else '' end SecDocNoTrue
--,case when c.LOTNO IS NULL then '{2}' ELSE c.EATTRIBUTE3 END AS participant
-- ,isnull((case when ISNULL( c.LOTNO ,'')!='' then c.EATTRIBUTE3 WHEN val.Define4='N' THEN '{2}' ELSE '' END),'') AS participant
,'' RcvLineInvLotFurnace
,c.mtime ckDateTime
FROM
ICSMO2Lot a
INNER JOIN ICSLOTSIMULATION b ON a.LOTNO= b.LOTNO
LEFT JOIN ICSEquipment f ON b.EQPCODE = f.EQPCode
LEFT JOIN ( SELECT * FROM ICSQualityCKDATA WHERE Type = '制程' ) c ON a.LOTNO= c.LOTNO
LEFT JOIN ICSMO d ON a.MOCODE= d.MOCODE
LEFT JOIN Base_Inventory e ON d.ITEMCODE= e.ITEMCODE
LEFT JOIN ICSQualityCKDATA ck ON a.MOCODE = ck.MOCODE AND a.LOTNO=ck.LOTNO AND ck.EATTRIBUTE1='放行'
LEFT JOIN (select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc) rowId,*
from ICSSecDoc ck ) as AuctionRecords
where rowId=1) h ON a.LOTNO=h.LOTNO
left join ICSSecDocType g on h.SecDocType = g.guid
LEFT JOIN (select * from (select ROW_NUMBER()over(partition by SrcDocInfo order by mtime desc) rowId,*
from ICSNCRDoc ck --where ck.NCR.SecDocCreateTime>='2020-03-30 00:00:00'
) as AuctionRecords
where rowId=1) ff ON CHARINDEX ( a.lotno , ff.SrcDocInfo )>0
left join ICSSecDocType gg on ff.SecDocType = gg.guid
-- left join Sys_EnumValues val ON EnumKey='082' AND EnumText='{3}' AND Define2='制程'
WHERE 1=1
--b.MTIME >= dateadd(day,-30,GETDATE())
AND b.IsCom= 1
AND ( e.ItemCode LIKE '12%' OR e.ItemCode LIKE '13%' OR e.ItemCode LIKE '16%' OR e.ItemCode LIKE '14%' )
AND (
e.ItemCode NOT LIKE '1222%'
AND e.ItemCode NOT LIKE '1233%'
AND e.ItemCode NOT LIKE '1232%'
AND e.ItemCode NOT LIKE '1231%'
and e.ItemCode NOT LIKE '1223%'
and e.ItemCode NOT LIKE '1248%'
) and (e.ItemName NOT LIKE '%备品%' and e.ItemName NOT LIKE '%备件%')
union all
SELECT distinct
CAST( 0 AS BIT ) AS isSelect,c.ID,
a.LOTNO,
a.LOTSEQ,
a.MOCODE,
b.ProjectCode,
d.ItemCode,
d.ItemName,
d.ItemStd,
a.MTIME,
q.[Address],
CASE
k.CKResult
WHEN '1' THEN
'合格'
WHEN '0' THEN
'不合格'
END AS Result,
CASE
WHEN k.LOTNO IS NOT NULL THEN
@WG ELSE @CJ
END AS Status,
a.LOTQTY ,ck.EATTRIBUTE1 AS ISOk
--,h.SecDocNO,h.ID SecDocID,g.DocTypeCode,h.SecDocSeq,g.DocTypePath
,ISNULL(ff.SecDocNo, h.SecDocNO) SecDocNO,ISNULL(ff.ID, h.ID) SecDocID,ISNULL(gg.DocTypeCode, g.DocTypeCode) DocTypeCode
,ISNULL(ff.SecDocSeq, h.SecDocSeq) SecDocSeq,ISNULL(gg.DocTypePath, g.DocTypePath) DocTypePath
,case when ff.SecDocNo is not null and ff.SecDocNo!='' then '1' when h.SecDocNo is not null and h.SecDocNo!='' then '0' else '' end SecDocNoTrue
--,case when k.LOTNO IS NULL then '{2}' ELSE k.EATTRIBUTE3 END AS participant
-- ,isnull((case when ISNULL( k.LOTNO ,'')!='' then k.EATTRIBUTE3 WHEN val.Define4='N' THEN '{2}' ELSE '' END),'') AS participant
,'' RcvLineInvLotFurnace
,k.mtime ckDateTime
FROM
ICSLOTSIMULATION a
LEFT JOIN ICSMO b ON a.MOCODE = b.MOCODE
LEFT JOIN ICSROUTE c ON a.ROUTECODE = c.ROUTECODE
LEFT JOIN Base_Inventory d ON a.ITEMCODE = d.ITEMCODE
LEFT JOIN ( SELECT ITEMCODE,ROUTECODE,OPCODE,OPSEQ FROM ICSITEMROUTE2OP) e ON e.ITEMCODE = a.ITEMCODE
AND e.ROUTECODE = a.ROUTECODE
AND e.OPSEQ = (SELECT MIN(OPSEQ) FROM ICSITEMROUTE2OP WHERE ITEMCODE = a.ITEMCODE AND ROUTECODE = a.ROUTECODE
AND OPSEQ > (SELECT OPSEQ FROM ICSITEMROUTE2OP WHERE ITEMCODE = a.ITEMCODE AND ROUTECODE = a.ROUTECODE AND OPCODE = a.OPCODE))
LEFT JOIN ICSOP f ON a.OPCODE = f.OPCODE
LEFT JOIN ICSEquipment q ON a.EQPCODE = q.EQPCode
LEFT JOIN ( SELECT * FROM ICSQualityCKDATA WHERE Type = '制程' ) k ON k.LOTNO= a.LOTNO
LEFT JOIN ICSQualityCKDATA ck ON a.MOCODE = ck.MOCODE AND a.LOTNO=ck.LOTNO AND ck.EATTRIBUTE1='放行'
LEFT JOIN (select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc) rowId,*
from ICSSecDoc ck ) as AuctionRecords
where rowId=1) h ON a.LOTNO=h.LOTNO
left join ICSSecDocType g on h.SecDocType = g.guid
LEFT JOIN (select * from (select ROW_NUMBER()over(partition by SrcDocInfo order by mtime desc) rowId,*
from ICSNCRDoc ck --where ck.NCR.SecDocCreateTime>='2020-03-30 00:00:00'
) as AuctionRecords
where rowId=1) ff ON CHARINDEX ( a.lotno , ff.SrcDocInfo )>0
left join ICSSecDocType gg on ff.SecDocType = gg.guid
-- left join Sys_EnumValues val ON EnumKey='082' AND EnumText='{3}' AND Define2='制程'
where a.CollectStatus = 'COLLECT_END' AND e.OPCODE = 'DB' AND a.ISCOM <> 1 --And a.mtime >= dateadd(day,-30,GETDATE())
and (d.ItemName NOT LIKE '%备品%' AND d.ItemName NOT LIKE '%备件%') --And a.mtime >= dateadd(day,-30,GETDATE())
and e.ItemCode NOT LIKE '1223%'
and e.ItemCode NOT LIKE '1248%'
) result where 1=1 ";
sql += Str_Where + @" ORDER BY Status,result.MTIME ASC";
sql = string.Format(sql, "已检验", "未检验", "", "");
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static string GetCustomerCode(string RCVNO, String Appconstr)
{
try
{
string sql = @" select top 1 RcvSupplierCode from WM_RCVShip where rcvdocno ='" + RCVNO + "' ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
else
{
return "";
}
}
catch (Exception ex)
{
return "";
}
}
public static Sys_EnumValues SelectToUserListMail(String ToUserList, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_EnumValues.Where(a => a.EnumKey == "083" && a.EnumText == ToUserList);
if (line != null && line.Count() > 0)
{ return (Sys_EnumValues)line.First(); }
}
catch (Exception ex)
{
return null;
}
return null;
}
public static Sys_EnumValues SelectMailCopy(String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_EnumValues.Where(a => a.EnumKey == "083" && a.EnumValue == "NCR邮件推送人");
if (line != null && line.Count() > 0)
{ return (Sys_EnumValues)line.First(); }
}
catch (Exception ex)
{
return null;
}
return null;
}
public static Sys_EnumValues SelectSetDatePersonListMail(String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_EnumValues.Where(a => a.EnumKey == "083" && a.EnumValue == "设置时间");
if (line != null && line.Count() > 0)
{ return (Sys_EnumValues)line.First(); }
}
catch (Exception ex)
{
return null;
}
return null;
}
public static string selectTypeByEQPCode(string EQPCode, String Appconstr)
{
try
{
string sql = @" select Top 1 Define2 from Sys_EnumValues where enumkey='082' and EnumText!='demo' and Define1='" + EQPCode + "' ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
else
{
return "";
}
}
catch (Exception ex)
{
return "";
}
}
public static DataTable GetUserList(String Appconstr)
{
try
{
string sql = @"
select distinct ename 人员 from ICSUserInfo
--select distinct deptno from ICSUserInfo where deptno!=''
";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static DataTable GetUserDepList(String Appconstr)
{
try
{
string sql = @" select * from(select distinct deptno 部门 from ICSUserInfo where deptno!='' union select 'N/A' ) dd order by 1 ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static DataTable GetUserGHList(String Appconstr)
{
try
{
string sql = @"
select * from(
select distinct workno 工号, ename 姓名 ,deptno 部门 from ICSUserInfo
union select 'N/A','N/A','N/A'
) dd
order by 1
";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static bool IsLastOP(String LotNo, string OPcode, String Appconstr)
{
try
{
string sql = @"
SELECT top 1 a.LOTNO,k.opcode,opseq
FROM ICSMO2Lot a
LEFT JOIN ICSMO d ON a.MOCODE=d.MOCODE
LEFT JOIN ICSMO2Route e ON d.MOCODE=e.MOCODE
left join ICSITEMROUTE2OP k on k.ItemCode = d.ItemCode ANd k.ROUTECODE = e.RouteCode
WHERE a.LOTNO='" + LotNo + @"' order by opseq desc
";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
if (dt.Rows[0]["opcode"].ToString() == OPcode)
{ return true; }
}
return false;
}
catch (Exception ex)
{
return false;
}
}
public static string WXOpcodeCK(String LotNo, string OPcode, String Appconstr)
{
try
{
string sqlPR = string.Format(@"SELECT a.*
FROM ICSCreatePR a
INNER JOIN (SELECT TOP 1 a.MOCODE,a.LOTNO,k.opcode,opseq
FROM ICSMO2Lot a
LEFT JOIN ICSMO d ON a.MOCODE=d.MOCODE
LEFT JOIN ICSMO2Route e ON d.MOCODE=e.MOCODE
left join ICSITEMROUTE2OP k on k.ItemCode = d.ItemCode ANd k.ROUTECODE = e.RouteCode
LEFT JOIN ICSLOTSIMULATION f ON f.LOTNO= a.LOTNO AND k.opcode=f.OPCODE
WHERE a.LOTNO='{0}'
AND OPSEQ>( SELECT OPSEQ FROM ICSITEMROUTE2OP
WHERE ItemCode = d.ItemCode ANd ROUTECODE = e.RouteCode AND OPCODE='{1}')
order by opseq) b ON a.ProductDocNo=b.MOCODE AND a.opcode=b.opcode", LotNo, OPcode);
DataTable dtPR = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sqlPR).Tables[0];
if (dtPR != null && dtPR.Rows.Count > 0)
{
return dtPR.Rows[0]["OPCode"].ToString();
}
return "";
}
catch (Exception ex)
{
return "";
}
}
public static DataTable GetToUserList(String Appconstr)
{
try
{
string sql = @"
SELECT DISTINCT ToUserList 编码,UU.USERNAME 名称 FROM ICSNCRDoc NN
LEFT JOIN SYS_USER UU ON NN.ToUserList=UU.USERCODE
WHERE ISNULL(ToUserList,'')!=''
UNION SELECT '',''
order by 1,2
";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
public static string IsCurrentDoPersonORToUserList(String SecDocNO, string CurrentUser, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.ICSNCRDoc.Where(a => a.SecDocNO == SecDocNO);
if (line != null && line.Count() > 0)
{
foreach (ICSNCRDoc item in line)
{
string ToUserist = item.ToUserList;
if (ToUserist.Contains(CurrentUser) || (!string.IsNullOrEmpty(item.EATTRIBUTE3) && item.EATTRIBUTE3.Contains(CurrentUser)))
{
return "";
}
else
{
//if (!string.IsNullOrEmpty(item.EATTRIBUTE3))
//{
// var line2 = db.Sys_User.Where(a => a.UserCode == item.EATTRIBUTE3);
// if (line2 != null && line2.Count() > 0)
// {
// return SecDocNO + "当前处理人是:" + line2.First().UserName + ",当前账号不能处理。";
// }
// else
// {
// return SecDocNO + "当前处理人账号是:" + item.EATTRIBUTE3 + ",当前账号不能处理。";
// }
//}
//else
//{
// return "OK";
//}
return "OK";
}
}
}
}
catch (Exception ex)
{
return "";
}
return "";
}
public static string GetCanYuRenList(String Appconstr)
{
try
{
string sql = @" select isnull(EnumText,'') CanYuRen from Sys_EnumValues where EnumKey ='083' and EnumValue='参与人' ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
else
{
return "";
}
}
catch (Exception ex)
{
return "";
}
}
public static string GetAPSProjectCode(string Lotno, String Appconstr)
{
try
{
string sql = @" select 子项目号 from [10.29.1.129].[aps_middb].dbo.peg_result_all_by_column
inner join icsmo mo on isnull(供应号,'')=mo.mocode
inner join icsmo2lot lot on lot.mocode=mo.mocode
WHERE 供应号 is not null
and CHARINDEX(lot.lotno,'" + Lotno + @"' )!=0 ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
else
{
return "";
}
}
catch (Exception ex)
{
return "";
}
}
public static List<NCR_SupplyModel> GetNCR_GongYingShang(String SecDocNO, List<string> TypeList, NCRCPIRModel CPIR, String Appconstr)
{
try
{
List<string> GYS = new List<string>();
List<NCR_SupplyModel> GYSModel = new List<NCR_SupplyModel>();
//10 11 料开头的
if (!string.IsNullOrEmpty(CPIR.ItemCode) &&
(CPIR.ItemCode.Substring(0, 2) == "10" || CPIR.ItemCode.Substring(0, 2) == "11"))
{
//1、抓取上料表
string SLItemsql = "";
if (TypeList != null && TypeList.Count > 0)
{
SLItemsql = " and ( 1=2 ";
foreach (string item in TypeList)
{
switch (item)
{
case "阀体": SLItemsql += " or a.INVCODE like '130101%' "; break;
case "阀帽": SLItemsql += " or a.INVCODE like '130102%' "; break;
case "球座组件": SLItemsql += " or a.INVCODE like '1249%' "; break;
case "阀杆": SLItemsql += " or a.INVCODE like '130402%' "; break;
case "螺柱": SLItemsql += " or a.INVCODE like '140402%' "; break;
case "螺母": SLItemsql += " or a.INVCODE like '140403%' "; break;
default: SLItemsql += " or a.INVCODE like '" + item + "%' "; break;
}
}
SLItemsql += " ) ";
}
string lotno = CPIR.SrcDocInfo;
lotno = lotno.Replace(",", "','");
string sqlSL = @" SELECT DISTINCT
RcvSupplierCode AS 供应商编码,
supp.name 供应商名称,
rcv.RcvLineSrcPOSrcDocNo as 采购单号,
rcv.RcvLineSrcPOSrcDocLineNo as 采购单行号
FROM ICSMO mo
left join ICSLOTONWIPITEM a on mo.MoCode = a.MoCode
LEFT JOIN Base_Inventory b ON a.ITEMCODE = b.ItemCode
LEFT JOIN Base_Inventory c ON a.INVCODE = c.ItemCode
LEFT JOIN ICSROUTE d ON a.ROUTECODE = d.ROUTECODE
LEFT JOIN ICSOP e ON a.OPCODE = e.OPCODE
LEFT JOIN WM_BarCode bar ON bar.BarCodeNo=a.INVLOTNO --AND a.INVLOTNO LIKE 'RCV%'
LEFT JOIN WM_InitialInvtory Invtory ON Invtory.guid=bar.Srcguid
LEFT JOIN WM_RCVShip rcv ON bar.RCVShipguid=rcv.guid
LEFT JOIN [10.29.1.115].[ATW].dbo.[CBO_Project] project(NOLOCK) ON project.Code=mo.ProjectCode
LEFT JOIN [10.29.1.115].[ATW].dbo.SM_SOLine SOLine ON soline.Project = project.ID
AND soline.DescFlexField_PrivateDescSeg17 is NOT NULL and soline.DescFlexField_PrivateDescSeg17!=''
left join (select ss.Code,ss_t.name from [10.29.1.115].[ATW].dbo.CBO_Supplier ss
left join [10.29.1.115].[ATW].dbo.CBO_Supplier_Trl ss_t on ss.id=ss_t.id ) supp on supp.code=RcvSupplierCode
where 1=1 And a.LOTNO <>''
and (a.INVLOTNO in ('{0}') OR a.LOTNO in ('{0}'))
{1}
UNION
SELECT DISTINCT
RcvSupplierCode AS 供应商编码,
supp.name 供应商名称,
rcv.RcvLineSrcPOSrcDocNo as 采购单号,
rcv.RcvLineSrcPOSrcDocLineNo as 采购单行号
FROM ICSMO mo
INNER join ICSLOTONWIPITEMHistory a on mo.MoCode = a.MoCode
LEFT JOIN Base_Inventory b ON a.ITEMCODE = b.ItemCode
LEFT JOIN Base_Inventory c ON a.INVCODE = c.ItemCode
LEFT JOIN ICSROUTE d ON a.ROUTECODE = d.ROUTECODE
LEFT JOIN ICSOP e ON a.OPCODE = e.OPCODE
LEFT JOIN WM_BarCode bar ON bar.BarCodeNo=a.INVLOTNO --AND a.INVLOTNO LIKE 'RCV%'
LEFT JOIN WM_InitialInvtory Invtory ON Invtory.guid=bar.Srcguid
LEFT JOIN WM_RCVShip rcv ON bar.RCVShipguid=rcv.guid
LEFT JOIN [10.29.1.115].[ATW].dbo.[CBO_Project] project(NOLOCK) ON project.Code=mo.ProjectCode
LEFT JOIN [10.29.1.115].[ATW].dbo.SM_SOLine SOLine ON soline.Project = project.ID
AND soline.DescFlexField_PrivateDescSeg17 is NOT NULL and soline.DescFlexField_PrivateDescSeg17!=''
left join (select ss.Code,ss_t.name from [10.29.1.115].[ATW].dbo.CBO_Supplier ss
left join [10.29.1.115].[ATW].dbo.CBO_Supplier_Trl ss_t on ss.id=ss_t.id ) supp on supp.code=RcvSupplierCode
where 1=1 And a.LOTNO <>''
and (a.INVLOTNO in ('{0}') OR a.LOTNO in ('{0}')) {1}";
sqlSL = string.Format(sqlSL, lotno, SLItemsql);
DataTable dtsl = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sqlSL).Tables[0];
if (dtsl != null && dtsl.Rows.Count > 0)
{
foreach (DataRow item in dtsl.Rows)
{
if (!string.IsNullOrEmpty(item["供应商编码"].ToString().Trim()) && !GYS.Contains(item["供应商编码"].ToString().Trim()))
{
GYS.Add(item["供应商编码"].ToString());
NCR_SupplyModel supp = new NCR_SupplyModel();
supp.SupplyCode = item["供应商编码"].ToString();
supp.SupplyName = item["供应商名称"].ToString();
supp.PONo = item["采购单号"].ToString();
supp.POLineNo = item["采购单行号"].ToString();
GYSModel.Add(supp);
}
}
}
}
//2、查炉号的方式 查供应商
if (GYS == null || GYS.Count == 0)
{
string[] LotList = null;
string GYSLL = "";
if (!string.IsNullOrEmpty(CPIR.SrcDocInfo))
{
LotList = CPIR.SrcDocInfo.Split(',');
}
if (LotList != null)
{
foreach (string lot in LotList)
{
//通过查炉号的方式 查供应商
DataTable dt_GY = GetInvLotFurnaceStr(lot, TypeList, Appconstr);
if (dt_GY != null && dt_GY.Rows.Count > 0)
{
for (int i = 0; i < dt_GY.Rows.Count; i++)
{
DataRow dr = dt_GY.Rows[i];
if (!GYS.Contains(dr["供应商编码"].ToString()) && !string.IsNullOrEmpty(dr["供应商编码"].ToString()))
{
GYS.Add(dr["供应商编码"].ToString());
NCR_SupplyModel supp = new NCR_SupplyModel();
supp.SupplyCode = dr["供应商编码"].ToString();
supp.SupplyName = dr["供应商名称"].ToString();
supp.PONo = dr["采购单号"].ToString();
supp.POLineNo = dr["采购单行号"].ToString();
GYSModel.Add(supp);
}
}
}
}
}
}
//3、查NCR责任人中写的供应商 //填写的是简称,不抓了。
if (GYS == null || GYS.Count == 0)
{
return null;
}
else
{
return GYSModel;
}
}
catch (Exception ex)
{
return null;
}
}
public static NCRCPIRModel GetNCR_CPIR(ICSNCRDoc NCR, String Appconstr)
{
NCRCPIRModel item=new NCRCPIRModel ();
try
{
item.SecDocNO=NCR.SecDocNO;
item.ContentDesc=NCR.ContentDesc;
item.ErrorType=NCR.ErrorType;
item.Furnace=NCR.Furnace;
item.ItemCode=NCR.ItemCode;
item.Point=NCR.Point;
item.ProjectCode=NCR.ProjectCode;
item.Qty=NCR.Qty;
item.SecDocCreateTime=NCR.SecDocCreateTime;
item.SrcDocInfo=NCR.SrcDocInfo;
string sql = @"
SELECT
d.itemname 物料描述,
(SELECT max(LimitTime) FROM ICSNCRDocRectifyProcess WHERE SecDocNO = a.SecDocNO GROUP BY SecDocNO) 要求完成日期
FROM ICSNCRDoc a
LEFT JOIN Base_Inventory d ON a.itemcode = d.itemcode
WHERE a.SECDOCNO='" + NCR.SecDocNO + @"'
";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count>0)
{
item.ItemName = dt.Rows[0]["物料描述"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[0]["要求完成日期"].ToString()))
{
item.RequirDate = Convert.ToDateTime(dt.Rows[0]["要求完成日期"].ToString());
}
}
return item;
}
catch (Exception ex)
{
return null;
}
}
public static List<string> GerNCRGYS(string SecDocNo, String Appconstr)
{
return null;
}
#region 返回供应商
private static DataTable GetInvLotFurnaceStr(string LotNo, List<string> TypeList, string dsconn)
{
string InvLotFurnaceStr = "";
string InvLotStr = "";
List<string> BarNoList = new List<string>();
//ICSInvLotFurnaceDAL.GetBarNoList(LotNo, BarNoList, dsconn);
DataTable dt = GetInvLotFurnace(BarNoList,TypeList, dsconn);
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
else
{
return null;
}
}
#endregion
#region 返回供应商New/炉号New
public static string GetInvLotFurnaceStrNew(string LotNo, string dsconn,string colsName)
{
string InvLotFurnaceStr = "";
string InvLotStr = "";
string[] lotlist = LotNo.Split(',');
for (int i = 0; i < lotlist.Length; i++)
{
List<string> BarNoList = new List<string>();
//ICSInvLotFurnaceDAL.GetBarNoList(lotlist[i], BarNoList, dsconn);
//DataTable dt = ICSInvLotFurnaceDAL.GetInvLotFurnace(BarNoList, dsconn);
//if (dt != null && dt.Rows.Count > 0)
//{
// foreach (DataRow dr in dt.Rows)
// {
// if (!("," + InvLotFurnaceStr).Contains("," + dr[colsName].ToString() + ","))
// {
// InvLotFurnaceStr += dr[colsName].ToString() + ",";
// }
// }
//}
}
return InvLotFurnaceStr.TrimEnd(',');
}
#endregion
#region 根据批次代码查询
public static DataTable GetInvLotFurnace(List<string> BarNoList, List<string> TypeList, string dsconn)
{
string Itemsql = "";
if (TypeList != null && TypeList.Count > 0)
{
Itemsql = " and ( 1=2 ";
foreach (string item in TypeList)
{
switch (item)
{
case "阀体": Itemsql += " or 物料编码 like '130101%' "; break;
case "阀帽": Itemsql += " or 物料编码 like '130102%' "; break;
case "球座组件": Itemsql += " or 物料编码 like '1249%' "; break;
case "阀杆": Itemsql += " or 物料编码 like '130402%' "; break;
case "螺柱": Itemsql += " or 物料编码 like '140402%' "; break;
case "螺母": Itemsql += " or 物料编码 like '140403%' "; break;
default: Itemsql += " or 物料编码 like '" + item + "%' "; break;
}
}
Itemsql += " ) ";
}
string sql = @" select * from GetInvLotFurnace where [条码] in ({0}) {1} ";
string lotNoStr = "";
if (BarNoList.Count > 0)
{
foreach (string str in BarNoList)
{
lotNoStr += "'" + str + "',";
}
lotNoStr = lotNoStr.TrimEnd(',');
sql = string.Format(sql, lotNoStr,Itemsql);
return DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
}
else
{
return new DataTable();
}
}
#endregion
#region 获取下一道工序
public static string GetCurrentOPCode(string LotNO)
{
string sql = @"
SELECT distinct
'' as isSelect,
a.ID,
lot.LOTNO,
b.MOPLANQTY as MoQty,
lot.MOCODE,
lot.LOTSEQ,
lot.LOTStatus,
d.ITEMCODE,
c.ROUTECODE,
'' as OPCODE,
CAST(a.ISCOM AS BIT) AS ISCOM,
a.ISHOLD,
a.SHELFNO,
b.MOSEQ,
'未开工' as CollectStatus,
b.MODESC,
c.ROUTEDESC,
d.ItemName,
e.OPCODE AS NEXTOPCODE,
f.OPDESC,
g.OPDESC AS NEXTOPDESC
FROM ICSMO2Lot lot
LEFT JOIN ICSLOTSIMULATION a on lot.LotNo = a.LotNo and a.MoCode = lot.MoCode
LEFT JOIN ICSMO b ON lot.MOCODE = b.MOCODE
LEFT JOIN ICSMO2Route k on b.MOCODE = k.MOCODE
LEFT JOIN ICSROUTE c ON k.ROUTECODE = c.ROUTECODE
LEFT JOIN Base_Inventory d ON b.ITEMCODE = d.ITEMCODE
inner JOIN ( SELECT ITEMCODE,ROUTECODE,OPCODE,OPSEQ FROM ICSITEMROUTE2OP) e ON e.ITEMCODE = b.ITEMCODE
AND e.ROUTECODE = k.ROUTECODE
AND e.OPSEQ = (SELECT MIN(OPSEQ) FROM ICSITEMROUTE2OP WHERE ITEMCODE = b.ITEMCODE AND ROUTECODE = k.ROUTECODE )
LEFT JOIN ICSOP f ON a.OPCODE = f.OPCODE
LEFT JOIN ICSOP g ON e.OPCODE = g.OPCODE
WHERE
1=1 and a.ID IS NULL And lot.LOTNO = '" + LotNO + @"'
union
SELECT distinct
'' as isSelect,
a.ID,
a.LOTNO,
b.MOPLANQTY as MoQty,
a.MOCODE,
a.LOTSEQ,
a.LOTStatus,
a.ITEMCODE,
a.ROUTECODE,
a.OPCODE,
CAST(a.ISCOM AS BIT) AS ISCOM,
a.ISHOLD,
a.SHELFNO,
a.MOSEQ,
case when a.CollectStatus = 'COLLECT_BEGIN' then '开始' else '结束' end as CollectStatus,
b.MODESC,
c.ROUTEDESC,
d.ItemName,
e.OPCODE AS NEXTOPCODE,
f.OPDESC,
g.OPDESC AS NEXTOPDESC
FROM
ICSLOTSIMULATION a
LEFT JOIN ICSMO b ON a.MOCODE = b.MOCODE
LEFT JOIN ICSROUTE c ON a.ROUTECODE = c.ROUTECODE
LEFT JOIN Base_Inventory d ON a.ITEMCODE = d.ITEMCODE
LEFT JOIN ( SELECT ITEMCODE,ROUTECODE,OPCODE,OPSEQ FROM ICSITEMROUTE2OP) e ON e.ITEMCODE = a.ITEMCODE
AND e.ROUTECODE = a.ROUTECODE
AND e.OPSEQ = (SELECT MIN(OPSEQ) FROM ICSITEMROUTE2OP WHERE ITEMCODE = a.ITEMCODE AND ROUTECODE = a.ROUTECODE
AND OPSEQ > (SELECT OPSEQ FROM ICSITEMROUTE2OP WHERE ITEMCODE = a.ITEMCODE AND ROUTECODE = a.ROUTECODE AND OPCODE = a.OPCODE))
LEFT JOIN ICSOP f ON a.OPCODE = f.OPCODE
LEFT JOIN ICSOP g ON e.OPCODE = g.OPCODE
WHERE
1=1 And a.LOTNO = '" + LotNO + "'";
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
if (data != null && data.Rows.Count > 0)
{
if (data.Rows[0]["CollectStatus"].ToString() == "未开工")
{
return data.Rows[0]["NEXTOPCODE"].ToString();
}
else if (data.Rows[0]["CollectStatus"].ToString() == "开始")
{
return data.Rows[0]["OPCODE"].ToString();
}
else if (data.Rows[0]["CollectStatus"].ToString() == "结束" && !string.IsNullOrEmpty(data.Rows[0]["NEXTOPCODE"].ToString()))
{
return data.Rows[0]["NEXTOPCODE"].ToString();
}
else
{
return GetNextOpCodeByModel(LotNO);
}
}
else
{
return GetNextOpCodeByModel(LotNO);
}
}
public static string GetNextOpCodeByModel(string LotNO)
{
string sql = @"
SELECT distinct
'' as isSelect,
a.ID,
lot.LOTNO,
b.MOPLANQTY as MoQty,
lot.MOCODE,
lot.LOTSEQ,
lot.LOTStatus,
d.ITEMCODE,
c.ROUTECODE,
'' as OPCODE,
CAST(a.ISCOM AS BIT) AS ISCOM,
a.ISHOLD,
a.SHELFNO,
b.MOSEQ,
'未开工' as CollectStatus,
b.MODESC,
c.ROUTEDESC,
d.ItemName,
e.OPCODE AS NEXTOPCODE,
f.OPDESC,
g.OPDESC AS NEXTOPDESC
FROM ICSMO2Lot lot
LEFT JOIN ICSLOTSIMULATION a on lot.LotNo = a.LotNo and a.MoCode = lot.MoCode
LEFT JOIN ICSMO b ON lot.MOCODE = b.MOCODE
LEFT JOIN ICSMO2Route k on b.MOCODE = k.MOCODE
LEFT JOIN ICSROUTE c ON k.ROUTECODE = c.ROUTECODE
LEFT JOIN Base_Inventory d ON b.ITEMCODE = d.ITEMCODE
LEFT JOIN ( SELECT MODELCODE,ROUTECODE,OPCODE,OPSEQ FROM ICSMODELROUTE2OP) e ON e.MODELCODE = d.ItemMainCategoryCode
AND e.ROUTECODE = k.ROUTECODE
AND e.OPSEQ = (SELECT MIN(OPSEQ) FROM ICSMODELROUTE2OP WHERE MODELCODE = d.ItemMainCategoryCode AND ROUTECODE = k.ROUTECODE )
LEFT JOIN ICSOP f ON a.OPCODE = f.OPCODE
LEFT JOIN ICSOP g ON e.OPCODE = g.OPCODE
WHERE
1=1 And a.ID is null and lot.LOTNO = '" + LotNO + @"'
union
SELECT distinct
'' as isSelect,
a.ID,
a.LOTNO,
b.MOPLANQTY as MoQty,
a.MOCODE,
a.LOTSEQ,
a.LOTStatus,
a.ITEMCODE,
a.ROUTECODE,
a.OPCODE,
CAST(a.ISCOM AS BIT) AS ISCOM,
a.ISHOLD,
a.SHELFNO,
a.MOSEQ,
case when a.CollectStatus = 'COLLECT_BEGIN' then '开始' else '结束' end as CollectStatus,
b.MODESC,
c.ROUTEDESC,
d.ItemName,
e.OPCODE AS NEXTOPCODE,
f.OPDESC,
g.OPDESC AS NEXTOPDESC
FROM
ICSLOTSIMULATION a
LEFT JOIN ICSMO b ON a.MOCODE = b.MOCODE
LEFT JOIN ICSROUTE c ON a.ROUTECODE = c.ROUTECODE
LEFT JOIN Base_Inventory d ON a.ITEMCODE = d.ITEMCODE
LEFT JOIN ( SELECT MODELCODE,ROUTECODE,OPCODE,OPSEQ FROM ICSMODELROUTE2OP) e ON e.MODELCODE = d.ItemMainCategoryCode
AND e.ROUTECODE = a.ROUTECODE
AND e.OPSEQ = (SELECT MIN(OPSEQ) FROM ICSMODELROUTE2OP WHERE MODELCODE = d.ItemMainCategoryCode AND ROUTECODE = a.ROUTECODE
AND OPSEQ > (SELECT OPSEQ FROM ICSMODELROUTE2OP WHERE MODELCODE = d.ItemMainCategoryCode AND ROUTECODE = a.ROUTECODE AND OPCODE = a.OPCODE))
LEFT JOIN ICSOP f ON a.OPCODE = f.OPCODE
LEFT JOIN ICSOP g ON e.OPCODE = g.OPCODE
WHERE
1=1 And a.LOTNO = '" + LotNO + "'";
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
if (data != null && data.Rows.Count > 0)
{
if (data.Rows[0]["CollectStatus"].ToString() == "未开工")
{
return data.Rows[0]["NEXTOPCODE"].ToString();
}
else if (data.Rows[0]["CollectStatus"].ToString() == "开始")
{
return data.Rows[0]["OPCODE"].ToString();
}
else if (data.Rows[0]["CollectStatus"].ToString() == "结束")
{
return data.Rows[0]["NEXTOPCODE"].ToString();
}
}
return "";
}
public static string GetUserName(String UserCode, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
var line = db.Sys_User.Where(a => a.UserCode == UserCode);
if (line != null && line.Count() > 0)
{
Sys_User UU = (Sys_User)line.First();
return UU.UserName;
}
}
catch (Exception ex)
{
return "";
}
return "";
}
public static string GetCurrentUserDep(String UserCode, String Appconstr)
{
string CurrentUserDep = "";
try
{
string sql = @"
SELECT EnumText
FROM
Sys_EnumValues vv
WHERE
1 = 1
AND ( CHARINDEX( '{0}', vv.Define1 ) != 0 OR CHARINDEX( '{0}', vv.Define5 ) != 0 )
AND vv.EnumKey= '076'
and EnumText!='质量'
UNION
SELECT EnumText
FROM
Sys_EnumValues vv
LEFT JOIN (
SELECT workno
FROM ICSUserInfo
WHERE
deptno IN (
SELECT items
FROM
[dbo].[splitl] (
( SELECT TOP 1 EATTRIBUTE1 FROM ICSUserInfo WHERE workno = '{0}'
AND EATTRIBUTE1 != '' AND EATTRIBUTE1 IS NOT NULL AND deptno != '' ),
','
))
) uu ON 1 = 1
WHERE
1 = 1
AND ( CHARINDEX( uu.workno, vv.Define1 ) != 0 OR CHARINDEX( uu.workno, vv.Define5 ) != 0 )
AND vv.EnumKey= '076'
and EnumText!='质量'
";
sql = string.Format(sql, UserCode);
DataTable data = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (data != null && data.Rows.Count > 0)
{
for (int i = 0; i < data.Rows.Count; i++)
{
CurrentUserDep += "," + data.Rows[i]["EnumText"].ToString().Trim();
}
}
return CurrentUserDep;
}
catch (Exception ex)
{
return "";
}
return "";
}
#endregion
public static List<NCRProcessBackModel> listPBackLog(String SecDocNO, string Type, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<NCRProcessBackModel> list = new List<NCRProcessBackModel>();
try
{
// var line = db.ICSNCRDocPreventionProcessLog.Where(a => a.DoType == Type && a.SecDocNO == SecDocNO).OrderByDescending(a => a.MTIME);
var line = from a in db.ICSNCRDocPreventionProcessLog
where a.SecDocNO == SecDocNO && a.DoType == Type
orderby a.MTIME
select new
{
ProcessName = db.ICSNCRDocPreventionProcess.Where
(b => b.ID == a.PreventionID && b.SecDocNO == a.SecDocNO).
Select(b => b.ProcessName).FirstOrDefault(),
a.EATTRIBUTE2,
a.MTIME
};
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRProcessBackModel model = new NCRProcessBackModel();
model.Department = item.ProcessName;
model.BackContect = item.EATTRIBUTE2;
model.BackTime = item.MTIME;
list.Add(model);
}
return list;
}
}
catch (Exception ex)
{
return null;
}
return null;
}
public static List<NCRProcessBackModel> listRBackLog(String SecDocNO, string Type, String Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
List<NCRProcessBackModel> list = new List<NCRProcessBackModel>();
try
{
var line = from a in db.ICSNCRDocRectifyProcessLog
where a.SecDocNO == SecDocNO && a.DoType == Type
orderby a.MTIME
select new
{
ProcessName = db.ICSNCRDocRectifyProcess.Where
(b => b.ID == a.RectifyID && b.SecDocNO == a.SecDocNO).
Select(b => b.ProcessName).FirstOrDefault(),
a.EATTRIBUTE2,
a.MTIME
};
if (line != null && line.Count() > 0)
{
foreach (var item in line)
{
NCRProcessBackModel model = new NCRProcessBackModel();
model.Department = item.ProcessName;
model.BackContect = item.EATTRIBUTE2;
model.BackTime = item.MTIME;
list.Add(model);
}
return list;
}
}
catch (Exception ex)
{
return null;
}
return null;
}
public static string CheckPZLJMO(String MOCode, String Appconstr)
{
try
{
string sql = @"
SELECT
LOT.LOTNO,
ISNULL( chk.CKRESULT, 0 ) CKResult
FROM
ICSMO2Lot lot
LEFT JOIN (
SELECT *
FROM
( SELECT ROW_NUMBER () OVER ( partition BY LOTNO ORDER BY mtime DESC ) rowId,*
FROM ICSQualityCKDATA ck WHERE type = '制程' ) AS AuctionRecords
WHERE
rowId = 1
) chk ON lot.lotno = chk.lotno
WHERE
lot.mocode = '" + MOCode + @"' ";
DataTable dt = DBHelper.ExecuteDataset(Appconstr, CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
DataRow[] drs = dt.Select(" CKResult=0 ");
if (drs != null && drs.Length > 0)
{
return MOCode + "未全部检验合格,不能关闭NCR";
}
else
{
return "";
}
}
else
{
return "未找到" + MOCode+"工单批号检验数据";
}
}
catch (Exception ex)
{
return ex.Message;
}
}
//public static ICSQualityCKDATA GetLastWXCK(string lotno, string opcode, string Appconstr)
//{
// FramDataContext db = new FramDataContext(Appconstr);
// db.Connection.Open();
// db.Transaction = db.Connection.BeginTransaction();
// try
// {
// var line = db.ICSQualityCKDATA.Where(a => a.LOTNO == lotno && a.OPCode == opcode && a.Type == "外协").OrderByDescending(a => a.MTIME);
// if (line != null && line.Count() > 0)
// { return (ICSQualityCKDATA)line.First(); }
// }
// catch (Exception ex)
// {
// return null;
// }
// return null;
//}
#endregion
#region 删除
#endregion
#region AddandEditList
public static void AddPreventionProcessList(List<ICSNCRDocPreventionProcess> InfoList, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
foreach (ICSNCRDocPreventionProcess Info in InfoList)
{
bool isNew = false;
var line = db.ICSNCRDocPreventionProcess.SingleOrDefault(a => a.SecDocNO == Info.SecDocNO && a.Seq == Info.Seq);
if (line == null)
{
isNew = true;
line = new ICSNCRDocPreventionProcess();
line.ID = AppConfig.GetGuid();
}
else
{
throw new Exception("已存在预防流程数据");
}
line.SecDocNO = Info.SecDocNO;
line.Seq = Info.Seq;
line.PreventionID = Info.PreventionID;
line.ProcessName = Info.ProcessName;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
line.LimitTime = Info.LimitTime;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew) db.ICSNCRDocPreventionProcess.InsertOnSubmit(line);
db.SubmitChanges();
}
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void AddRectifyProcessList(List<ICSNCRDocRectifyProcess> InfoList, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
foreach (ICSNCRDocRectifyProcess Info in InfoList)
{
bool isNew = false;
var line = db.ICSNCRDocRectifyProcess.SingleOrDefault(a => a.SecDocNO == Info.SecDocNO && a.Seq == Info.Seq);
if (line == null)
{
isNew = true;
line = new ICSNCRDocRectifyProcess();
line.ID = AppConfig.GetGuid();
}
else
{
throw new Exception("已存在纠正流程数据");
}
line.SecDocNO = Info.SecDocNO;
line.Seq = Info.Seq;
line.SubmitTime = Info.SubmitTime;
line.SubmitDep = Info.SubmitDep;
line.SubmitPerson = Info.SubmitPerson;
line.SubmitStatus = Info.SubmitStatus;
line.ConfirmStatus = Info.CKStatus;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
line.RectifyID = Info.RectifyID;
line.ProcessName = Info.ProcessName;
line.CKStatus = Info.CKStatus;
line.LimitTime = Info.LimitTime;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew) db.ICSNCRDocRectifyProcess.InsertOnSubmit(line);
db.SubmitChanges();
}
db.Transaction.Commit();
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void EditRectifyProcessList(List<ICSNCRDocRectifyProcess> InfoList, String SecDocNo, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (IsExistRectifyLog(SecDocNo, Appconstr))
{
throw new Exception("已存在纠正流程记录数据");
}
else
{
var lineolds = db.ICSNCRDocRectifyProcess.Where(a => a.SecDocNO == SecDocNo);
if (lineolds != null)
{
db.ICSNCRDocRectifyProcess.DeleteAllOnSubmit(lineolds);
db.SubmitChanges();
}
if (InfoList != null && InfoList.Count > 0)
{
foreach (ICSNCRDocRectifyProcess Info in InfoList)
{
bool isNew = false;
var line = db.ICSNCRDocRectifyProcess.SingleOrDefault(a => a.SecDocNO == Info.SecDocNO && a.Seq == Info.Seq);
if (line == null)
{
isNew = true;
line = new ICSNCRDocRectifyProcess();
line.ID = AppConfig.GetGuid();
}
else
{
throw new Exception("已存在纠正流程数据");
}
line.SecDocNO = Info.SecDocNO;
line.Seq = Info.Seq;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
line.RectifyID = Info.RectifyID;
line.CKStatus = Info.CKStatus;
line.ProcessName = Info.ProcessName;
line.LimitTime = Info.LimitTime;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew) db.ICSNCRDocRectifyProcess.InsertOnSubmit(line);
db.SubmitChanges();
}
}
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
public static void EditPreventionProcessList(List<ICSNCRDocPreventionProcess> InfoList, String SecDocNo, string Appconstr)
{
FramDataContext db = new FramDataContext(Appconstr);
db.Connection.Open();
db.Transaction = db.Connection.BeginTransaction();
try
{
if (IsExistPreventionLog(SecDocNo, Appconstr))
{
throw new Exception("已存在预防流程记录数据");
}
else
{
var lineolds = db.ICSNCRDocPreventionProcess.Where(a => a.SecDocNO == SecDocNo);
if (lineolds != null)
{
db.ICSNCRDocPreventionProcess.DeleteAllOnSubmit(lineolds);
db.SubmitChanges();
}
if (InfoList != null && InfoList.Count > 0)
{
foreach (ICSNCRDocPreventionProcess Info in InfoList)
{
bool isNew = false;
var line = db.ICSNCRDocPreventionProcess.SingleOrDefault(a => a.SecDocNO == Info.SecDocNO && a.Seq == Info.Seq);
if (line == null)
{
isNew = true;
line = new ICSNCRDocPreventionProcess();
line.ID = AppConfig.GetGuid();
}
else
{
throw new Exception("已存在预防流程数据");
}
line.SecDocNO = Info.SecDocNO;
line.Seq = Info.Seq;
line.EATTRIBUTE1 = Info.EATTRIBUTE1;
line.EATTRIBUTE2 = Info.EATTRIBUTE2;
line.PreventionID = Info.PreventionID;
line.ProcessName = Info.ProcessName;
line.LimitTime = Info.LimitTime;
line.MUSER = AppConfig.UserId;
line.MUSERName = AppConfig.UserName;
line.MTIME = DateTime.Now;
line.WorkPoint = AppConfig.WorkPointCode;
if (isNew) db.ICSNCRDocPreventionProcess.InsertOnSubmit(line);
db.SubmitChanges();
}
}
db.Transaction.Commit();
}
}
catch (Exception ex)
{
db.Transaction.Rollback();
throw new Exception(ex.Message);
}
}
#endregion
#region 退料
//public static void AddUpdateNCRTuiLiao( List<ICSNCRDocTuiLiao> List,String Appconstr)
//{
// FramDataContext db = new FramDataContext(Appconstr);
// db.Connection.Open();
// db.Transaction = db.Connection.BeginTransaction();
// try
// {
// foreach (ICSNCRDocTuiLiao Info in List)
// {
// bool isNew = false;
// var line = db.ICSNCRDocTuiLiao.SingleOrDefault(a => a.ID == Info.ID );
// if (line == null)
// {
// isNew = true;
// line = new ICSNCRDocTuiLiao();
// line.ID = AppConfig.GetGuid();
// }
// line.SecDocNo = Info.SecDocNo;
// line.Qty = Info.Qty;
// line.IssueDoc = Info.IssueDoc;
// line.ItemCode = Info.ItemCode;
// line.LotNo = Info.LotNo;
// line.MOCode = Info.MOCode;
// line.NewLotNo = Info.NewLotNo;
// line.EATTRIBUTE1 = Info.EATTRIBUTE1;//炉号
// line.EATTRIBUTE2 = Info.EATTRIBUTE2;
// line.EATTRIBUTE3 = Info.EATTRIBUTE3;
// line.MUSER = AppConfig.UserId;
// line.MUSERName = AppConfig.UserName;
// line.MTIME = DateTime.Now;
// line.WorkPoint = AppConfig.WorkPointCode;
// if (isNew) db.ICSNCRDocTuiLiao.InsertOnSubmit(line);
// db.SubmitChanges();
// }
// db.Transaction.Commit();
// }
// catch (Exception ex)
// {
// db.Transaction.Rollback();
// throw new Exception(ex.Message);
// }
//}
//public static void NCRTuiLiaoToWMShip(string SecDocNo, String Appconstr)
//{
// FramDataContext db = new FramDataContext(Appconstr);
// db.Connection.Open();
// db.Transaction = db.Connection.BeginTransaction();
// try
// {
// bool isNew = true;
// int MaxLine=0;
// string DocNo ="";
// List<WM_RCVShip> Infolist = new List<WM_RCVShip>();
// var line = db.ICSNCRDocTLRelation.Where(a => a.SecDocNo == SecDocNo).OrderByDescending(a => a.LineNo);
// var TuiLiaoLine = from a in db.ICSNCRDocTuiLiao
// join b in db.ICSNCRDocTLRelation
// on new { SecDocNo = a.SecDocNo, ID = a.ID } equals new { SecDocNo = b.SecDocNo, ID = b.TuiLiaoID } into dd
// from bb in dd.DefaultIfEmpty()
// join c in db.Base_Inventory on a.ItemCode equals c.ItemCode
// where a.SecDocNo == SecDocNo
// select new
// {
// SecDocNo = a.SecDocNo,
// ID = a.ID,
// DocNo = bb.DocNo,
// LineNo = bb.LineNo,
// Qty = a.Qty,
// ItemCode = a.ItemCode,
// ItemName = c.ItemName,
// ItemID = c.ItemID,
// LuHoa = a.EATTRIBUTE1
// };
// if (line != null && line.Count() > 0)
// {
// MaxLine = Convert.ToInt32(line.First().LineNo);
// DocNo = line.First().DocNo;
// }
// else
// {
// //生成新退料单号
// string LBCodePer = "RL" + AppConfig.GetSeverDateTime("yyyy-MM-dd").ToString("yyyyMMdd");
// string NewLBCodeNo = GetSerialCode(AppConfig.AppConnectString, "ICSNCRDocTLRelation", "DocNo", LBCodePer, 4);
// DocNo = NewLBCodeNo;
// }
// if (TuiLiaoLine != null && TuiLiaoLine.Count() > 0)
// {
// foreach (var item in TuiLiaoLine)
// {
// if (string.IsNullOrEmpty(item.LineNo))
// {
// MaxLine = MaxLine + 10;
// string NewLineNo = MaxLine.ToString();
// var newline = db.ICSNCRDocTLRelation.SingleOrDefault(a => a.SecDocNo == SecDocNo && a.LineNo == NewLineNo);
// if (newline != null)
// {
// throw new Exception("退料行号异常:" + NewLineNo);
// }
// else
// {
// newline = new ICSNCRDocTLRelation();
// }
// newline.ID = AppConfig.GetGuid();
// newline.DocNo = DocNo;
// newline.LineNo = NewLineNo;
// newline.SecDocNo = SecDocNo;
// newline.TuiLiaoID = item.ID;
// newline.MTIME = DateTime.Now;
// newline.MUSER = AppConfig.UserCode;
// newline.MUSERName = AppConfig.UserName;
// newline.WorkPoint = AppConfig.WorkPointCode;
// if (isNew) db.ICSNCRDocTLRelation.InsertOnSubmit(newline);
// #region WM_RCVShip
// WM_RCVShip entity = new WM_RCVShip();
// entity = new WM_RCVShip();
// entity.guid = AppConfig.GetGuid();
// entity.RcvDocNo = DocNo;
// entity.RcvDocBusinessDate = DateTime.Now;
// entity.RcvDocStatus = "0";
// entity.RcvOrgID = 1001606030000019;
// entity.RcvOrgCode = "01";
// entity.RcvOrgName = "无锡智能自控工程股份有限公司";
// entity.RcvDocTypeName = "退料单";
// entity.RcvLineNo = MaxLine;
// entity.RcvLineItemMasterID = item.ItemID;
// entity.RcvLineItemMasterCode = item.ItemCode;
// entity.RcvLineItemMasterName = item.ItemName;
// entity.RcvLineStoreUOMID = 0;
// entity.RcvLineStoreUOMCode = "";
// entity.RcvLineStoreUOMName = "";
// entity.RcvLineStoreQty = item.Qty;
// entity.barcodeSumQty = 0;
// entity.barcodeSumNo = 0;
// entity.RcvLineInvLotFurnace = item.LuHoa;
// entity.isEff = true;
// entity.isDel = false;
// entity.WorkPointCode = AppConfig.WorkPointCode;
// entity.MUSERCode = AppConfig.UserCode;
// entity.MUSERName = AppConfig.UserName;
// entity.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString());
// Infolist.Add(entity);
// #endregion
// }
// }
// if (Infolist != null && Infolist.Count > 0)
// {
// WM_RCVShipDAL.AddMISList(Infolist, Appconstr);
// }
// db.SubmitChanges();
// db.Transaction.Commit();
// }
// }
// catch (Exception ex)
// {
// db.Transaction.Rollback();
// throw new Exception(ex.Message);
// }
//}
#endregion
}
}