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; } } /// /// 根据半成品零件号查找扫描的订单中是否有此产品的生产计划 /// /// /// 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; } } /// /// 根据半成品零件号查找订单号 /// /// /// 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; } } /// /// 更新订单完成数 /// /// /// /// 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; } } #region 243 public DataTable SearhByOrderNo1(string OrderNo) { try { string sql = @"SELECT dbo.tb_Plan_243.OrderNo, dbo.tb_Plan_243.PartNo, dbo.tb_Plan_243.OrderCount, dbo.tb_Plan_243.IsFinish, dbo.tb_Plan_243.CompleteCount, dbo.tb_Mistake_243.PartName2 FROM dbo.tb_Plan_243 LEFT OUTER JOIN dbo.tb_Mistake_243 ON dbo.tb_Plan_243.PartNo = dbo.tb_Mistake_243.PartNo2 WHERE (dbo.tb_Plan_243.OrderNo = @OrderNo) ORDER BY dbo.tb_Plan_243.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 IsHavePlan1(string partNo1, string orderNo) { try { string sql = @"SELECT dbo.tb_Plan_243.OrderNo, dbo.tb_Plan_243.Item, dbo.tb_Plan_243.PartNo, dbo.tb_Plan_243.OrderCount, dbo.tb_Plan_243.CompleteCount, dbo.tb_Mistake_243.PartNo1 FROM dbo.tb_Plan_243 LEFT OUTER JOIN dbo.tb_Mistake_243 ON dbo.tb_Plan_243.PartNo = dbo.tb_Mistake_243.PartNo2 WHERE (dbo.tb_Plan_243.OrderNo = @orderNo) AND (dbo.tb_Plan_243.IsFinish = 0) ORDER BY dbo.tb_Plan_243.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; } } #endregion } }