Example #1
0
        public static KPI GetKPIById(int kpiId)
        {
            if (kpiId <= 0)
            {
                throw new ArgumentException(Resources.Organization.MessageZeroAreaId);
            }

            KPI theData = null;

            try
            {
                KPITableAdapter    localAdapter = new KPITableAdapter();
                KPIDS.KPIDataTable theTable     = localAdapter.GetKPIById(kpiId);
                if (theTable != null && theTable.Rows.Count > 0)
                {
                    KPIDS.KPIRow theRow = theTable[0];
                    theData = FillRecord(theRow);
                }
            }
            catch (Exception exc)
            {
                log.Error(Resources.Kpi.MessageErrorKpiInformation + " KpiId: " + kpiId, exc);
                throw new Exception(Resources.Kpi.MessageErrorKpiInformation);
            }

            return(theData);
        }
Example #2
0
        private static KPI FillRecord(KPIDS.KPIRow row)
        {
            KPI theNewRecord = new KPI(
                row.kpiID,
                row.name,
                row.IsorganizationIDNull() ? 0 : row.organizationID,
                row.IsareaIDNull() ? 0 : row.areaID,
                row.IsprojectIDNull() ? 0 : row.projectID,
                row.IsactivityIDNull() ? 0 : row.activityID,
                row.IspersonIDNull() ? 0 : row.personID,
                row.unitID,
                row.directionID,
                row.strategyID,
                row.IsstartDateNull() ? DateTime.MinValue : row.startDate,
                row.reportingUnitID,
                row.IstargetPeriodNull() ? 0 : row.targetPeriod,
                row.allowsCategories,
                row.IscurrencyNull() ? "" : row.currency,
                row.IscurrencyUnitIDNull() ? "" : row.currencyUnitID,
                row.kpiTypeID);

            theNewRecord.OrganizationName = row.IsorganizationNameNull() ? "" : row.organizationName;
            theNewRecord.AreaName         = row.IsareaNameNull() ? "" : row.areaName;
            theNewRecord.ProjectName      = row.IsprojectNameNull() ? "" : row.projectName;
            theNewRecord.ActivityName     = row.IsactivityNameNull() ? "" : row.activityName;
            theNewRecord.PersonName       = row.IspersonNameNull() ? "" : row.personName;
            theNewRecord.Progress         = row.IsprogressNull() ? 0 : row.progress;
            theNewRecord.Trend            = row.IstrendNull() ? 0 : row.trend;
            theNewRecord.IsOwner          = row.IsisOwnerNull() ? false : Convert.ToBoolean(row.isOwner);

            return(theNewRecord);
        }