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.
110 lines
3.4 KiB
110 lines
3.4 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 ICSECSGDAL
|
|
{
|
|
|
|
#region AddandEdit
|
|
public static void AddandEdit(ICSECSG ItemLot, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSECSG.SingleOrDefault(a => a.ID == ItemLot.ID);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSECSG();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
|
|
var codes = db.ICSECSG.Where(a => a.ECSGCODE == ItemLot.ECSGCODE && a.ID != line.ID);
|
|
if (codes.ToList().Count > 0)
|
|
{
|
|
throw new Exception("不良原因组代码已存在");
|
|
}
|
|
|
|
line.ECSGCODE = ItemLot.ECSGCODE;
|
|
line.ECSGDESC = ItemLot.ECSGDESC;
|
|
line.MUSER = ItemLot.MUSER;
|
|
line.MUSERName = ItemLot.MUSERName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
if (isNew) db.ICSECSG.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region select
|
|
public static ICSECSG select(String guid, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSECSG entity = new ICSECSG();
|
|
try
|
|
{
|
|
var line = db.ICSECSG.SingleOrDefault(a => a.ID == guid);
|
|
return (ICSECSG)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region delete
|
|
public static void delete(List<String> guidList, List<string> codeList)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSECSG.Where(a => guidList.Contains(a.ID));
|
|
var line = db.ICSECSG2ECS.Where(a => codeList.Contains(a.ECSGCODE));
|
|
if (line.Count() != 0)
|
|
{
|
|
throw new Exception("该不良原因组已与不良原因关联,无法删除!");
|
|
}
|
|
db.ICSECSG.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|