652 lines
29 KiB
C#
652 lines
29 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 DOperationRoom
|
|
{
|
|
#region 插入实体操作部份
|
|
/// <summary>
|
|
/// 插入
|
|
/// </summary>
|
|
/// <param name="cmd">Command对象</param>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>标识列值或影响的记录行数</returns>
|
|
internal static int Insert(SqlCommand cmd, OperationRoom operationRoom)
|
|
{
|
|
cmd.Parameters.Clear();
|
|
cmd.CommandText = "insert into OperationRoom (Name,HelpCode,Ip,Ip2,Ip3,RoomOrder,IsValid,OperatorNo,OperatorName,OperateDate,Site,PhysioSetting) values (@Name,@HelpCode,@Ip,@Ip2,@Ip3,@RoomOrder,@IsValid,@OperatorNo,@OperatorName,@OperateDate,@Site,@PhysioSetting);select @@identity";
|
|
//从实体中取出值放入Command的参数列表
|
|
cmd.Parameters.Add(new SqlParameter("@Name", operationRoom.Name == null ? (object)DBNull.Value : (object)operationRoom.Name));
|
|
cmd.Parameters.Add(new SqlParameter("@HelpCode", operationRoom.HelpCode == null ? (object)DBNull.Value : (object)operationRoom.HelpCode));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip", operationRoom.Ip == null ? (object)DBNull.Value : (object)operationRoom.Ip));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip2", operationRoom.Ip2 == null ? (object)DBNull.Value : (object)operationRoom.Ip2));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip3", operationRoom.Ip3 == null ? (object)DBNull.Value : (object)operationRoom.Ip3));
|
|
cmd.Parameters.Add(new SqlParameter("@RoomOrder", operationRoom.RoomOrder.HasValue ? (object)operationRoom.RoomOrder.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@IsValid", operationRoom.IsValid.HasValue ? (object)operationRoom.IsValid.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorNo", operationRoom.OperatorNo == null ? (object)DBNull.Value : (object)operationRoom.OperatorNo));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorName", operationRoom.OperatorName == null ? (object)DBNull.Value : (object)operationRoom.OperatorName));
|
|
cmd.Parameters.Add(new SqlParameter("@OperateDate", operationRoom.OperateDate.HasValue ? (object)operationRoom.OperateDate.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@Site", operationRoom.Site == null ? (object)DBNull.Value : (object)operationRoom.Site));
|
|
cmd.Parameters.Add(new SqlParameter("@PhysioSetting", operationRoom.PhysioSetting == null ? (object)DBNull.Value : (object)operationRoom.PhysioSetting));
|
|
return Convert.ToInt32(cmd.ExecuteScalar());
|
|
}
|
|
/// <summary>
|
|
/// 不使用事务的插入方法
|
|
/// </summary>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>标识列值或影响的记录行数</returns>
|
|
internal static int Insert(OperationRoom operationRoom)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
return Insert(cmd, operationRoom);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 使用事务的插入方法
|
|
/// </summary>
|
|
/// <param name="connection">实现共享Connection的对象</param>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>标识列值或影响的记录行数</returns>
|
|
internal static int Insert(Connection connection, OperationRoom operationRoom)
|
|
{
|
|
return Insert(connection.Command, operationRoom);
|
|
}
|
|
#endregion
|
|
|
|
#region 删除实体操作
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="cmd">Command对象</param>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int ExcuteDeleteCommand(SqlCommand cmd, OperationRoom operationRoom)
|
|
{
|
|
cmd.Parameters.Clear();
|
|
cmd.CommandText = "delete from OperationRoom where Id=@Id";
|
|
//从实体中取出值放入Command的参数列表
|
|
cmd.Parameters.Add(new SqlParameter("@Id", operationRoom.Id));
|
|
return cmd.ExecuteNonQuery();
|
|
}
|
|
/// <summary>
|
|
/// 不使用事务的删除方法
|
|
/// </summary>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int Delete(OperationRoom operationRoom)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
return ExcuteDeleteCommand(cmd, operationRoom);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 使用事务的删除方法
|
|
/// </summary>
|
|
/// <param name="connection">实现共享Connection的对象</param>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int Delete(Connection connection, OperationRoom operationRoom)
|
|
{
|
|
return ExcuteDeleteCommand(connection.Command, operationRoom);
|
|
}
|
|
|
|
/// <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 OperationRoomMap());
|
|
if (filterString != string.Empty)
|
|
{
|
|
filterString = " where " + filterString;
|
|
}
|
|
cmd.Parameters.Clear();
|
|
cmd.CommandText = "delete from OperationRoom " + 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="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int ExcuteUpdateCommand(SqlCommand cmd, OperationRoom operationRoom)
|
|
{
|
|
cmd.CommandText = "update OperationRoom set Name=@Name,HelpCode=@HelpCode,Ip=@Ip,Ip2=@Ip2,Ip3=@Ip3,RoomOrder=@RoomOrder,IsValid=@IsValid,OperatorNo=@OperatorNo,OperatorName=@OperatorName,OperateDate=@OperateDate,Site=@Site,PhysioSetting=@PhysioSetting where Id=@Id";
|
|
//从实体中取出值放入Command的参数列表
|
|
cmd.Parameters.Add(new SqlParameter("@Name", operationRoom.Name == null ? (object)DBNull.Value : (object)operationRoom.Name));
|
|
cmd.Parameters.Add(new SqlParameter("@HelpCode", operationRoom.HelpCode == null ? (object)DBNull.Value : (object)operationRoom.HelpCode));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip", operationRoom.Ip == null ? (object)DBNull.Value : (object)operationRoom.Ip));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip2", operationRoom.Ip2 == null ? (object)DBNull.Value : (object)operationRoom.Ip2));
|
|
cmd.Parameters.Add(new SqlParameter("@Ip3", operationRoom.Ip3 == null ? (object)DBNull.Value : (object)operationRoom.Ip3));
|
|
cmd.Parameters.Add(new SqlParameter("@RoomOrder", operationRoom.RoomOrder.HasValue ? (object)operationRoom.RoomOrder.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@IsValid", operationRoom.IsValid.HasValue ? (object)operationRoom.IsValid.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorNo", operationRoom.OperatorNo == null ? (object)DBNull.Value : (object)operationRoom.OperatorNo));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorName", operationRoom.OperatorName == null ? (object)DBNull.Value : (object)operationRoom.OperatorName));
|
|
cmd.Parameters.Add(new SqlParameter("@OperateDate", operationRoom.OperateDate.HasValue ? (object)operationRoom.OperateDate.Value : (object)DBNull.Value));
|
|
cmd.Parameters.Add(new SqlParameter("@Site", operationRoom.Site == null ? (object)DBNull.Value : (object)operationRoom.Site));
|
|
cmd.Parameters.Add(new SqlParameter("@PhysioSetting", operationRoom.PhysioSetting == null ? (object)DBNull.Value : (object)operationRoom.PhysioSetting));
|
|
cmd.Parameters.Add(new SqlParameter("@Id", operationRoom.Id));
|
|
return cmd.ExecuteNonQuery();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 不使用事务的更新方法
|
|
/// </summary>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int Update(OperationRoom operationRoom)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
return ExcuteUpdateCommand(cmd, operationRoom);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 使用事务的更新方法
|
|
/// </summary>
|
|
/// <param name="connection">实现共享Connection的对象</param>
|
|
/// <param name="operationRoom">实体类对象</param>
|
|
/// <returns>影响的记录行数</returns>
|
|
internal static int Update(Connection connection, OperationRoom operationRoom)
|
|
{
|
|
return ExcuteUpdateCommand(connection.Command, operationRoom);
|
|
}
|
|
/// <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 OperationRoomMap());
|
|
cmd.CommandText = "update OperationRoom 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<OperationRoom> ExcuteSelectCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
List<OperationRoom> operationRoomList = new List<OperationRoom>();
|
|
using (SqlDataReader dr = cmd.ExecuteReader())
|
|
{
|
|
while (dr.Read())
|
|
{
|
|
OperationRoom operationRoom = DataReaderToEntity(dr);
|
|
operationRoomList.Add(operationRoom);
|
|
}
|
|
}
|
|
return operationRoomList;
|
|
}
|
|
/// <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<OperationRoom> ExcuteSelectCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
//解析过滤部份Sql语句
|
|
string filterString = SyntaxAnalyzer.ParseSql(oql, new OperationRoomMap());
|
|
if (filterString != string.Empty)
|
|
{
|
|
if (filterString.Trim().ToLower().IndexOf("order ") != 0)
|
|
filterString = " where " + filterString;
|
|
}
|
|
cmd.Parameters.Clear();
|
|
cmd.CommandText = "select * from OperationRoom " + 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<OperationRoom> Select()
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
cmd.CommandText = "select * from OperationRoom";
|
|
return ExcuteSelectCommand(cmd, RecursiveType.Parent, 1);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据对象查询语句查询实体集合
|
|
/// </summary>
|
|
/// <param name="recursiveType">递归类型</param>
|
|
/// <param name="recursiveDepth">递归深度</param>
|
|
/// <returns>实体类对象集合</returns>
|
|
internal static List<OperationRoom> Select(RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(Connection.ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
cmd.CommandText = "select * from OperationRoom";
|
|
return ExcuteSelectCommand(cmd, recursiveType, recursiveDepth);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据对象查询语句查询实体集合
|
|
/// </summary>
|
|
/// <param name="oql">对象查询语句</param>
|
|
/// <param name="parameters">参数列表</param>
|
|
/// <returns>实体类对象集合</returns>
|
|
internal static List<OperationRoom> 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<OperationRoom> 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<OperationRoom> 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 OperationRoom ExcuteSelectSingleCommand(SqlCommand cmd, RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
OperationRoom operationRoom = null;
|
|
using (SqlDataReader dr = cmd.ExecuteReader())
|
|
{
|
|
if (dr.Read())
|
|
operationRoom = DataReaderToEntity(dr);
|
|
}
|
|
if (operationRoom == null)
|
|
return operationRoom;
|
|
return operationRoom;
|
|
}
|
|
/// <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 OperationRoom ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
//解析过滤部份Sql语句
|
|
string filterString = SyntaxAnalyzer.ParseSql(oql, new OperationRoomMap());
|
|
if (filterString != string.Empty)
|
|
{
|
|
filterString = " where " + filterString;
|
|
}
|
|
cmd.CommandText = "select * from OperationRoom " + 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 OperationRoom 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 OperationRoom 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 OperationRoom 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 OperationRoom SelectSingle(SqlCommand cmd, int? id, RecursiveType recursiveType, int recursiveDepth)
|
|
{
|
|
cmd.Parameters.Clear();
|
|
if (id.HasValue)
|
|
{
|
|
cmd.CommandText = "select * from OperationRoom where Id=@pk";
|
|
cmd.Parameters.Add(new SqlParameter("@pk", id.Value));
|
|
}
|
|
else
|
|
{
|
|
cmd.CommandText = "select * from OperationRoom where Id is null";
|
|
}
|
|
return ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按主键字段查询特定实体
|
|
/// </summary>
|
|
/// <param name="id">主键值</param>
|
|
/// <returns>实体类对象</returns>
|
|
internal static OperationRoom 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 OperationRoom 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 OperationRoom 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 OperationRoom DataReaderToEntity(SqlDataReader dr)
|
|
{
|
|
OperationRoom entity = new OperationRoom();
|
|
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["HelpCode"] != System.DBNull.Value)
|
|
{
|
|
entity.HelpCode = dr["HelpCode"].ToString();
|
|
}
|
|
if (dr["Ip"] != System.DBNull.Value)
|
|
{
|
|
entity.Ip = dr["Ip"].ToString();
|
|
}
|
|
if (dr["Ip2"] != System.DBNull.Value)
|
|
{
|
|
entity.Ip2 = dr["Ip2"].ToString();
|
|
}
|
|
if (dr["Ip3"] != System.DBNull.Value)
|
|
{
|
|
entity.Ip3 = dr["Ip3"].ToString();
|
|
}
|
|
if (dr["RoomOrder"] != System.DBNull.Value)
|
|
{
|
|
entity.RoomOrder = Convert.ToInt32(dr["RoomOrder"]);
|
|
}
|
|
if (dr["IsValid"] != System.DBNull.Value)
|
|
{
|
|
entity.IsValid = Convert.ToInt32(dr["IsValid"]);
|
|
}
|
|
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"]);
|
|
}
|
|
if (dr["Site"] != System.DBNull.Value)
|
|
{
|
|
entity.Site = dr["Site"].ToString();
|
|
}
|
|
if (dr["PhysioSetting"] != System.DBNull.Value)
|
|
{
|
|
entity.PhysioSetting = dr["PhysioSetting"].ToString();
|
|
}
|
|
return entity;
|
|
}
|
|
}
|
|
}
|
|
|