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.
241 lines
8.2 KiB
241 lines
8.2 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 ICSEQPTSDAL
|
|
{
|
|
|
|
|
|
|
|
#region 增加修改
|
|
|
|
public static void AddAndEdit(List<FormICSEQPTSUIModel> equipmentInfoList, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSEQPTSUIModel equipmentInfo in equipmentInfoList)
|
|
{
|
|
|
|
bool isNew = false;
|
|
var line = db.ICSEQPTS.SingleOrDefault(a => a.GUID == equipmentInfo.GUID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSEQPTS();
|
|
line.GUID = AppConfig.GetGuid();
|
|
|
|
}
|
|
line.EQPID = equipmentInfo.EQPID;
|
|
line.EQPCode= equipmentInfo.EQPCode;
|
|
line.FINDUSER = equipmentInfo.FINDUSER;
|
|
line.FINDMTIME = Convert.ToDateTime(equipmentInfo.FINDMTIME);
|
|
line.TSINFO = equipmentInfo.TSINFO;
|
|
line.REASON = equipmentInfo.REASON;
|
|
line.Solution = equipmentInfo.Solution;
|
|
line.Result = equipmentInfo.Result;
|
|
line.TSType = equipmentInfo.TSType;
|
|
line.STATUS = equipmentInfo.STATUS;
|
|
line.Duration = Convert.ToInt32(equipmentInfo.Duration);
|
|
line.MUSER = equipmentInfo.MUSER;
|
|
line.MUSERName = equipmentInfo.MUSERName;
|
|
line.MTIME = Convert.ToDateTime(equipmentInfo.MTIME);
|
|
line.WorkPoint = equipmentInfo.WorkPoint;
|
|
line.EATTRIBUTE1 = equipmentInfo.EATTRIBUTE1;
|
|
|
|
if (isNew)
|
|
db.ICSEQPTS.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 班次代码是否存在
|
|
public static bool IsIncludingShiftCode(string shiftcode, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSSHIFT.SingleOrDefault(a => a.SHIFTCODE == shiftcode);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
//#region 班次次序是否存在
|
|
//public static bool IsIncludingInShiftSeq(int shiftsqe, string shifttypeid)
|
|
//{
|
|
|
|
// FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
// var line = db.ICSSHIFT.SingleOrDefault(a => a.SHIFTSEQ == shiftsqe && a.SHIFTTYPEID == shifttypeid);
|
|
// if (line == null)
|
|
// return true;
|
|
// else
|
|
// return false;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw ex;
|
|
// }
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
|
|
public static List<FormICSEQPTSUIModel> SearchEQPTSInfoByID(string id, string dsconn)
|
|
{
|
|
List<FormICSEQPTSUIModel> returnshift = new List<FormICSEQPTSUIModel>();
|
|
string sql = @"select a.GUID,b.EQPID,b.EQPCode,a.FINDUSER,a.FINDMTIME,a.TSINFO,a.REASON,a.Solution,a.Result,a.TSType,a.STATUS,a.Duration,a.MUSERName,a.MTIME
|
|
from ICSEQPTS a
|
|
left join ICSEquipment b on a.EQPCode=b.EQPCode
|
|
where a.GUID='{0}'";
|
|
sql = string.Format(sql, id);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSEQPTSUIModel eqptsInfo = new FormICSEQPTSUIModel();
|
|
eqptsInfo.GUID = dr["GUID"].ToString();
|
|
eqptsInfo.equipment = new FormICSEquipmentUIModel();
|
|
eqptsInfo.equipment.EQPID = dr["EQPID"].ToString();
|
|
eqptsInfo.equipment.EQPCode = dr["EQPCode"].ToString();
|
|
eqptsInfo.FINDUSER = dr["FINDUSER"].ToString();
|
|
eqptsInfo.FINDMTIME = Convert.ToDateTime(dr["FINDMTIME"].ToString());
|
|
eqptsInfo.TSINFO = dr["TSINFO"].ToString();
|
|
eqptsInfo.REASON = dr["REASON"].ToString();
|
|
eqptsInfo.Solution = dr["Solution"].ToString();
|
|
eqptsInfo.Result = dr["Result"].ToString();
|
|
eqptsInfo.TSType = dr["TSType"].ToString();
|
|
eqptsInfo.STATUS = dr["STATUS"].ToString();
|
|
eqptsInfo.Duration =Convert.ToInt32(dr["Duration"].ToString());
|
|
eqptsInfo.MUSERName = dr["MUSERName"].ToString();
|
|
eqptsInfo.MTIME = System.DateTime.Parse(dr["MTIME"].ToString());
|
|
|
|
if (!returnshift.Contains(eqptsInfo))
|
|
{
|
|
returnshift.Add(eqptsInfo);
|
|
}
|
|
|
|
}
|
|
return returnshift;
|
|
|
|
}
|
|
|
|
public static DataTable SelectShiftTypeCode()
|
|
{
|
|
string sql = @"select SHIFTTYPECODE as [班制代码]
|
|
from dbo.ICSSHIFTTYPE
|
|
where 1=1";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
|
|
public static DataTable SelectShiftTypeId(string str)
|
|
{
|
|
string sql = @"select ID
|
|
from dbo.ICSSHIFTTYPE
|
|
where SHIFTTYPECODE='" + str + "'";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
|
|
|
|
#region delete
|
|
public static void delete(List<String> guidList)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSEQPTS.Where(a => guidList.Contains(a.GUID));
|
|
db.ICSEQPTS.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static DataTable GetShiftCode()
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select TOP 1 [SHIFTCODE]
|
|
FROM [dbo].[ICSSHIFT] order by SHIFTCODE desc";
|
|
return DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
// public static DataTable GetShiftSeqCode()
|
|
// {
|
|
// try
|
|
// {
|
|
// string sql = @"select TOP 1 [SHIFTSEQ]
|
|
// FROM [dbo].[ICSSHIFT] order by [SHIFTTYPEID] desc";
|
|
// return DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
}
|
|
|