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.
189 lines
7.5 KiB
189 lines
7.5 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;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.Mistake247
|
||
|
{
|
||
|
public class Plan247DAL
|
||
|
{
|
||
|
public static string TableName = "tb_Plan_247";
|
||
|
|
||
|
public DataTable SearhByOrderNo(string OrderNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
|
||
|
dbo.tb_Plan_247.OrderCount,dbo.tb_Plan_247.IsFinish,dbo.tb_Plan_247.CompleteCount
|
||
|
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
|
||
|
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
|
||
|
where dbo.tb_Plan_247.OrderNo=@OrderNo
|
||
|
ORDER BY dbo.tb_Plan_247.CreateTime";
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable DetailOrderNo(string OrderNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
|
||
|
dbo.tb_Plan_247.OrderCount
|
||
|
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
|
||
|
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
|
||
|
where dbo.tb_Plan_247.OrderNo=@OrderNo
|
||
|
ORDER BY dbo.tb_Plan_247.CreateTime";
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据半成品零件号查找扫描的订单中是否有此产品的生产计划
|
||
|
/// </summary>
|
||
|
/// <param name="Part1"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable IsHavePlan(string partNo1,string orderNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT top 1 dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo,
|
||
|
dbo.tb_Plan_247.OrderCount, dbo.tb_Plan_247.CompleteCount, dbo.tb_Mistake_247.PartNo1
|
||
|
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
|
||
|
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
|
||
|
where PartNo1=@PartNo1 and OrderNo =@orderNo and IsFinish =0
|
||
|
ORDER BY dbo.tb_Plan_247.CreateTime";
|
||
|
SqlParameter[] param = new SqlParameter[2];
|
||
|
|
||
|
param[0] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
|
||
|
param[0].Value = partNo1;
|
||
|
|
||
|
param[1] = new SqlParameter("@orderNo", SqlDbType.VarChar);
|
||
|
param[1].Value = orderNo;
|
||
|
|
||
|
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="partNo1"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchOrderNoByPart1(string partNo1)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT top 1 dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo,
|
||
|
dbo.tb_Plan_247.OrderCount, dbo.tb_Plan_247.CompleteCount, dbo.tb_Mistake_247.PartNo1
|
||
|
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
|
||
|
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
|
||
|
where PartNo1=@PartNo1 and IsFinish =0
|
||
|
ORDER BY dbo.tb_Plan_247.CreateTime ";
|
||
|
SqlParameter[] param = new SqlParameter[1];
|
||
|
|
||
|
param[0] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
|
||
|
param[0].Value = partNo1;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable SearhCountByOrderNo(string OrderNo,string partNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
|
||
|
dbo.tb_Plan_247.OrderCount,dbo.tb_Plan_247.IsFinish
|
||
|
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
|
||
|
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
|
||
|
where dbo.tb_Plan_247.OrderNo=@OrderNo and dbo.tb_Plan_247.PartNo=@PartNo
|
||
|
ORDER BY dbo.tb_Plan_247.CreateTime";
|
||
|
SqlParameter[] param = new SqlParameter[2];
|
||
|
|
||
|
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
|
||
|
param[0].Value = OrderNo;
|
||
|
|
||
|
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
||
|
param[1].Value = partNo;
|
||
|
|
||
|
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="partno"></param>
|
||
|
/// <param name="orderNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool UpdateCount(string partNo, string orderNo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "update tb_Plan_247 set [CompleteCount]=[CompleteCount]+1 where OrderNo=@OrderNo and PartNo =@PartNo";
|
||
|
SqlParameter[] param = null;
|
||
|
|
||
|
#region 添加参数
|
||
|
param = new SqlParameter[2];
|
||
|
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
|
||
|
param[0].Value = orderNo;
|
||
|
|
||
|
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
|
||
|
param[1].Value = partNo;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|