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

OA系统

开发平台:

C#

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