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

OA系统

开发平台:

C#

  1. // =================================================================== 
  2. // 产品(COM.OA.SqlServerDAL)项目
  3. //====================================================================
  4. // wangyp @Copy Right 2006-2008
  5. // 文件:usersDAL.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.users
  24.     /// </summary>
  25.     public partial class usersDAL : IusersDAL
  26.     {
  27.         #region 构造函数
  28.         /// <summary>
  29.         /// 数据层实例化
  30.         /// </summary>
  31.         public usersDAL()
  32.         {
  33.         }
  34.         #endregion
  35.         #region -----------实例化接口函数-----------
  36.         #region 添加
  37.         /// <summary>
  38.         /// 向数据库中插入一条新记录
  39.         /// </summary>
  40.         /// <param name="users">users实体对象</param>
  41.         /// <returns></returns>
  42.         public int Insert(users users)
  43.         {
  44.             string sqlCommand = "usersInsert";
  45.             int res;
  46.             SqlParameter[] param ={
  47. new SqlParameter("@u_id",SqlDbType.Int),
  48. new SqlParameter("@u_username",SqlDbType.VarChar),
  49. new SqlParameter("@u_password",SqlDbType.VarChar),
  50. new SqlParameter("@u_dept_id",SqlDbType.Int),
  51. new SqlParameter("@u_em_id",SqlDbType.Int),
  52. new SqlParameter("@u_state",SqlDbType.Int),
  53. new SqlParameter("@u_logintime",SqlDbType.DateTime),
  54. new SqlParameter("@u_logindegree",SqlDbType.Int),
  55. new SqlParameter("@u_pwdbind",SqlDbType.VarChar),
  56. new SqlParameter("@u_g_id",SqlDbType.Int),
  57. new SqlParameter("@u_landip",SqlDbType.VarChar)
  58. };
  59.             param[0].Direction = ParameterDirection.Output;
  60.             param[1].Value = users.u_username;
  61.             param[2].Value = users.u_password;
  62.             param[3].Value = users.u_dept_id;
  63.             param[4].Value = users.u_em_id;
  64.             param[5].Value = users.u_state;
  65.             param[6].Value = users.u_logintime;
  66.             param[7].Value = users.u_logindegree;
  67.             param[8].Value = users.u_pwdbind;
  68.             param[9].Value = users.u_g_id;
  69.             param[10].Value = users.u_landip;
  70.             res = SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  71.             users.u_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="users">users实体对象</param>
  79.         /// <returns></returns>
  80.         public int Insert(SqlTransaction sp, users users)
  81.         {
  82.             string sqlCommand = "usersInsert";
  83.             int res;
  84.             SqlParameter[] param ={
  85. new SqlParameter("@u_id",SqlDbType.Int),
  86. new SqlParameter("@u_username",SqlDbType.VarChar),
  87. new SqlParameter("@u_password",SqlDbType.VarChar),
  88. new SqlParameter("@u_dept_id",SqlDbType.Int),
  89. new SqlParameter("@u_em_id",SqlDbType.Int),
  90. new SqlParameter("@u_state",SqlDbType.Int),
  91. new SqlParameter("@u_logintime",SqlDbType.DateTime),
  92. new SqlParameter("@u_logindegree",SqlDbType.Int),
  93. new SqlParameter("@u_pwdbind",SqlDbType.VarChar),
  94. new SqlParameter("@u_g_id",SqlDbType.Int),
  95. new SqlParameter("@u_landip",SqlDbType.VarChar)
  96. };
  97.             param[0].Direction = ParameterDirection.Output;
  98.             param[1].Value = users.u_username;
  99.             param[2].Value = users.u_password;
  100.             param[3].Value = users.u_dept_id;
  101.             param[4].Value = users.u_em_id;
  102.             param[5].Value = users.u_state;
  103.             param[6].Value = users.u_logintime;
  104.             param[7].Value = users.u_logindegree;
  105.             param[8].Value = users.u_pwdbind;
  106.             param[9].Value = users.u_g_id;
  107.             param[10].Value = users.u_landip;
  108.             res = SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  109.             users.u_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
  110.             return res;
  111.         }
  112.         #endregion
  113.         #region 更新
  114.         /// <summary>
  115.         /// 向数据表users更新一条记录
  116.         /// </summary>
  117.         /// <param name="users">users实体对象</param>
  118.         /// <returns></returns>
  119.         public int Update(users users)
  120.         {
  121.             string sqlCommand = "usersUpdate";
  122.             SqlParameter[] param ={
  123. new SqlParameter("@u_id",SqlDbType.Int),
  124. new SqlParameter("@u_username",SqlDbType.VarChar),
  125. new SqlParameter("@u_password",SqlDbType.VarChar),
  126. new SqlParameter("@u_dept_id",SqlDbType.Int),
  127. new SqlParameter("@u_em_id",SqlDbType.Int),
  128. new SqlParameter("@u_state",SqlDbType.Int),
  129. new SqlParameter("@u_logintime",SqlDbType.DateTime),
  130. new SqlParameter("@u_logindegree",SqlDbType.Int),
  131. new SqlParameter("@u_pwdbind",SqlDbType.VarChar),
  132. new SqlParameter("@u_g_id",SqlDbType.Int),
  133. new SqlParameter("@u_landip",SqlDbType.VarChar)
  134. };
  135.             param[0].Value = users.u_id;
  136.             param[1].Value = users.u_username;
  137.             param[2].Value = users.u_password;
  138.             param[3].Value = users.u_dept_id;
  139.             param[4].Value = users.u_em_id;
  140.             param[5].Value = users.u_state;
  141.             param[6].Value = users.u_logintime;
  142.             param[7].Value = users.u_logindegree;
  143.             param[8].Value = users.u_pwdbind;
  144.             param[9].Value = users.u_g_id;
  145.             param[10].Value = users.u_landip;
  146.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  147.         }
  148.         /// <summary>
  149.         /// 向数据表users更新一条记录。带事务
  150.         /// </summary>
  151.         /// <param name="sp">事务对象</param>
  152.         /// <param name="users">users实体对象</param>
  153.         /// <returns></returns>
  154.         public int Update(SqlTransaction sp, users users)
  155.         {
  156.             string sqlCommand = "usersUpdate";
  157.             SqlParameter[] param ={
  158. new SqlParameter("@u_id",SqlDbType.Int),
  159. new SqlParameter("@u_username",SqlDbType.VarChar),
  160. new SqlParameter("@u_password",SqlDbType.VarChar),
  161. new SqlParameter("@u_dept_id",SqlDbType.Int),
  162. new SqlParameter("@u_em_id",SqlDbType.Int),
  163. new SqlParameter("@u_state",SqlDbType.Int),
  164. new SqlParameter("@u_logintime",SqlDbType.DateTime),
  165. new SqlParameter("@u_logindegree",SqlDbType.Int),
  166. new SqlParameter("@u_pwdbind",SqlDbType.VarChar),
  167. new SqlParameter("@u_g_id",SqlDbType.Int),
  168. new SqlParameter("@u_landip",SqlDbType.VarChar)
  169. };
  170.             param[0].Value = users.u_id;
  171.             param[1].Value = users.u_username;
  172.             param[2].Value = users.u_password;
  173.             param[3].Value = users.u_dept_id;
  174.             param[4].Value = users.u_em_id;
  175.             param[5].Value = users.u_state;
  176.             param[6].Value = users.u_logintime;
  177.             param[7].Value = users.u_logindegree;
  178.             param[8].Value = users.u_pwdbind;
  179.             param[9].Value = users.u_g_id;
  180.             param[10].Value = users.u_landip;
  181.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  182.         }
  183.         #endregion
  184.         #region 删除
  185.         /// <summary>
  186.         /// 删除数据表users中的一条记录
  187.         /// </summary>
  188.         /// <param name="u_id">u_id</param>
  189.         /// <returns></returns>
  190.         public int Delete(int u_id)
  191.         {
  192.             string sqlCommand = "usersDelete";
  193.             SqlParameter[] param ={
  194. new SqlParameter("@u_id",SqlDbType.Int)
  195. };
  196.             param[0].Value = u_id;
  197.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  198.         }
  199.         /// <summary>
  200.         /// 删除数据表users中的一条记录
  201.         /// </summary>
  202.         /// <param name="users">users实体对象</param>
  203.         /// <returns></returns>
  204.         public int Delete(users users)
  205.         {
  206.             string sqlCommand = "usersDelete";
  207.             SqlParameter[] param ={
  208. new SqlParameter("@u_id",SqlDbType.Int)
  209. };
  210.             param[0].Value = users.u_id;
  211.             return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  212.         }
  213.         /// <summary>
  214.         /// 删除数据表users中的一条记录,带事务
  215.         /// </summary>
  216.         /// <param name="sp">事务对象</param>
  217.         /// <param name="u_id">u_id</param>
  218.         /// <returns></returns>
  219.         public int Delete(SqlTransaction sp, int u_id)
  220.         {
  221.             string sqlCommand = "usersDelete";
  222.             SqlParameter[] param ={
  223. new SqlParameter("@u_id",SqlDbType.Int)
  224. };
  225.             param[0].Value = u_id;
  226.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  227.         }
  228.         /// <summary>
  229.         /// 删除数据表users中的一条记录,带事务
  230.         /// </summary>
  231.         /// <param name="sp">事务对象</param>
  232.         /// <param name="users">users实体对象</param>
  233.         /// <returns></returns>
  234.         public int Delete(SqlTransaction sp, users users)
  235.         {
  236.             string sqlCommand = "usersDelete";
  237.             SqlParameter[] param ={
  238. new SqlParameter("@u_id",SqlDbType.Int)
  239. };
  240.             param[0].Value = users.u_id;
  241.             return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
  242.         }
  243.         #endregion
  244.         #region 实体对象
  245.         /// <summary>
  246.         /// 得到users实体对象
  247.         /// </summary>
  248.         /// <param name="row">row</param>
  249.         /// <returns>users实体对象</returns>
  250.         public users Select(DataRow row)
  251.         {
  252.             users obj = new users();
  253.             if (row != null)
  254.             {
  255.                 obj.u_id = ((row["u_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_id"]);
  256.                 obj.u_username = row["u_username"].ToString();
  257.                 obj.u_password = row["u_password"].ToString();
  258.                 obj.u_dept_id = ((row["u_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_dept_id"]);
  259.                 obj.u_em_id = ((row["u_em_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_em_id"]);
  260.                 obj.u_state = ((row["u_state"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_state"]);
  261.                 obj.u_logintime = ((row["u_logintime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["u_logintime"]);
  262.                 obj.u_logindegree = ((row["u_logindegree"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_logindegree"]);
  263.                 obj.u_pwdbind = row["u_pwdbind"].ToString();
  264.                 obj.u_g_id = ((row["u_g_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["u_g_id"]);
  265.                 obj.u_landip = row["u_landip"].ToString();
  266.             }
  267.             else
  268.             {
  269.                 return null;
  270.             }
  271.             return obj;
  272.         }
  273.         /// <summary>
  274.         /// 得到users实体对象
  275.         /// </summary>
  276.         /// <param name="dr">dr</param>
  277.         /// <returns>users实体对象</returns>
  278.         public users Select(IDataReader dr)
  279.         {
  280.             users obj = new users();
  281.             obj.u_id = ((dr["u_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_id"]);
  282.             obj.u_username = dr["u_username"].ToString();
  283.             obj.u_password = dr["u_password"].ToString();
  284.             obj.u_dept_id = ((dr["u_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_dept_id"]);
  285.             obj.u_em_id = ((dr["u_em_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_em_id"]);
  286.             obj.u_state = ((dr["u_state"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_state"]);
  287.             obj.u_logintime = ((dr["u_logintime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["u_logintime"]);
  288.             obj.u_logindegree = ((dr["u_logindegree"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_logindegree"]);
  289.             obj.u_pwdbind = dr["u_pwdbind"].ToString();
  290.             obj.u_g_id = ((dr["u_g_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["u_g_id"]);
  291.             obj.u_landip = dr["u_landip"].ToString();
  292.             return obj;
  293.         }
  294.         /// <summary>
  295.         /// 根据ID,返回一个users实体对象
  296.         /// </summary>
  297.         /// <param name="u_id">u_id</param>
  298.         /// <returns>users实体对象</returns>
  299.         public users Select(int u_id)
  300.         {
  301.             return this.Select(u_id, false, false);
  302.         }
  303.         /// <summary>
  304.         /// 根据ID,返回一个users实体对象
  305.         /// </summary>
  306.         /// <param name="u_id">u_id</param>
  307.         /// <param name="bParentTable">将users对象设置与父表关联</param>
  308.         /// <param name="bChildrenTable">将users对象设置与子表关联</param>
  309.         /// <returns>users实体对象</returns>
  310.         public users Select(int u_id, bool bParentTable, bool bChildrenTable)
  311.         {
  312.             users obj = null;
  313.             SqlParameter[] param ={
  314. new SqlParameter("@u_id",SqlDbType.Int)
  315. };
  316.             param[0].Value = u_id;
  317.             string sqlCommand = "usersSelect";
  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.         /// 将users实体对象设置与父表和子表关联
  330.         /// </summary>
  331.         /// <param name="obj">users实体对象</param>
  332.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  333.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  334.         public void Select(users obj, bool bParentTable, bool bChildrenTable)
  335.         {
  336.             //关联的主表
  337.             if (bParentTable)
  338.             {
  339.                 obj.employee = employeeBLL.Select(obj.u_em_id);
  340.                 obj.groups = groupsBLL.Select(obj.u_g_id);
  341.                 obj.department = departmentBLL.Select(obj.u_dept_id);
  342.             }
  343.             //关联的子表集合
  344.             if (bChildrenTable)
  345.             {
  346.                 obj.addresslist = addresslistBLL.Select("al_u_id=" + obj.u_id.ToString());
  347.                 foreach (addresslist item in obj.addresslist)
  348.                 {
  349.                     item.users = obj;
  350.                 }
  351.                 obj.attendance = attendanceBLL.Select("att_u_id=" + obj.u_id.ToString());
  352.                 foreach (attendance item in obj.attendance)
  353.                 {
  354.                     item.users = obj;
  355.                 }
  356.                 obj.bbsrevert = bbsrevertBLL.Select("br_u_id=" + obj.u_id.ToString());
  357.                 foreach (bbsrevert item in obj.bbsrevert)
  358.                 {
  359.                     item.users = obj;
  360.                 }
  361.                 obj.document = documentBLL.Select("doc_u_id=" + obj.u_id.ToString());
  362.                 foreach (document item in obj.document)
  363.                 {
  364.                     item.users = obj;
  365.                 }
  366.                 obj.examine = examineBLL.Select("ex_u_id=" + obj.u_id.ToString());
  367.                 foreach (examine item in obj.examine)
  368.                 {
  369.                     item.users = obj;
  370.                 }
  371.                 obj.filerevert = filerevertBLL.Select("fre_u_id=" + obj.u_id.ToString());
  372.                 foreach (filerevert item in obj.filerevert)
  373.                 {
  374.                     item.users = obj;
  375.                 }
  376.                 obj.files = filesBLL.Select("f_takeu_id=" + obj.u_id.ToString());
  377.                 foreach (files item in obj.files)
  378.                 {
  379.                     item.users = obj;
  380.                 }
  381.                 obj.message = messageBLL.Select("m_u_id=" + obj.u_id.ToString());
  382.                 foreach (message item in obj.message)
  383.                 {
  384.                     item.users = obj;
  385.                 }
  386.                 obj.news = newsBLL.Select("n_u_id=" + obj.u_id.ToString());
  387.                 foreach (news item in obj.news)
  388.                 {
  389.                     item.users = obj;
  390.                 }
  391.                 obj.operate = operateBLL.Select("op_u_id=" + obj.u_id.ToString());
  392.                 foreach (operate item in obj.operate)
  393.                 {
  394.                     item.users = obj;
  395.                 }
  396.                 obj.sendword = sendwordBLL.Select("sw_u_id=" + obj.u_id.ToString());
  397.                 foreach (sendword item in obj.sendword)
  398.                 {
  399.                     item.users = obj;
  400.                 }
  401.                 obj.timeorder = timeorderBLL.Select("to_u_id=" + obj.u_id.ToString());
  402.                 foreach (timeorder item in obj.timeorder)
  403.                 {
  404.                     item.users = obj;
  405.                 }
  406.                 obj.worklog = worklogBLL.Select("w_u_id=" + obj.u_id.ToString());
  407.                 foreach (worklog item in obj.worklog)
  408.                 {
  409.                     item.users = obj;
  410.                 }
  411.                 obj.worksumup = worksumupBLL.Select("ws_u_id=" + obj.u_id.ToString());
  412.                 foreach (worksumup item in obj.worksumup)
  413.                 {
  414.                     item.users = obj;
  415.                 }
  416.             }
  417.         }
  418.         #endregion
  419.         #region 父表
  420.         /// <summary>
  421.         /// 设置实体对象(users)的父表对象
  422.         /// </summary>
  423.         /// <param name="users">实体对象</param>
  424.         public void employee(users users)
  425.         {
  426.             users.employee = employeeBLL.Select(users.u_em_id);
  427.         }
  428.         /// <summary>
  429.         /// 设置实体对象(users)的父表对象
  430.         /// </summary>
  431.         /// <param name="users">实体对象</param>
  432.         public void groups(users users)
  433.         {
  434.             users.groups = groupsBLL.Select(users.u_g_id);
  435.         }
  436.         /// <summary>
  437.         /// 设置实体对象(users)的父表对象
  438.         /// </summary>
  439.         /// <param name="users">实体对象</param>
  440.         public void department(users users)
  441.         {
  442.             users.department = departmentBLL.Select(users.u_dept_id);
  443.         }
  444.         #endregion
  445.         #region 子表
  446.         /// <summary>
  447.         /// 设置实体对象(users)的子表对象
  448.         /// </summary>
  449.         /// <param name="users">实体对象</param>
  450.         public void addresslist(users users)
  451.         {
  452.             users.addresslist = addresslistBLL.Select("al_u_id=" + users.u_id.ToString());
  453.         }
  454.         /// <summary>
  455.         /// 设置实体对象(users)的子表对象
  456.         /// </summary>
  457.         /// <param name="users">实体对象</param>
  458.         public void attendance(users users)
  459.         {
  460.             users.attendance = attendanceBLL.Select("att_u_id=" + users.u_id.ToString());
  461.         }
  462.         /// <summary>
  463.         /// 设置实体对象(users)的子表对象
  464.         /// </summary>
  465.         /// <param name="users">实体对象</param>
  466.         public void bbsrevert(users users)
  467.         {
  468.             users.bbsrevert = bbsrevertBLL.Select("br_u_id=" + users.u_id.ToString());
  469.         }
  470.         /// <summary>
  471.         /// 设置实体对象(users)的子表对象
  472.         /// </summary>
  473.         /// <param name="users">实体对象</param>
  474.         public void document(users users)
  475.         {
  476.             users.document = documentBLL.Select("doc_u_id=" + users.u_id.ToString());
  477.         }
  478.         /// <summary>
  479.         /// 设置实体对象(users)的子表对象
  480.         /// </summary>
  481.         /// <param name="users">实体对象</param>
  482.         public void examine(users users)
  483.         {
  484.             users.examine = examineBLL.Select("ex_u_id=" + users.u_id.ToString());
  485.         }
  486.         /// <summary>
  487.         /// 设置实体对象(users)的子表对象
  488.         /// </summary>
  489.         /// <param name="users">实体对象</param>
  490.         public void filerevert(users users)
  491.         {
  492.             users.filerevert = filerevertBLL.Select("fre_u_id=" + users.u_id.ToString());
  493.         }
  494.         /// <summary>
  495.         /// 设置实体对象(users)的子表对象
  496.         /// </summary>
  497.         /// <param name="users">实体对象</param>
  498.         public void files(users users)
  499.         {
  500.             users.files = filesBLL.Select("f_takeu_id=" + users.u_id.ToString());
  501.         }
  502.         /// <summary>
  503.         /// 设置实体对象(users)的子表对象
  504.         /// </summary>
  505.         /// <param name="users">实体对象</param>
  506.         public void message(users users)
  507.         {
  508.             users.message = messageBLL.Select("m_u_id=" + users.u_id.ToString());
  509.         }
  510.         /// <summary>
  511.         /// 设置实体对象(users)的子表对象
  512.         /// </summary>
  513.         /// <param name="users">实体对象</param>
  514.         public void news(users users)
  515.         {
  516.             users.news = newsBLL.Select("n_u_id=" + users.u_id.ToString());
  517.         }
  518.         /// <summary>
  519.         /// 设置实体对象(users)的子表对象
  520.         /// </summary>
  521.         /// <param name="users">实体对象</param>
  522.         public void operate(users users)
  523.         {
  524.             users.operate = operateBLL.Select("op_u_id=" + users.u_id.ToString());
  525.         }
  526.         /// <summary>
  527.         /// 设置实体对象(users)的子表对象
  528.         /// </summary>
  529.         /// <param name="users">实体对象</param>
  530.         public void sendword(users users)
  531.         {
  532.             users.sendword = sendwordBLL.Select("sw_u_id=" + users.u_id.ToString());
  533.         }
  534.         /// <summary>
  535.         /// 设置实体对象(users)的子表对象
  536.         /// </summary>
  537.         /// <param name="users">实体对象</param>
  538.         public void timeorder(users users)
  539.         {
  540.             users.timeorder = timeorderBLL.Select("to_u_id=" + users.u_id.ToString());
  541.         }
  542.         /// <summary>
  543.         /// 设置实体对象(users)的子表对象
  544.         /// </summary>
  545.         /// <param name="users">实体对象</param>
  546.         public void worklog(users users)
  547.         {
  548.             users.worklog = worklogBLL.Select("w_u_id=" + users.u_id.ToString());
  549.         }
  550.         /// <summary>
  551.         /// 设置实体对象(users)的子表对象
  552.         /// </summary>
  553.         /// <param name="users">实体对象</param>
  554.         public void worksumup(users users)
  555.         {
  556.             users.worksumup = worksumupBLL.Select("ws_u_id=" + users.u_id.ToString());
  557.         }
  558.         #endregion
  559.         #region 查询
  560.         /// <summary>
  561.         /// 得到数据表users所有记录
  562.         /// </summary>
  563.         /// <returns>结果集</returns>
  564.         public IList<users> Select()
  565.         {
  566.             return this.Select(false, false);
  567.         }
  568.         /// <summary>
  569.         /// 得到数据表users所有记录
  570.         /// </summary>
  571.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  572.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  573.         /// <returns>结果集</returns>
  574.         public IList<users> Select(bool bParentTable, bool bChildrenTable)
  575.         {
  576.             IList<users> list = new List<users>();
  577.             string sqlCommand = "usersSelectAll";
  578.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand))
  579.             {
  580.                 while (dr.Read())
  581.                 {
  582.                     list.Add(this.Select(dr));
  583.                 }
  584.             }
  585.             foreach (users obj in list)
  586.             {
  587.                 this.Select(obj, bParentTable, bChildrenTable);
  588.             }
  589.             return list;
  590.         }
  591.         /// <summary>
  592.         /// 得到数据表users满足查询条件的记录
  593.         /// </summary>
  594.         /// <param name="where">查询条件</param>
  595.         /// <returns>结果集</returns>
  596.         public IList<users> Select(string where)
  597.         {
  598.             return this.Select(where, false, false);
  599.         }
  600.         /// <summary>
  601.         /// 得到数据表users满足查询条件的记录
  602.         /// </summary>
  603.         /// <param name="where">查询条件</param>
  604.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  605.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  606.         /// <returns>结果集</returns>
  607.         public IList<users> Select(string where, bool bParentTable, bool bChildrenTable)
  608.         {
  609.             IList<users> list = new List<users>();
  610.             SqlParameter[] param ={
  611. new SqlParameter("@where",SqlDbType.VarChar,8000)
  612. };
  613.             param[0].Value = where;
  614.             string sqlCommand = "usersSelectByParams";
  615.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  616.             {
  617.                 while (dr.Read())
  618.                 {
  619.                     list.Add(this.Select(dr));
  620.                 }
  621.             }
  622.             foreach (users obj in list)
  623.             {
  624.                 this.Select(obj, bParentTable, bChildrenTable);
  625.             }
  626.             return list;
  627.         }
  628.         /// <summary>
  629.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  630.         /// </summary>
  631.         /// <param name="foreignFieldName">外键字段名称</param>
  632.         /// <param name="foreignFieldValue">外键字段值</param>
  633.         /// <returns>结果集</returns>
  634.         public IList<users> Select(string foreignFieldName, int foreignFieldValue)
  635.         {
  636.             return this.Select(foreignFieldName, foreignFieldValue, false, false);
  637.         }
  638.         /// <summary>
  639.         /// 得到数据表ArticalInfo满足外键字段查询条件的记录
  640.         /// </summary>
  641.         /// <param name="foreignFieldName">外键字段名称</param>
  642.         /// <param name="foreignFieldValue">外键字段值</param>
  643.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  644.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  645.         /// <returns>结果集</returns>
  646.         public IList<users> Select(string foreignFieldName, int foreignFieldValue, bool bParentTable, bool bChildrenTable)
  647.         {
  648.             return this.Select(string.Format("{0}='{1}'", foreignFieldName, foreignFieldValue), bParentTable, bChildrenTable);
  649.         }
  650.         /// <summary>
  651.         /// 得到数据表users满足查询条件的记录数
  652.         /// </summary>
  653.         /// <param name="where">查询条件</param>
  654.         /// <param name="recordCount">记录数</param>
  655.         public void Select(string where, out int recordCount)
  656.         {
  657.             string sqlCommand = "usersCountByWhere";
  658.             SqlParameter[] param ={
  659. new SqlParameter("@where",SqlDbType.VarChar,8000),
  660. new SqlParameter("@recordCount",SqlDbType.Int)
  661. };
  662.             param[0].Value = where;
  663.             param[1].Direction = ParameterDirection.Output;
  664.             SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
  665.             recordCount = Convert.ToInt32(param[1].Value);
  666.         }
  667.         /// <summary>
  668.         /// 得到数据表users满足查询条件的分页记录
  669.         /// </summary>
  670.         /// <param name="pageSize">每页显示记录数</param>
  671.         /// <param name="pageIndex">当前显示第几页</param>
  672.         /// <param name="where">查询条件</param>
  673.         /// <returns>结果集</returns>
  674.         public IList<users> Select(int pageSize, int pageIndex, string where)
  675.         {
  676.             return this.Select(pageSize, pageIndex, where, false, false);
  677.         }
  678.         /// <summary>
  679.         /// 得到数据表users满足查询条件的分页记录
  680.         /// </summary>
  681.         /// <param name="pageSize">每页显示记录数</param>
  682.         /// <param name="pageIndex">当前显示第几页</param>
  683.         /// <param name="where">查询条件</param>
  684.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  685.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  686.         /// <returns>结果集</returns>
  687.         public IList<users> Select(int pageSize, int pageIndex, string where, bool bParentTable, bool bChildrenTable)
  688.         {
  689.             IList<users> list = new List<users>();
  690.             string sqlCommand = "usersSelectByPagerParams";
  691.             SqlParameter[] param ={
  692. new SqlParameter("@pageSize",SqlDbType.Int),
  693. new SqlParameter("@pageIndex",SqlDbType.Int),
  694. new SqlParameter("@where",SqlDbType.VarChar,8000)
  695. };
  696.             param[0].Value = pageSize;
  697.             param[1].Value = pageIndex;
  698.             param[2].Value = where;
  699.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
  700.             {
  701.                 while (dr.Read())
  702.                 {
  703.                     list.Add(this.Select(dr));
  704.                 }
  705.             }
  706.             foreach (users obj in list)
  707.             {
  708.                 this.Select(obj, bParentTable, bChildrenTable);
  709.             }
  710.             return list;
  711.         }
  712.         /// <summary>
  713.         /// 得到数据表users满足查询条件记录
  714.         /// </summary>
  715.         /// <param name="commandType">命令类型</param>
  716.         /// <param name="sqlCommand">SQL命令</param>
  717.         /// <param name="SqlParameter[]">命令参数数组</param>
  718.         /// <returns>结果集</returns>
  719.         public IList<users> Select(CommandType commandType, string sqlCommand, params SqlParameter[] param)
  720.         {
  721.             return this.Select(false, false, commandType, sqlCommand, param);
  722.         }
  723.         /// <summary>
  724.         /// 得到数据表users满足查询条件记录
  725.         /// </summary>
  726.         /// <param name="bParentTable">是/否设置与父表对象关联</param>
  727.         /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
  728.         /// <param name="commandType">命令类型</param>
  729.         /// <param name="sqlCommand">SQL命令</param>
  730.         /// <param name="SqlParameter[]">命令参数数组</param>
  731.         /// <returns>结果集</returns>
  732.         public IList<users> Select(bool bParentTable, bool bChildrenTable, CommandType commandType, string sqlCommand, params SqlParameter[] param)
  733.         {
  734.             IList<users> list = new List<users>();
  735.             using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, commandType, sqlCommand, param))
  736.             {
  737.                 while (dr.Read())
  738.                 {
  739.                     list.Add(this.Select(dr));
  740.                 }
  741.             }
  742.             foreach (users obj in list)
  743.             {
  744.                 this.Select(obj, bParentTable, bChildrenTable);
  745.             }
  746.             return list;
  747.         }
  748.         /// <summary>
  749.         /// 根据主键检测是否存在该条记录
  750.         /// </summary>
  751.         /// <param name="u_id">u_id</param>
  752.         /// <returns>存在/不存在</returns>
  753.         public bool Exists(int u_id)
  754.         {
  755.             SqlParameter[] param ={
  756.                                  new SqlParameter("@u_id",SqlDbType.Int)
  757.                                  };
  758.             param[0].Value = u_id;
  759.             string sqlCommand = "usersIsExist";
  760.             int a = Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param));
  761.             if (a > 0)
  762.             {
  763.                 return true;
  764.             }
  765.             else
  766.             {
  767.                 return false;
  768.             }
  769.         }
  770.         #endregion
  771.         #endregion
  772.     }
  773. }
  774. //51aspx