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.
145 lines
4.3 KiB
145 lines
4.3 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.Model;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.Hybrid
|
||
|
{
|
||
|
public class HybridPlanDAL
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 查询所有设备未完成的计划
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchAllPlan()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"SELECT * from tb_HybridPlan where IsFinish=0 order by CreateTime";
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool AddInfo(HybridPlanModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "";
|
||
|
SqlParameter[] param = null;
|
||
|
sql = " insert into tb_HybridPlan(ID,ProductName,Color,PlanCount";
|
||
|
sql += ") VALUES (";
|
||
|
sql += "@ID,";
|
||
|
sql += "@ProductName,";
|
||
|
sql += "@Color,";
|
||
|
sql += "@PlanCount)";
|
||
|
|
||
|
param = new SqlParameter[4];
|
||
|
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
|
||
|
param[0].Value = md.ID;
|
||
|
|
||
|
param[1] = new SqlParameter("@ProductName", SqlDbType.VarChar);
|
||
|
param[1].Value = md.ProductName;
|
||
|
|
||
|
param[2] = new SqlParameter("@Color", SqlDbType.VarChar);
|
||
|
param[2].Value = md.Color;
|
||
|
|
||
|
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(HybridPlanModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"update tb_HybridPlan 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 UpdateQty(HybridPlanModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"update tb_HybridPlan set Qty=Qty+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(HybridPlanModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"delete from tb_HybridPlan 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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|