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.
108 lines
3.9 KiB
108 lines
3.9 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 ICSITEMBoxDAL
|
|
{
|
|
#region 新增和修改
|
|
public static void Add(List<FormICSITEMBoxUIModel> InfoList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSITEMBoxUIModel info in InfoList)
|
|
{
|
|
bool isNew = false;
|
|
var line = db.ICSITEMBox.SingleOrDefault(a => a.ID == info.ID && a.WorkPoint == AppConfig.WorkPointCode);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSITEMBox();
|
|
line.ID = AppConfig.GetGuid();
|
|
}
|
|
line.BoxNO = info.BoxNO;
|
|
line.NO = info.NO;
|
|
line.CUSORDERNO = info.CUSORDERNO;
|
|
line.CUSITEMCODE = info.CUSITEMCODE;
|
|
line.INVStd = info.INVStd;
|
|
line.QTY = info.QTY;
|
|
|
|
line.MUSER = AppConfig.UserCode;
|
|
line.MUSERName = AppConfig.UserName;
|
|
line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
line.WorkPoint = AppConfig.WorkPointCode;
|
|
if (isNew)
|
|
{
|
|
db.ICSITEMBox.InsertOnSubmit(line);
|
|
}
|
|
db.SubmitChanges();
|
|
foreach (ICSITEMBoxDetail infoDetail in info.ITEMBoxDetail)
|
|
{
|
|
bool isNewDetail = false;
|
|
var lineDetail = db.ICSITEMBoxDetail.SingleOrDefault(a => a.ID == infoDetail.ID && a.WorkPoint == AppConfig.WorkPointCode);
|
|
if (lineDetail == null)
|
|
{
|
|
isNewDetail = true;
|
|
lineDetail = new ICSITEMBoxDetail();
|
|
lineDetail.ID = AppConfig.GetGuid();
|
|
}
|
|
lineDetail.NO = infoDetail.NO;
|
|
lineDetail.LOTNO = infoDetail.LOTNO;
|
|
lineDetail.QTY = infoDetail.QTY;
|
|
|
|
lineDetail.MUSER = AppConfig.UserCode;
|
|
lineDetail.MUSERName = AppConfig.UserName;
|
|
lineDetail.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss");
|
|
lineDetail.WorkPoint = AppConfig.WorkPointCode;
|
|
if (isNewDetail)
|
|
{
|
|
db.ICSITEMBoxDetail.InsertOnSubmit(lineDetail);
|
|
}
|
|
db.SubmitChanges();
|
|
|
|
}
|
|
}
|
|
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
public static void deleteInfo(List<string> codeList, string dsconn)
|
|
{
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSITEMBox.Where(a => codeList.Contains(a.ID));
|
|
db.ICSITEMBox.DeleteAllOnSubmit(lines);
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|