132 lines
5.8 KiB
C#
132 lines
5.8 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using AIMSModel;
|
|
using AIMSObjectQuery;
|
|
using System.Text;
|
|
|
|
namespace AIMSDAL
|
|
{
|
|
internal partial class DOutputLiquids
|
|
{
|
|
public static bool IsExit(string Name)
|
|
{
|
|
string strSql = "select * from OutputLiquids where name ='" + Name + "'";
|
|
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public static void Add(OutputLiquids OutputLiquidsObj)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into [OutputLiquids](");
|
|
strSql.Append("Name,HelpCode,IsValid,OperatorNo,OperatorName,OperateDate");
|
|
strSql.Append(")");
|
|
strSql.Append(" values (");
|
|
strSql.Append("'" + OutputLiquidsObj.Name + "',");
|
|
strSql.Append("'" + OutputLiquidsObj.HelpCode + "',");
|
|
strSql.Append("" + OutputLiquidsObj.IsValid + ",");
|
|
strSql.Append("'" + OutputLiquidsObj.OperatorNo + "',");
|
|
strSql.Append("'" + OutputLiquidsObj.OperatorName + "',");
|
|
strSql.Append("'" + OutputLiquidsObj.OperateDate + "'");
|
|
strSql.Append(")");
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
|
|
|
|
}
|
|
public static void Delete(int Id)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete OutputLiquids ");
|
|
strSql.Append(" where Id=" + Id + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
|
|
}
|
|
public static OutputLiquids GetModel(int Id)
|
|
{
|
|
OutputLiquids OutputLiquidsObj = new OutputLiquids();
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
strSql.Append("Id,Name,HelpCode,IsValid,OperatorNo,OperatorName,OperateDate ");
|
|
strSql.Append(" from OutputLiquids ");
|
|
strSql.Append(" where Id=" + Id + "");
|
|
DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString());
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|
}
|
|
OutputLiquidsObj.Name = ds.Tables[0].Rows[0]["Name"].ToString();
|
|
OutputLiquidsObj.HelpCode = ds.Tables[0].Rows[0]["HelpCode"].ToString();
|
|
if (ds.Tables[0].Rows[0]["IsValid"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.IsValid = int.Parse(ds.Tables[0].Rows[0]["IsValid"].ToString());
|
|
}
|
|
OutputLiquidsObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString();
|
|
OutputLiquidsObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString();
|
|
if (ds.Tables[0].Rows[0]["OperateDate"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString());
|
|
}
|
|
}
|
|
return OutputLiquidsObj;
|
|
}
|
|
|
|
public static OutputLiquids GetModelByName(string Name)
|
|
{
|
|
OutputLiquids OutputLiquidsObj = new OutputLiquids();
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select top 1 ");
|
|
strSql.Append("Id,Name,HelpCode,IsValid,OperatorNo,OperatorName,OperateDate ");
|
|
strSql.Append(" from OutputLiquids ");
|
|
strSql.Append(" where Name='" + Name + "'");
|
|
DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString());
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|
}
|
|
OutputLiquidsObj.Name = ds.Tables[0].Rows[0]["Name"].ToString();
|
|
OutputLiquidsObj.HelpCode = ds.Tables[0].Rows[0]["HelpCode"].ToString();
|
|
if (ds.Tables[0].Rows[0]["IsValid"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.IsValid = int.Parse(ds.Tables[0].Rows[0]["IsValid"].ToString());
|
|
}
|
|
OutputLiquidsObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString();
|
|
OutputLiquidsObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString();
|
|
if (ds.Tables[0].Rows[0]["OperateDate"].ToString() != "")
|
|
{
|
|
OutputLiquidsObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString());
|
|
}
|
|
}
|
|
return OutputLiquidsObj;
|
|
}
|
|
public static DataTable GetDataTable()
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select [Id], [Name],HelpCode,CASE IsValid WHEN 1 THEN '有效' WHEN 0 THEN '无效' END AS IsValid");
|
|
strSql.Append(" FROM OutputLiquids ");
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetDataTable(string HelpCode)
|
|
{
|
|
string strSql = "SELECT Id,Name FROM dbo.OutputLiquids WHERE (NAME LIKE '%" + HelpCode + "%') OR (HelpCode LIKE '%" + HelpCode + "%')";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
public static DataTable GetEventDataTable()
|
|
{
|
|
string strSql = "SELECT TOP 17 e.Id, e.Name FROM OutputLiquids e WHERE e.IsValid=1 ORDER BY e.UseRate DESC ";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql);
|
|
}
|
|
}
|
|
}
|