121 lines
5.1 KiB
C#
121 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
namespace DataDictionary.DAL
|
|
{
|
|
public class OperationDB
|
|
{
|
|
|
|
public bool IsExit(string Name)
|
|
{
|
|
|
|
string strSql = "select * from Operation where name ='" + Name + "'";
|
|
|
|
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public void Add(Model.Operation OperationObj)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into [Operation](");
|
|
strSql.Append("IcdCode,Name,HelpCode,UseRate,IsValid,OperatorNo,OperatorName,OperateDate");
|
|
strSql.Append(")");
|
|
strSql.Append(" values (");
|
|
strSql.Append("'" + OperationObj.IcdCode + "',");
|
|
strSql.Append("'" + OperationObj.Name + "',");
|
|
strSql.Append("'" + OperationObj.HelpCode + "',");
|
|
strSql.Append("" + OperationObj.UseRate + ",");
|
|
strSql.Append("" + OperationObj.IsValid + ",");
|
|
strSql.Append("'" + OperationObj.OperatorNo + "',");
|
|
strSql.Append("'" + OperationObj.OperatorName + "',");
|
|
strSql.Append("'" + OperationObj.OperateDate + "'");
|
|
strSql.Append(")");
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
|
|
}
|
|
|
|
public void Update(Model.Operation OperationObj)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update Operation set ");
|
|
strSql.Append("IcdCode='" + OperationObj.IcdCode + "',");
|
|
strSql.Append("Name='" + OperationObj.Name + "',");
|
|
strSql.Append("HelpCode='" + OperationObj.HelpCode + "',");
|
|
strSql.Append("IsValid=" + OperationObj.IsValid + ",");
|
|
strSql.Append("OperatorNo='" + OperationObj.OperatorNo + "',");
|
|
strSql.Append("OperatorName='" + OperationObj.OperatorName + "',");
|
|
strSql.Append("OperateDate='" + OperationObj.OperateDate + "'");
|
|
strSql.Append(" where Id=" + OperationObj.Id + " ");
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
|
|
}
|
|
|
|
public Model.Operation GetModel(int Id)
|
|
{
|
|
Model.Operation OperationObj = new Model.Operation();
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
strSql.Append("Id,IcdCode,Name,HelpCode,UseRate,IsValid,OperatorNo,OperatorName,OperateDate ");
|
|
strSql.Append(" from Operation ");
|
|
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() != "")
|
|
{
|
|
OperationObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|
}
|
|
OperationObj.IcdCode = ds.Tables[0].Rows[0]["IcdCode"].ToString();
|
|
OperationObj.Name = ds.Tables[0].Rows[0]["Name"].ToString();
|
|
OperationObj.HelpCode = ds.Tables[0].Rows[0]["HelpCode"].ToString();
|
|
if (ds.Tables[0].Rows[0]["UseRate"].ToString() != "")
|
|
{
|
|
OperationObj.UseRate = int.Parse(ds.Tables[0].Rows[0]["UseRate"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["IsValid"].ToString() != "")
|
|
{
|
|
OperationObj.IsValid = int.Parse(ds.Tables[0].Rows[0]["IsValid"].ToString());
|
|
}
|
|
OperationObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString();
|
|
OperationObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString();
|
|
if (ds.Tables[0].Rows[0]["OperateDate"].ToString() != "")
|
|
{
|
|
OperationObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString());
|
|
}
|
|
}
|
|
return OperationObj;
|
|
}
|
|
|
|
public DataTable GetDataTable(string HelpCode)
|
|
{
|
|
string strSql = "";
|
|
if (HelpCode == "")
|
|
{
|
|
strSql = "SELECT TOP 75 d.Id, d.IcdCode, d.Name FROM Operation d WHERE d.IsValid=1 order by UseRate desc";
|
|
}
|
|
else
|
|
{
|
|
strSql = "SELECT d.Id, d.IcdCode, d.Name FROM Operation d WHERE d.IsValid=1 AND (d.IcdCode LIKE '" + HelpCode + "%' OR d.Name LIKE '" + HelpCode + "%' OR d.HelpCode LIKE '" + HelpCode + "%') order by UseRate desc";
|
|
}
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
|
|
internal DataTable GetDataTable()
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select [Id], IcdCode,[Name],HelpCode,CASE IsValid WHEN 1 THEN '有效' WHEN 0 THEN '无效' END AS IsValid");
|
|
strSql.Append(" FROM Operation ");
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
}
|
|
}
|