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.
209 lines
7.6 KiB
209 lines
7.6 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 System.Data.Sql;
|
|
using System.Data.Linq;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSOQCCKGROUPDAL
|
|
{
|
|
public static void AddandEdit(ICSOQCCKGROUP MODEL, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.ID == MODEL.ID && a.WorkPoint==MODEL.WorkPoint);
|
|
|
|
var codes = db.ICSOQCCKGROUP.Where(a => a.CKGROUP == MODEL.CKGROUP && a.WorkPoint == MODEL.WorkPoint && a.ID != MODEL.ID);
|
|
if (codes.ToList().Count > 0)
|
|
{
|
|
throw new Exception("检验项目编码已存在!");
|
|
}
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSOQCCKGROUP();
|
|
line.ID = MODEL.ID;
|
|
}
|
|
|
|
line.CKGROUP = MODEL.CKGROUP;
|
|
line.CKGROUPDNAME = MODEL.CKGROUPDNAME;
|
|
line.CKGROUPDESC = MODEL.CKGROUPDESC;
|
|
line.ISREF = MODEL.ISREF;
|
|
line.MUSERName = MODEL.MUSERName;
|
|
line.MUSER = MODEL.MUSER;
|
|
line.MTIME = MODEL.MTIME;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
if (isNew) db.ICSOQCCKGROUP.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
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.ICSOQCCKGROUP.Where(a => guidList.Contains(a.ID) && a.WorkPoint == AppConfig.WorkPointCode);
|
|
foreach (var item in lines)
|
|
{
|
|
var list = db.ICSOQCCKLIST.Where(a => a.CKGROUPCode == item.CKGROUP && a.WorkPoint == item.WorkPoint);
|
|
if (list != null && list.Count() > 0)
|
|
throw new Exception("检验项目编码:" + item.CKGROUP + " 已被引用,不能删除!");
|
|
}
|
|
db.ICSOQCCKGROUP.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#region 获取检验方式
|
|
public static DataTable SearchData(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00015' AND WorkPointCode = '{0}' ";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable SearchData(string EnumText, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00015' AND EnumText = '{0}' AND WorkPointCode = '{1}' ";
|
|
sql = string.Format(sql, EnumText, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取检验属性
|
|
public static DataTable SearchDataa(string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00016' AND WorkPointCode = '{0}' ";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static DataTable SearchDataa(string EnumText, string dsconn)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT EnumKey, EnumText FROM Sys_EnumValues WHERE 1=1 AND EnumKey = '00016' AND EnumText = '{0}' AND WorkPointCode = '{1}' ";
|
|
sql = string.Format(sql, EnumText, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static ICSOQCCKGROUP search(string CKGROUP, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSOQCCKGROUP entity = new ICSOQCCKGROUP();
|
|
try
|
|
{
|
|
var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.CKGROUP == CKGROUP && a.WorkPoint == AppConfig.WorkPointCode);
|
|
return (ICSOQCCKGROUP)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static string AddList(List<ICSOQCCKGROUP> InfoList, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
string str = "OK";
|
|
foreach (ICSOQCCKGROUP info in InfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSOQCCKGROUP.SingleOrDefault(a => a.CKGROUP == info.CKGROUP && a.WorkPoint == info.WorkPoint);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSOQCCKGROUP();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
line.CKGROUP = info.CKGROUP;
|
|
line.CKGROUPDESC = info.CKGROUPDESC;
|
|
line.CKGROUPDNAME = info.CKGROUPDNAME;
|
|
line.ISREF = info.ISREF;
|
|
line.MUSER = info.MUSER;
|
|
line.MUSERName = info.MUSERName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.EATTRIBUTE1 = null;
|
|
if (isNew) db.ICSOQCCKGROUP.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
return str;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|