689 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			689 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Collections;
 | |
| using AIMSModel;
 | |
| using AIMSObjectQuery;
 | |
| using System.Collections.Generic;
 | |
| using DrawGraph;
 | |
| 
 | |
| namespace AIMSDAL
 | |
| {
 | |
|     public partial class DBloodGasAnalysisDict
 | |
|     {
 | |
|         #region 插入实体操作部份
 | |
|         /// <summary>
 | |
|         /// 插入
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
|         public static int Insert(SqlCommand cmd, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "insert into BloodGasAnalysisDict (Name,EName,ShowName,TagName,Code,HCode,HighLimit,LowLimit,IsShow,IsWarning,IsValid,OrderBy,Remark) values (@Name,@EName,@ShowName,@TagName,@Code,@HCode,@HighLimit,@LowLimit,@IsShow,@IsWarning,@IsValid,@OrderBy,@Remark);select @@identity";
 | |
|             //从实体中取出值放入Command的参数列表
 | |
|             cmd.Parameters.Add(new SqlParameter("@Name", bloodGasAnalysisDict.Name == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Name));
 | |
|             cmd.Parameters.Add(new SqlParameter("@EName", bloodGasAnalysisDict.EName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.EName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@ShowName", bloodGasAnalysisDict.ShowName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.ShowName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@TagName", bloodGasAnalysisDict.TagName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.TagName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@Code", bloodGasAnalysisDict.Code == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Code));
 | |
|             cmd.Parameters.Add(new SqlParameter("@HCode", bloodGasAnalysisDict.HCode == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.HCode));
 | |
|             cmd.Parameters.Add(new SqlParameter("@HighLimit", bloodGasAnalysisDict.HighLimit.HasValue ? (object)bloodGasAnalysisDict.HighLimit.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@LowLimit", bloodGasAnalysisDict.LowLimit.HasValue ? (object)bloodGasAnalysisDict.LowLimit.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsShow", bloodGasAnalysisDict.IsShow.HasValue ? (object)bloodGasAnalysisDict.IsShow.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsWarning", bloodGasAnalysisDict.IsWarning.HasValue ? (object)bloodGasAnalysisDict.IsWarning.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsValid", bloodGasAnalysisDict.IsValid.HasValue ? (object)bloodGasAnalysisDict.IsValid.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@OrderBy", bloodGasAnalysisDict.OrderBy.HasValue ? (object)bloodGasAnalysisDict.OrderBy.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@Remark", bloodGasAnalysisDict.Remark == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Remark));
 | |
|             return Convert.ToInt32(cmd.ExecuteScalar());
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 不使用事务的插入方法
 | |
|         /// </summary>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
|         public static int Insert(BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return Insert(cmd, bloodGasAnalysisDict);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 使用事务的插入方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
|         public static int Insert(Connection connection, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             return Insert(connection.Command, bloodGasAnalysisDict);
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 删除实体操作
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 删除
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int ExcuteDeleteCommand(SqlCommand cmd, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "delete from BloodGasAnalysisDict where Id=@Id";
 | |
|             //从实体中取出值放入Command的参数列表
 | |
|             cmd.Parameters.Add(new SqlParameter("@Id", bloodGasAnalysisDict.Id));
 | |
|             return cmd.ExecuteNonQuery();
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 不使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Delete(BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteDeleteCommand(cmd, bloodGasAnalysisDict);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Delete(Connection connection, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             return ExcuteDeleteCommand(connection.Command, bloodGasAnalysisDict);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 执行删除命令
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int ExcuteDeleteCommand(SqlCommand cmd, string oql, ParameterList parameters)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new BloodGasAnalysisDictMap());
 | |
|             if (filterString != string.Empty)
 | |
|             {
 | |
|                 filterString = " where " + filterString;
 | |
|             }
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "delete from BloodGasAnalysisDict " + filterString;
 | |
|             //添加参数
 | |
|             if (parameters != null)
 | |
|             {
 | |
|                 foreach (string key in parameters.Keys)
 | |
|                 {
 | |
|                     cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
 | |
|                 }
 | |
|             }
 | |
|             return cmd.ExecuteNonQuery();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 不使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Delete(string oql, ParameterList parameters)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteDeleteCommand(cmd, oql, parameters);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Delete(Connection connection, string oql, ParameterList parameters)
 | |
|         {
 | |
|             return ExcuteDeleteCommand(connection.Command, oql, parameters);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region 更新实体操作
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 更新
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int ExcuteUpdateCommand(SqlCommand cmd, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             cmd.CommandText = "update BloodGasAnalysisDict set Name=@Name,EName=@EName,ShowName=@ShowName,TagName=@TagName,Code=@Code,HCode=@HCode,HighLimit=@HighLimit,LowLimit=@LowLimit,IsShow=@IsShow,IsWarning=@IsWarning,IsValid=@IsValid,OrderBy=@OrderBy,Remark=@Remark where Id=@Id";
 | |
|             //从实体中取出值放入Command的参数列表
 | |
|             cmd.Parameters.Add(new SqlParameter("@Name", bloodGasAnalysisDict.Name == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Name));
 | |
|             cmd.Parameters.Add(new SqlParameter("@EName", bloodGasAnalysisDict.EName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.EName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@ShowName", bloodGasAnalysisDict.ShowName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.ShowName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@TagName", bloodGasAnalysisDict.TagName == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.TagName));
 | |
|             cmd.Parameters.Add(new SqlParameter("@Code", bloodGasAnalysisDict.Code == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Code));
 | |
|             cmd.Parameters.Add(new SqlParameter("@HCode", bloodGasAnalysisDict.HCode == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.HCode));
 | |
|             cmd.Parameters.Add(new SqlParameter("@HighLimit", bloodGasAnalysisDict.HighLimit.HasValue ? (object)bloodGasAnalysisDict.HighLimit.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@LowLimit", bloodGasAnalysisDict.LowLimit.HasValue ? (object)bloodGasAnalysisDict.LowLimit.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsShow", bloodGasAnalysisDict.IsShow.HasValue ? (object)bloodGasAnalysisDict.IsShow.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsWarning", bloodGasAnalysisDict.IsWarning.HasValue ? (object)bloodGasAnalysisDict.IsWarning.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@IsValid", bloodGasAnalysisDict.IsValid.HasValue ? (object)bloodGasAnalysisDict.IsValid.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@OrderBy", bloodGasAnalysisDict.OrderBy.HasValue ? (object)bloodGasAnalysisDict.OrderBy.Value : (object)DBNull.Value));
 | |
|             cmd.Parameters.Add(new SqlParameter("@Remark", bloodGasAnalysisDict.Remark == null ? (object)DBNull.Value : (object)bloodGasAnalysisDict.Remark));
 | |
|             cmd.Parameters.Add(new SqlParameter("@Id", bloodGasAnalysisDict.Id));
 | |
|             return cmd.ExecuteNonQuery();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 不使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Update(BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteUpdateCommand(cmd, bloodGasAnalysisDict);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="bloodGasAnalysisDict">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Update(Connection connection, BloodGasAnalysisDict bloodGasAnalysisDict)
 | |
|         {
 | |
|             return ExcuteUpdateCommand(connection.Command, bloodGasAnalysisDict);
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 执行更新命令
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int ExcuteUpdateCommand(SqlCommand cmd, string oql, ParameterList parameters)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string updateString = SyntaxAnalyzer.ParseSql(oql, new BloodGasAnalysisDictMap());
 | |
|             cmd.CommandText = "update BloodGasAnalysisDict set " + updateString;
 | |
|             cmd.Parameters.Clear();
 | |
|             //添加参数
 | |
|             if (parameters != null)
 | |
|             {
 | |
|                 foreach (string key in parameters.Keys)
 | |
|                 {
 | |
|                     cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
 | |
|                 }
 | |
|             }
 | |
|             return cmd.ExecuteNonQuery();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 不使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Update(string oql, ParameterList parameters)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteUpdateCommand(cmd, oql, parameters);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         public static int Update(Connection connection, string oql, ParameterList parameters)
 | |
|         {
 | |
|             return ExcuteUpdateCommand(connection.Command, oql, parameters);
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 查询实体集合
 | |
|         /// <summary>
 | |
|         /// 执行Command获取对象列表
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象列表</returns>
 | |
|         public static List<BloodGasAnalysisDict> ExcuteSelectCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             List<BloodGasAnalysisDict> bloodGasAnalysisDictList = new List<BloodGasAnalysisDict>();
 | |
|             using (SqlDataReader dr = cmd.ExecuteReader())
 | |
|             {
 | |
|                 while (dr.Read())
 | |
|                 {
 | |
|                     BloodGasAnalysisDict bloodGasAnalysisDict = DataReaderToEntity(dr);
 | |
|                     bloodGasAnalysisDictList.Add(bloodGasAnalysisDict);
 | |
|                 }
 | |
|             } 
 | |
|             return bloodGasAnalysisDictList;
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 执行查询命令
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> ExcuteSelectCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new BloodGasAnalysisDictMap());
 | |
|             if (filterString != string.Empty)
 | |
|             {
 | |
|                 if (filterString.Trim().ToLower().IndexOf("order ") != 0)
 | |
|                     filterString = " where " + filterString;
 | |
|             }
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "select * from BloodGasAnalysisDict " + filterString;
 | |
|             //添加参数
 | |
|             if (parameters != null)
 | |
|             {
 | |
|                 foreach (string key in parameters.Keys)
 | |
|                 {
 | |
|                     cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
 | |
|                 }
 | |
|             }
 | |
|             return ExcuteSelectCommand(cmd, recursiveType, recursiveDepth);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> Select()
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     cmd.CommandText = "select * from BloodGasAnalysisDict";
 | |
|                     return ExcuteSelectCommand(cmd, RecursiveType.Parent, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> Select(RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     cmd.CommandText = "select * from BloodGasAnalysisDict";
 | |
|                     return ExcuteSelectCommand(cmd, recursiveType, recursiveDepth);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> Select(string oql, ParameterList parameters)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteSelectCommand(cmd, oql, parameters, RecursiveType.Parent, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> Select(string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteSelectCommand(cmd, oql, parameters, recursiveType, recursiveDepth);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合(启用事务)
 | |
|         /// </summary>
 | |
|         /// <param name="connection">连接对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> Select(Connection connection, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             return ExcuteSelectCommand(connection.Command, oql, parameters, recursiveType, recursiveDepth);
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 查询单个实体
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 递归查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict ExcuteSelectSingleCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             BloodGasAnalysisDict bloodGasAnalysisDict = null;
 | |
|             using (SqlDataReader dr = cmd.ExecuteReader())
 | |
|             {
 | |
|                 if (dr.Read())
 | |
|                     bloodGasAnalysisDict = DataReaderToEntity(dr);
 | |
|             }
 | |
|             if (bloodGasAnalysisDict == null)
 | |
|                 return bloodGasAnalysisDict;
 | |
|             //由外键获取相关实体 
 | |
|             return bloodGasAnalysisDict;
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 更据对象查询语句递归查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new BloodGasAnalysisDictMap());
 | |
|             if (filterString != string.Empty)
 | |
|             {
 | |
|                 filterString = " where " + filterString;
 | |
|             }
 | |
|             cmd.CommandText = "select * from BloodGasAnalysisDict " + filterString;
 | |
|             cmd.Parameters.Clear();
 | |
|             //添加参数
 | |
|             if (parameters != null)
 | |
|             {
 | |
|                 foreach (string key in parameters.Keys)
 | |
|                 {
 | |
|                     cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
 | |
|                 }
 | |
|             }
 | |
|             return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 更据对象查询语句递归查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteSelectSingleCommand(cmd, oql, parameters, recursiveType, recursiveDepth);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 更据对象查询语句查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(string oql, ParameterList parameters)
 | |
|         {
 | |
|             return SelectSingle(oql, parameters, RecursiveType.Parent, 1);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 更据对象查询语句并启用事务查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="connection">连接对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(Connection connection, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             return ExcuteSelectSingleCommand(connection.Command, oql, parameters, recursiveType, recursiveDepth);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 更据主键值递归查询单个实体
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="id">主键值</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(SqlCommand cmd, int? id, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             cmd.Parameters.Clear();
 | |
|             if (id.HasValue)
 | |
|             {
 | |
|                 cmd.CommandText = "select * from BloodGasAnalysisDict where Id=@pk";
 | |
|                 cmd.Parameters.Add(new SqlParameter("@pk", id.Value));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 cmd.CommandText = "select * from BloodGasAnalysisDict where Id is null";
 | |
|             }
 | |
|             return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 按主键字段查询特定实体
 | |
|         /// </summary>
 | |
|         /// <param name="id">主键值</param>
 | |
|         /// <returns>实体类对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(int? id)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return SelectSingle(cmd, id, RecursiveType.Parent, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 按主键字段查询特定实体
 | |
|         /// </summary>
 | |
|         /// <param name="id">主键值</param>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(int? id, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return SelectSingle(cmd, id, recursiveType, recursiveDepth);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 使用事务并按主键字段查询特定实体
 | |
|         /// </summary>
 | |
|         /// <param name="connection">连接对象</param>
 | |
|         /// <param name="id">主键值</param>
 | |
|         /// <returns>实体类对象</returns>
 | |
|         public static BloodGasAnalysisDict SelectSingle(Connection connection, int? id, RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
|             return SelectSingle(connection.Command, id, recursiveType, recursiveDepth);
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 从DataReader中取出值生成实体对象
 | |
|         /// </summary>
 | |
|         /// <param name="searcher">查询对象</param>
 | |
|         /// <returns>过滤条件字符串</returns>
 | |
|         private static BloodGasAnalysisDict DataReaderToEntity(SqlDataReader dr)
 | |
|         {
 | |
|             BloodGasAnalysisDict entity = new BloodGasAnalysisDict();
 | |
|             if (dr["Id"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.Id = Convert.ToInt32(dr["Id"]);
 | |
|             }
 | |
|             if (dr["Name"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.Name = dr["Name"].ToString();
 | |
|             }
 | |
|             if (dr["EName"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.EName = dr["EName"].ToString();
 | |
|             }
 | |
|             if (dr["ShowName"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.ShowName = dr["ShowName"].ToString();
 | |
|             }
 | |
|             if (dr["TagName"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.TagName = dr["TagName"].ToString();
 | |
|             }
 | |
|             if (dr["Code"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.Code = dr["Code"].ToString();
 | |
|             }
 | |
|             if (dr["HCode"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.HCode = dr["HCode"].ToString();
 | |
|             }
 | |
|             if (dr["HighLimit"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.HighLimit = Convert.ToDecimal(dr["HighLimit"]);
 | |
|             }
 | |
|             if (dr["LowLimit"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.LowLimit = Convert.ToDecimal(dr["LowLimit"]);
 | |
|             }
 | |
|             if (dr["IsShow"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.IsShow = Convert.ToInt32(dr["IsShow"]);
 | |
|             }
 | |
|             if (dr["IsWarning"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.IsWarning = Convert.ToInt32(dr["IsWarning"]);
 | |
|             }
 | |
|             if (dr["IsValid"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.IsValid = Convert.ToInt32(dr["IsValid"]);
 | |
|             }
 | |
|             if (dr["OrderBy"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.OrderBy = Convert.ToInt32(dr["OrderBy"]);
 | |
|             }
 | |
|             if (dr["Remark"] != System.DBNull.Value)
 | |
|             {
 | |
|                 entity.Remark = dr["Remark"].ToString();
 | |
|             }
 | |
|             return entity;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         public static List<BloodGasAnalysisDict> SelectAllDate(params string[] where)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     cmd.CommandText = "select BloodGasAnalysisDict.* from BloodGasAnalysisDict where  BloodGasAnalysisDict.name like '%" + where[0] + "%' order by orderby asc";
 | |
| 
 | |
|                     List<BloodGasAnalysisDict> BloodGasAnalysisDictList = new List<BloodGasAnalysisDict>();
 | |
|                     using (SqlDataReader dr = cmd.ExecuteReader())
 | |
|                     {
 | |
|                         while (dr.Read())
 | |
|                         {
 | |
|                             BloodGasAnalysisDict BloodGasAnalysisDict = DataReaderToEntity(dr);
 | |
|                             BloodGasAnalysisDictList.Add(BloodGasAnalysisDict);
 | |
|                         }
 | |
|                     }
 | |
|                     return BloodGasAnalysisDictList;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 |