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.
157 lines
5.8 KiB
157 lines
5.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using System.Data;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSAQLDAL
|
|
{
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSAQLUIModel> aqlInfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSAQLUIModel aqlinfo in aqlInfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSAQL.SingleOrDefault(a => a.ID==aqlinfo.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSAQL();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.AQLSEQ = aqlinfo.AQLSEQ;
|
|
line.AQLLEVEL = aqlinfo.AQLLEVEL;
|
|
}
|
|
|
|
line.LOTSIZEMIN = aqlinfo.LOTSIZEMIN;
|
|
line.LOTSIZEMAX = aqlinfo.LOTSIZEMAX;
|
|
line.SampleSize = aqlinfo.SampleSize;
|
|
line.RejectSize = aqlinfo.RejectSize;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
|
|
if (isNew)
|
|
db.ICSAQL.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 代码是否存在
|
|
public static bool IsIncluding(int AQLSEQ,string AQLLEVEL,string workpoint, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSAQL.SingleOrDefault(a => a.AQLSEQ == AQLSEQ && a.AQLLEVEL == AQLLEVEL && a.WorkPoint == workpoint);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 通过guid查询
|
|
public static List<FormICSAQLUIModel> SearchAQLInfoByID(string aqlid, string dsconn)
|
|
{
|
|
List<FormICSAQLUIModel> returnaql = new List<FormICSAQLUIModel>();
|
|
string sql = @"select AQLSEQ as AQLSEQ,AQLLEVEL as AQLLEVEL,LOTSIZEMIN as LOTSIZEMIN,LOTSIZEMAX as LOTSIZEMAX,SampleSize as SampleSize,RejectSize as RejectSize
|
|
from ICSAQL
|
|
where ID='{0}'";
|
|
sql = string.Format(sql, aqlid);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSAQLUIModel returnInfo = new FormICSAQLUIModel();
|
|
returnInfo.AQLSEQ = Convert.ToInt32(dr["AQLSEQ"].ToString());
|
|
returnInfo.AQLLEVEL = dr["AQLLEVEL"].ToString();
|
|
returnInfo.LOTSIZEMIN = Convert.ToInt32(dr["LOTSIZEMIN"].ToString());
|
|
returnInfo.LOTSIZEMAX = Convert.ToInt32(dr["LOTSIZEMAX"].ToString());
|
|
returnInfo.SampleSize = Convert.ToInt32(dr["SampleSize"].ToString());
|
|
returnInfo.RejectSize = Convert.ToInt32(dr["RejectSize"].ToString());
|
|
if (!returnaql.Contains(returnInfo))
|
|
{
|
|
returnaql.Add(returnInfo);
|
|
}
|
|
|
|
|
|
}
|
|
return returnaql;
|
|
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public static void deleteInfo(List<string> aqlid, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
var lines = db.ICSAQL.Where(a=>aqlid.Contains(a.ID));
|
|
db.ICSAQL.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 通过检验标准查询
|
|
public static List<FormICSAQLUIModel> SearchAQLInfoByLevel(string aqllevel, string dsconn)
|
|
{
|
|
List<FormICSAQLUIModel> returnaql = new List<FormICSAQLUIModel>();
|
|
string sql = @"select LOTSIZEMIN as LOTSIZEMIN,LOTSIZEMAX as LOTSIZEMAX
|
|
from ICSAQL
|
|
where AQLLEVEL='{0}'";
|
|
sql = string.Format(sql, aqllevel);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSAQLUIModel returnInfo = new FormICSAQLUIModel();
|
|
returnInfo.LOTSIZEMIN = Convert.ToInt32(dr["LOTSIZEMIN"].ToString());
|
|
returnInfo.LOTSIZEMAX = Convert.ToInt32(dr["LOTSIZEMAX"].ToString());
|
|
if (!returnaql.Contains(returnInfo))
|
|
{
|
|
returnaql.Add(returnInfo);
|
|
}
|
|
|
|
|
|
}
|
|
return returnaql;
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|