documentDAL.cs
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:25k
源码类别:

OA系统

开发平台:

C#

  1. // =================================================================== 
  2. // 产品(COM.OA.SqlServerDAL)项目
  3. //====================================================================
  4. // wangyp @Copy Right 2006-2008
  5. // 文件:documentDAL.cs
  6. // 项目名称:工程项目管理
  7. // 创建时间:2008-9-23
  8. // 负责人:wangyp
  9. // 先创建SqlHelper.cs文件,引用System.Configuration程序集和实体(COM.OA.Entity)、产品规则(COM.OA.IDAL)项目、引用业务逻辑(COM.OA.BLL)项目
  10. // ===================================================================
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Data.SqlClient;
  16. using System.Text;
  17. using COM.OA.Entity;
  18. using COM.OA.IDAL;
  19. using COM.OA.BLL;
  20. namespace COM.OA.SqlServerDAL
  21. {
  22.     /// <summary>
  23.     /// 数据访问层dbo.document
  24.     /// </summary>
  25.     public partial class documentDAL : IdocumentDAL
  26.     {
  27.         #region 构造函数
  28.         /// <summary>
  29.         /// 数据层实例化
  30.         /// </summary>
  31.         public documentDAL()
  32.         {
  33.         }
  34.         #endregion
  35.         #region -----------实例化接口函数-----------
  36.         #region 添加
  37.         /// <summary>
  38.         /// 向数据库中插入一条新记录
  39.         /// </summary>
  40.         /// <param name="document">document实体对象</param>
  41.         /// <returns></returns>
  42.         public int Insert(document document)
  43.         {
  44.             string sqlCommand = "documentInsert";
  45.             int res;
  46.             SqlParameter[] param ={
  47. new SqlParameter("@doc_id",SqlDbType.Int),
  48. new SqlParameter("@doc_dept_id",SqlDbType.Int),
  49. new SqlParameter("@doc_g_id",SqlDbType.Int),
  50. new SqlParameter("@doc_u_id",SqlDbType.Int),
  51. new SqlParameter("@doc_title",SqlDbType.VarChar),
  52. new SqlParameter("@doc_annex",SqlDbType.VarChar),
  53. new SqlParameter("@doc_downloads",SqlDbType.Int),
  54. new SqlParameter("@doc_reads",SqlDbType.Int),
  55. new SqlParameter("@doc_clicks",SqlDbType.Int),
  56. new SqlParameter("@doc_releasetime",SqlDbType.DateTime),
  57. new SqlParameter("@doc_sendu_id",SqlDbType.Int)
  58. };
  59.             param[0].Direction = ParameterDirection.Output;
  60.             param[1].Value = document.doc_dept_id;
  61.             param[2].Value = document.doc_g_id;
  62.             param[3].Value = document.doc_u_id;
  63.             param[4].Value = document.doc_title;
  64.             param[5].Value = document.doc_annex;
  65.             param[6].Value = document.doc_downloads;
  66.             param[7].Value = document.doc_reads;
  67.             param[8].Value = document.doc_clicks;
  68.             param[9].Value = document.doc_releasetime;
  69.             param[10].Value = document.doc_sendu_id;
  70.             res = SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  71.             document.doc_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
  72.             return res;
  73.         }
  74.         /// <summary>
  75.         /// 向数据库中插入一条新记录。带事务
  76.         /// </summary>
  77.         /// <param name="sp">事务对象</param>
  78.         /// <param name="document">document实体对象</param>
  79.         /// <returns></returns>
  80.         public int Insert(SqlTransaction sp, document document)
  81.         {
  82.             string sqlCommand = "documentInsert";
  83.             int res;
  84.             SqlParameter[] param ={
  85. new SqlParameter("@doc_id",SqlDbType.Int),
  86. new SqlParameter("@doc_dept_id",SqlDbType.Int),
  87. new SqlParameter("@doc_g_id",SqlDbType.Int),
  88. new SqlParameter("@doc_u_id",SqlDbType.Int),
  89. new SqlParameter("@doc_title",SqlDbType.VarChar),
  90. new SqlParameter("@doc_annex",SqlDbType.VarChar),
  91. new SqlParameter("@doc_downloads",SqlDbType.Int),
  92. new SqlParameter("@doc_reads",SqlDbType.Int),
  93. new SqlParameter("@doc_clicks",SqlDbType.Int),
  94. new SqlParameter("@doc_releasetime",SqlDbType.DateTime),
  95. new SqlParameter("@doc_sendu_id",SqlDbType.Int)
  96. };
  97.             param[0].Direction = ParameterDirection.Output;
  98.             param[1].Value = document.doc_dept_id;
  99.             param[2].Value = document.doc_g_id;
  100.             param[3].Value = document.doc_u_id;
  101.             param[4].Value = document.doc_title;
  102.             param[5].Value = document.doc_annex;
  103.             param[6].Value = document.doc_downloads;
  104.             param[7].Value = document.doc_reads;
  105.             param[8].Value = document.doc_clicks;
  106.             param[9].Value = document.doc_releasetime;
  107.             param[10].Value = document.doc_sendu_id;
  108.             res = SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  109.             document.doc_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
  110.             return res;
  111.         }
  112.         #endregion
  113.         #region 更新
  114.         /// <summary>
  115.         /// 向数据表document更新一条记录
  116.         /// </summary>
  117.         /// <param name="document">document实体对象</param>
  118.         /// <returns></returns>
  119.         public int Update(document document)
  120.         {
  121.             string sqlCommand = "documentUpdate";
  122.             SqlParameter[] param ={
  123. new SqlParameter("@doc_id",SqlDbType.Int),
  124. new SqlParameter("@doc_dept_id",SqlDbType.Int),
  125. new SqlParameter("@doc_g_id",SqlDbType.Int),
  126. new SqlParameter("@doc_u_id",SqlDbType.Int),
  127. new SqlParameter("@doc_title",SqlDbType.VarChar),
  128. new SqlParameter("@doc_annex",SqlDbType.VarChar),
  129. new SqlParameter("@doc_downloads",SqlDbType.Int),
  130. new SqlParameter("@doc_reads",SqlDbType.Int),
  131. new SqlParameter("@doc_clicks",SqlDbType.Int),
  132. new SqlParameter("@doc_releasetime",SqlDbType.DateTime),
  133. new SqlParameter("@doc_sendu_id",SqlDbType.Int)
  134. };
  135.             param[0].Value = document.doc_id;
  136.             param[1].Value = document.doc_dept_id;
  137.             param[2].Value = document.doc_g_id;
  138.             param[3].Value = document.doc_u_id;
  139.             param[4].Value = document.doc_title;
  140.             param[5].Value = document.doc_annex;
  141.             param[6].Value = document.doc_downloads;
  142.             param[7].Value = document.doc_reads;
  143.             param[8].Value = document.doc_clicks;
  144.             param[9].Value = document.doc_releasetime;
  145.             param[10].Value = document.doc_sendu_id;
  146.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  147.         }
  148.         /// <summary>
  149.         /// 向数据表document更新一条记录。带事务
  150.         /// </summary>
  151.         /// <param name="sp">事务对象</param>
  152.         /// <param name="document">document实体对象</param>
  153.         /// <returns></returns>
  154.         public int Update(SqlTransaction sp, document document)
  155.         {
  156.             string sqlCommand = "documentUpdate";
  157.             SqlParameter[] param ={
  158. new SqlParameter("@doc_id",SqlDbType.Int),
  159. new SqlParameter("@doc_dept_id",SqlDbType.Int),
  160. new SqlParameter("@doc_g_id",SqlDbType.Int),
  161. new SqlParameter("@doc_u_id",SqlDbType.Int),
  162. new SqlParameter("@doc_title",SqlDbType.VarChar),
  163. new SqlParameter("@doc_annex",SqlDbType.VarChar),
  164. new SqlParameter("@doc_downloads",SqlDbType.Int),
  165. new SqlParameter("@doc_reads",SqlDbType.Int),
  166. new SqlParameter("@doc_clicks",SqlDbType.Int),
  167. new SqlParameter("@doc_releasetime",SqlDbType.DateTime),
  168. new SqlParameter("@doc_sendu_id",SqlDbType.Int)
  169. };
  170.             param[0].Value = document.doc_id;
  171.             param[1].Value = document.doc_dept_id;
  172.             param[2].Value = document.doc_g_id;
  173.             param[3].Value = document.doc_u_id;
  174.             param[4].Value = document.doc_title;
  175.             param[5].Value = document.doc_annex;
  176.             param[6].Value = document.doc_downloads;
  177.             param[7].Value = document.doc_reads;
  178.             param[8].Value = document.doc_clicks;
  179.             param[9].Value = document.doc_releasetime;
  180.             param[10].Value = document.doc_sendu_id;
  181.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  182.         }
  183.         #endregion
  184.         #region 删除
  185.         /// <summary>
  186.         /// 删除数据表document中的一条记录
  187.         /// </summary>
  188.         /// <param name="doc_id">doc_id</param>
  189.         /// <returns></returns>
  190.         public int Delete(int doc_id)
  191.         {
  192.             string sqlCommand = "documentDelete";
  193.             SqlParameter[] param ={
  194. new SqlParameter("@doc_id",SqlDbType.Int)
  195. };
  196.             param[0].Value = doc_id;
  197.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  198.         }
  199.         /// <summary>
  200.         /// 删除数据表document中的一条记录
  201.         /// </summary>
  202.         /// <param name="document">document实体对象</param>
  203.         /// <returns></returns>
  204.         public int Delete(document document)
  205.         {
  206.             string sqlCommand = "documentDelete";
  207.             SqlParameter[] param ={
  208. new SqlParameter("@doc_id",SqlDbType.Int)
  209. };
  210.             param[0].Value = document.doc_id;
  211.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  212.         }
  213.         /// <summary>
  214.         /// 删除数据表document中的一条记录,带事务
  215.         /// </summary>
  216.         /// <param name="sp">事务对象</param>
  217.         /// <param name="doc_id">doc_id</param>
  218.         /// <returns></returns>
  219.         public int Delete(SqlTransaction sp, int doc_id)
  220.         {
  221.             string sqlCommand = "documentDelete";
  222.             SqlParameter[] param ={
  223. new SqlParameter("@doc_id",SqlDbType.Int)
  224. };
  225.             param[0].Value = doc_id;
  226.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  227.         }
  228.         /// <summary>
  229.         /// 删除数据表document中的一条记录,带事务
  230.         /// </summary>
  231.         /// <param name="sp">事务对象</param>
  232.         /// <param name="document">document实体对象</param>
  233.         /// <returns></returns>
  234.         public int Delete(SqlTransaction sp, document document)
  235.         {
  236.             string sqlCommand = "documentDelete";
  237.             SqlParameter[] param ={
  238. new SqlParameter("@doc_id",SqlDbType.Int)
  239. };
  240.             param[0].Value = document.doc_id;
  241.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  242.         }
  243.         #endregion
  244.         #region 实体对象
  245.         /// <summary>
  246.         /// 得到document实体对象
  247.         /// </summary>
  248.         /// <param name="row">row</param>
  249.         /// <returns>document实体对象</returns>
  250.         public document Select(DataRow row)
  251.         {
  252.             document obj = new document();
  253.             if (row != null)
  254.             {
  255.                 obj.doc_id = ((row["doc_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_id"]);
  256.                 obj.doc_dept_id = ((row["doc_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_dept_id"]);
  257.                 obj.doc_g_id = ((row["doc_g_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_g_id"]);
  258.                 obj.doc_u_id = ((row["doc_u_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_u_id"]);
  259.                 obj.doc_title = row["doc_title"].ToString();
  260.                 obj.doc_annex = row["doc_annex"].ToString();
  261.                 obj.doc_downloads = ((row["doc_downloads"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_downloads"]);
  262.                 obj.doc_reads = ((row["doc_reads"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_reads"]);
  263.                 obj.doc_clicks = ((row["doc_clicks"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_clicks"]);
  264.                 obj.doc_releasetime = ((row["doc_releasetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["doc_releasetime"]);
  265.                 obj.doc_sendu_id = ((row["doc_sendu_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["doc_sendu_id"]);
  266.             }
  267.             else
  268.             {
  269.                 return null;
  270.             }
  271.             return obj;
  272.         }
  273.         /// <summary>
  274.         /// 得到document实体对象
  275.         /// </summary>
  276.         /// <param name="dr">dr</param>
  277.         /// <returns>document实体对象</returns>
  278.         public document Select(IDataReader dr)
  279.         {
  280.             document obj = new document();
  281.             obj.doc_id = ((dr["doc_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_id"]);
  282.             obj.doc_dept_id = ((dr["doc_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_dept_id"]);
  283.             obj.doc_g_id = ((dr["doc_g_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_g_id"]);
  284.             obj.doc_u_id = ((dr["doc_u_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_u_id"]);
  285.             obj.doc_title = dr["doc_title"].ToString();
  286.             obj.doc_annex = dr["doc_annex"].ToString();
  287.             obj.doc_downloads = ((dr["doc_downloads"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_downloads"]);
  288.             obj.doc_reads = ((dr["doc_reads"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_reads"]);
  289.             obj.doc_clicks = ((dr["doc_clicks"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_clicks"]);
  290.             obj.doc_releasetime = ((dr["doc_releasetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["doc_releasetime"]);
  291.             obj.doc_sendu_id = ((dr["doc_sendu_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["doc_sendu_id"]);
  292.             return obj;
  293.         }
  294.         /// <summary>
  295.         /// 根据ID,返回一个document实体对象
  296.         /// </summary>
  297.         /// <param name="doc_id">doc_id</param>
  298.         /// <returns>document实体对象</returns>
  299.         public document Select(int doc_id)
  300.         {
  301.             return this.Select(doc_id, false, false);
  302.         }
  303.         /// <summary>
  304.         /// 根据ID,返回一个document实体对象
  305.         /// </summary>
  306.         /// <param name="doc_id">doc_id</param>
  307.         /// <param name="bParentTable">将document对象设置与父表关联</param>
  308.         /// <param name="bChildrenTable">将document对象设置与子表关联</param>
  309.         /// <returns>document实体对象</returns>
  310.         public document Select(int doc_id, bool bParentTable, bool bChildrenTable)
  311.         {
  312.             document obj = null;
  313.             SqlParameter[] param ={
  314. new SqlParameter("@doc_id",SqlDbType.Int)
  315. };
  316.             param[0].Value = doc_id;
  317.             string sqlCommand = "documentSelect";
  318.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  319.             {
  320.                 while (dr.Read())
  321.                 {
  322.                     obj = this.Select(dr);
  323.                 }
  324.             }
  325.             this.Select(obj, bParentTable, bChildrenTable);
  326.             return obj;
  327.         }
  328.         /// <summary>
  329.         /// 将document实体对象设置与父表和子表关联
  330.         /// </summary>
  331.         /// <param name="obj">document实体对象</param>
  332.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  333.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  334.         public void Select(document obj, bool bParentTable, bool bChildrenTable)
  335.         {
  336.             //关联的主表
  337.             if (bParentTable)
  338.             {
  339.                 obj.users = usersBLL.Select(obj.doc_u_id);
  340.                 obj.groups = groupsBLL.Select(obj.doc_g_id);
  341.                 obj.department = departmentBLL.Select(obj.doc_dept_id);
  342.             }
  343.             //关联的子表集合
  344.             if (bChildrenTable)
  345.             {
  346.             }
  347.         }
  348.         #endregion
  349.         #region 父表
  350.         /// <summary>
  351.         /// 设置实体对象(document)的父表对象
  352.         /// </summary>
  353.         /// <param name="document">实体对象</param>
  354.         public void users(document document)
  355.         {
  356.             document.users = usersBLL.Select(document.doc_u_id);
  357.         }
  358.         /// <summary>
  359.         /// 设置实体对象(document)的父表对象
  360.         /// </summary>
  361.         /// <param name="document">实体对象</param>
  362.         public void groups(document document)
  363.         {
  364.             document.groups = groupsBLL.Select(document.doc_g_id);
  365.         }
  366.         /// <summary>
  367.         /// 设置实体对象(document)的父表对象
  368.         /// </summary>
  369.         /// <param name="document">实体对象</param>
  370.         public void department(document document)
  371.         {
  372.             document.department = departmentBLL.Select(document.doc_dept_id);
  373.         }
  374.         #endregion
  375.         #region 子表
  376.         #endregion
  377.         #region 查询
  378.         /// <summary>
  379.         /// 得到数据表document所有记录
  380.         /// </summary>
  381.         /// <returns>结果集</returns>
  382.         public IList<document> Select()
  383.         {
  384.             return this.Select(false, false);
  385.         }
  386.         /// <summary>
  387.         /// 得到数据表document所有记录
  388.         /// </summary>
  389.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  390.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  391.         /// <returns>结果集</returns>
  392.         public IList<document> Select(bool bParentTable, bool bChildrenTable)
  393.         {
  394.             IList<document> list = new List<document>();
  395.             string sqlCommand = "documentSelectAll";
  396.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand))
  397.             {
  398.                 while (dr.Read())
  399.                 {
  400.                     list.Add(this.Select(dr));
  401.                 }
  402.             }
  403.             foreach (document obj in list)
  404.             {
  405.                 this.Select(obj, bParentTable, bChildrenTable);
  406.             }
  407.             return list;
  408.         }
  409.         /// <summary>
  410.         /// 得到数据表document满足查询条件的记录
  411.         /// </summary>
  412.         /// <param name="where">查询条件</param>
  413.         /// <returns>结果集</returns>
  414.         public IList<document> Select(string where)
  415.         {
  416.             return this.Select(where, false, false);
  417.         }
  418.         /// <summary>
  419.         /// 得到数据表document满足查询条件的记录
  420.         /// </summary>
  421.         /// <param name="where">查询条件</param>
  422.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  423.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  424.         /// <returns>结果集</returns>
  425.         public IList<document> Select(string where, bool bParentTable, bool bChildrenTable)
  426.         {
  427.             IList<document> list = new List<document>();
  428.             SqlParameter[] param ={
  429. new SqlParameter("@where",SqlDbType.VarChar,8000)
  430. };
  431.             param[0].Value = where;
  432.             string sqlCommand = "documentSelectByParams";
  433.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  434.             {
  435.                 while (dr.Read())
  436.                 {
  437.                     list.Add(this.Select(dr));
  438.                 }
  439.             }
  440.             foreach (document obj in list)
  441.             {
  442.                 this.Select(obj, bParentTable, bChildrenTable);
  443.             }
  444.             return list;
  445.         }
  446.         /// <summary>
  447.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  448.         /// </summary>
  449.         /// <param name="foreignFieldName">外键字段名称</param>
  450.         /// <param name="foreignFieldValue">外键字段值</param>
  451.         /// <returns>结果集</returns>
  452.         public IList<document> Select(string foreignFieldName, int foreignFieldValue)
  453.         {
  454.             return this.Select(foreignFieldName, foreignFieldValue, false, false);
  455.         }
  456.         /// <summary>
  457.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  458.         /// </summary>
  459.         /// <param name="foreignFieldName">外键字段名称</param>
  460.         /// <param name="foreignFieldValue">外键字段值</param>
  461.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  462.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  463.         /// <returns>结果集</returns>
  464.         public IList<document> Select(string foreignFieldName, int foreignFieldValue, bool bParentTable, bool bChildrenTable)
  465.         {
  466.             return this.Select(string.Format("{0}='{1}'", foreignFieldName, foreignFieldValue), bParentTable, bChildrenTable);
  467.         }
  468.         /// <summary>
  469.         /// 得到数据表document满足查询条件的记录数
  470.         /// </summary>
  471.         /// <param name="where">查询条件</param>
  472.         /// <param name="recordCount">记录数</param>
  473.         public void Select(string where, out int recordCount)
  474.         {
  475.             string sqlCommand = "documentCountByWhere";
  476.             SqlParameter[] param ={
  477. new SqlParameter("@where",SqlDbType.VarChar,8000),
  478. new SqlParameter("@recordCount",SqlDbType.Int)
  479. };
  480.             param[0].Value = where;
  481.             param[1].Direction = ParameterDirection.Output;
  482.             SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  483.             recordCount = Convert.ToInt32(param[1].Value);
  484.         }
  485.         /// <summary>
  486.         /// 得到数据表document满足查询条件的分页记录
  487.         /// </summary>
  488.         /// <param name="pageSize">每页显示记录数</param>
  489.         /// <param name="pageIndex">当前显示第几页</param>
  490.         /// <param name="where">查询条件</param>
  491.         /// <returns>结果集</returns>
  492.         public IList<document> Select(int pageSize, int pageIndex, string where)
  493.         {
  494.             return this.Select(pageSize, pageIndex, where, false, false);
  495.         }
  496.         /// <summary>
  497.         /// 得到数据表document满足查询条件的分页记录
  498.         /// </summary>
  499.         /// <param name="pageSize">每页显示记录数</param>
  500.         /// <param name="pageIndex">当前显示第几页</param>
  501.         /// <param name="where">查询条件</param>
  502.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  503.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  504.         /// <returns>结果集</returns>
  505.         public IList<document> Select(int pageSize, int pageIndex, string where, bool bParentTable, bool bChildrenTable)
  506.         {
  507.             IList<document> list = new List<document>();
  508.             string sqlCommand = "documentSelectByPagerParams";
  509.             SqlParameter[] param ={
  510. new SqlParameter("@pageSize",SqlDbType.Int),
  511. new SqlParameter("@pageIndex",SqlDbType.Int),
  512. new SqlParameter("@where",SqlDbType.VarChar,8000)
  513. };
  514.             param[0].Value = pageSize;
  515.             param[1].Value = pageIndex;
  516.             param[2].Value = where;
  517.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  518.             {
  519.                 while (dr.Read())
  520.                 {
  521.                     list.Add(this.Select(dr));
  522.                 }
  523.             }
  524.             foreach (document obj in list)
  525.             {
  526.                 this.Select(obj, bParentTable, bChildrenTable);
  527.             }
  528.             return list;
  529.         }
  530.         /// <summary>
  531.         /// 得到数据表document满足查询条件记录
  532.         /// </summary>
  533.         /// <param name="commandType">命令类型</param>
  534.         /// <param name="sqlCommand">SQL命令</param>
  535.         /// <param name="SqlParameter[]">命令参数数组</param>
  536.         /// <returns>结果集</returns>
  537.         public IList<document> Select(CommandType commandType, string sqlCommand, params SqlParameter[] param)
  538.         {
  539.             return this.Select(false, false, commandType, sqlCommand, param);
  540.         }
  541.         /// <summary>
  542.         /// 得到数据表document满足查询条件记录
  543.         /// </summary>
  544.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  545.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  546.         /// <param name="commandType">命令类型</param>
  547.         /// <param name="sqlCommand">SQL命令</param>
  548.         /// <param name="SqlParameter[]">命令参数数组</param>
  549.         /// <returns>结果集</returns>
  550.         public IList<document> Select(bool bParentTable, bool bChildrenTable, CommandType commandType, string sqlCommand, params SqlParameter[] param)
  551.         {
  552.             IList<document> list = new List<document>();
  553.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, commandType, sqlCommand, param))
  554.             {
  555.                 while (dr.Read())
  556.                 {
  557.                     list.Add(this.Select(dr));
  558.                 }
  559.             }
  560.             foreach (document obj in list)
  561.             {
  562.                 this.Select(obj, bParentTable, bChildrenTable);
  563.             }
  564.             return list;
  565.         }
  566.         /// <summary>
  567.         /// 根据主键检测是否存在该条记录
  568.         /// </summary>
  569.         /// <param name="doc_id">doc_id</param>
  570.         /// <returns>存在/不存在</returns>
  571.         public bool Exists(int doc_id)
  572.         {
  573.             SqlParameter[] param ={
  574.                                  new SqlParameter("@doc_id",SqlDbType.Int)
  575.                                  };
  576.             param[0].Value = doc_id;
  577.             string sqlCommand = "documentIsExist";
  578.             int a = Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param));
  579.             if (a > 0)
  580.             {
  581.                 return true;
  582.             }
  583.             else
  584.             {
  585.                 return false;
  586.             }
  587.         }
  588.         #endregion
  589.         #endregion
  590.     }
  591. }