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.
138 lines
4.5 KiB
138 lines
4.5 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 ICSOQCCKDAL
|
|
{
|
|
public static void AddandEdit(ICSOQCCK MODEL, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSOQCCK.SingleOrDefault(a => a.ID == MODEL.ID);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSOQCCK();
|
|
line.ID = AppConfig.GetGuid(); ;
|
|
}
|
|
line.ItemCode = MODEL.ItemCode;
|
|
line.IsOPCheck = MODEL.IsOPCheck;
|
|
line.ISREF = MODEL.ISREF;
|
|
line.MUSER = MODEL.MUSER;
|
|
line.MUSERName = MODEL.MUSERName;
|
|
line.MTIME = MODEL.MTIME;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
if (isNew)
|
|
db.ICSOQCCK.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.ICSOQCCK.Where(a => guidList.Contains(a.ID));
|
|
db.ICSOQCCK.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
|
|
}
|
|
}
|