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.
428 lines
15 KiB
428 lines
15 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.Model;
|
|
|
|
namespace MESClassLibrary.DAL.Mistake247
|
|
{
|
|
public class BoxDAL
|
|
{
|
|
public static string TableName = "tb_Box_247";
|
|
|
|
|
|
|
|
|
|
#region 门板
|
|
/// <summary>
|
|
/// 左前
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247LF_MB()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo in('A2477204606','A2477204806','A2477205006') AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 左后
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247LR_MB()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo in('A2477305303','A2477305503','A2477305703') AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 右前
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247RF_MB()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo in('A2477204706','A2477204906','A2477205106') AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 右后
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247RR_MB()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo in('A2477305603','A2477305403','A2477305803') AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
#endregion
|
|
|
|
#region 轮眉
|
|
/// <summary>
|
|
/// 轮眉前左
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247LF_LM()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850022' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 轮眉前右
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247RF_LM()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850122' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 轮眉后左 -轮眉后左后和后左一样
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247LR_LM()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850222' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 轮眉后右 --大装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247RR_LM()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850322' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 后左前轮眉
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HLF_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477309400' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 后左后轮眉 和后左一样
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HLH_LM()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850222' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 后右前轮眉
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HRF_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477309600' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 后右后轮眉
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HRH_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2478850322' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
|
|
#region X243轮眉
|
|
/// <summary>
|
|
/// 前左 --X243
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX243LF_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_243] WHERE PartNo ='A2438808501' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 后左轮眉 --X243
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX243LR_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_243] WHERE PartNo ='A2478850222' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 前右 --X243
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX243RF_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_243] WHERE PartNo ='A2438808601' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// 后右后轮眉 --X243
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX243HRH_LM()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_243] WHERE PartNo ='A2478850322' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 扰流板
|
|
/// <summary>
|
|
/// X247后部扰流板装箱单 --大装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247H_RLB()
|
|
{
|
|
string sql = "SELECT top 1 * FROM [dbo].[tb_Box_247] WHERE PartNo='A2477900588' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// X247后部左侧扰流板装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HL_RLB()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477901300' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// X247后部右侧扰流板装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetX247HR_RLB()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477901400' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// H247 后部左侧扰流板装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetH247HL_RLB()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477900300' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
/// <summary>
|
|
/// H247 后部右侧扰流板装箱单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetH247HR_RLB()
|
|
{
|
|
string sql = "SELECT * FROM [dbo].[tb_Box_247] WHERE PartNo ='A2477900400' AND [PrintTime] IS NULL ORDER BY [CreateTime]";
|
|
return GetDoorAssemble(sql);
|
|
}
|
|
///// <summary>
|
|
///// 扰流板前左
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public DataTable GetX247LF_RLB()
|
|
//{
|
|
// string sql = "";
|
|
// return GetDoorAssemble(sql);
|
|
//}
|
|
///// <summary>
|
|
///// 扰流板前右
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public DataTable GetX247RF_RLB()
|
|
//{
|
|
// string sql = "";
|
|
// return GetDoorAssemble(sql);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 扰流板后左
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public DataTable GetX247LR_RLB()
|
|
//{
|
|
// string sql = "";
|
|
// return GetDoorAssemble(sql);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 扰流板后右
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public DataTable GetX247RR_RLB()
|
|
//{
|
|
// string sql = "";
|
|
// return GetDoorAssemble(sql);
|
|
//}
|
|
#endregion
|
|
|
|
DataTable GetDoorAssemble(string sql)
|
|
{
|
|
try
|
|
{
|
|
SqlParameter[] param = new SqlParameter[0];
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
public bool AddInfo(BoxModel md)
|
|
{
|
|
try
|
|
{
|
|
#region 添加数据
|
|
string sql = "";
|
|
SqlParameter[] param = null;
|
|
sql = "INSERT INTO " + TableName + " (ID,BoxNo,PartNo,PartName,BatchNo,BoxCount,Des,Flag,Validity,ValidityDate";
|
|
sql += ") VALUES (";
|
|
sql += "@ID,";
|
|
sql += "@BoxNo,";
|
|
sql += "@PartNo,";
|
|
sql += "@PartName,";
|
|
sql += "@BatchNo,";
|
|
sql += "@BoxCount,";
|
|
sql += "@Des,";
|
|
sql += "@Flag,";
|
|
sql += "@Validity,";
|
|
sql += "@ValidityDate)";
|
|
|
|
#region 添加参数
|
|
param = new SqlParameter[10];
|
|
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
|
|
param[0].Value = md.ID;
|
|
|
|
param[1] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
|
|
param[1].Value = md.BoxNo;
|
|
|
|
param[2] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
|
param[2].Value = md.PartNo;
|
|
|
|
param[3] = new SqlParameter("@PartName", SqlDbType.VarChar);
|
|
param[3].Value = md.PartName;
|
|
|
|
param[4] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
|
|
param[4].Value = md.BatchNo;
|
|
|
|
param[5] = new SqlParameter("@BoxCount", SqlDbType.Int);
|
|
param[5].Value = md.BoxCount;
|
|
|
|
param[6] = new SqlParameter("@Des", SqlDbType.VarChar);
|
|
param[6].Value = md.Des;
|
|
|
|
param[7] = new SqlParameter("@Flag", SqlDbType.Int);
|
|
param[7].Value = md.Flag;
|
|
|
|
param[8] = new SqlParameter("@Validity", SqlDbType.VarChar);
|
|
param[8].Value = md.Validity;
|
|
|
|
param[9] = new SqlParameter("@ValidityDate", SqlDbType.VarChar);
|
|
param[9].Value = md.ValidityDate;
|
|
|
|
#endregion
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
|
#endregion
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public DataTable SearchByNo(string PartNo,string BatchNo)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT top 1 * from " + TableName + " where PartNo=@PartNo and SUBSTRING(BoxNo,13,6)=@BatchNo order by CreateTime";
|
|
SqlParameter[] param = new SqlParameter[2];
|
|
|
|
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
|
param[0].Value = PartNo;
|
|
|
|
param[1] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
|
|
param[1].Value = BatchNo;
|
|
|
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool UpdateInfo(BoxModel md)
|
|
{
|
|
try
|
|
{
|
|
string sql = "";
|
|
SqlParameter[] param = null;
|
|
sql = "update " + TableName + " set PrintTime=(select getdate()) where PartNo=@PartNo and PrintTime is null";
|
|
|
|
param = new SqlParameter[1];
|
|
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
|
param[0].Value = md.PartNo;
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public DataTable SearchBox(string partno)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT top 1 * from " + TableName + " where PartNo=@PartNo and Flag=0 order by CreateTime";
|
|
SqlParameter[] param = null;
|
|
|
|
param = new SqlParameter[1];
|
|
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
|
param[0].Value = partno;
|
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public DataTable SearchBoxIsExsit(string box)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT * from " + TableName + " where BoxNo=@BoxNo";
|
|
SqlParameter[] param = null;
|
|
|
|
param = new SqlParameter[1];
|
|
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
|
|
param[0].Value = box;
|
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|