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

144 lines
4.9 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.ZPPlan
{
public class ZPRecordDAL
{
public bool AddInfo(ZPRecordModel md)
{
try
{
string sql = @"insert into tb_ZPRecord (ID,OneBarCode,IsOK,PrintType,PlanID)";
SqlParameter[] param = new SqlParameter[3];
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("@PlanID", SqlDbType.VarChar);
param[2].Value = md.planID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchInfo(string barCode)
{
try
{
string sql = @"select * from tb_ZPRecord where OneBarCode=@barCode";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@barCode", SqlDbType.VarChar);
param[0].Value = barCode;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查找产品未打印的第一条
/// </summary>
/// <param name="stockNo"></param>
/// <returns></returns>
public DataTable SearchPrint(string stockNo)
{
try
{
string sql = @"select top 1 * from tb_ZPRecord where substring(OneBarCode,0,LEN(OneBarCode)-10) like @stockNo and (PrintType is null or PrintType ='' and IsOK is not null) order by CreateTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@stockNo", SqlDbType.VarChar);
param[0].Value = stockNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode(string stockNo, string batch)
{
try
{
string sql = @"select top 1 * from tb_ZPRecord where substring(OneBarCode,0,LEN(OneBarCode)-10) like @stockNo and OneBarCode1 is not null and SUBSTRING(OneBarCode1,LEN(OneBarCode1)-9,6) order by CreateTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@stockNo", SqlDbType.VarChar);
param[0].Value = stockNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdatePrint(ZPRecordModel md)
{
try
{
string sql = @"update tb_ZPRecord set IsOK=@IsOK,PrintType=@PrintType,PrintTime=@PrintTime,BarCode=@BarCode,OneBarCode1=@OneBarCode1 where ID=@ID";
SqlParameter[] param = new SqlParameter[6];
param[0] = new SqlParameter("@IsOK", SqlDbType.Int);
param[0].Value = md.IsOK;
param[1] = new SqlParameter("@PrintType", SqlDbType.Int);
param[1].Value = md.PrintType;
param[2] = new SqlParameter("@PrintTime", SqlDbType.DateTime);
param[2].Value = md.PrintTime;
param[3] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[3].Value = md.BarCode;
param[4] = new SqlParameter("@OneBarCode1", SqlDbType.VarChar);
param[4].Value = md.OneBarCode1;
param[5] = new SqlParameter("@ID", SqlDbType.VarChar);
param[5].Value = md.ID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}