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.
198 lines
6.7 KiB
198 lines
6.7 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;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSSecDocTypeStepDAL
|
|
{
|
|
#region 增加修改
|
|
public static void AddandEdit(ICSSecDocTypeStep lineNew, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSSecDocTypeStep.SingleOrDefault(a => a.guid == lineNew.guid);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSSecDocTypeStep();
|
|
line.guid = AppConfig.GetGuid();
|
|
}
|
|
|
|
var codes = db.ICSSecDocTypeStep.Where(a => a.DocTypeID == lineNew.DocTypeID && a.DocTypeStep == lineNew.DocTypeStep && a.guid != line.guid);
|
|
if (codes.ToList().Count > 0)
|
|
{
|
|
throw new Exception("消息类型对应的次序已存在");
|
|
}
|
|
|
|
line.DocTypeID = lineNew.DocTypeID;
|
|
line.DocTypeStep = lineNew.DocTypeStep;
|
|
line.DocTypeStepDesc = lineNew.DocTypeStepDesc;
|
|
line.DocTypeTo = lineNew.DocTypeTo;
|
|
line.DocTypeCC = lineNew.DocTypeCC;
|
|
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
if (isNew)
|
|
db.ICSSecDocTypeStep.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 增加修改List
|
|
public static void AddandEditList(List<ICSSecDocTypeStep> lineNewList, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSSecDocTypeStep lineNew in lineNewList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSSecDocTypeStep.SingleOrDefault(a => a.DocTypeID == lineNew.DocTypeID && a.DocTypeStep == lineNew.DocTypeStep);
|
|
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSSecDocTypeStep();
|
|
line.guid = AppConfig.GetGuid();
|
|
}
|
|
|
|
line.DocTypeID = lineNew.DocTypeID;
|
|
line.DocTypeStep = lineNew.DocTypeStep;
|
|
line.DocTypeStepDesc = lineNew.DocTypeStepDesc;
|
|
line.DocTypeTo = lineNew.DocTypeTo;
|
|
line.DocTypeCC = lineNew.DocTypeCC;
|
|
line.EATTRIBUTE1 = lineNew.EATTRIBUTE1;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
if (isNew)
|
|
db.ICSSecDocTypeStep.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
public static ICSSecDocTypeStep select(String ID, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSSecDocTypeStep entity = new ICSSecDocTypeStep();
|
|
try
|
|
{
|
|
var line = db.ICSSecDocTypeStep.SingleOrDefault(a => a.guid == ID);
|
|
return (ICSSecDocTypeStep)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public static ICSSecDocTypeStep selectSeqTop(String DocTypeID, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSSecDocTypeStep entity = new ICSSecDocTypeStep();
|
|
try
|
|
{
|
|
var line = db.ICSSecDocTypeStep.Where(a => a.DocTypeID == DocTypeID).OrderBy(a=>a.DocTypeStep);
|
|
if (line != null)
|
|
return (ICSSecDocTypeStep)line.First();
|
|
else
|
|
return null;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static ICSSecDocTypeStep selectStepBySeq(String DocTypeID, String seq, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSSecDocTypeStep.Where(a => a.DocTypeID == DocTypeID && a.DocTypeStep == seq).OrderBy(a => a.DocTypeStep);
|
|
if (line != null)
|
|
return (ICSSecDocTypeStep)line.First();
|
|
else
|
|
return null;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static void delete(List<String> guidList, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSSecDocTypeStep.Where(a => guidList.Contains(a.guid));
|
|
db.ICSSecDocTypeStep.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|