一厂MES,含注塑,喷涂,冲孔
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.

203 lines
6.8 KiB

3 months ago
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 AssemblyDAL
{
public static string TableName = "tb_Assembly_247";
public bool AddInfo(AssemblyModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PartNo,PartName,BatchNo,Color,ColorNo,PartType,TapeBatchNo,Validity,ValidityDate,Des,Flag";
sql += ") VALUES (";
sql += "@ID,";
sql += "@PartNo,";
sql += "@PartName,";
sql += "@BatchNo,";
sql += "@Color,";
sql += "@ColorNo,";
sql += "@PartType,";
sql += "@TapeBatchNo,";
sql += "@Validity,";
sql += "@ValidityDate,";
sql += "@Des,";
sql += "@Flag)";
#region 添加参数
param = new SqlParameter[12];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = md.PartNo;
param[2] = new SqlParameter("@PartName", SqlDbType.VarChar);
param[2].Value = md.PartName;
param[3] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
param[3].Value = md.BatchNo;
param[4] = new SqlParameter("@Color", SqlDbType.VarChar);
param[4].Value = md.Color;
param[5] = new SqlParameter("@ColorNo", SqlDbType.VarChar);
param[5].Value = md.ColorNo;
param[6] = new SqlParameter("@PartType", SqlDbType.VarChar);
param[6].Value = md.PartType;
param[7] = new SqlParameter("@TapeBatchNo", SqlDbType.VarChar);
param[7].Value = md.TapeBatchNo;
param[8] = new SqlParameter("@Validity", SqlDbType.VarChar);
param[8].Value = md.Validity;
param[9] = new SqlParameter("@ValidityDate", SqlDbType.VarChar);
param[9].Value = md.ValidityDate;
param[10] = new SqlParameter("@Des", SqlDbType.VarChar);
param[10].Value = md.Des;
param[11] = new SqlParameter("@Flag", SqlDbType.Int);
param[11].Value = md.Flag;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(AssemblyModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set PrintTime=(select getdate()) where substring (PartNo,1,11)= @PartNo and (PrintTime is null or PrintTime='')";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = md.PartNo.Substring(0,11);
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCount(string PartNo)
{
try
{
string sql = @"SELECT count(*) as sum from tb_Assembly_247 where PartNo=@PartNo and IsPrintBox=0";
SqlParameter[] 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 bool UpdatePrintFlag(AssemblyModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set IsPrintBox=1 where PartNo=@PartNo and IsPrintBox =0";
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 bool UpdatePrintFlag1(string partno)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set IsPrintBox=1 where PartNo=@PartNo and IsPrintBox =0";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = partno;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable searchPartNo(string partNo)
{
try
{
string sql = @"SELECT top 1 * from tb_Assembly_247 where PartNo like '%" + partNo + "%' and Flag=0 order by CreateTime desc";
//SqlParameter[] param = new SqlParameter[1];
//param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
//param[0].Value = partNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}