码迷,mamicode.com
首页 > 其他好文 > 详细

DalEmployeeInfo

时间:2014-07-26 00:57:06      阅读:356      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   io   for   

bubuko.com,布布扣
namespace Global.PM.Common.Data
{
    using Global.PM.Common.Entity.HR;
    using Global.Utils.ORM;
    using Global.Utils.ORM.Common;
    using Global.Utils;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data.SqlClient;

    public class DalEmployeeInfo
    {
        private DBHelper dbHelper = null;
        public DalEmployeeInfo()
        {
            dbHelper = new DBHelper();
        }

        public int DeleteBargainInfo(string id)
        {
            return dbHelper.Remove<BargainInfo>(id);
        }

        public int DeleteBargainInfoByEmployeeID(string employeeID)
        {
            string sql = "delete from OA_HR_BargainInfo where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeID)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteEmployeeInfo(string id)
        {
            return dbHelper.Remove<EmployeeInfo>(id);
        }

        public int DeleteFamilyMember(string id)
        {
            return dbHelper.Remove<FamilyMember>(id);
        }

        public int DeleteFamilyMemberByEmployeeId(string employeeId)
        {
            string sql = "delete from OA_HR_FamilyMemberInfo where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteLanguageAbility(string id)
        {
            return dbHelper.Remove<LanguageAbility>(id);
        }

        public int DeleteLanguageAbilityByEmployeeId(string employeeId)
        {
            string sql = "delete from OA_HR_LanguageAbility where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteRewardsPunishmentInfo(string id)
        {
            return dbHelper.Remove<RewardsPunishmentInfo>(id);
        }

        public int DeleteRewardsPunishmentInfoByEmployeeID(string employeeId)
        {
            string sql = "delete from OA_HR_RewardsPunishment where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteSalaryInfo(string id)
        {
            return dbHelper.Remove<SalaryInfo>(id);
        }

        public int DeleteSalaryInfoByEmployeeID(string employeeId)
        {
            string sql = "delete from OA_HR_SalaryInfo where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteSchoolingInfo(string id)
        {
            return dbHelper.Remove<SchoolingInfo>(id);
        }

        public int DeleteSchoolingInfoByEmployeeId(string employeeId)
        {
            string sql = "delete from OA_HR_SchoolingInfo where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteSkillsInfo(string id)
        {
            return dbHelper.Remove<SkillsInfo>(id);
        }

        public int DeleteSkillsInfoByEmployeeID(string employeeId)
        {
            string sql = "delete from OA_HR_OtherSkills where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public int DeleteVitaInfo(string id)
        {
            return dbHelper.Remove<VitaInfo>(id);
        }

        public int DeleteVitaInfoByEmployeeId(string employeeId)
        {
            string sql = "delete from OA_HR_VitaInfo where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", employeeId)};

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public BargainInfo GetBargainInfo(string id)
        {
            return dbHelper.FindById<BargainInfo>(id);
        }

        public IList GetBargainInfoListByEmployeeID(string employeeID)
        {
            return dbHelper.FindByProperty<BargainInfo>("EmployeeID", employeeID);
        }

        public EmployeeInfo GetEmployeeInfo(string id)
        {
            string sql = @"select OA_HR_EmployeeInfo.*, IBP_T_EA.PK_UnitID as UnitID,
                            IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
                            from OA_HR_EmployeeInfo
                            left outer join IBP_T_User 
                            on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
                            left outer join IBP_T_EA
                            on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
                            where EmployeeID=@EmployeeID";
            ParamMap param = ParamMap.newMap();
            param.setParameter("@EmployeeID", id);
            List<EmployeeInfo> list = dbHelper.FindBySql<EmployeeInfo>(sql, param);
            if (list.Count > 0)
                return list[0];
            return null;
        }

        public EmployeeInfo GetEmployeeInfoByUserID(string userId)
        {
            string sql = @"select OA_HR_EmployeeInfo.*, IBP_T_EA.PK_UnitID as UnitID,
                            IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
                            from OA_HR_EmployeeInfo
                            left outer join IBP_T_User 
                            on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
                            left outer join IBP_T_EA
                            on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
                            where EmployeeUserID=@UserID";
            ParamMap param = ParamMap.newMap();
            param.setParameter("@UserID", userId);
            List<EmployeeInfo> list = dbHelper.FindBySql<EmployeeInfo>(sql, param);
            if (list.Count > 0)
                return list[0];
            return null;
        }

        public IList GetEmployeeInfoList()
        {
            string sql = @"select OA_HR_EmployeeInfo.*,IBP_T_EA.PK_UnitID as UnitID,
                            IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
                            from OA_HR_EmployeeInfo left outer join IBP_T_User 
                            on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
                            left outer join IBP_T_EA on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
                            from OA_HR_EmployeeInfo WHERE EmployeeDataStatus=2 AND IsDeleted = 0";
            return dbHelper.FindBySql<EmployeeInfo>(sql);
        }

        public IList GetEmployeeInfoList(EmployeeInfo _employeeInfo)
        {
            string sql = @"select OA_HR_EmployeeInfo.*,IBP_T_EA.PK_UnitID as UnitID,
                            IBP_T_EA.UnitName As UnitName,IBP_T_User.LogonName As UserAccount
                            from OA_HR_EmployeeInfo
                            left outer join IBP_T_User 
                            on IBP_T_User.PK_UserID = OA_HR_EmployeeInfo.EmployeeUserID
                            left outer join IBP_T_EA
                            on IBP_T_EA.PK_UnitID = IBP_T_User.FK_UnitID
                            WHERE EmployeeDataStatus=2 AND IsDeleted = 0 
                            AND (@UserAccount is null or LTRIM(RTRIM(@UserAccount)) = ‘‘ or IBP_T_User.LogonName = @UserAccount)
                            AND (@Name is null or LTRIM(RTRIM(@Name)) = ‘‘ or Name = @Name)
                            AND (@Sex is null or LTRIM(RTRIM(@Sex)) = ‘‘ or OA_HR_EmployeeInfo.Sex= @Sex)
                            AND (@EmploeeStatus is null or LTRIM(RTRIM(@EmploeeStatus)) = ‘‘ or EmploeeStatus= @EmploeeStatus)
                            AND (@UnitID is null or LTRIM(RTRIM(@UnitID)) = ‘‘ or IBP_T_User.FK_UnitID= @UnitID)";

            ParamMap param = ParamMap.newMap();
            param.setParameter("@UserAccount", _employeeInfo.UserAccount);
            param.setParameter("@Name", _employeeInfo.Name);
            param.setParameter("@Sex", _employeeInfo.Sex);
            param.setParameter("@EmploeeStatus", _employeeInfo.EmploeeStatus);
            param.setParameter("@UnitID", _employeeInfo.UnitID);
            return dbHelper.FindBySql<EmployeeInfo>(sql, param);
        }

        public FamilyMember GetFamilyMember(string id)
        {
            return dbHelper.FindById<FamilyMember>(id);
        }
        
        public IList GetFamilyMemberList(string employeeID)
        {
            return dbHelper.FindByProperty<FamilyMember>("EmployeeID", employeeID);
        }

        public LanguageAbility GetLanguageAbility(string id)
        {
            return dbHelper.FindById<LanguageAbility>(id);
        }

        public IList GetLanguageAbilityByEmployeeID(string employeeID)
        {
            return dbHelper.FindByProperty<LanguageAbility>("EmployeeID", employeeID);
        }
        
        public int GetMaxMiddleNumOfEmployeeCode(string strPrefix, string strPostfix, int middleNumCount)
        {
            int num = 0;
            string sql = @"SELECT TOP 1
                            SUBSTRING(EmployeeCode, LEN(@Prefix)+1, @MiddleNumCount) AS MiddleNum
                            FROM OA_HR_EmployeeInfo
                            WHERE 
                            LEN(EmployeeCode)-LEN(@Prefix)-LEN(@Postfix)=@MiddleNumCount
                            AND (LEN(@Prefix)=0 OR (CHARINDEX(@Prefix, EmployeeCode) = 1)) 
                            AND (LEN(@Postfix)=0 OR (CHARINDEX(@Postfix, EmployeeCode) = LEN(EmployeeCode) - LEN(@Postfix)+1))
                            ORDER BY MiddleNum DESC";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@Prefix", strPrefix),
                                               new SqlParameter("@Postfix", strPostfix),
                                               new SqlParameter("@MiddleNumCount", middleNumCount)
            };

            object obj2 = SqlHelper.ExecuteScalar(AppConfiguration.ConnectionString, sql, parms);
            if (obj2 != null)
            {
                try
                {
                    num = int.Parse(obj2.ToString());
                }
                catch
                {
                }
            }
            return num;
        }

        public RewardsPunishmentInfo GetRewardsPunishmentInfo(string id)
        {
            return dbHelper.FindById<RewardsPunishmentInfo>(id);
        }
        
        public IList GetRewardsPunishmentInfoListByEmployeeID(string employeeID)
        {
            return dbHelper.FindByProperty<RewardsPunishmentInfo>("EmployeeID", employeeID);
        }

        public SalaryInfo GetSalaryInfo(string id)
        {
            return dbHelper.FindById<SalaryInfo>(id);
        }

        public IList GetSalaryInfoListByEmployeeID(string employeeID)
        {
            return dbHelper.FindByProperty<SalaryInfo>("EmployeeID", employeeID);
        }

        public SchoolingInfo GetSchoolingInfo(string id)
        {
            return dbHelper.FindById<SchoolingInfo>(id);
        }

        public IList GetSchoolingInfoList(string employeeID)
        {
            return dbHelper.FindByProperty<SchoolingInfo>("EmployeeID", employeeID);
        }

        public SkillsInfo GetSkillsInfo(string id)
        {
            return dbHelper.FindById<SkillsInfo>(id);
        }

        public IList GetSkillsInfoByEmployeeID(string employeeID)
        {
            return dbHelper.FindByProperty<SkillsInfo>("EmployeeID", employeeID);
        }


        public VitaInfo GetVitaInfo(string id)
        {
            return dbHelper.FindById<VitaInfo>(id);
        }

        public IList GetVitaInfoList(string employeeID)
        {
            return dbHelper.FindByProperty<VitaInfo>("EmployeeID", employeeID);
        }

        public void InsertBargainInfo(BargainInfo _bargainInfo)
        {
            dbHelper.Save<BargainInfo>(_bargainInfo);
        }

        public string InsertEmployeeInfo(EmployeeInfo _employeeInfo)
        {
            dbHelper.Save<EmployeeInfo>(_employeeInfo);
            return _employeeInfo.EmployeeID.ToString();
        }

        public void InsertFamilyMember(FamilyMember _familyMember)
        {
            dbHelper.Save<FamilyMember>(_familyMember);
        }

        public void InsertLanguageAbility(LanguageAbility _languageAbility)
        {
            dbHelper.Save<LanguageAbility>(_languageAbility);
        }

        public void InsertRewardsPunishmentInfo(RewardsPunishmentInfo _rewardsPunishmentInfo)
        {
            dbHelper.Save<RewardsPunishmentInfo>(_rewardsPunishmentInfo);
        }

        public void InsertSalaryInfo(SalaryInfo _salaryInfo)
        {
            dbHelper.Save<SalaryInfo>(_salaryInfo);
        }

        public void InsertSchoolingInfo(SchoolingInfo _schoolingInfo)
        {
            dbHelper.Save<SchoolingInfo>(_schoolingInfo);
        }

        public void InsertSkillsInfo(SkillsInfo _skillsInfo)
        {
            dbHelper.Save<SkillsInfo>(_skillsInfo);
        }

        public void InsertVitaInfo(VitaInfo _vitaInfo)
        {
            dbHelper.Save<VitaInfo>(_vitaInfo);
        }

        public void UpdateBargainInfo(BargainInfo _bargainInfo)
        {
            dbHelper.Save<BargainInfo>(_bargainInfo);
        }

        public int UpdateDeletedStatus(string employeeId, bool isDeleted)
        {
            string sql = "update OA_HR_EmployeeInfo set IsDeleted=@IsDeleted where EmployeeID=@EmployeeID";
            SqlParameter[] parms = new SqlParameter[] {
                                               new SqlParameter("@EmployeeID", int.Parse(employeeId)),
                                               new SqlParameter("@IsDeleted", isDeleted)
            };

            return SqlHelper.ExecuteNonQuery(AppConfiguration.ConnectionString, sql, parms);
        }

        public void UpdateDimissionInfo(EmployeeInfo _employeeInfo)
        {
            dbHelper.Update<EmployeeInfo>(_employeeInfo);
        }

        public void UpdateEmployeeInfo(EmployeeInfo _employeeInfo)
        {
            dbHelper.Update<EmployeeInfo>(_employeeInfo);
        }

        public void UpdateFamilyMember(FamilyMember _familyMember)
        {
            dbHelper.Update<FamilyMember>(_familyMember);
        }

        public void UpdateLanguageAbility(LanguageAbility _languageAbility)
        {
            dbHelper.Update<LanguageAbility>(_languageAbility);
        }

        public void UpdateRewardsPunishmentInfo(RewardsPunishmentInfo _rewardsPunishmentInfo)
        {
            dbHelper.Update<RewardsPunishmentInfo>(_rewardsPunishmentInfo);
        }

        public void UpdateSalaryInfo(SalaryInfo _salaryInfo)
        {
            dbHelper.Update<SalaryInfo>(_salaryInfo);
        }

        public void UpdateSchoolingInfo(SchoolingInfo _schoolingInfo)
        {
            dbHelper.Update<SchoolingInfo>(_schoolingInfo);
        }

        public void UpdateSkillsInfo(SkillsInfo _skillsInfo)
        {
            dbHelper.Update<SkillsInfo>(_skillsInfo);
        }

        public void UpdateVitaInfo(VitaInfo _vitaInfo)
        {
            dbHelper.Update<VitaInfo>(_vitaInfo);
        }
    }
}
View Code

 

Example : Entity.User

bubuko.com,布布扣
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Global.Utils.ORM.CustomAttributes;
//using System.Runtime.Serialization.Formatters.Binary;

namespace IbatisTest.Entity
{
    [Table(Name="ibp_t_user")]
    public class User
    {
        [Column(Name="PK_UserID")]
        public string Id { get; set; }

        [Column(Name="UserName")]
        public string Name { get; set; }

        [Id(Name = "Id", Strategy = GenerationType.INDENTITY)]
        public int IdentityId { get; set; }

        [Column(Name="UserCode")]
        public string UserCode { get; set; }
    }
}
View Code

 

DalEmployeeInfo,布布扣,bubuko.com

DalEmployeeInfo

标签:des   style   blog   http   color   os   io   for   

原文地址:http://www.cnblogs.com/rebecca-ty/p/3868657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!