一厂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.

93 lines
2.9 KiB

3 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.BasicInfo
{
public class BadInjectionDAL
{
public static string TableName = "tb_Bad_Injection";
public bool AddInfo(BadInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO tb_Bad_Injection (ID,OneBarCode,[BarCode],[BadPosition],[BadReason]";
sql += ") VALUES (";
sql += "@ID,";
sql += "@OneBarCode,";
sql += "@BarCode,";
sql += "@BadPosition,";
sql += "@BadReason)";
#region 添加参数
param = new SqlParameter[5];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
param[1].Value = md.OneBarCode;
param[2] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[2].Value = md.BarCode;
param[3] = new SqlParameter("@BadPosition", SqlDbType.VarChar);
param[3].Value = md.BadPosition;
param[4] = new SqlParameter("@BadReason", SqlDbType.VarChar);
param[4].Value = md.BadReason;
#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 SearchByCode(string code)
{
try
{
string sql = "";
if (code.Contains("."))
{
sql = @"select * from " + TableName + " where BarCode=@BarCode";
}
else
{
sql = @"select * from " + TableName + " where OneBarCode=@BarCode";
}
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[0].Value = code;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}