예제 #1
0
        public Staff GetStaffByLoginName(string loginName)
        {
            Staff staff = new Staff();

            currentPeriodDb = new CurrentPeriodDb();

            int     periodId        = 0;
            DataSet dsCurrentPeriod = currentPeriodDb.SelectAllCurrentPeriod();

            if (dsCurrentPeriod != null)
            {
                periodId = Convert.ToInt32(dsCurrentPeriod.Tables[0].Rows[0][currentPeriodDb.FIELD_PERIOD_ID]);
            }

            if (periodId <= 0)
            {
                throw new Exception("No current period exist in the system! Please contact your system administrator.");
            }

            DataSet dsStaff = staffDb.SelectStaffByLoginName(loginName, periodId);

            if (dsStaff != null)
            {
                if (dsStaff.Tables[0].Rows.Count > 0)
                {
                    staff.Id                         = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_STAFF_ID]);
                    staff.Name                       = Convert.ToString(dsStaff.Tables[0].Rows[0]["Name"]);
                    staff.LoginName                  = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_LOGIN_NAME]);
                    staff.Email                      = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_EMAIL]);
                    staff.Company.Name               = Convert.ToString(dsStaff.Tables[0].Rows[0]["Company_Name"]);
                    staff.Department.Name            = Convert.ToString(dsStaff.Tables[0].Rows[0]["Department_Name"]);
                    staff.JobRole.Id                 = Convert.ToInt32(dsStaff.Tables[0].Rows[0]["Job_Role_ID"]);
                    staff.JobRole.Name               = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Name"]);
                    staff.Level.Name                 = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Level_Name"]);
                    staff.Level.Id                   = Convert.ToString(dsStaff.Tables[0].Rows[0]["Job_Role_Level_ID"]);
                    staff.CompanyDepartmentJobRoleId = Convert.ToInt32(dsStaff.Tables[0].Rows[0][staffDb.FIELD_COMPANY_DEPARTMENT_JOB_ROLE_ID]);
                    staff.Location.Name              = Convert.ToString(dsStaff.Tables[0].Rows[0][staffDb.FIELD_LOCATION_NAME]);
                    staff.MetricsCount               = metricDbFacade.CountMetrics(staff.CompanyDepartmentJobRoleId, periodId);
                    staff.IsActive                   = Convert.ToBoolean(dsStaff.Tables[0].Rows[0]["Is_Active"]);

                    staff.Role    = new Role();
                    staff.Role.Id = Convert.ToInt32(dsStaff.Tables[0].Rows[0]["Role_Id"]);

                    RoleLogic roleLogic = new RoleLogic();
                    staff.Role = roleLogic.Get(staff);

                    staff.FormatNameToPascalCasing();

                    return(staff);
                }
            }

            return(null);
        }
예제 #2
0
        //public Period GetCurrentPeriod()
        //{
        //    try
        //    {
        //        Period period = new Period();
        //        DataSet dsPeriod = currentPeriodD.SelectAllCurrentPeriod();
        //        if (dsPeriod != null)
        //        {
        //            if (dsPeriod.Tables[0].Rows.Count > 0)
        //            {
        //                periodDbFacade = new PeriodDbFacade();
        //                period.Id = Convert.ToInt32(dsPeriod.Tables[0].Rows[0][currentPeriodD.FIELD_PERIOD_ID]);
        //                period = periodLogic.GetCurrentPeriod(period.Id);

        //                //period = periodDbFacade.LoadCurrentAppraisalDetail(period.Id);

        //                return period;
        //            }
        //        }

        //        return null;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        public Period GetCurrentPeriod()
        {
            try
            {
                Period  period   = null;
                DataSet dsPeriod = currentPeriodD.SelectAllCurrentPeriod();
                if (dsPeriod != null)
                {
                    if (dsPeriod.Tables[0].Rows.Count > 0)
                    {
                        period         = new Period();
                        periodDbFacade = new PeriodDbFacade();
                        period.Id      = Convert.ToInt32(dsPeriod.Tables[0].Rows[0][currentPeriodD.FIELD_PERIOD_ID]);
                        period         = periodLogic.GetCurrentPeriod(period.Id);
                    }
                }

                return(period);
            }
            catch (Exception)
            {
                throw;
            }
        }