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.
89 lines
2.8 KiB
89 lines
2.8 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 ICSSoft.Base.Config.AppConfig;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class FormICSAutoCMPOPADDDLL
|
|
{
|
|
|
|
public static void AddorEdit(List<ICSAutoCMPOP> list,string conn) {
|
|
FramDataContext frame = new FramDataContext(conn);
|
|
frame.Connection.Open();
|
|
frame.Transaction = frame.Connection.BeginTransaction();
|
|
try {
|
|
foreach (ICSAutoCMPOP op in list) {
|
|
bool isnew = false;
|
|
var isexist = frame.ICSAutoCMPOP.Where(a => a.id != op.id && a.opcode == op.opcode).FirstOrDefault(); ;
|
|
if (isexist != null) {
|
|
throw new Exception("工序:"+op.opcode+"已维护");
|
|
}
|
|
var autoop = frame.ICSAutoCMPOP.Where(a => a.id == op.id).FirstOrDefault();
|
|
if (autoop == null) {
|
|
isnew = true;
|
|
autoop = new ICSAutoCMPOP();
|
|
autoop.id = AppConfig.GetGuid();
|
|
}
|
|
autoop.opcode = op.opcode;
|
|
autoop.Mtime = DateTime.Now;
|
|
autoop.Muser = AppConfig.UserCode;
|
|
autoop.Musername = AppConfig.UserName;
|
|
autoop.Status = op.Status;
|
|
|
|
if (isnew)
|
|
frame.ICSAutoCMPOP.InsertOnSubmit(autoop);
|
|
|
|
frame.SubmitChanges();
|
|
|
|
}
|
|
|
|
|
|
frame.Transaction.Commit();
|
|
}
|
|
catch (Exception ex) {
|
|
frame.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
public static ICSAutoCMPOP Search(string id, string conn)
|
|
{
|
|
FramDataContext frame = new FramDataContext(conn);
|
|
frame.Connection.Open();
|
|
try
|
|
{
|
|
return frame.ICSAutoCMPOP.Where(a => a.id == id).FirstOrDefault();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
public static void Delete(List<string> id, string conn)
|
|
{
|
|
FramDataContext frame = new FramDataContext(conn);
|
|
frame.Connection.Open();
|
|
frame.Transaction = frame.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
frame.ICSAutoCMPOP.DeleteAllOnSubmit(frame.ICSAutoCMPOP.Where(a => id.Contains(a.id)));
|
|
frame.SubmitChanges();
|
|
frame.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
frame.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|