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.
362 lines
13 KiB
362 lines
13 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.EFModel;
|
|
using MESClassLibrary.Model;
|
|
|
|
namespace MESClassLibrary.DAL.ZPPlan
|
|
{
|
|
public class ZPRecordDAL
|
|
{
|
|
public bool AddInfo(tb_ZPRecord md)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"insert into tb_ZPRecord (OneBarCode,PlanID) values(@OneBarCode,@PlanID)";
|
|
|
|
SqlParameter[] param = new SqlParameter[2];
|
|
|
|
param[0] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
|
|
param[0].Value = md.OneBarCode;
|
|
|
|
param[1] = new SqlParameter("@PlanID", SqlDbType.VarChar);
|
|
param[1].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 bool AddZcInfo(tb_ZPRecord md)
|
|
{
|
|
try
|
|
{
|
|
string sql=@"insert into tb_ZPRecord (OneBarCode,IsOK,PrintType,BarCode)
|
|
values(@OneBarCode,@IsOK,@PrintType,@BarCode)";
|
|
|
|
SqlParameter[] param=new SqlParameter[4];
|
|
|
|
param[0] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
|
|
param[0].Value = md.OneBarCode;
|
|
|
|
param[1] = new SqlParameter("@IsOK", SqlDbType.Int);
|
|
param[1].Value = md.IsOK;
|
|
|
|
param[2] = new SqlParameter("@PrintType", SqlDbType.Int);
|
|
param[2].Value = md.PrintType;
|
|
|
|
param[3] = new SqlParameter("@BarCode", SqlDbType.VarChar);
|
|
param[3].Value = md.BarCode;
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据一维码查询装配信息
|
|
/// </summary>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
public DataTable SearchInfo(string barCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_ZPRecord where OneBarCode=@barCode and PrintType=0 order by CreateTime desc";
|
|
|
|
SqlParameter[] param = new SqlParameter[1];
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public DataTable SearchInfobyOne(string barCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_ZPRecord where OneBarCode=@barCode and PrintType=0 order by CreateTime desc";
|
|
|
|
SqlParameter[] param = new SqlParameter[1];
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public DataTable SearchZcInfo(string batchNo)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select top 1 BarCode from tb_ZPRecord where BarCode like '" + batchNo +
|
|
@"%' order by id desc";
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).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 planID)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_ZPRecord where PlanID like @PlanID and (PrintTime is null or PrintTime ='') and IsOK =1 order by CreateTime";
|
|
|
|
SqlParameter[] param = new SqlParameter[1];
|
|
|
|
param[0] = new SqlParameter("@PlanID", SqlDbType.VarChar);
|
|
param[0].Value = planID;
|
|
|
|
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(OneBarCode1,1,10) like @stockNo and OneBarCode1 is not null and SUBSTRING(OneBarCode1,11,6) like @batch and PrintType=0 order by CreateTime desc";
|
|
|
|
SqlParameter[] param = new SqlParameter[2];
|
|
|
|
param[0] = new SqlParameter("@stockNo", SqlDbType.VarChar);
|
|
param[0].Value = stockNo;
|
|
|
|
param[1] = new SqlParameter("@batch", SqlDbType.VarChar);
|
|
param[1].Value = batch;
|
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool UpdatePrintOK(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;
|
|
}
|
|
}
|
|
|
|
public bool UpdateBad(ZPRecordModel md)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"update tb_ZPRecord set IsOK=@IsOK where ID=@ID";
|
|
|
|
SqlParameter[] param = new SqlParameter[2];
|
|
|
|
param[0] = new SqlParameter("@IsOK", SqlDbType.Int);
|
|
param[0].Value = md.IsOK;
|
|
|
|
param[1] = new SqlParameter("@ID", SqlDbType.VarChar);
|
|
param[1].Value = md.ID;
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据二维码查询装配信息
|
|
/// </summary>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
public DataTable SearchBarCode(string barCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select top 1 * from tb_ZPRecord where OneBarCode=@barCode order by CreateTime desc";
|
|
|
|
SqlParameter[] param = new SqlParameter[1];
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public bool AddBudaInfo(ZPRecordModel md)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"insert into tb_ZPRecord (ID,OneBarCode,PlanID,IsOK,PrintType,BarCode,OneBarCode1,PrintTime) values(@ID,@OneBarCode,@PlanID,@IsOK,@PrintType,@BarCode,@OneBarCode1,@PrintTime)";
|
|
|
|
SqlParameter[] param = new SqlParameter[8];
|
|
|
|
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;
|
|
|
|
param[3] = new SqlParameter("@IsOK", SqlDbType.Int);
|
|
param[3].Value = md.IsOK;
|
|
|
|
param[4] = new SqlParameter("@PrintType", SqlDbType.Int);
|
|
param[4].Value = md.PrintType;
|
|
|
|
param[5] = new SqlParameter("@BarCode", SqlDbType.VarChar);
|
|
param[5].Value = md.BarCode;
|
|
|
|
param[6] = new SqlParameter("@OneBarCode1", SqlDbType.VarChar);
|
|
param[6].Value = md.OneBarCode1;
|
|
|
|
param[7] = new SqlParameter("@PrintTime", SqlDbType.DateTime);
|
|
param[7].Value = md.PrintTime;
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public DataTable GetCountByPartNo(string partNo)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"select Count(*) as qty from tb_ZPRecord where isnull(BoxNo,'') = '' and BarCode like '" +
|
|
partNo + @"%' and PrintType=0 and IsOK=1";
|
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool UpdateBox(string partNo,string boxNo)
|
|
{
|
|
try
|
|
{
|
|
string sql = @"update tb_ZPRecord set BoxNo='" + boxNo + @"' where BarCode like '" + partNo + @"%' and PrintType=0 and IsOK=1 and (BoxNo is null or BoxNo='')";
|
|
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, null);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public string GetPrintCount(string startTime,string endTime)
|
|
{
|
|
string res = "0";
|
|
try
|
|
{
|
|
string sql = @"select count(ID) as qty
|
|
FROM [BBMPT1].[dbo].[tb_ZPRecord]
|
|
WHERE BarCode LIKE '2146103301%' AND PrintType=0 and CreateTime between '" + startTime + @"' and '" + endTime + @"'";
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["qty"].ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
}
|
|
}
|
|
|