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.
114 lines
3.9 KiB
114 lines
3.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSEqpSuspendDetailDAL
|
|
{
|
|
public static void Begin(Entity.ICSEqpSuspendDetail info, string conn)
|
|
{
|
|
FramDataContext db = new FramDataContext(conn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
int i = db.ICSEqpSuspendDetail.Where(a => a.PAUSEID == info.PAUSEID && a.BeginTime != null && a.EndTime == null).Count();
|
|
if (i > 0)
|
|
{
|
|
throw new Exception("本次暂停过程中,上次调机未结束, 你的账号是否在多处登录报工界面并对同一[跟踪单-工序]进行操作?请退出所有此[跟踪单-工序]的报工,重新登陆");
|
|
}
|
|
db.ICSEqpSuspendDetail.InsertOnSubmit(info);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
}
|
|
public static void End(Entity.ICSEqpSuspendDetail info, string conn)
|
|
{
|
|
FramDataContext db = new FramDataContext(conn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.LOTNO == info.LOTNO
|
|
&& a.ROUTECODE == info.ROUTECODE
|
|
&& a.OPCODE == info.OPCODE
|
|
&& a.OPUserCode == info.OPUserCode
|
|
&& a.SuspendState == "BEGIN"
|
|
&& a.WorkPoint == info.WorkPoint
|
|
);
|
|
line.EndTime = info.EndTime;
|
|
line.SuspendState = info.SuspendState;
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static void EndSus(Entity.ICSEqpSuspendDetail info, string conn)
|
|
{
|
|
FramDataContext db = new FramDataContext(conn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.ID == info.ID && a.SuspendState == "BEGIN");
|
|
if (line != null)
|
|
{
|
|
line.EndTime = info.EndTime;
|
|
line.SuspendState = info.SuspendState;
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
}
|
|
|
|
public static void End(string ID, string conn)
|
|
{
|
|
FramDataContext db = new FramDataContext(conn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.ID == ID);
|
|
line.EndTime = DateTime.Now;
|
|
line.SuspendState = "END";
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|