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.
124 lines
4.0 KiB
124 lines
4.0 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 ICSUser2ResDAL
|
|
{
|
|
#region AddandEdit
|
|
public static void AddandEdit(ICSUser2Res ItemLot, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
ICSUser2Res line = new ICSUser2Res();
|
|
|
|
line.USERID = ItemLot.USERID;
|
|
|
|
line.RESID = ItemLot.RESID;
|
|
line.RESCODE = ItemLot.RESCODE;
|
|
line.USERCODE = ItemLot.USERCODE;
|
|
line.MUSER = ItemLot.MUSER;
|
|
line.MUSERName = ItemLot.MUSERName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
db.ICSUser2Res.InsertOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 根据资源代码查询资源id
|
|
public static DataTable SelectResID(string rescode)
|
|
{
|
|
string sql = @"select ID
|
|
from dbo.ICSRES
|
|
where RESCODE='" + rescode + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
#region 根据人员代码查询人员id
|
|
public static DataTable SelectUserID(string usercode)
|
|
{
|
|
string sql = @"select ID
|
|
from dbo.Sys_User
|
|
where UserCode='" + usercode + "' and WorkPointCode='" + AppConfig.WorkPointCode + "'";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
#endregion
|
|
|
|
#region select
|
|
public static ICSDCT select(String guid, String Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
ICSDCT entity = new ICSDCT();
|
|
try
|
|
{
|
|
var line = db.ICSDCT.SingleOrDefault(a => a.ID == guid);
|
|
return (ICSDCT)line;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region delete
|
|
public static void delete(List<String> useridList,List<string> residList)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSUser2Res.Where(a => useridList.Contains(a.USERID) && residList.Contains(a.RESID));
|
|
//var line = db.ICSRES.Where(a => codeList.Contains(a.DCTCODE));
|
|
//if (line.Count() != 0)
|
|
//{
|
|
// throw new Exception("DCT指令在资源维护已经使用,无法删除!");
|
|
//}
|
|
db.ICSUser2Res.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|