700 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			700 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Collections;
 | |
| using AIMSModel;
 | |
| using AIMSObjectQuery;
 | |
| using System.Collections.Generic;
 | |
| 
 | |
| namespace AIMSDAL
 | |
| {
 | |
|     internal partial class DOperationRecover
 | |
| 	{
 | |
| 	    #region 插入实体操作部份
 | |
| 	    /// <summary>
 | |
|         /// 插入
 | |
|         /// </summary>
 | |
| 		/// <param name="cmd">Command对象</param>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
| 		internal static int Insert(SqlCommand cmd, OperationRecover operationRecover)
 | |
| 		{
 | |
| 		    cmd.Parameters.Clear();
 | |
| 			cmd.CommandText = "insert into OperationRecover (PatientId,OperationApplyId,InRoomTime,OutRoomTime,InStewardScore,RespirePattern,BloodPressure,Pulse,Respire,Spo2,OutStewardScore,SkinMucosa,RespireSound,Hoarseness,DoctorSign,NurseSign,Remarks,OperatorNo,OperatorName,OperateDate) values (@PatientId,@OperationApplyId,@InRoomTime,@OutRoomTime,@InStewardScore,@RespirePattern,@BloodPressure,@Pulse,@Respire,@Spo2,@OutStewardScore,@SkinMucosa,@RespireSound,@Hoarseness,@DoctorSign,@NurseSign,@Remarks,@OperatorNo,@OperatorName,@OperateDate);select @@identity";
 | |
| 			//从实体中取出值放入Command的参数列表
 | |
| 			cmd.Parameters.Add(new SqlParameter("@PatientId",operationRecover.PatientId.HasValue?(object)operationRecover.PatientId.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperationApplyId",operationRecover.OperationApplyId.HasValue?(object)operationRecover.OperationApplyId.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@InRoomTime",operationRecover.InRoomTime.HasValue?(object)operationRecover.InRoomTime.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OutRoomTime",operationRecover.OutRoomTime.HasValue?(object)operationRecover.OutRoomTime.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@InStewardScore",operationRecover.InStewardScore==null?(object)DBNull.Value:(object)operationRecover.InStewardScore));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@RespirePattern",operationRecover.RespirePattern==null?(object)DBNull.Value:(object)operationRecover.RespirePattern));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@BloodPressure",operationRecover.BloodPressure==null?(object)DBNull.Value:(object)operationRecover.BloodPressure));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Pulse",operationRecover.Pulse==null?(object)DBNull.Value:(object)operationRecover.Pulse));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Respire",operationRecover.Respire==null?(object)DBNull.Value:(object)operationRecover.Respire));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Spo2",operationRecover.Spo2==null?(object)DBNull.Value:(object)operationRecover.Spo2));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OutStewardScore",operationRecover.OutStewardScore==null?(object)DBNull.Value:(object)operationRecover.OutStewardScore));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@SkinMucosa",operationRecover.SkinMucosa==null?(object)DBNull.Value:(object)operationRecover.SkinMucosa));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@RespireSound",operationRecover.RespireSound.HasValue?(object)operationRecover.RespireSound.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Hoarseness",operationRecover.Hoarseness==null?(object)DBNull.Value:(object)operationRecover.Hoarseness));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@DoctorSign",operationRecover.DoctorSign==null?(object)DBNull.Value:(object)operationRecover.DoctorSign));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@NurseSign",operationRecover.NurseSign==null?(object)DBNull.Value:(object)operationRecover.NurseSign));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Remarks",operationRecover.Remarks==null?(object)DBNull.Value:(object)operationRecover.Remarks));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperatorNo",operationRecover.OperatorNo==null?(object)DBNull.Value:(object)operationRecover.OperatorNo));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperatorName",operationRecover.OperatorName==null?(object)DBNull.Value:(object)operationRecover.OperatorName));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperateDate",operationRecover.OperateDate.HasValue?(object)operationRecover.OperateDate.Value:(object)DBNull.Value));
 | |
| 			return Convert.ToInt32(cmd.ExecuteScalar());
 | |
| 		}
 | |
| 	    /// <summary>
 | |
|         /// 不使用事务的插入方法
 | |
|         /// </summary>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
| 	    internal static int Insert(OperationRecover operationRecover)
 | |
| 		{
 | |
| 			using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
 | |
| 			{
 | |
| 				conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return Insert(cmd, operationRecover);
 | |
|                 }
 | |
| 			}
 | |
| 		}
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 使用事务的插入方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>标识列值或影响的记录行数</returns>
 | |
|         internal static int Insert(Connection connection,OperationRecover operationRecover)
 | |
|         {
 | |
|             return Insert(connection.Command, operationRecover);
 | |
|         }
 | |
| 		#endregion
 | |
| 		
 | |
| 		#region 删除实体操作
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 删除
 | |
|         /// </summary>
 | |
| 		/// <param name="cmd">Command对象</param>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
| 		internal static int ExcuteDeleteCommand(SqlCommand cmd, OperationRecover operationRecover)
 | |
|         {
 | |
| 			cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "delete from OperationRecover where Id=@Id";
 | |
|             //从实体中取出值放入Command的参数列表
 | |
| 		    cmd.Parameters.Add(new SqlParameter("@Id", operationRecover.Id));
 | |
|             return cmd.ExecuteNonQuery();
 | |
|         }
 | |
| 		/// <summary>
 | |
|         /// 不使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         internal static int Delete(OperationRecover operationRecover)
 | |
|         {
 | |
|             using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteDeleteCommand(cmd, operationRecover);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 		/// <summary>
 | |
|         /// 使用事务的删除方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         internal static int Delete(Connection connection,OperationRecover operationRecover)
 | |
|         {
 | |
|             return  ExcuteDeleteCommand(connection.Command, operationRecover);
 | |
| 		}
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 执行删除命令
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         internal static int ExcuteDeleteCommand(SqlCommand cmd, string oql, ParameterList parameters)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new OperationRecoverMap());
 | |
|             if (filterString != string.Empty)
 | |
|             {
 | |
|                 filterString = " where " + filterString;
 | |
|             }
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "delete from OperationRecover " + 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>
 | |
|         internal 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>
 | |
|         internal 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="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
| 		internal static int ExcuteUpdateCommand(SqlCommand cmd, OperationRecover operationRecover)
 | |
| 		{
 | |
| 		    cmd.CommandText = "update OperationRecover set PatientId=@PatientId,OperationApplyId=@OperationApplyId,InRoomTime=@InRoomTime,OutRoomTime=@OutRoomTime,InStewardScore=@InStewardScore,RespirePattern=@RespirePattern,BloodPressure=@BloodPressure,Pulse=@Pulse,Respire=@Respire,Spo2=@Spo2,OutStewardScore=@OutStewardScore,SkinMucosa=@SkinMucosa,RespireSound=@RespireSound,Hoarseness=@Hoarseness,DoctorSign=@DoctorSign,NurseSign=@NurseSign,Remarks=@Remarks,OperatorNo=@OperatorNo,OperatorName=@OperatorName,OperateDate=@OperateDate where Id=@Id";
 | |
| 			//从实体中取出值放入Command的参数列表
 | |
| 			cmd.Parameters.Add(new SqlParameter("@PatientId",operationRecover.PatientId.HasValue?(object)operationRecover.PatientId.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperationApplyId",operationRecover.OperationApplyId.HasValue?(object)operationRecover.OperationApplyId.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@InRoomTime",operationRecover.InRoomTime.HasValue?(object)operationRecover.InRoomTime.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OutRoomTime",operationRecover.OutRoomTime.HasValue?(object)operationRecover.OutRoomTime.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@InStewardScore",operationRecover.InStewardScore==null?(object)DBNull.Value:(object)operationRecover.InStewardScore));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@RespirePattern",operationRecover.RespirePattern==null?(object)DBNull.Value:(object)operationRecover.RespirePattern));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@BloodPressure",operationRecover.BloodPressure==null?(object)DBNull.Value:(object)operationRecover.BloodPressure));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Pulse",operationRecover.Pulse==null?(object)DBNull.Value:(object)operationRecover.Pulse));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Respire",operationRecover.Respire==null?(object)DBNull.Value:(object)operationRecover.Respire));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Spo2",operationRecover.Spo2==null?(object)DBNull.Value:(object)operationRecover.Spo2));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OutStewardScore",operationRecover.OutStewardScore==null?(object)DBNull.Value:(object)operationRecover.OutStewardScore));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@SkinMucosa",operationRecover.SkinMucosa==null?(object)DBNull.Value:(object)operationRecover.SkinMucosa));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@RespireSound",operationRecover.RespireSound.HasValue?(object)operationRecover.RespireSound.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Hoarseness",operationRecover.Hoarseness==null?(object)DBNull.Value:(object)operationRecover.Hoarseness));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@DoctorSign",operationRecover.DoctorSign==null?(object)DBNull.Value:(object)operationRecover.DoctorSign));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@NurseSign",operationRecover.NurseSign==null?(object)DBNull.Value:(object)operationRecover.NurseSign));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Remarks",operationRecover.Remarks==null?(object)DBNull.Value:(object)operationRecover.Remarks));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperatorNo",operationRecover.OperatorNo==null?(object)DBNull.Value:(object)operationRecover.OperatorNo));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperatorName",operationRecover.OperatorName==null?(object)DBNull.Value:(object)operationRecover.OperatorName));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@OperateDate",operationRecover.OperateDate.HasValue?(object)operationRecover.OperateDate.Value:(object)DBNull.Value));
 | |
| 			cmd.Parameters.Add(new SqlParameter("@Id", operationRecover.Id));
 | |
|             return cmd.ExecuteNonQuery();
 | |
| 		}
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 不使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
| 	    internal static int Update(OperationRecover operationRecover)
 | |
| 		{
 | |
| 			using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
 | |
| 			{
 | |
| 				conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     return ExcuteUpdateCommand(cmd, operationRecover);
 | |
|                 }
 | |
| 			}
 | |
| 		}
 | |
| 		/// <summary>
 | |
|         /// 使用事务的更新方法
 | |
|         /// </summary>
 | |
|         /// <param name="connection">实现共享Connection的对象</param>
 | |
|         /// <param name="operationRecover">实体类对象</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         internal static int Update(Connection connection,OperationRecover operationRecover)
 | |
|         {
 | |
|             return ExcuteUpdateCommand(connection.Command, operationRecover);
 | |
| 		}
 | |
| 		/// <summary>
 | |
|         /// 执行更新命令
 | |
|         /// </summary>
 | |
|         /// <param name="cmd">Command对象</param>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>影响的记录行数</returns>
 | |
|         internal static int ExcuteUpdateCommand(SqlCommand cmd, string oql, ParameterList parameters)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string updateString = SyntaxAnalyzer.ParseSql(oql, new OperationRecoverMap());
 | |
|             cmd.CommandText = "update OperationRecover 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>
 | |
|         internal 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>
 | |
|         internal 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>
 | |
|         internal static List<OperationRecover> ExcuteSelectCommand(SqlCommand cmd,RecursiveType recursiveType,int recursiveDepth)
 | |
|         {
 | |
|             List<OperationRecover> operationRecoverList = new List<OperationRecover>();
 | |
|             using (SqlDataReader dr = cmd.ExecuteReader())
 | |
|             {
 | |
|                 while (dr.Read())
 | |
|                 {
 | |
|                     OperationRecover operationRecover = DataReaderToEntity(dr);
 | |
|                     operationRecoverList.Add(operationRecover);
 | |
|                 }
 | |
|             }
 | |
| 			return operationRecoverList;
 | |
|         }
 | |
| 		/// <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>
 | |
|         internal static List<OperationRecover> ExcuteSelectCommand(SqlCommand cmd, string oql, ParameterList parameters,RecursiveType recursiveType,int recursiveDepth)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new OperationRecoverMap());
 | |
|             if (filterString != string.Empty)
 | |
|             {
 | |
| 				if(filterString.Trim().ToLower().IndexOf("order ")!=0)
 | |
|                 	filterString = " where " + filterString;
 | |
|             }
 | |
|             cmd.Parameters.Clear();
 | |
|             cmd.CommandText = "select * from OperationRecover " + 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>
 | |
|         internal static List<OperationRecover> Select()
 | |
|         {
 | |
| 			using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     cmd.CommandText = "select * from OperationRecover";
 | |
|                     return ExcuteSelectCommand(cmd, RecursiveType.Parent, 1);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 		/// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
| 		/// <param name="recursiveType">递归类型</param>
 | |
|         /// <param name="recursiveDepth">递归深度</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         internal static List<OperationRecover> Select(RecursiveType recursiveType, int recursiveDepth)
 | |
|         {
 | |
| 			using(SqlConnection conn=new SqlConnection(Connection.ConnectionString))
 | |
|             {
 | |
|                 conn.Open();
 | |
|                 using (SqlCommand cmd = conn.CreateCommand())
 | |
|                 {
 | |
|                     cmd.CommandText = "select * from OperationRecover";
 | |
|                     return ExcuteSelectCommand(cmd, recursiveType, recursiveDepth);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 根据对象查询语句查询实体集合
 | |
|         /// </summary>
 | |
|         /// <param name="oql">对象查询语句</param>
 | |
|         /// <param name="parameters">参数列表</param>
 | |
|         /// <returns>实体类对象集合</returns>
 | |
|         internal static List<OperationRecover> 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>
 | |
|         internal static List<OperationRecover> 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>
 | |
|         internal static List<OperationRecover> 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>
 | |
| 		internal static OperationRecover ExcuteSelectSingleCommand(SqlCommand cmd,RecursiveType recursiveType,int recursiveDepth)
 | |
| 		{
 | |
| 			OperationRecover operationRecover=null;
 | |
| 			using (SqlDataReader dr = cmd.ExecuteReader())
 | |
|             {
 | |
| 			    if(dr.Read())
 | |
| 				    operationRecover = DataReaderToEntity(dr);
 | |
| 			}
 | |
| 			if(operationRecover==null)
 | |
| 			    return operationRecover;
 | |
|             return operationRecover;
 | |
| 		}
 | |
| 		/// <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>
 | |
|         internal static OperationRecover ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters,RecursiveType recursiveType,int recursiveDepth)
 | |
|         {
 | |
|             //解析过滤部份Sql语句
 | |
|             string filterString = SyntaxAnalyzer.ParseSql(oql, new OperationRecoverMap());
 | |
| 			if(filterString!=string.Empty)
 | |
| 			{
 | |
| 			    filterString=" where "+filterString;
 | |
| 			}
 | |
|             cmd.CommandText = "select * from OperationRecover " + 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>
 | |
|         internal static OperationRecover 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>
 | |
|         internal static OperationRecover 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>
 | |
|         internal static OperationRecover 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>
 | |
|         internal static OperationRecover SelectSingle(SqlCommand cmd, int? id,RecursiveType recursiveType,int recursiveDepth)
 | |
| 		{
 | |
| 		    cmd.Parameters.Clear();
 | |
| 			if(id.HasValue)
 | |
| 			{
 | |
| 		    	cmd.CommandText = "select * from OperationRecover where Id=@pk";
 | |
| 				cmd.Parameters.Add(new SqlParameter("@pk",id.Value));
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 			    cmd.CommandText = "select * from OperationRecover where Id is null";
 | |
| 			}
 | |
| 			return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
 | |
| 		}
 | |
| 		
 | |
| 		/// <summary>
 | |
|         /// 按主键字段查询特定实体
 | |
|         /// </summary>
 | |
|         /// <param name="id">主键值</param>
 | |
|         /// <returns>实体类对象</returns>
 | |
|         internal static OperationRecover 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>
 | |
|         internal static OperationRecover 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>
 | |
|         internal static OperationRecover 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 OperationRecover DataReaderToEntity(SqlDataReader dr)
 | |
| 		{
 | |
| 		    OperationRecover entity = new OperationRecover ();
 | |
| 			if(dr["Id"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Id=Convert.ToInt32(dr["Id"]);
 | |
| 			}
 | |
| 			if(dr["PatientId"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.PatientId=Convert.ToInt32(dr["PatientId"]);
 | |
| 			}
 | |
| 			if(dr["OperationApplyId"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OperationApplyId=Convert.ToInt32(dr["OperationApplyId"]);
 | |
| 			}
 | |
| 			if(dr["InRoomTime"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.InRoomTime=Convert.ToDateTime(dr["InRoomTime"]);
 | |
| 			}
 | |
| 			if(dr["OutRoomTime"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OutRoomTime=Convert.ToDateTime(dr["OutRoomTime"]);
 | |
| 			}
 | |
| 			if(dr["InStewardScore"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.InStewardScore=dr["InStewardScore"].ToString();
 | |
| 			}
 | |
| 			if(dr["RespirePattern"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.RespirePattern=dr["RespirePattern"].ToString();
 | |
| 			}
 | |
| 			if(dr["BloodPressure"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.BloodPressure=dr["BloodPressure"].ToString();
 | |
| 			}
 | |
| 			if(dr["Pulse"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Pulse=dr["Pulse"].ToString();
 | |
| 			}
 | |
| 			if(dr["Respire"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Respire=dr["Respire"].ToString();
 | |
| 			}
 | |
| 			if(dr["Spo2"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Spo2=dr["Spo2"].ToString();
 | |
| 			}
 | |
| 			if(dr["OutStewardScore"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OutStewardScore=dr["OutStewardScore"].ToString();
 | |
| 			}
 | |
| 			if(dr["SkinMucosa"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.SkinMucosa=dr["SkinMucosa"].ToString();
 | |
| 			}
 | |
| 			if(dr["RespireSound"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.RespireSound=Convert.ToInt32(dr["RespireSound"]);
 | |
| 			}
 | |
| 			if(dr["Hoarseness"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Hoarseness=dr["Hoarseness"].ToString();
 | |
| 			}
 | |
| 			if(dr["DoctorSign"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.DoctorSign=dr["DoctorSign"].ToString();
 | |
| 			}
 | |
| 			if(dr["NurseSign"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.NurseSign=dr["NurseSign"].ToString();
 | |
| 			}
 | |
| 			if(dr["Remarks"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.Remarks=dr["Remarks"].ToString();
 | |
| 			}
 | |
| 			if(dr["OperatorNo"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OperatorNo=dr["OperatorNo"].ToString();
 | |
| 			}
 | |
| 			if(dr["OperatorName"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OperatorName=dr["OperatorName"].ToString();
 | |
| 			}
 | |
| 			if(dr["OperateDate"]!=System.DBNull.Value)
 | |
| 			{
 | |
| 			    entity.OperateDate=Convert.ToDateTime(dr["OperateDate"]);
 | |
| 			}
 | |
| 			return entity;
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 |