AIMS/AIMSEntity/DAL/Extension/DFactAnaesthesiaMethod.cs
2022-09-26 17:39:34 +08:00

118 lines
4.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 DFactAnaesthesiaMethod
{
public static void Add(FactAnaesthesiaMethod FactAnaesthesiaMethodObj)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into [FactAnaesthesiaMethod](");
strSql.Append("PatientId,ApplyId,AnaesthesiaMethodId,OperatorNo,OperatorName,OperateDate");
strSql.Append(")");
strSql.Append(" values (");
strSql.Append(""+FactAnaesthesiaMethodObj.PatientId+",");
strSql.Append(""+FactAnaesthesiaMethodObj.ApplyId+",");
strSql.Append(""+FactAnaesthesiaMethodObj.AnaesthesiaMethodId+",");
strSql.Append("'"+FactAnaesthesiaMethodObj.OperatorNo+"',");
strSql.Append("'"+FactAnaesthesiaMethodObj.OperatorName+"',");
strSql.Append("'"+FactAnaesthesiaMethodObj.OperateDate+"'");
strSql.Append(")");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
//public static void Update(FactAnaesthesiaMethod FactAnaesthesiaMethodObj)
//{
// StringBuilder strSql=new StringBuilder();
// strSql.Append("update FactAnaesthesiaMethod set ");
// strSql.Append("PatientId="+FactAnaesthesiaMethodObj.PatientId+",");
// strSql.Append("ApplyId="+FactAnaesthesiaMethodObj.ApplyId+",");
// strSql.Append("AnaesthesiaMethodId="+FactAnaesthesiaMethodObj.AnaesthesiaMethodId+",");
// strSql.Append("OperatorNo='"+FactAnaesthesiaMethodObj.OperatorNo+"',");
// strSql.Append("OperatorName='"+FactAnaesthesiaMethodObj.OperatorName+"',");
// strSql.Append("OperateDate='"+FactAnaesthesiaMethodObj.OperateDate+"'");
// strSql.Append(" where Id="+FactAnaesthesiaMethodObj.Id+" ");
// HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
//}
public static void Delete(int PatientId)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete FactAnaesthesiaMethod ");
strSql.Append(" where PatientId=" + PatientId + "");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
public static FactAnaesthesiaMethod GetModel(int Id)
{
FactAnaesthesiaMethod FactAnaesthesiaMethodObj = new FactAnaesthesiaMethod();
StringBuilder strSql=new StringBuilder();
strSql.Append("select ");
strSql.Append("Id,PatientId,ApplyId,AnaesthesiaMethodId,OperatorNo,OperatorName,OperateDate ");
strSql.Append(" from FactAnaesthesiaMethod ");
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()!="")
{
FactAnaesthesiaMethodObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
}
if(ds.Tables[0].Rows[0]["PatientId"].ToString()!="")
{
FactAnaesthesiaMethodObj.PatientId = int.Parse(ds.Tables[0].Rows[0]["PatientId"].ToString());
}
if(ds.Tables[0].Rows[0]["ApplyId"].ToString()!="")
{
FactAnaesthesiaMethodObj.ApplyId = int.Parse(ds.Tables[0].Rows[0]["ApplyId"].ToString());
}
if(ds.Tables[0].Rows[0]["AnaesthesiaMethodId"].ToString()!="")
{
FactAnaesthesiaMethodObj.AnaesthesiaMethodId = int.Parse(ds.Tables[0].Rows[0]["AnaesthesiaMethodId"].ToString());
}
FactAnaesthesiaMethodObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString();
FactAnaesthesiaMethodObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString();
if(ds.Tables[0].Rows[0]["OperateDate"].ToString()!="")
{
FactAnaesthesiaMethodObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString());
}
}
return FactAnaesthesiaMethodObj;
}
public static DataTable GetDataTable(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select [Id],[PatientId],[ApplyId],[AnaesthesiaMethodId],[OperatorNo],[OperatorName],[OperateDate] ");
strSql.Append(" FROM FactAnaesthesiaMethod ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
}
public static List<int> GetFactAnaesthesiaMethodIdList(int PatientId)
{
List<int> AnaesthesiaMethodIdList = new List<int>();
string strSql = "SELECT AnaesthesiaMethodId FROM FactAnaesthesiaMethod WHERE PatientId='" + PatientId + "'";
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
for (int i = 0; i < dt.Rows.Count; i++)
{
AnaesthesiaMethodIdList.Add(int.Parse(dt.Rows[i]["AnaesthesiaMethodId"].ToString()));
}
return AnaesthesiaMethodIdList;
}
}
}