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.
186 lines
6.4 KiB
186 lines
6.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSShifTypeDAL
|
|
{
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSShifTypeUIModel> typeInfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSShifTypeUIModel typeinfo in typeInfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSSHIFTTYPE.SingleOrDefault(a => a.ID == typeinfo.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSSHIFTTYPE();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.SHIFTTYPECODE = typeinfo.SHIFTTYPECODE;
|
|
|
|
}
|
|
line.SHIFTTYPEDESC = typeinfo.SHIFTTYPEDESC;
|
|
line.EFFDATE = Convert.ToDateTime(typeinfo.EFFDATE);
|
|
line.IVLDATE = Convert.ToDateTime(typeinfo.IVLDATE);
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
if (isNew)
|
|
db.ICSSHIFTTYPE.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 通过班制id查询
|
|
public static List<FormICSShifTypeUIModel> SearchTypeInfoByCode(string typeID, string dsconn)
|
|
{
|
|
List<FormICSShifTypeUIModel> returntype = new List<FormICSShifTypeUIModel>();
|
|
string sql = @"select ID,SHIFTTYPECODE,SHIFTTYPEDESC,EFFDATE,IVLDATE
|
|
from ICSSHIFTTYPE
|
|
where ID='{0}'";
|
|
sql = string.Format(sql, typeID);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSShifTypeUIModel returnInfo = new FormICSShifTypeUIModel();
|
|
returnInfo.ID = dr["ID"].ToString();
|
|
returnInfo.SHIFTTYPECODE = dr["SHIFTTYPECODE"].ToString();
|
|
returnInfo.SHIFTTYPEDESC = dr["SHIFTTYPEDESC"].ToString();
|
|
returnInfo.EFFDATE = Convert.ToDateTime(dr["EFFDATE"].ToString());
|
|
returnInfo.IVLDATE = Convert.ToDateTime(dr["IVLDATE"].ToString());
|
|
returntype.Add(returnInfo);
|
|
|
|
}
|
|
return returntype;
|
|
|
|
}
|
|
#endregion
|
|
#region 班制代码是否存在
|
|
public static bool IsIncluding(string SHIFTTYPECODE, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSSHIFTTYPE.SingleOrDefault(a => a.SHIFTTYPECODE == SHIFTTYPECODE);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 判断是否在班次中
|
|
public static bool IncludingShift(List<string> idList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
bool flag = false;
|
|
var lines = db.ICSSHIFT.Where(a => idList.Contains(a.SHIFTTYPEID));
|
|
if (lines.Count() != 0)
|
|
flag = true;
|
|
|
|
return flag;
|
|
|
|
|
|
//bool flag=false;
|
|
//foreach (string test in idList)
|
|
//{
|
|
// var lines = db.ICSSHIFT.SingleOrDefault(a => a.SHIFTTYPEID == test);
|
|
// if (lines != null)
|
|
// flag = true;
|
|
//}
|
|
//return flag;
|
|
//var lines = db.ICSSHIFT.Where(a => idList.Contains(a.SHIFTTYPEID));
|
|
|
|
//if (lines == null)
|
|
// return true;
|
|
//else
|
|
// return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public static void deleteInfo(List<string> idList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSSHIFTTYPE.Where(a => idList.Contains(a.ID));
|
|
db.ICSSHIFTTYPE.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 查询最大的班制代码
|
|
public static string SearchMaxCode(string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
string lines = db.ICSSHIFTTYPE.Max(a=>a.SHIFTTYPECODE);
|
|
return lines;
|
|
//db.ICSSHIFTTYPE.DeleteAllOnSubmit(lines);
|
|
//db.SubmitChanges();
|
|
//db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|