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.
337 lines
11 KiB
337 lines
11 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using System.Data;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Data.Linq;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSNCTP2DAL
|
|
{
|
|
#region 新增和修改
|
|
public static void Add(List<ICSNCTP2> InfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSNCTP2 info in InfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSNCTP2.SingleOrDefault(a => a.guid == info.guid);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSNCTP2();
|
|
|
|
|
|
}
|
|
//var codes = db.ICSEQPSTP.Where(a => a.ITEMCODE == info.ITEMCODE && a.OPCODE == info.OPCODE && a.EQPTypeCode == info.EQPTypeCode && a.ID != info.ID);
|
|
//if (codes.ToList().Count > 0)
|
|
//{
|
|
// throw new Exception("已存在相同产品工序设备类型的标准工时");
|
|
//}
|
|
|
|
line.guid = info.guid;
|
|
line.NCTPType = info.NCTPType;
|
|
line.ProductDate = info.ProductDate;
|
|
line.ProductMO = info.ProductMO;
|
|
line.ItemCode = info.ItemCode;
|
|
line.ItemName = info.ItemName;
|
|
line.ProjectCode = info.ProjectCode;
|
|
|
|
line.OPCode = info.OPCode;
|
|
line.OPName = info.OPName;
|
|
line.ProductNum = info.ProductNum;
|
|
|
|
line.EQPCode = info.EQPCode;
|
|
|
|
line.EQPName = info.EQPName;
|
|
|
|
line.UnitTP = info.UnitTP;
|
|
line.TotalTP = info.TotalTP;
|
|
line.ProductUser = info.ProductUser;
|
|
line.Status = info.Status;
|
|
|
|
// line.DeptCheckUser = info.DeptCheckUser;
|
|
line.TotalTP = info.TotalTP;
|
|
line.DeptCheckTime = info.DeptCheckTime;
|
|
//line.MECheckUser = info.MECheckUser;
|
|
//line.MECheckTime = info.MECheckTime;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.EATTRIBUTE1 = info.EATTRIBUTE1;
|
|
|
|
if (isNew)
|
|
db.ICSNCTP2.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 新增和修改List
|
|
public static string AddList(List<ICSNCTP2> InfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
string str = "";
|
|
foreach (ICSNCTP2 info in InfoList)
|
|
{
|
|
var opcode = db.ICSOP.SingleOrDefault(a => a.OPCODE == info.OPCode);
|
|
if (opcode == null)
|
|
{
|
|
str += "工序代码:" + info.OPCode + "不存在" + "\r\n";
|
|
continue;
|
|
|
|
}
|
|
var eqp = db.ICSEquipment.SingleOrDefault(a => a.EQPCode == info.EQPCode);
|
|
if (eqp == null)
|
|
{
|
|
str += "设备编号:" + info.EQPCode + "不存在" + "\r\n";
|
|
continue;
|
|
|
|
}
|
|
|
|
ICSNCTP2 line = new ICSNCTP2();
|
|
line.guid = AppConfig.GetGuid();
|
|
|
|
line.ProductDate = info.ProductDate;
|
|
line.ProductMO = info.ProductMO;
|
|
line.ItemCode = info.ItemCode;
|
|
line.ItemName = info.ItemName;
|
|
line.ProjectCode = info.ProjectCode;
|
|
|
|
line.OPCode = info.OPCode;
|
|
line.OPName = info.OPName;
|
|
|
|
line.NCTPType = info.NCTPType;
|
|
|
|
line.ProductNum = info.ProductNum;
|
|
line.EQPCode = info.EQPCode;
|
|
line.EQPName = info.EQPName;
|
|
|
|
line.UnitTP = info.UnitTP;
|
|
line.TotalTP = info.TotalTP;
|
|
line.ProductUser = info.ProductUser;
|
|
line.Status = "新增";
|
|
|
|
// line.DeptCheckUser = info.DeptCheckUser;
|
|
line.TotalTP = info.TotalTP;
|
|
line.DeptCheckTime = info.DeptCheckTime;
|
|
// line.MECheckUser = info.MECheckUser;
|
|
//line.MECheckTime = info.MECheckTime;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = Convert.ToDateTime(AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString());;
|
|
|
|
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.EATTRIBUTE1 = info.EATTRIBUTE1;
|
|
|
|
db.ICSNCTP2.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
|
|
db.Transaction.Commit();
|
|
return str;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 通过ID查询
|
|
public static DataTable searchInfoByID(string ID, string dsconn)
|
|
{
|
|
|
|
string sql = @"select a.guid,
|
|
a.ProductDate,
|
|
a.ProductMO,
|
|
a.ItemCode,
|
|
a.ItemName,
|
|
a.ProjectCode,
|
|
a.OPCode,
|
|
a.ProductNum,
|
|
a.EQPCode,
|
|
a.EQPName,
|
|
a.UnitTP,
|
|
a.TotalTP,
|
|
a.ProductUser,
|
|
|
|
a.WorkPoint,
|
|
a.MUSER,
|
|
a.MUSERName,
|
|
a.MTIME,
|
|
a.EATTRIBUTE1,
|
|
a.NCTPType,
|
|
a.Status,
|
|
a.DeptCheckTime,
|
|
a.OPName,
|
|
|
|
b.OPDESC
|
|
|
|
|
|
FROM ICSNCTP2 a
|
|
LEFT JOIN ICSOP b on a.OPCODE=b.OPCODE
|
|
|
|
where a.guid='{0}'";
|
|
|
|
|
|
//原本的查询语句 多余的部分
|
|
// a.DeptCheckUser,
|
|
//
|
|
//a.MECheckUser,
|
|
//a.MECheckTime,
|
|
|
|
sql = string.Format(sql, ID);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 是否存在
|
|
public static bool IsIncluding(string ItemCode, string OPCode, string eqptype, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSNCTP2.SingleOrDefault(a => a.ItemCode == ItemCode && a.OPCode == OPCode);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public static void deleteInfo(List<string> codeList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSNCTP2.Where(a => codeList.Contains(a.guid));
|
|
db.ICSNCTP2.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 部门审核
|
|
public static void depCheck(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSNCTP2.SingleOrDefault(a => a.guid==id);
|
|
line.Status = "已审核";
|
|
// line.DeptCheckUser = AppConfig.UserCode;
|
|
line.DeptCheckTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 工艺审核
|
|
public static void meCheck(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSNCTP2.SingleOrDefault(a => a.guid == id);
|
|
// line.MECheckUser = AppConfig.UserCode;
|
|
// line.MECheckTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 弃审
|
|
public static void DiscardedTrialCheck(string id, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSNCTP2.SingleOrDefault(a => a.guid == id);
|
|
line.Status = "新增";
|
|
// line.DeptCheckUser = AppConfig.UserCode;
|
|
line.DeptCheckTime = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|