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.
257 lines
9.4 KiB
257 lines
9.4 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 ICSSEGDAL
|
|
{
|
|
// public static List<FormICSShifTypeUIModel> SearchShifTypeInfoList(string dsconn)
|
|
// {
|
|
// try
|
|
// {
|
|
// List<FormICSShifTypeUIModel> returntype = new List<FormICSShifTypeUIModel>();
|
|
// string sql = @"select [ID],[SHIFTTYPECODE],[SHIFTTYPEDESC],[EFFDATE],[IVLDATE],[MUSER],[MUSERName],[MTIME],[WorkPoint]
|
|
// from [ICSSHIFTTYPE]";
|
|
// sql = string.Format(sql);
|
|
// DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
// foreach (DataRow dr in dt.Rows)
|
|
// {
|
|
// FormICSShifTypeUIModel typemodel = new FormICSShifTypeUIModel();
|
|
// typemodel.ID = dr["ID"].ToString();
|
|
// typemodel.SHIFTTYPECODE = dr["SHIFTTYPECODE"].ToString();
|
|
// typemodel.SHIFTTYPEDESC = dr["SHIFTTYPEDESC"].ToString();
|
|
// if (!returntype.Contains(typemodel))
|
|
// returntype.Add(typemodel);
|
|
// }
|
|
// return returntype;
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
// }
|
|
public static List<FormICSFactoryUIModel> SearchFacInfoList(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
List<FormICSFactoryUIModel> returnfac = new List<FormICSFactoryUIModel>();
|
|
string sql = @"select [ID],[FACCODE],[FACDESC],[MUSER],[MUSERName],[MTIME],[WorkPoint]
|
|
from [ICSFACTORY]";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSFactoryUIModel facmodel = new FormICSFactoryUIModel();
|
|
facmodel.ID = dr["ID"].ToString();
|
|
facmodel.FACCODE = dr["FACCODE"].ToString();
|
|
facmodel.FACDESC = dr["FACDESC"].ToString();
|
|
if (!returnfac.Contains(facmodel))
|
|
returnfac.Add(facmodel);
|
|
}
|
|
return returnfac;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSSEGUIModel> SEGInfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSSEGUIModel seginfo in SEGInfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSSEG.SingleOrDefault(a => a.SEGCODE == seginfo.SEGCODE && a.WorkPoint == seginfo.WorkPoint);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSSEG();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.SEGCODE = seginfo.SEGCODE;
|
|
}
|
|
|
|
//line.SEGSEQ = seginfo.SEGSEQ;
|
|
line.SEGDESC = seginfo.SEGDESC;
|
|
line.SHIFTTYPEID = "";
|
|
|
|
if (seginfo.fac != null)
|
|
line.FACID = seginfo.fac.ID;
|
|
else
|
|
line.FACID = null;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.SEGManager = "";
|
|
if (isNew)
|
|
db.ICSSEG.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 通过车间代码查询
|
|
public static List<FormICSSEGUIModel> SearchSEGInfoByCode(string CODE, string dsconn)
|
|
{
|
|
List<FormICSSEGUIModel> returnseg = new List<FormICSSEGUIModel>();
|
|
// string sql = @"select a.[SEGCODE],a.[SEGSEQ],a.[SEGDESC],b.[UserCode],c.[ID] as cID,c.[FACCODE],c.[FACDESC]
|
|
// from ICSSEG as a
|
|
// left join Sys_User as b on (a.SEGManager=b.UserCode)
|
|
// left join ICSFACTORY as c on (a.FACID=c.ID)
|
|
//
|
|
// where a.SEGCODE='{0}'";
|
|
string sql = @"select [ID] as cID, SEGCODE,SEGDESC,MUSER,MTIME
|
|
from ICSSEG
|
|
where SEGCODE='{0}' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql, CODE);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSSEGUIModel returnInfo = new FormICSSEGUIModel();
|
|
returnInfo.SEGCODE = dr["SEGCODE"].ToString();
|
|
//returnInfo.SEGSEQ = Convert.ToInt32(dr["SEGSEQ"].ToString());
|
|
returnInfo.SEGDESC = dr["SEGDESC"].ToString();
|
|
//returnInfo.SEGManager = dr["UserCode"].ToString();
|
|
//returnInfo.SEGManager ="";
|
|
//returnInfo.shifType = new FormICSShifTypeUIModel();
|
|
|
|
|
|
|
|
string cIDtest = dr["cID"].ToString();
|
|
|
|
if (!cIDtest.Equals(""))
|
|
{
|
|
returnInfo.fac = new FormICSFactoryUIModel();
|
|
returnInfo.fac.ID = dr["cID"].ToString();
|
|
//returnInfo.fac.FACCODE = dr["FACCODE"].ToString();
|
|
//returnInfo.fac.FACDESC = dr["FACDESC"].ToString();
|
|
}
|
|
if (!returnseg.Contains(returnInfo))
|
|
{
|
|
returnseg.Add(returnInfo);
|
|
}
|
|
|
|
|
|
}
|
|
return returnseg;
|
|
|
|
}
|
|
#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.ICSSEG.Where(a => codeList.Contains(a.SEGCODE));
|
|
db.ICSSEG.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 判断是否在产线中
|
|
public static bool IncludingSS(List<string> idList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool flag = false;
|
|
var lines = db.ICSSS.Where(a => idList.Contains(a.SEGID));
|
|
if (lines.Count() != 0)
|
|
flag = true;
|
|
|
|
return flag;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 车间代码是否存在
|
|
public static bool IsIncluding(string segCODE, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSSEG.SingleOrDefault(a => a.SEGCODE == segCODE && a.WorkPoint== AppConfig.WorkPointCode);
|
|
if (line == null)
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 判断车间是否和设备类型关联
|
|
public static bool IncludingEquipment(List<string> idList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool flag = false;
|
|
var lines = db.ICSEquipmentType.Where(a => idList.Contains(a.SEGCODE));
|
|
if (lines.Count() != 0)
|
|
flag = true;
|
|
return flag;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|