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.
312 lines
10 KiB
312 lines
10 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 MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.Model;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.Mistake247
|
||
|
{
|
||
|
public class RecordDAL
|
||
|
{
|
||
|
public static string TableName = "tb_Record_247";
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查找半成品是否已经装配
|
||
|
/// </summary>
|
||
|
/// <param name="PartNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchByPartNo1(string PartNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT * from " + TableName + " where PartNo1=@PartNo";
|
||
|
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 DataTable SearchCountByBox(string boxNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT count(*) as sum from " + TableName + " where BoxNo=@BoxNo and Flag <>2";
|
||
|
SqlParameter[] param = new SqlParameter[1];
|
||
|
|
||
|
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
|
||
|
param[0].Value = boxNo;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool AddInfo(RecordModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "";
|
||
|
SqlParameter[] param = null;
|
||
|
sql = "INSERT INTO " + TableName + " (ID,PartNo1,PartNo2,OrderNo,Type";
|
||
|
sql += ") VALUES (";
|
||
|
sql += "@ID,";
|
||
|
sql += "@PartNo1,";
|
||
|
sql += "@PartNo2,";
|
||
|
sql += "@OrderNo,";
|
||
|
sql += "@Type)";
|
||
|
|
||
|
#region 添加参数
|
||
|
param = new SqlParameter[5];
|
||
|
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
|
||
|
param[0].Value = md.ID;
|
||
|
|
||
|
param[1] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
|
||
|
param[1].Value = md.PartNo1;
|
||
|
|
||
|
param[2] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
|
||
|
param[2].Value = md.PartNo2;
|
||
|
|
||
|
param[3] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
|
||
|
param[3].Value = md.OrderNo;
|
||
|
|
||
|
param[4] = new SqlParameter("@Type", SqlDbType.Int);
|
||
|
param[4].Value = md.Type;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool updateBoxInfo(RecordModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "";
|
||
|
SqlParameter[] param = null;
|
||
|
|
||
|
sql = @"update " + TableName + " set BoxNo=@BoxNo,CreateTime2=(select getdate()),Flag=@Flag where PartNo2=@PartNo2";
|
||
|
|
||
|
#region 添加参数
|
||
|
|
||
|
param = new SqlParameter[3];
|
||
|
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
|
||
|
param[0].Value = md.BoxNo;
|
||
|
|
||
|
param[1] = new SqlParameter("@Flag", SqlDbType.Int);
|
||
|
param[1].Value = md.Flag;
|
||
|
|
||
|
param[2] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
|
||
|
param[2].Value = md.PartNo2;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable SearchState(int type1,int type2,int type3)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
|
||
|
|
||
|
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
|
||
|
|
||
|
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
|
||
|
string sql = @"
|
||
|
SELECT * from tb_record_247 where Type in (@type1,@type2,@type3) and Flag =0 AND CreateTime1 >= CONVERT(VARCHAR(10),GETDATE(),120) AND CreateTime1 < (CONVERT(VARCHAR(10),GETDATE(),120)+' 23:59:59') order by CreateTime1
|
||
|
";
|
||
|
|
||
|
SqlParameter[] param = new SqlParameter[3];
|
||
|
|
||
|
param[0] = new SqlParameter("@type1", SqlDbType.Int);
|
||
|
param[0].Value = type1;
|
||
|
|
||
|
param[1] = new SqlParameter("@type2", SqlDbType.Int);
|
||
|
param[1].Value = type2;
|
||
|
|
||
|
param[2] = new SqlParameter("@type3", SqlDbType.Int);
|
||
|
param[2].Value = type3;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool DelInfo(RecordModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "";
|
||
|
SqlParameter[] param = null;
|
||
|
|
||
|
sql = @"update " + TableName + " set Flag=@Flag where PartNo2=@PartNo2";
|
||
|
|
||
|
#region 添加参数
|
||
|
|
||
|
param = new SqlParameter[2];
|
||
|
|
||
|
param[0] = new SqlParameter("@Flag", SqlDbType.Int);
|
||
|
param[0].Value = md.Flag;
|
||
|
|
||
|
param[1] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
|
||
|
param[1].Value = md.PartNo2;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable SearchBoxByPart(string part)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT top 1 * from " + TableName + " where SUBSTRING(PartNo2,1,11)=@PartNo2 order by CreateTime2 desc";
|
||
|
SqlParameter[] param = new SqlParameter[1];
|
||
|
|
||
|
param[0] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
|
||
|
param[0].Value = part;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable SearchByPartNo2(string partno)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT * from " + TableName + " where PartNo2=@PartNo";
|
||
|
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 DataTable GetCount(string part,string batch)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT count(*) as sum from " + TableName + " where SUBSTRING(PartNo2,1,11)=@PartNo2 and SUBSTRING(PartNo2,13,6)=@batch ";
|
||
|
SqlParameter[] param = new SqlParameter[2];
|
||
|
|
||
|
param[0] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
|
||
|
param[0].Value = part;
|
||
|
|
||
|
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 DataTable GetRecord(string boxNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
SELECT PartNo2,CreateTime1 FROM tb_record_247 WHERE boxno = '" + boxNo + @"' ORDER BY createtime1
|
||
|
";
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
///根据改订单的生产数量
|
||
|
/// </summary>
|
||
|
/// <param name="orderno"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable GetOrderNum(string orderno)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT count(*) as sum from tb_record_247 where OrderNo=@OrderNo";
|
||
|
SqlParameter[] param = new SqlParameter[1];
|
||
|
|
||
|
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
|
||
|
param[0].Value = orderno;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|