注塑喷涂
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.
 
 
 
 
 

137 lines
4.6 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Mistake243
{
public class Assembly243DAL
{
public static string TableName = "tb_Assembly_243";
public DataTable searchPartNo(string partNo)
{
try
{
string sql = @"SELECT top 1 PartNo from tb_Assembly_243 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;
}
}
public bool AddInfo(Assembly243Model 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(Assembly243Model 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;
}
}
}
}