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

OA系统

开发平台:

C#

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