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.
256 lines
8.5 KiB
256 lines
8.5 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 ICSShipToStockDAL
|
|
{
|
|
|
|
|
|
|
|
#region 增加修改
|
|
|
|
public static void AddAndEdit(List<FormICSShipToStockUIModel> ShipToStockList, string dsconn)
|
|
{
|
|
|
|
FramDataContext db = new FramDataContext(dsconn);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
foreach (FormICSShipToStockUIModel ShipToStock in ShipToStockList)
|
|
{
|
|
|
|
bool isNew = false;
|
|
var line = db.ICSShipToStock.SingleOrDefault(a => a.ID == ShipToStock.ID);
|
|
if (line == null)
|
|
{
|
|
isNew = true;
|
|
line = new ICSShipToStock();
|
|
line.ID = AppConfig.GetGuid();
|
|
|
|
|
|
}
|
|
line.ITEMCODE = ShipToStock.ITEMCODE;
|
|
line.VENDORCODE = ShipToStock.VENDORCODE;
|
|
line.EFFDATE = Convert.ToDateTime(ShipToStock.EFFDATE);
|
|
line.IVLDATE = Convert.ToDateTime(ShipToStock.IVLDATE);
|
|
line.ACTIVE = ShipToStock.ACTIVE;
|
|
line.MUSER = ShipToStock.MUSER;
|
|
line.MUSERName = ShipToStock.MUSERName;
|
|
line.MTIME = Convert.ToDateTime(ShipToStock.MTIME);
|
|
line.WorkPoint = ShipToStock.WorkPoint;
|
|
line.EATTRIBUTE1 = ShipToStock.EATTRIBUTE1;
|
|
|
|
if (isNew)
|
|
db.ICSShipToStock.InsertOnSubmit(line);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
////#region 班次代码是否存在
|
|
////public static bool IsIncludingShiftCode(string shiftcode, string dsconn)
|
|
////{
|
|
|
|
//// FramDataContext db = new FramDataContext(dsconn);
|
|
//// db.Connection.Open();
|
|
//// db.Transaction = db.Connection.BeginTransaction();
|
|
//// try
|
|
//// {
|
|
//// var line = db.ICSSHIFT.SingleOrDefault(a => a.SHIFTCODE == shiftcode);
|
|
//// if (line == null)
|
|
//// return true;
|
|
//// else
|
|
//// return false;
|
|
//// }
|
|
//// catch (Exception ex)
|
|
//// {
|
|
//// db.Transaction.Rollback();
|
|
//// throw ex;
|
|
//// }
|
|
|
|
////}
|
|
////#endregion
|
|
|
|
|
|
|
|
//#region 班次次序是否存在
|
|
//public static bool IsIncludingInShiftSeq(int shiftsqe, string shifttypeid)
|
|
//{
|
|
|
|
// FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
// db.Connection.Open();
|
|
// db.Transaction = db.Connection.BeginTransaction();
|
|
// try
|
|
// {
|
|
// var line = db.ICSSHIFT.SingleOrDefault(a => a.SHIFTSEQ == shiftsqe && a.SHIFTTYPEID == shifttypeid);
|
|
// if (line == null)
|
|
// return true;
|
|
// else
|
|
// return false;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// db.Transaction.Rollback();
|
|
// throw ex;
|
|
// }
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
//#region 班次代码是否在时段维护中使用
|
|
//public static bool isIncludingInICSTP(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.ICSTP.Where(a => idList.Contains(a.SHIFTID));
|
|
// if (lines.Count() != 0)
|
|
// flag = true;
|
|
|
|
// return flag;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// //db.Transaction.Rollback();
|
|
// throw ex;
|
|
// }
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
|
|
public static List<FormICSShipToStockUIModel> SearchShipToStockByCode(string id, string dsconn)
|
|
{
|
|
List<FormICSShipToStockUIModel> returnshift = new List<FormICSShipToStockUIModel>();
|
|
string sql = @"select a.ID as ID,b.INVCODE as ITEMCODE,c.VendorCode as VENDORCODE,a.EFFDATE as EFFDATE,a.IVLDATE as IVLDATE,a.ACTIVE as ACTIVE,a.MUSERName as MUSERName,a.MTIME as MTIME
|
|
from ICSShipToStock a
|
|
left join ICSINVENTORY b on a.ITEMCODE=b.INVCODE
|
|
left join ICSVendor c on a.VENDORCODE=c.VendorCode
|
|
where a.ID='{0}'";
|
|
sql = string.Format(sql, id);
|
|
DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
FormICSShipToStockUIModel shiftInfo = new FormICSShipToStockUIModel();
|
|
shiftInfo.ID = dr["ID"].ToString();
|
|
shiftInfo.inventory = new FormICSINVENTORYUIModel();
|
|
shiftInfo.inventory.INVCODE = dr["ITEMCODE"].ToString();
|
|
shiftInfo.vendor = new FormICSVendorUIModel();
|
|
shiftInfo.vendor.VendorCode = dr["VENDORCODE"].ToString();
|
|
shiftInfo.EFFDATE = Convert.ToDateTime(dr["EFFDATE"]);
|
|
shiftInfo.IVLDATE = Convert.ToDateTime(dr["IVLDATE"]);
|
|
shiftInfo.ACTIVE =dr["ACTIVE"].ToString();
|
|
shiftInfo.MUSERName = dr["MUSERName"].ToString();
|
|
shiftInfo.MTIME = System.DateTime.Parse(dr["MTIME"].ToString());
|
|
|
|
if (!returnshift.Contains(shiftInfo))
|
|
{
|
|
returnshift.Add(shiftInfo);
|
|
}
|
|
|
|
}
|
|
return returnshift;
|
|
|
|
}
|
|
|
|
public static DataTable SelectShiftTypeCode()
|
|
{
|
|
string sql = @"select SHIFTTYPECODE as [班制代码]
|
|
from dbo.ICSSHIFTTYPE
|
|
where 1=1";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
|
|
public static DataTable SelectShiftTypeId(string str)
|
|
{
|
|
string sql = @"select ID
|
|
from dbo.ICSSHIFTTYPE
|
|
where SHIFTTYPECODE='" + str + "'";
|
|
sql = string.Format(sql);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
return dt;
|
|
}
|
|
|
|
|
|
#region delete
|
|
public static void delete(List<String> guidList)
|
|
{
|
|
FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
|
|
db.Connection.Open();
|
|
db.Transaction = db.Connection.BeginTransaction();
|
|
try
|
|
{
|
|
var lines = db.ICSShipToStock.Where(a => guidList.Contains(a.ID));
|
|
db.ICSShipToStock.DeleteAllOnSubmit(lines);
|
|
|
|
db.SubmitChanges();
|
|
db.Transaction.Commit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public static DataTable GetShiftCode()
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select TOP 1 [SHIFTCODE]
|
|
FROM [dbo].[ICSSHIFT] order by SHIFTCODE desc";
|
|
return DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
// public static DataTable GetShiftSeqCode()
|
|
// {
|
|
// try
|
|
// {
|
|
// string sql = @"select TOP 1 [SHIFTSEQ]
|
|
// FROM [dbo].[ICSSHIFT] order by [SHIFTTYPEID] desc";
|
|
// return DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
}
|
|
|