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

266 lines
9.8 KiB

6 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
namespace MESClassLibrary.DAL.BasicInfo
{
public class ProductOfInjectionDAL
{
public static string TableName = "tb_Product_Injection";
public bool AddInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PlanID,StationID,ProductDate,ClassName,StockNo,PartNo,ProductCount,BadCount)";
sql += " VALUES (";
sql += "@ID,";
sql += "@PlanID,";
sql += "@StationID,";
sql += "@ProductDate,";
sql += "@ClassName,";
sql += "@StockNo,";
sql += "@PartNo,";
sql += "@ProductCount,";
sql += "@BadCount)";
#region 添加参数
param = new SqlParameter[9];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[1].Value = md.PlanID;
param[2] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[2].Value = md.StationID;
param[3] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[3].Value = md.ProductDate;
param[4] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[4].Value = md.ClassName;
param[5] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[5].Value = md.StockNo;
param[6] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[6].Value = md.PartNo;
param[7] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[7].Value = md.ProductCount;
param[8] = new SqlParameter("@BadCount", SqlDbType.Int);
param[8].Value = md.BadCount;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCountByInfo(string station,string date,string classname,string StockNo,string PartNo)
{
try
{
string sql = @"select * from " + TableName + " where StationID=@StationID and " +
"ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo and PartNo=@PartNo";
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = station;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = date;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = classname;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = StockNo;
param[4] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[4].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 UpdateInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set ProductCount=ProductCount+@ProductCount,BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo and PartNo=@PartNo and PlanID=@PlanID";
#region 添加参数
param = new SqlParameter[8];
param[0] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[0].Value = md.ProductCount;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = md.StationID;
param[2] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[2].Value = md.ProductDate;
param[3] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[3].Value = md.ClassName;
param[4] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[4].Value = md.StockNo;
param[5] = new SqlParameter("@BadCount", SqlDbType.Int);
param[5].Value = md.BadCount;
param[6] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[6].Value = md.PartNo;
param[7] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[7].Value = md.PlanID;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdteBadInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
if (md.StockNo != "")
{
sql = @"update " + TableName + " set BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo ";
}
else
{
sql = @"update " + TableName + " set BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and PartNo=@PartNo";
}
#region 添加参数
param = new SqlParameter[6];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = md.ProductDate;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = md.ClassName;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = md.StockNo;
param[4] = new SqlParameter("@BadCount", SqlDbType.Int);
param[4].Value = md.BadCount;
param[5] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[5].Value = md.PartNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 开机报废减产量
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool updateProductCount(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
if (md.StockNo != "")
{
sql = @"update " + TableName + " set ProductCount=ProductCount-@ProductCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo ";
}
else
{
sql = @"update " + TableName + " set ProductCount=ProductCount-@ProductCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and PartNo=@PartNo";
}
#region 添加参数
param = new SqlParameter[6];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = md.ProductDate;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = md.ClassName;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = md.StockNo;
param[4] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[4].Value = md.ProductCount;
param[5] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[5].Value = md.PartNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}