注塑喷涂
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.

173 lines
6.0 KiB

6 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.DAL;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchPlanDAL
{
/// <summary>
/// 查询设备当前计划
/// </summary>
/// <param name="deviceNo"></param>
/// <returns></returns>
public DataTable SearchPlan(string deviceNo)
{
try
{
string sql =@"SELECT top 1 dbo.tb_PunchPlan.ID, dbo.tb_PunchPlan.DeviceNo, dbo.tb_PunchPlan.PlanCount, dbo.tb_PunchPlan.CompleteCount,
dbo.tb_PunchPlan.BadCount, dbo.tb_PunchPlan.IsFinish, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName
FROM dbo.tb_PunchPlan LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_PunchPlan.ProductID = dbo.tb_Product.ProductID where dbo.tb_PunchPlan.DeviceNo=@DeviceNo and IsFinish=0 order by CreateTime";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[0].Value = deviceNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询所有设备未完成的计划
/// </summary>
/// <returns></returns>
public DataTable SearchAllPlan()
{
string sql = @"SELECT dbo.tb_PunchPlan.ID, dbo.tb_PunchPlan.DeviceNo, dbo.tb_PunchPlan.PlanCount, dbo.tb_PunchPlan.CompleteCount,
dbo.tb_PunchPlan.BadCount, dbo.tb_PunchPlan.IsFinish, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName,
dbo.tb_PunchDevice.DeviceName
FROM dbo.tb_PunchPlan LEFT OUTER JOIN
dbo.tb_PunchDevice ON dbo.tb_PunchPlan.DeviceNo = dbo.tb_PunchDevice.DeviceNo LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_PunchPlan.ProductID = dbo.tb_Product.ProductID where IsFinish=0 order by CreateTime";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
public bool AddInfo(PunchPlanModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = " insert into tb_PunchPlan(ID,DeviceNo,ProductID,PlanCount";
sql += ") VALUES (";
sql += "@ID,";
sql += "@DeviceNo,";
sql += "@ProductID,";
sql += "@PlanCount)";
param = new SqlParameter[4];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[1].Value = md.DeviceNo;
param[2] = new SqlParameter("@ProductID", SqlDbType.VarChar);
param[2].Value = md.ProductID;
param[3] = new SqlParameter("@PlanCount", SqlDbType.Int);
param[3].Value = md.PlanCount;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(PunchPlanModel md)
{
try
{
string sql = @"update tb_PunchPlan set PlanCount=@PlanCount where ID=@ID";
SqlParameter[] param = null;
param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PlanCount", SqlDbType.Int);
param[1].Value = md.PlanCount;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateDty(PunchPlanModel md)
{
try
{
string sql = @"update tb_PunchPlan set CompleteCount=CompleteCount+1 where ID=@ID";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].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 DelInfo(PunchPlanModel md)
{
try
{
string sql = @"delete from tb_PunchPlan where ID=@ID";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}