一厂MES,含注塑,喷涂,冲孔
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.

185 lines
6.2 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.Injection
{
public class InjectionQtyDAL
{
public static string TableName = "tb_Product_Injection";
public bool AddInfo(InjectionQtyModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PlanID,StationID,ProductDate,ClassName,StockNo,PartNo,ProductCount,MarketCount";
sql += ") VALUES (";
sql += "@ID,";
sql += "@PlanID,";
sql += "@StationID,";
sql += "@ProductDate,";
sql += "@ClassName,";
sql += "@StockNo,";
sql += "@PartNo,";
sql += "@ProductCount,";
sql += "@MarketCount)";
#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("@MarketCount", SqlDbType.Int);
param[8].Value = md.MarketCount;
#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 UpdateQty(InjectionQtyModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set ProductCount=ProductCount+1,MarketCount=MarketCount+@MarketCount where PlanID=@PlanID and PartNo=@PartNo";
param = new SqlParameter[3];
param[0] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[0].Value = md.PlanID;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = md.PartNo;
param[2] = new SqlParameter("@MarketCount", SqlDbType.Int);
param[2].Value = md.MarketCount;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 更新市场件数量
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateMarketQty(InjectionQtyModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set MarketCount=@MarketCount where PlanID=@PlanID and PartNo=@PartNo";
param = new SqlParameter[3];
param[0] = new SqlParameter("@MarketCount", SqlDbType.Int);
param[0].Value = md.MarketCount;
param[1] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[1].Value = md.PlanID;
param[2] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[2].Value = md.PartNo;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查找产量信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public DataTable SearchInfo(InjectionQtyModel md)
{
try
{
string sql = @"select * from " + TableName + " where PlanID=@PlanID and PartNo=@PartNo and ProductDate=@ProductDate and ClassName=@ClassName";
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[0].Value = md.PlanID;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = md.PartNo;
param[2] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[2].Value = md.ProductDate;
param[3] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[3].Value = md.ClassName;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}