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.
123 lines
4.5 KiB
123 lines
4.5 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 ICSSoft.Base.Config.DBHelper;
|
|
|
|
namespace ICSSoft.Frame.Data.DAL
|
|
{
|
|
public class ICSINVBusinessDAL
|
|
{
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSINVBusinessUIModel> maInfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSINVBusinessUIModel maInfo in maInfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSINVBusiness.SingleOrDefault(a => a.ID == maInfo.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSINVBusiness();
|
|
line.ID = AppConfig.GetGuid();
|
|
line.BusinessCode = maInfo.BusinessCode;
|
|
}
|
|
line.BusinessDesc = maInfo.BusinessDesc;
|
|
line.BusinessType = maInfo.BusinessType;
|
|
line.ISFIFO = maInfo.ISFIFO;
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
line.MUSER = AppConfig.UserId;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = DateTime.Now;
|
|
if (isNew)
|
|
db.ICSINVBusiness.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 通过guid查询
|
|
public static List<FormICSINVBusinessUIModel> SearchMAInfoByID(string maid, string dsconn)
|
|
{
|
|
List<FormICSINVBusinessUIModel> returnmma = new List<FormICSINVBusinessUIModel>();
|
|
string sql = @"select BusinessCode as BusinessCode,BusinessDesc as BusinessDesc,BusinessType as BusinessType,ISFIFO as ISFIFO
|
|
from ICSINVBusiness
|
|
where ID='{0}'";
|
|
sql = string.Format(sql, maid);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSINVBusinessUIModel returnInfo = new FormICSINVBusinessUIModel();
|
|
returnInfo.BusinessCode = dr["BusinessCode"].ToString();
|
|
returnInfo.BusinessDesc = dr["BusinessDesc"].ToString();
|
|
returnInfo.BusinessType = dr["BusinessType"].ToString();
|
|
returnInfo.ISFIFO = dr["ISFIFO"].ToString();
|
|
if (!returnmma.Contains(returnInfo))
|
|
{
|
|
returnmma.Add(returnInfo);
|
|
}
|
|
}
|
|
return returnmma;
|
|
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public static void deleteInfo(List<string> maidList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSINVBusiness.Where(a => maidList.Contains(a.ID));
|
|
db.ICSINVBusiness.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 代码是否存在
|
|
public static bool IsIncluding(string macode,string workpoint, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var line = db.ICSINVBusiness.SingleOrDefault(a => a.BusinessCode == macode && a.WorkPoint == workpoint);
|
|
if (line == null)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|