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.
99 lines
3.3 KiB
99 lines
3.3 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 ICSOP2RESDAL
|
|
{
|
|
#region AddandEdit
|
|
public static void AddandEdit(DataTable dt,string opid,string code, string Appconstr)
|
|
{
|
|
FramDataContext db = new FramDataContext(Appconstr);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
int seq = 0;
|
|
string sql = @"SELECT MAX(RESSEQ) as RESSEQ FROM dbo.ICSOP2RES WHERE OPID='{0}'";
|
|
sql = string.Format(sql,opid);
|
|
DataTable seqDt = DBHelper.ExecuteDataset(Appconstr,CommandType.Text,sql).Tables[0];
|
|
if (seqDt.Rows[0]["RESSEQ"].ToString()!="")
|
|
{
|
|
seq = int.Parse(seqDt.Rows[0]["RESSEQ"].ToString());
|
|
}
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
seq++;
|
|
ICSOP2RES lines = new ICSOP2RES();
|
|
lines.OPID = opid;
|
|
lines.RESID = dt.Rows[i]["ID"].ToString();
|
|
lines.OPCODE = code;
|
|
lines.RESCODE = dt.Rows[i]["资源代码"].ToString();
|
|
lines.RESSEQ = seq;
|
|
lines.MUSER = AppConfig.UserId;
|
|
lines.MUSERName = AppConfig.UserName;
|
|
lines.WorkPoint = AppConfig.WorkPointCode;
|
|
lines.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
|
|
db.ICSOP2RES.InsertOnSubmit(lines);
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region delete
|
|
public static void delete(List<String> guidList,string conn)
|
|
{
|
|
FramDataContext db = new FramDataContext(conn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSOP2RES.Where(a => guidList.Contains(a.RESID));
|
|
db.ICSOP2RES.DeleteAllOnSubmit(line);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static void Edit(List<string> idList, List<string> seqList)
|
|
{
|
|
try
|
|
{
|
|
for(int i=0;i<idList.Count;i++){
|
|
string sql = @"UPDATE dbo.ICSOP2RES SET RESSEQ='{0}' WHERE RESID='{1}'";
|
|
sql = string.Format(sql,seqList[i],idList[i]);
|
|
DBHelper.ExecuteNonQuery(AppConfig.AppConnectString,CommandType.Text,sql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|