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.
132 lines
4.1 KiB
132 lines
4.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Data;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSTeamGroupDAL
|
|
{
|
|
public static void Edit(List<ICSSGroup> list)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (ICSSGroup g in list)
|
|
{
|
|
bool add = false;
|
|
var line = db.ICSSGroup.SingleOrDefault(a => a.SGroup == g.SGroup && a.WorkPoint == g.WorkPoint);
|
|
if (line == null)
|
|
{
|
|
add = true;
|
|
line = new ICSSGroup();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.SGroup = g.SGroup;
|
|
line.WorkPoint = g.WorkPoint;
|
|
}
|
|
line.SGroupDESC = g.SGroupDESC;
|
|
line.MUSER = g.MUSER;
|
|
line.MUSERName = g.MUSERName;
|
|
line.MTIME = g.MTIME;
|
|
if (add)
|
|
{
|
|
db.ICSSGroup.InsertOnSubmit(line);
|
|
}
|
|
db.SubmitChanges();
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
}
|
|
|
|
public static void DeleteFromID(List<string> list)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSSGroup.Where(a => list.Contains(a.ID));
|
|
db.ICSSGroup.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
|
|
}
|
|
public static void DeleteFromCode(List<string> list)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSSGroup.Where(a => list.Contains(a.SGroup) && a.WorkPoint == AppConfig.WorkPointCode);
|
|
db.ICSSGroup.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public static List<ICSSGroup> Select(List<string> listID)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSSGroup.Where(a => listID.Contains(a.ID)).ToList();
|
|
return lines;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
db.Connection.Close();
|
|
}
|
|
|
|
}
|
|
|
|
public static DataTable SelectAll()
|
|
{
|
|
string sql = "SELECT SGroup 班组代码,SGroupDESC 班组说明 FROM dbo.ICSSGroup WHERE WorkPoint='" + AppConfig.WorkPointCode + "'";
|
|
return DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
}
|
|
}
|
|
}
|