employeeDAL.cs
资源名称:OASystem.rar [点击查看]
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:48k
源码类别:
OA系统
开发平台:
C#
- // ===================================================================
- // 产品(COM.OA.SqlServerDAL)项目
- //====================================================================
- // wangyp @Copy Right 2006-2008
- // 文件:employeeDAL.cs
- // 项目名称:工程项目管理
- // 创建时间:2008-9-23
- // 负责人:wangyp
- // 先创建SqlHelper.cs文件,引用System.Configuration程序集和实体(COM.OA.Entity)、产品规则(COM.OA.IDAL)项目、引用业务逻辑(COM.OA.BLL)项目
- // ===================================================================
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Text;
- using COM.OA.Entity;
- using COM.OA.IDAL;
- using COM.OA.BLL;
- namespace COM.OA.SqlServerDAL
- {
- /// <summary>
- /// 数据访问层dbo.employee
- /// </summary>
- public partial class employeeDAL : IemployeeDAL
- {
- #region 构造函数
- /// <summary>
- /// 数据层实例化
- /// </summary>
- public employeeDAL()
- {
- }
- #endregion
- #region -----------实例化接口函数-----------
- #region 添加
- /// <summary>
- /// 向数据库中插入一条新记录
- /// </summary>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Insert(employee employee)
- {
- string sqlCommand = "employeeInsert";
- int res;
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int),
- new SqlParameter("@em_number",SqlDbType.VarChar),
- new SqlParameter("@em_name",SqlDbType.VarChar),
- new SqlParameter("@em_evername",SqlDbType.VarChar),
- new SqlParameter("@em_gender",SqlDbType.Int),
- new SqlParameter("@em_birth",SqlDbType.DateTime),
- new SqlParameter("@em_marriage",SqlDbType.VarChar),
- new SqlParameter("@em_n_id",SqlDbType.Int),
- new SqlParameter("@em_na_id",SqlDbType.Int),
- new SqlParameter("@em_p_id",SqlDbType.Int),
- new SqlParameter("@em_stature",SqlDbType.VarChar),
- new SqlParameter("@em_avoirdupois",SqlDbType.VarChar),
- new SqlParameter("@em_v_id",SqlDbType.Int),
- new SqlParameter("@em_statuscard",SqlDbType.VarChar),
- new SqlParameter("@em_health",SqlDbType.VarChar),
- new SqlParameter("@em_bloodtype",SqlDbType.VarChar),
- new SqlParameter("@em_phone",SqlDbType.VarChar),
- new SqlParameter("@em_mobile",SqlDbType.VarChar),
- new SqlParameter("@em_email",SqlDbType.VarChar),
- new SqlParameter("@em_finishschool",SqlDbType.VarChar),
- new SqlParameter("@em_speciality",SqlDbType.VarChar),
- new SqlParameter("@em_l_id",SqlDbType.Int),
- new SqlParameter("@em_graduatetime",SqlDbType.DateTime),
- new SqlParameter("@em_degree",SqlDbType.VarChar),
- new SqlParameter("@em_language",SqlDbType.VarChar),
- new SqlParameter("@em_languagelevel",SqlDbType.VarChar),
- new SqlParameter("@em_languageletter",SqlDbType.VarChar),
- new SqlParameter("@em_computerlevel",SqlDbType.VarChar),
- new SqlParameter("@em_computerletter",SqlDbType.VarChar),
- new SqlParameter("@em_computergood",SqlDbType.VarChar),
- new SqlParameter("@em_mandarinlevel",SqlDbType.VarChar),
- new SqlParameter("@em_familyaddress",SqlDbType.VarChar),
- new SqlParameter("@em_postalcode",SqlDbType.VarChar),
- new SqlParameter("@em_address",SqlDbType.VarChar),
- new SqlParameter("@em_familyphone",SqlDbType.VarChar),
- new SqlParameter("@em_addresspostalcode",SqlDbType.VarChar),
- new SqlParameter("@em_familycircs",SqlDbType.VarChar),
- new SqlParameter("@em_recordlocus",SqlDbType.VarChar),
- new SqlParameter("@em_jobname",SqlDbType.VarChar),
- new SqlParameter("@em_whenjoinwork",SqlDbType.VarChar),
- new SqlParameter("@em_whenthiswork",SqlDbType.VarChar),
- new SqlParameter("@em_addlength",SqlDbType.VarChar),
- new SqlParameter("@em_thisunitlength",SqlDbType.VarChar),
- new SqlParameter("@em_dept_id",SqlDbType.Int),
- new SqlParameter("@em_duty",SqlDbType.VarChar),
- new SqlParameter("@em_remark",SqlDbType.VarChar),
- new SqlParameter("@em_bookerid",SqlDbType.Int),
- new SqlParameter("@em_registertime",SqlDbType.DateTime),
- new SqlParameter("@em_photo",SqlDbType.VarChar)
- };
- param[0].Direction = ParameterDirection.Output;
- param[1].Value = employee.em_number;
- param[2].Value = employee.em_name;
- param[3].Value = employee.em_evername;
- param[4].Value = employee.em_gender;
- param[5].Value = employee.em_birth;
- param[6].Value = employee.em_marriage;
- param[7].Value = employee.em_n_id;
- param[8].Value = employee.em_na_id;
- param[9].Value = employee.em_p_id;
- param[10].Value = employee.em_stature;
- param[11].Value = employee.em_avoirdupois;
- param[12].Value = employee.em_v_id;
- param[13].Value = employee.em_statuscard;
- param[14].Value = employee.em_health;
- param[15].Value = employee.em_bloodtype;
- param[16].Value = employee.em_phone;
- param[17].Value = employee.em_mobile;
- param[18].Value = employee.em_email;
- param[19].Value = employee.em_finishschool;
- param[20].Value = employee.em_speciality;
- param[21].Value = employee.em_l_id;
- param[22].Value = employee.em_graduatetime;
- param[23].Value = employee.em_degree;
- param[24].Value = employee.em_language;
- param[25].Value = employee.em_languagelevel;
- param[26].Value = employee.em_languageletter;
- param[27].Value = employee.em_computerlevel;
- param[28].Value = employee.em_computerletter;
- param[29].Value = employee.em_computergood;
- param[30].Value = employee.em_mandarinlevel;
- param[31].Value = employee.em_familyaddress;
- param[32].Value = employee.em_postalcode;
- param[33].Value = employee.em_address;
- param[34].Value = employee.em_familyphone;
- param[35].Value = employee.em_addresspostalcode;
- param[36].Value = employee.em_familycircs;
- param[37].Value = employee.em_recordlocus;
- param[38].Value = employee.em_jobname;
- param[39].Value = employee.em_whenjoinwork;
- param[40].Value = employee.em_whenthiswork;
- param[41].Value = employee.em_addlength;
- param[42].Value = employee.em_thisunitlength;
- param[43].Value = employee.em_dept_id;
- param[44].Value = employee.em_duty;
- param[45].Value = employee.em_remark;
- param[46].Value = employee.em_bookerid;
- param[47].Value = employee.em_registertime;
- param[48].Value = employee.em_photo;
- res = SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- employee.em_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
- return res;
- }
- /// <summary>
- /// 向数据库中插入一条新记录。带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Insert(SqlTransaction sp, employee employee)
- {
- string sqlCommand = "employeeInsert";
- int res;
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int),
- new SqlParameter("@em_number",SqlDbType.VarChar),
- new SqlParameter("@em_name",SqlDbType.VarChar),
- new SqlParameter("@em_evername",SqlDbType.VarChar),
- new SqlParameter("@em_gender",SqlDbType.Int),
- new SqlParameter("@em_birth",SqlDbType.DateTime),
- new SqlParameter("@em_marriage",SqlDbType.VarChar),
- new SqlParameter("@em_n_id",SqlDbType.Int),
- new SqlParameter("@em_na_id",SqlDbType.Int),
- new SqlParameter("@em_p_id",SqlDbType.Int),
- new SqlParameter("@em_stature",SqlDbType.VarChar),
- new SqlParameter("@em_avoirdupois",SqlDbType.VarChar),
- new SqlParameter("@em_v_id",SqlDbType.Int),
- new SqlParameter("@em_statuscard",SqlDbType.VarChar),
- new SqlParameter("@em_health",SqlDbType.VarChar),
- new SqlParameter("@em_bloodtype",SqlDbType.VarChar),
- new SqlParameter("@em_phone",SqlDbType.VarChar),
- new SqlParameter("@em_mobile",SqlDbType.VarChar),
- new SqlParameter("@em_email",SqlDbType.VarChar),
- new SqlParameter("@em_finishschool",SqlDbType.VarChar),
- new SqlParameter("@em_speciality",SqlDbType.VarChar),
- new SqlParameter("@em_l_id",SqlDbType.Int),
- new SqlParameter("@em_graduatetime",SqlDbType.DateTime),
- new SqlParameter("@em_degree",SqlDbType.VarChar),
- new SqlParameter("@em_language",SqlDbType.VarChar),
- new SqlParameter("@em_languagelevel",SqlDbType.VarChar),
- new SqlParameter("@em_languageletter",SqlDbType.VarChar),
- new SqlParameter("@em_computerlevel",SqlDbType.VarChar),
- new SqlParameter("@em_computerletter",SqlDbType.VarChar),
- new SqlParameter("@em_computergood",SqlDbType.VarChar),
- new SqlParameter("@em_mandarinlevel",SqlDbType.VarChar),
- new SqlParameter("@em_familyaddress",SqlDbType.VarChar),
- new SqlParameter("@em_postalcode",SqlDbType.VarChar),
- new SqlParameter("@em_address",SqlDbType.VarChar),
- new SqlParameter("@em_familyphone",SqlDbType.VarChar),
- new SqlParameter("@em_addresspostalcode",SqlDbType.VarChar),
- new SqlParameter("@em_familycircs",SqlDbType.VarChar),
- new SqlParameter("@em_recordlocus",SqlDbType.VarChar),
- new SqlParameter("@em_jobname",SqlDbType.VarChar),
- new SqlParameter("@em_whenjoinwork",SqlDbType.VarChar),
- new SqlParameter("@em_whenthiswork",SqlDbType.VarChar),
- new SqlParameter("@em_addlength",SqlDbType.VarChar),
- new SqlParameter("@em_thisunitlength",SqlDbType.VarChar),
- new SqlParameter("@em_dept_id",SqlDbType.Int),
- new SqlParameter("@em_duty",SqlDbType.VarChar),
- new SqlParameter("@em_remark",SqlDbType.VarChar),
- new SqlParameter("@em_bookerid",SqlDbType.Int),
- new SqlParameter("@em_registertime",SqlDbType.DateTime),
- new SqlParameter("@em_photo",SqlDbType.VarChar)
- };
- param[0].Direction = ParameterDirection.Output;
- param[1].Value = employee.em_number;
- param[2].Value = employee.em_name;
- param[3].Value = employee.em_evername;
- param[4].Value = employee.em_gender;
- param[5].Value = employee.em_birth;
- param[6].Value = employee.em_marriage;
- param[7].Value = employee.em_n_id;
- param[8].Value = employee.em_na_id;
- param[9].Value = employee.em_p_id;
- param[10].Value = employee.em_stature;
- param[11].Value = employee.em_avoirdupois;
- param[12].Value = employee.em_v_id;
- param[13].Value = employee.em_statuscard;
- param[14].Value = employee.em_health;
- param[15].Value = employee.em_bloodtype;
- param[16].Value = employee.em_phone;
- param[17].Value = employee.em_mobile;
- param[18].Value = employee.em_email;
- param[19].Value = employee.em_finishschool;
- param[20].Value = employee.em_speciality;
- param[21].Value = employee.em_l_id;
- param[22].Value = employee.em_graduatetime;
- param[23].Value = employee.em_degree;
- param[24].Value = employee.em_language;
- param[25].Value = employee.em_languagelevel;
- param[26].Value = employee.em_languageletter;
- param[27].Value = employee.em_computerlevel;
- param[28].Value = employee.em_computerletter;
- param[29].Value = employee.em_computergood;
- param[30].Value = employee.em_mandarinlevel;
- param[31].Value = employee.em_familyaddress;
- param[32].Value = employee.em_postalcode;
- param[33].Value = employee.em_address;
- param[34].Value = employee.em_familyphone;
- param[35].Value = employee.em_addresspostalcode;
- param[36].Value = employee.em_familycircs;
- param[37].Value = employee.em_recordlocus;
- param[38].Value = employee.em_jobname;
- param[39].Value = employee.em_whenjoinwork;
- param[40].Value = employee.em_whenthiswork;
- param[41].Value = employee.em_addlength;
- param[42].Value = employee.em_thisunitlength;
- param[43].Value = employee.em_dept_id;
- param[44].Value = employee.em_duty;
- param[45].Value = employee.em_remark;
- param[46].Value = employee.em_bookerid;
- param[47].Value = employee.em_registertime;
- param[48].Value = employee.em_photo;
- res = SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- employee.em_id = ((param[0].Value) == DBNull.Value) ? 0 : Convert.ToInt32(param[0].Value);
- return res;
- }
- #endregion
- #region 更新
- /// <summary>
- /// 向数据表employee更新一条记录
- /// </summary>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Update(employee employee)
- {
- string sqlCommand = "employeeUpdate";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int),
- new SqlParameter("@em_number",SqlDbType.VarChar),
- new SqlParameter("@em_name",SqlDbType.VarChar),
- new SqlParameter("@em_evername",SqlDbType.VarChar),
- new SqlParameter("@em_gender",SqlDbType.Int),
- new SqlParameter("@em_birth",SqlDbType.DateTime),
- new SqlParameter("@em_marriage",SqlDbType.VarChar),
- new SqlParameter("@em_n_id",SqlDbType.Int),
- new SqlParameter("@em_na_id",SqlDbType.Int),
- new SqlParameter("@em_p_id",SqlDbType.Int),
- new SqlParameter("@em_stature",SqlDbType.VarChar),
- new SqlParameter("@em_avoirdupois",SqlDbType.VarChar),
- new SqlParameter("@em_v_id",SqlDbType.Int),
- new SqlParameter("@em_statuscard",SqlDbType.VarChar),
- new SqlParameter("@em_health",SqlDbType.VarChar),
- new SqlParameter("@em_bloodtype",SqlDbType.VarChar),
- new SqlParameter("@em_phone",SqlDbType.VarChar),
- new SqlParameter("@em_mobile",SqlDbType.VarChar),
- new SqlParameter("@em_email",SqlDbType.VarChar),
- new SqlParameter("@em_finishschool",SqlDbType.VarChar),
- new SqlParameter("@em_speciality",SqlDbType.VarChar),
- new SqlParameter("@em_l_id",SqlDbType.Int),
- new SqlParameter("@em_graduatetime",SqlDbType.DateTime),
- new SqlParameter("@em_degree",SqlDbType.VarChar),
- new SqlParameter("@em_language",SqlDbType.VarChar),
- new SqlParameter("@em_languagelevel",SqlDbType.VarChar),
- new SqlParameter("@em_languageletter",SqlDbType.VarChar),
- new SqlParameter("@em_computerlevel",SqlDbType.VarChar),
- new SqlParameter("@em_computerletter",SqlDbType.VarChar),
- new SqlParameter("@em_computergood",SqlDbType.VarChar),
- new SqlParameter("@em_mandarinlevel",SqlDbType.VarChar),
- new SqlParameter("@em_familyaddress",SqlDbType.VarChar),
- new SqlParameter("@em_postalcode",SqlDbType.VarChar),
- new SqlParameter("@em_address",SqlDbType.VarChar),
- new SqlParameter("@em_familyphone",SqlDbType.VarChar),
- new SqlParameter("@em_addresspostalcode",SqlDbType.VarChar),
- new SqlParameter("@em_familycircs",SqlDbType.VarChar),
- new SqlParameter("@em_recordlocus",SqlDbType.VarChar),
- new SqlParameter("@em_jobname",SqlDbType.VarChar),
- new SqlParameter("@em_whenjoinwork",SqlDbType.VarChar),
- new SqlParameter("@em_whenthiswork",SqlDbType.VarChar),
- new SqlParameter("@em_addlength",SqlDbType.VarChar),
- new SqlParameter("@em_thisunitlength",SqlDbType.VarChar),
- new SqlParameter("@em_dept_id",SqlDbType.Int),
- new SqlParameter("@em_duty",SqlDbType.VarChar),
- new SqlParameter("@em_remark",SqlDbType.VarChar),
- new SqlParameter("@em_bookerid",SqlDbType.Int),
- new SqlParameter("@em_registertime",SqlDbType.DateTime),
- new SqlParameter("@em_photo",SqlDbType.VarChar)
- };
- param[0].Value = employee.em_id;
- param[1].Value = employee.em_number;
- param[2].Value = employee.em_name;
- param[3].Value = employee.em_evername;
- param[4].Value = employee.em_gender;
- param[5].Value = employee.em_birth;
- param[6].Value = employee.em_marriage;
- param[7].Value = employee.em_n_id;
- param[8].Value = employee.em_na_id;
- param[9].Value = employee.em_p_id;
- param[10].Value = employee.em_stature;
- param[11].Value = employee.em_avoirdupois;
- param[12].Value = employee.em_v_id;
- param[13].Value = employee.em_statuscard;
- param[14].Value = employee.em_health;
- param[15].Value = employee.em_bloodtype;
- param[16].Value = employee.em_phone;
- param[17].Value = employee.em_mobile;
- param[18].Value = employee.em_email;
- param[19].Value = employee.em_finishschool;
- param[20].Value = employee.em_speciality;
- param[21].Value = employee.em_l_id;
- param[22].Value = employee.em_graduatetime;
- param[23].Value = employee.em_degree;
- param[24].Value = employee.em_language;
- param[25].Value = employee.em_languagelevel;
- param[26].Value = employee.em_languageletter;
- param[27].Value = employee.em_computerlevel;
- param[28].Value = employee.em_computerletter;
- param[29].Value = employee.em_computergood;
- param[30].Value = employee.em_mandarinlevel;
- param[31].Value = employee.em_familyaddress;
- param[32].Value = employee.em_postalcode;
- param[33].Value = employee.em_address;
- param[34].Value = employee.em_familyphone;
- param[35].Value = employee.em_addresspostalcode;
- param[36].Value = employee.em_familycircs;
- param[37].Value = employee.em_recordlocus;
- param[38].Value = employee.em_jobname;
- param[39].Value = employee.em_whenjoinwork;
- param[40].Value = employee.em_whenthiswork;
- param[41].Value = employee.em_addlength;
- param[42].Value = employee.em_thisunitlength;
- param[43].Value = employee.em_dept_id;
- param[44].Value = employee.em_duty;
- param[45].Value = employee.em_remark;
- param[46].Value = employee.em_bookerid;
- param[47].Value = employee.em_registertime;
- param[48].Value = employee.em_photo;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 向数据表employee更新一条记录。带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Update(SqlTransaction sp, employee employee)
- {
- string sqlCommand = "employeeUpdate";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int),
- new SqlParameter("@em_number",SqlDbType.VarChar),
- new SqlParameter("@em_name",SqlDbType.VarChar),
- new SqlParameter("@em_evername",SqlDbType.VarChar),
- new SqlParameter("@em_gender",SqlDbType.Int),
- new SqlParameter("@em_birth",SqlDbType.DateTime),
- new SqlParameter("@em_marriage",SqlDbType.VarChar),
- new SqlParameter("@em_n_id",SqlDbType.Int),
- new SqlParameter("@em_na_id",SqlDbType.Int),
- new SqlParameter("@em_p_id",SqlDbType.Int),
- new SqlParameter("@em_stature",SqlDbType.VarChar),
- new SqlParameter("@em_avoirdupois",SqlDbType.VarChar),
- new SqlParameter("@em_v_id",SqlDbType.Int),
- new SqlParameter("@em_statuscard",SqlDbType.VarChar),
- new SqlParameter("@em_health",SqlDbType.VarChar),
- new SqlParameter("@em_bloodtype",SqlDbType.VarChar),
- new SqlParameter("@em_phone",SqlDbType.VarChar),
- new SqlParameter("@em_mobile",SqlDbType.VarChar),
- new SqlParameter("@em_email",SqlDbType.VarChar),
- new SqlParameter("@em_finishschool",SqlDbType.VarChar),
- new SqlParameter("@em_speciality",SqlDbType.VarChar),
- new SqlParameter("@em_l_id",SqlDbType.Int),
- new SqlParameter("@em_graduatetime",SqlDbType.DateTime),
- new SqlParameter("@em_degree",SqlDbType.VarChar),
- new SqlParameter("@em_language",SqlDbType.VarChar),
- new SqlParameter("@em_languagelevel",SqlDbType.VarChar),
- new SqlParameter("@em_languageletter",SqlDbType.VarChar),
- new SqlParameter("@em_computerlevel",SqlDbType.VarChar),
- new SqlParameter("@em_computerletter",SqlDbType.VarChar),
- new SqlParameter("@em_computergood",SqlDbType.VarChar),
- new SqlParameter("@em_mandarinlevel",SqlDbType.VarChar),
- new SqlParameter("@em_familyaddress",SqlDbType.VarChar),
- new SqlParameter("@em_postalcode",SqlDbType.VarChar),
- new SqlParameter("@em_address",SqlDbType.VarChar),
- new SqlParameter("@em_familyphone",SqlDbType.VarChar),
- new SqlParameter("@em_addresspostalcode",SqlDbType.VarChar),
- new SqlParameter("@em_familycircs",SqlDbType.VarChar),
- new SqlParameter("@em_recordlocus",SqlDbType.VarChar),
- new SqlParameter("@em_jobname",SqlDbType.VarChar),
- new SqlParameter("@em_whenjoinwork",SqlDbType.VarChar),
- new SqlParameter("@em_whenthiswork",SqlDbType.VarChar),
- new SqlParameter("@em_addlength",SqlDbType.VarChar),
- new SqlParameter("@em_thisunitlength",SqlDbType.VarChar),
- new SqlParameter("@em_dept_id",SqlDbType.Int),
- new SqlParameter("@em_duty",SqlDbType.VarChar),
- new SqlParameter("@em_remark",SqlDbType.VarChar),
- new SqlParameter("@em_bookerid",SqlDbType.Int),
- new SqlParameter("@em_registertime",SqlDbType.DateTime),
- new SqlParameter("@em_photo",SqlDbType.VarChar)
- };
- param[0].Value = employee.em_id;
- param[1].Value = employee.em_number;
- param[2].Value = employee.em_name;
- param[3].Value = employee.em_evername;
- param[4].Value = employee.em_gender;
- param[5].Value = employee.em_birth;
- param[6].Value = employee.em_marriage;
- param[7].Value = employee.em_n_id;
- param[8].Value = employee.em_na_id;
- param[9].Value = employee.em_p_id;
- param[10].Value = employee.em_stature;
- param[11].Value = employee.em_avoirdupois;
- param[12].Value = employee.em_v_id;
- param[13].Value = employee.em_statuscard;
- param[14].Value = employee.em_health;
- param[15].Value = employee.em_bloodtype;
- param[16].Value = employee.em_phone;
- param[17].Value = employee.em_mobile;
- param[18].Value = employee.em_email;
- param[19].Value = employee.em_finishschool;
- param[20].Value = employee.em_speciality;
- param[21].Value = employee.em_l_id;
- param[22].Value = employee.em_graduatetime;
- param[23].Value = employee.em_degree;
- param[24].Value = employee.em_language;
- param[25].Value = employee.em_languagelevel;
- param[26].Value = employee.em_languageletter;
- param[27].Value = employee.em_computerlevel;
- param[28].Value = employee.em_computerletter;
- param[29].Value = employee.em_computergood;
- param[30].Value = employee.em_mandarinlevel;
- param[31].Value = employee.em_familyaddress;
- param[32].Value = employee.em_postalcode;
- param[33].Value = employee.em_address;
- param[34].Value = employee.em_familyphone;
- param[35].Value = employee.em_addresspostalcode;
- param[36].Value = employee.em_familycircs;
- param[37].Value = employee.em_recordlocus;
- param[38].Value = employee.em_jobname;
- param[39].Value = employee.em_whenjoinwork;
- param[40].Value = employee.em_whenthiswork;
- param[41].Value = employee.em_addlength;
- param[42].Value = employee.em_thisunitlength;
- param[43].Value = employee.em_dept_id;
- param[44].Value = employee.em_duty;
- param[45].Value = employee.em_remark;
- param[46].Value = employee.em_bookerid;
- param[47].Value = employee.em_registertime;
- param[48].Value = employee.em_photo;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- #endregion
- #region 删除
- /// <summary>
- /// 删除数据表employee中的一条记录
- /// </summary>
- /// <param name="em_id">em_id</param>
- /// <returns></returns>
- public int Delete(int em_id)
- {
- string sqlCommand = "employeeDelete";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = em_id;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表employee中的一条记录
- /// </summary>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Delete(employee employee)
- {
- string sqlCommand = "employeeDelete";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = employee.em_id;
- return SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表employee中的一条记录,带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="em_id">em_id</param>
- /// <returns></returns>
- public int Delete(SqlTransaction sp, int em_id)
- {
- string sqlCommand = "employeeDelete";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = em_id;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- /// <summary>
- /// 删除数据表employee中的一条记录,带事务
- /// </summary>
- /// <param name="sp">事务对象</param>
- /// <param name="employee">employee实体对象</param>
- /// <returns></returns>
- public int Delete(SqlTransaction sp, employee employee)
- {
- string sqlCommand = "employeeDelete";
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = employee.em_id;
- return SqlHelper.ExecuteNonQuery(sp, CommandType.StoredProcedure, sqlCommand, param);
- }
- #endregion
- #region 实体对象
- /// <summary>
- /// 得到employee实体对象
- /// </summary>
- /// <param name="row">row</param>
- /// <returns>employee实体对象</returns>
- public employee Select(DataRow row)
- {
- employee obj = new employee();
- if (row != null)
- {
- obj.em_id = ((row["em_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_id"]);
- obj.em_number = row["em_number"].ToString();
- obj.em_name = row["em_name"].ToString();
- obj.em_evername = row["em_evername"].ToString();
- obj.em_gender = ((row["em_gender"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_gender"]);
- obj.em_birth = ((row["em_birth"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["em_birth"]);
- obj.em_marriage = row["em_marriage"].ToString();
- obj.em_n_id = ((row["em_n_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_n_id"]);
- obj.em_na_id = ((row["em_na_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_na_id"]);
- obj.em_p_id = ((row["em_p_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_p_id"]);
- obj.em_stature = row["em_stature"].ToString();
- obj.em_avoirdupois = row["em_avoirdupois"].ToString();
- obj.em_v_id = ((row["em_v_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_v_id"]);
- obj.em_statuscard = row["em_statuscard"].ToString();
- obj.em_health = row["em_health"].ToString();
- obj.em_bloodtype = row["em_bloodtype"].ToString();
- obj.em_phone = row["em_phone"].ToString();
- obj.em_mobile = row["em_mobile"].ToString();
- obj.em_email = row["em_email"].ToString();
- obj.em_finishschool = row["em_finishschool"].ToString();
- obj.em_speciality = row["em_speciality"].ToString();
- obj.em_l_id = ((row["em_l_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_l_id"]);
- obj.em_graduatetime = ((row["em_graduatetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["em_graduatetime"]);
- obj.em_degree = row["em_degree"].ToString();
- obj.em_language = row["em_language"].ToString();
- obj.em_languagelevel = row["em_languagelevel"].ToString();
- obj.em_languageletter = row["em_languageletter"].ToString();
- obj.em_computerlevel = row["em_computerlevel"].ToString();
- obj.em_computerletter = row["em_computerletter"].ToString();
- obj.em_computergood = row["em_computergood"].ToString();
- obj.em_mandarinlevel = row["em_mandarinlevel"].ToString();
- obj.em_familyaddress = row["em_familyaddress"].ToString();
- obj.em_postalcode = row["em_postalcode"].ToString();
- obj.em_address = row["em_address"].ToString();
- obj.em_familyphone = row["em_familyphone"].ToString();
- obj.em_addresspostalcode = row["em_addresspostalcode"].ToString();
- obj.em_familycircs = row["em_familycircs"].ToString();
- obj.em_recordlocus = row["em_recordlocus"].ToString();
- obj.em_jobname = row["em_jobname"].ToString();
- obj.em_whenjoinwork = row["em_whenjoinwork"].ToString();
- obj.em_whenthiswork = row["em_whenthiswork"].ToString();
- obj.em_addlength = row["em_addlength"].ToString();
- obj.em_thisunitlength = row["em_thisunitlength"].ToString();
- obj.em_dept_id = ((row["em_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_dept_id"]);
- obj.em_duty = row["em_duty"].ToString();
- obj.em_remark = row["em_remark"].ToString();
- obj.em_bookerid = ((row["em_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["em_bookerid"]);
- obj.em_registertime = ((row["em_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(row["em_registertime"]);
- obj.em_photo = row["em_photo"].ToString();
- }
- else
- {
- return null;
- }
- return obj;
- }
- /// <summary>
- /// 得到employee实体对象
- /// </summary>
- /// <param name="dr">dr</param>
- /// <returns>employee实体对象</returns>
- public employee Select(IDataReader dr)
- {
- employee obj = new employee();
- obj.em_id = ((dr["em_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_id"]);
- obj.em_number = dr["em_number"].ToString();
- obj.em_name = dr["em_name"].ToString();
- obj.em_evername = dr["em_evername"].ToString();
- obj.em_gender = ((dr["em_gender"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_gender"]);
- obj.em_birth = ((dr["em_birth"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["em_birth"]);
- obj.em_marriage = dr["em_marriage"].ToString();
- obj.em_n_id = ((dr["em_n_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_n_id"]);
- obj.em_na_id = ((dr["em_na_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_na_id"]);
- obj.em_p_id = ((dr["em_p_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_p_id"]);
- obj.em_stature = dr["em_stature"].ToString();
- obj.em_avoirdupois = dr["em_avoirdupois"].ToString();
- obj.em_v_id = ((dr["em_v_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_v_id"]);
- obj.em_statuscard = dr["em_statuscard"].ToString();
- obj.em_health = dr["em_health"].ToString();
- obj.em_bloodtype = dr["em_bloodtype"].ToString();
- obj.em_phone = dr["em_phone"].ToString();
- obj.em_mobile = dr["em_mobile"].ToString();
- obj.em_email = dr["em_email"].ToString();
- obj.em_finishschool = dr["em_finishschool"].ToString();
- obj.em_speciality = dr["em_speciality"].ToString();
- obj.em_l_id = ((dr["em_l_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_l_id"]);
- obj.em_graduatetime = ((dr["em_graduatetime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["em_graduatetime"]);
- obj.em_degree = dr["em_degree"].ToString();
- obj.em_language = dr["em_language"].ToString();
- obj.em_languagelevel = dr["em_languagelevel"].ToString();
- obj.em_languageletter = dr["em_languageletter"].ToString();
- obj.em_computerlevel = dr["em_computerlevel"].ToString();
- obj.em_computerletter = dr["em_computerletter"].ToString();
- obj.em_computergood = dr["em_computergood"].ToString();
- obj.em_mandarinlevel = dr["em_mandarinlevel"].ToString();
- obj.em_familyaddress = dr["em_familyaddress"].ToString();
- obj.em_postalcode = dr["em_postalcode"].ToString();
- obj.em_address = dr["em_address"].ToString();
- obj.em_familyphone = dr["em_familyphone"].ToString();
- obj.em_addresspostalcode = dr["em_addresspostalcode"].ToString();
- obj.em_familycircs = dr["em_familycircs"].ToString();
- obj.em_recordlocus = dr["em_recordlocus"].ToString();
- obj.em_jobname = dr["em_jobname"].ToString();
- obj.em_whenjoinwork = dr["em_whenjoinwork"].ToString();
- obj.em_whenthiswork = dr["em_whenthiswork"].ToString();
- obj.em_addlength = dr["em_addlength"].ToString();
- obj.em_thisunitlength = dr["em_thisunitlength"].ToString();
- obj.em_dept_id = ((dr["em_dept_id"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_dept_id"]);
- obj.em_duty = dr["em_duty"].ToString();
- obj.em_remark = dr["em_remark"].ToString();
- obj.em_bookerid = ((dr["em_bookerid"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["em_bookerid"]);
- obj.em_registertime = ((dr["em_registertime"]) == DBNull.Value) ? DateTime.MinValue : Convert.ToDateTime(dr["em_registertime"]);
- obj.em_photo = dr["em_photo"].ToString();
- return obj;
- }
- /// <summary>
- /// 根据ID,返回一个employee实体对象
- /// </summary>
- /// <param name="em_id">em_id</param>
- /// <returns>employee实体对象</returns>
- public employee Select(int em_id)
- {
- return this.Select(em_id, false, false);
- }
- /// <summary>
- /// 根据ID,返回一个employee实体对象
- /// </summary>
- /// <param name="em_id">em_id</param>
- /// <param name="bParentTable">将employee对象设置与父表关联</param>
- /// <param name="bChildrenTable">将employee对象设置与子表关联</param>
- /// <returns>employee实体对象</returns>
- public employee Select(int em_id, bool bParentTable, bool bChildrenTable)
- {
- employee obj = null;
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = em_id;
- string sqlCommand = "employeeSelect";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- obj = this.Select(dr);
- }
- }
- this.Select(obj, bParentTable, bChildrenTable);
- return obj;
- }
- /// <summary>
- /// 将employee实体对象设置与父表和子表关联
- /// </summary>
- /// <param name="obj">employee实体对象</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- public void Select(employee obj, bool bParentTable, bool bChildrenTable)
- {
- //关联的主表
- if (bParentTable)
- {
- obj.nation = nationBLL.Select(obj.em_na_id);
- obj.visage = visageBLL.Select(obj.em_v_id);
- obj.province = provinceBLL.Select(obj.em_p_id);
- obj.native = nativeBLL.Select(obj.em_n_id);
- obj.learn = learnBLL.Select(obj.em_l_id);
- obj.department = departmentBLL.Select(obj.em_dept_id);
- }
- //关联的子表集合
- if (bChildrenTable)
- {
- obj.users = usersBLL.Select("u_em_id=" + obj.em_id.ToString());
- foreach (users item in obj.users)
- {
- item.employee = obj;
- }
- }
- }
- #endregion
- #region 父表
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void nation(employee employee)
- {
- employee.nation = nationBLL.Select(employee.em_na_id);
- }
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void visage(employee employee)
- {
- employee.visage = visageBLL.Select(employee.em_v_id);
- }
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void province(employee employee)
- {
- employee.province = provinceBLL.Select(employee.em_p_id);
- }
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void native(employee employee)
- {
- employee.native = nativeBLL.Select(employee.em_n_id);
- }
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void learn(employee employee)
- {
- employee.learn = learnBLL.Select(employee.em_l_id);
- }
- /// <summary>
- /// 设置实体对象(employee)的父表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void department(employee employee)
- {
- employee.department = departmentBLL.Select(employee.em_dept_id);
- }
- #endregion
- #region 子表
- /// <summary>
- /// 设置实体对象(employee)的子表对象
- /// </summary>
- /// <param name="employee">实体对象</param>
- public void users(employee employee)
- {
- employee.users = usersBLL.Select("u_em_id=" + employee.em_id.ToString());
- }
- #endregion
- #region 查询
- /// <summary>
- /// 得到数据表employee所有记录
- /// </summary>
- /// <returns>结果集</returns>
- public IList<employee> Select()
- {
- return this.Select(false, false);
- }
- /// <summary>
- /// 得到数据表employee所有记录
- /// </summary>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(bool bParentTable, bool bChildrenTable)
- {
- IList<employee> list = new List<employee>();
- string sqlCommand = "employeeSelectAll";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (employee obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表employee满足查询条件的记录
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(string where)
- {
- return this.Select(where, false, false);
- }
- /// <summary>
- /// 得到数据表employee满足查询条件的记录
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(string where, bool bParentTable, bool bChildrenTable)
- {
- IList<employee> list = new List<employee>();
- SqlParameter[] param ={
- new SqlParameter("@where",SqlDbType.VarChar,8000)
- };
- param[0].Value = where;
- string sqlCommand = "employeeSelectByParams";
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (employee obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表ArticalInfo满足外键字段查询条件的记录
- /// </summary>
- /// <param name="foreignFieldName">外键字段名称</param>
- /// <param name="foreignFieldValue">外键字段值</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(string foreignFieldName, int foreignFieldValue)
- {
- return this.Select(foreignFieldName, foreignFieldValue, false, false);
- }
- /// <summary>
- /// 得到数据表ArticalInfo满足外键字段查询条件的记录
- /// </summary>
- /// <param name="foreignFieldName">外键字段名称</param>
- /// <param name="foreignFieldValue">外键字段值</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(string foreignFieldName, int foreignFieldValue, bool bParentTable, bool bChildrenTable)
- {
- return this.Select(string.Format("{0}='{1}'", foreignFieldName, foreignFieldValue), bParentTable, bChildrenTable);
- }
- /// <summary>
- /// 得到数据表employee满足查询条件的记录数
- /// </summary>
- /// <param name="where">查询条件</param>
- /// <param name="recordCount">记录数</param>
- public void Select(string where, out int recordCount)
- {
- string sqlCommand = "employeeCountByWhere";
- SqlParameter[] param ={
- new SqlParameter("@where",SqlDbType.VarChar,8000),
- new SqlParameter("@recordCount",SqlDbType.Int)
- };
- param[0].Value = where;
- param[1].Direction = ParameterDirection.Output;
- SqlHelper.ExecuteNonQuery(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param);
- recordCount = Convert.ToInt32(param[1].Value);
- }
- /// <summary>
- /// 得到数据表employee满足查询条件的分页记录
- /// </summary>
- /// <param name="pageSize">每页显示记录数</param>
- /// <param name="pageIndex">当前显示第几页</param>
- /// <param name="where">查询条件</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(int pageSize, int pageIndex, string where)
- {
- return this.Select(pageSize, pageIndex, where, false, false);
- }
- /// <summary>
- /// 得到数据表employee满足查询条件的分页记录
- /// </summary>
- /// <param name="pageSize">每页显示记录数</param>
- /// <param name="pageIndex">当前显示第几页</param>
- /// <param name="where">查询条件</param>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(int pageSize, int pageIndex, string where, bool bParentTable, bool bChildrenTable)
- {
- IList<employee> list = new List<employee>();
- string sqlCommand = "employeeSelectByPagerParams";
- SqlParameter[] param ={
- new SqlParameter("@pageSize",SqlDbType.Int),
- new SqlParameter("@pageIndex",SqlDbType.Int),
- new SqlParameter("@where",SqlDbType.VarChar,8000)
- };
- param[0].Value = pageSize;
- param[1].Value = pageIndex;
- param[2].Value = where;
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (employee obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 得到数据表employee满足查询条件记录
- /// </summary>
- /// <param name="commandType">命令类型</param>
- /// <param name="sqlCommand">SQL命令</param>
- /// <param name="SqlParameter[]">命令参数数组</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(CommandType commandType, string sqlCommand, params SqlParameter[] param)
- {
- return this.Select(false, false, commandType, sqlCommand, param);
- }
- /// <summary>
- /// 得到数据表employee满足查询条件记录
- /// </summary>
- /// <param name="bParentTable">是/否设置与父表对象关联</param>
- /// <param name="bChildrenTable">是/否设置与子表对象关联</param>
- /// <param name="commandType">命令类型</param>
- /// <param name="sqlCommand">SQL命令</param>
- /// <param name="SqlParameter[]">命令参数数组</param>
- /// <returns>结果集</returns>
- public IList<employee> Select(bool bParentTable, bool bChildrenTable, CommandType commandType, string sqlCommand, params SqlParameter[] param)
- {
- IList<employee> list = new List<employee>();
- using (SqlDataReader dr = SqlHelper.ExecuteReader(Conn.SqlConn, commandType, sqlCommand, param))
- {
- while (dr.Read())
- {
- list.Add(this.Select(dr));
- }
- }
- foreach (employee obj in list)
- {
- this.Select(obj, bParentTable, bChildrenTable);
- }
- return list;
- }
- /// <summary>
- /// 根据主键检测是否存在该条记录
- /// </summary>
- /// <param name="em_id">em_id</param>
- /// <returns>存在/不存在</returns>
- public bool Exists(int em_id)
- {
- SqlParameter[] param ={
- new SqlParameter("@em_id",SqlDbType.Int)
- };
- param[0].Value = em_id;
- string sqlCommand = "employeeIsExist";
- int a = Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConn, CommandType.StoredProcedure, sqlCommand, param));
- if (a > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- #endregion
- #endregion
- }
- }