예제 #1
0
        /// <summary>
        /// 绑定职务
        /// </summary>
        private void BindPrincipalshipSource()
        {
            List <PrincipalShip> principalShipSource = PrincipalShip.GetAllPrincipalShip();

            if (principalShipSource != null)
            {
                _ItsView.PrincipalShipSource = principalShipSource;
            }
        }
        private void CollectWorkInfo()
        {
            DateTime comedate;

            if (DateTime.TryParse(_ItsView.ComeDate, out comedate))
            {
                _TheEmployeeToComplete.EmployeeDetails.Work.ComeDate = comedate;
            }
            else
            {
                _TheEmployeeToComplete.EmployeeDetails.Work.ComeDate = Convert.ToDateTime("1900-1-1");
            }
            //_TheEmployeeToComplete.EmployeeDetails.Work.ComeDate = DateTime.Parse(_ItsView.ComeDate);
            _TheEmployeeToComplete.EmployeeDetails.Work.ContractPosition = _ItsView.ContractPosition;
            _TheEmployeeToComplete.EmployeeDetails.Work.Company          =
                new Department(Convert.ToInt32(_ItsView.Company), "");
            _TheEmployeeToComplete.EmployeeDetails.Work.Responsibility = _ItsView.Responsibility;
            _TheEmployeeToComplete.EmployeeDetails.Work.WorkPlace      = _ItsView.WorkPlace;
            _TheEmployeeToComplete.EmployeeDetails.Work.Principalship  =
                PrincipalShip.GetById(Convert.ToInt32(_ItsView.PrincipalShipId));
        }
예제 #3
0
 public static Employee Convert(EmployeeEntity e)
 {
     return(new Employee
     {
         Account = new Account
         {
             Id = e.AccountID,
             Name = e.EmployeeName,
             MobileNum = e.MobileNum,
             Dept = new Department(e.DepartmentID, e.DepartmentName),
             Position = new Position(e.PositionID, e.PositionName, new PositionGrade(e.PositionGradeId, e.PositionGradeName, ""))
         },
         EmployeeType = (EmployeeTypeEnum)e.EmployeeType,
         EmployeeDetails = new EmployeeDetails
         {
             ProbationTime = e.ProbationTime.GetValueOrDefault(),
             Work = new Work
             {
                 ComeDate =
                     e.ComeDate.GetValueOrDefault(),
                 DimissionInfo = new DimissionInfo
                 {
                     DimissionDate = e.LeaveDate.GetValueOrDefault()
                 },
                 Company =
                     new Department(e.CompanyID,
                                    e.CompanyName),
                 SalaryCardNo = e.SalaryCardNo,
                 WorkPlace = e.WorkPlace,
                 Principalship = PrincipalShip.GetById(e.PrincipalShipID == null ? -1 : e.PrincipalShipID.Value)
             }
         },
         EmployeeAttendance = new EmployeeAttendance {
             DoorCardNo = e.DoorCardNo,
             PlanDutyDetailList = new List <PlanDutyDetail>()
         }
     });
 }
예제 #4
0
        /// <summary>
        /// 除了image以外的所有数据绑定
        /// </summary>
        /// <param name="sdr"></param>
        /// <param name="employee"></param>
        private static void GetEmployeeNotImageFieldFromParm(SqlDataReader sdr, Employee employee)
        {
            for (int i = 0; i < sdr.FieldCount; i++)
            {
                DateTime tryDateTimeParse;
                int      tryIntParse;
                bool     tryBoolParse;
                switch (sdr.GetName(i))
                {
                case _DBAccountID:
                    if (sdr[_DBAccountID] != null && int.TryParse(sdr[_DBAccountID].ToString(), out tryIntParse))
                    {
                        employee.Account                   = employee.Account ?? new Account();
                        employee.Account.Id                = (int)sdr[_DBAccountID];
                        employee.Account.Position          = new Position();
                        employee.Account.Position.Grade    = new PositionGrade();
                        employee.Account.Position.Grade.Id = (int)sdr[_DBPositionGradeID];
                    }
                    break;

                case _DBCompanyID:
                    if (sdr[_DBCompanyID] != null && int.TryParse(sdr[_DBCompanyID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails              = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work         = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.Company =
                            employee.EmployeeDetails.Work.Company ?? new Department();
                        employee.EmployeeDetails.Work.Company.DepartmentID = (int)sdr[_DBCompanyID];
                    }
                    break;

                case _DBEmployeeType:
                    if (sdr[_DBEmployeeType] != null &&
                        int.TryParse(sdr[_DBEmployeeType].ToString(), out tryIntParse))
                    {
                        employee.EmployeeType = (EmployeeTypeEnum)sdr[_DBEmployeeType];
                    }
                    break;

                case _DBComeDate:
                    if (sdr[_DBComeDate] != null &&
                        DateTime.TryParse(sdr[_DBComeDate].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails               = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work          = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.ComeDate = (DateTime)sdr[_DBComeDate];
                    }
                    break;

                case _DBLeaveDate:
                    if (sdr[_DBLeaveDate] != null &&
                        DateTime.TryParse(sdr[_DBLeaveDate].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails      = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.DimissionInfo = employee.EmployeeDetails.Work.DimissionInfo ??
                                                                      new DimissionInfo();
                        employee.EmployeeDetails.Work.DimissionInfo.DimissionDate = (DateTime)sdr[_DBLeaveDate];
                    }
                    break;

                case _DBBirthday:
                    if (sdr[_DBBirthday] != null &&
                        DateTime.TryParse(sdr[_DBBirthday].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails          = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Birthday = (DateTime)sdr[_DBBirthday];
                    }
                    break;

                case _DBResidencePermit:
                    if (sdr[_DBResidencePermit] != null &&
                        DateTime.TryParse(sdr[_DBResidencePermit].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ResidencePermits = employee.EmployeeDetails.ResidencePermits ??
                                                                    new ResidencePermit();
                        employee.EmployeeDetails.ResidencePermits.DueDate = (DateTime)sdr[_DBResidencePermit];
                    }
                    break;

                case _DBEnglishName:
                    if (sdr[_DBEnglishName] != null)
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();

                        employee.EmployeeDetails.EnglishName = sdr[_DBEnglishName].ToString();
                    }
                    break;

                case _DBGender:
                    if (sdr[_DBGender] != null && int.TryParse(sdr[_DBGender].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails        = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Gender = Gender.GetById((int)sdr[_DBGender]);
                    }
                    break;

                case _DBPoliticalAffiliation:
                    if (sdr[_DBPoliticalAffiliation] != null &&
                        int.TryParse(sdr[_DBPoliticalAffiliation].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.PoliticalAffiliation =
                            PoliticalAffiliation.GetById((int)sdr[_DBPoliticalAffiliation]);
                    }
                    break;

                case _DBMaritalStatus:
                    if (sdr[_DBMaritalStatus] != null &&
                        int.TryParse(sdr[_DBMaritalStatus].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.MaritalStatus = MaritalStatus.GetById((int)sdr[_DBMaritalStatus]);
                    }
                    break;

                case _DBEducationalBackground:
                    if (sdr[_DBEducationalBackground] != null &&
                        int.TryParse(sdr[_DBEducationalBackground].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails           = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Education = employee.EmployeeDetails.Education ?? new Education();
                        employee.EmployeeDetails.Education.EducationalBackground =
                            EducationalBackground.GetById((int)sdr[_DBEducationalBackground]);
                    }
                    break;

                case _DBWorkType:
                    if (sdr[_DBWorkType] != null && int.TryParse(sdr[_DBWorkType].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails               = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work          = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.WorkType = WorkType.GetById((int)sdr[_DBWorkType]);
                    }
                    break;

                case _DBHasChild:
                    if (sdr[_DBHasChild] != null && bool.TryParse(sdr[_DBHasChild].ToString(), out tryBoolParse))
                    {
                        employee.EmployeeDetails                 = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Family          = employee.EmployeeDetails.Family ?? new Family();
                        employee.EmployeeDetails.Family.HasChild = (bool)sdr[_DBHasChild];
                    }
                    break;

                case _DBCertificates:
                    if (sdr[_DBCertificates] != null)
                    {
                        employee.EmployeeDetails           = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Education = employee.EmployeeDetails.Education ?? new Education();
                        employee.EmployeeDetails.Education.Certificates = sdr[_DBCertificates].ToString();
                    }
                    break;

                case _DBPRPArea:
                    if (sdr[_DBPRPArea] != null)
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.RegisteredPermanentResidence =
                            employee.EmployeeDetails.RegisteredPermanentResidence ??
                            new RegisteredPermanentResidence();
                        employee.EmployeeDetails.RegisteredPermanentResidence.PRPArea = sdr[_DBPRPArea].ToString();
                    }
                    break;

                case _DBProbationTime:
                    if (sdr[_DBProbationTime] != null &&
                        DateTime.TryParse(sdr[_DBProbationTime].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ProbationTime = (DateTime)sdr[_DBProbationTime];
                    }
                    break;

                case _DBProbationStartTime:
                    if (sdr[_DBProbationStartTime] != null &&
                        DateTime.TryParse(sdr[_DBProbationStartTime].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ProbationStartTime = (DateTime)sdr[_DBProbationStartTime];
                    }
                    break;

                case _DBDoorCardNo:
                    if (sdr[_DBDoorCardNo] != null)
                    {
                        employee.EmployeeAttendance            = employee.EmployeeAttendance ?? new EmployeeAttendance();
                        employee.EmployeeAttendance.DoorCardNo = sdr[_DBDoorCardNo].ToString();
                    }
                    break;

                case _DBSocietyWorkAge:
                    if (sdr[_DBSocietyWorkAge] != null &&
                        int.TryParse(sdr[_DBSocietyWorkAge].ToString(), out tryIntParse))
                    {
                        employee.SocWorkAgeAndVacationList = employee.SocWorkAgeAndVacationList ??
                                                             new SocWorkAgeAndVacationList();
                        employee.SocWorkAgeAndVacationList.SocietyWorkAge = (int)sdr[_DBSocietyWorkAge];
                    }
                    break;

                case _DBCountryNationalityID:
                    if (sdr[_DBCountryNationalityID] != null &&
                        int.TryParse(sdr[_DBCountryNationalityID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails.CountryNationality =
                            new Nationality((int)sdr[_DBCountryNationalityID], "", "");
                    }
                    break;

                case _DBWorkPlace:
                    employee.EmployeeDetails.Work           = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.WorkPlace = sdr[_DBWorkPlace].ToString();
                    break;

                case _DBPrincipalShipID:
                    if (sdr[_DBPrincipalShipID] != null &&
                        int.TryParse(sdr[_DBPrincipalShipID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.Principalship = PrincipalShip.GetById((
                                                                                                int)
                                                                                            sdr[_DBPrincipalShipID]);
                    }
                    break;

                case _DBSalaryCardNo:
                    employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.SalaryCardNo = sdr[_DBSalaryCardNo].ToString();
                    break;

                case _DBSalaryCardBank:
                    employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.SalaryCardBank = sdr[_DBSalaryCardBank].ToString();
                    break;

                default:
                    break;
                }
            }
        }