Esempio n. 1
0
        /// <summary>
        /// Gets the report by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns></returns>
        public BaseReport GetReportById(int reportId, ReportParameter parameter)
        {
            if (reportId > 0)
            {
                var standardReport = new StandardReport(reportId)
                {
                    ResultDataTable       = StandardReportRepository.GetReportById(reportId, parameter),
                    Columns               = StandardReportRepository.GetReportColumns(reportId).ToList(),
                    ExtraHeaderCollection = StandardReportRepository.GetExtraHeaderById(reportId).ToList()
                };

                if (parameter.Unit != null && parameter.Unit != ConstValues.Unit_100M)
                {
                    foreach (var c in standardReport.Columns)
                    {
                        if (c.ColumnType == null || !c.ColumnType.Equals("decimal"))
                        {
                            continue;
                        }
                        foreach (var r in standardReport.ResultDataTable.AsEnumerable())
                        {
                            if (r[c.ColumnName] != null && r[c.ColumnName].GetType() != typeof(DBNull))
                            {
                                r[c.ColumnName] = Convert.ToDecimal(SwitchAmountUnit(parameter.Unit, Convert.ToDouble(r[c.ColumnName])));
                            }
                        }
                    }
                }
                return(standardReport);
            }
            return(new StandardReport(reportId));
        }
Esempio n. 2
0
        public BaseReport GetStructureReportById(int reportId, ReportParameter parameter)
        {
            if (reportId > 0)
            {
                var standardReport = new StandardReport(reportId)
                {
                    ResultDataTable       = StandardReportRepository.GetStructureReportById(reportId, parameter),
                    Columns               = StandardReportRepository.GetReportColumns(reportId).ToList(),
                    ExtraHeaderCollection = StandardReportRepository.GetExtraHeaderById(reportId).ToList()
                };


                return(standardReport);
            }
            return(new StandardReport(reportId));
        }