Пример #1
0
        private void DrawViewPart(int SummaryReportViewType)
        {
            var header_link_onclick = String.Format("javascript:get_link('FundsReport.aspx?org={0}&fy={1}&bl={2}", Organization, FiscalYear, BusinessLine);

            header_link_onclick = header_link_onclick + "&bm={0}');";

            var cell_link_onclick = String.Format("javascript:get_link('FundSearch.aspx?org={0}&fy={1}&bl={2}&ba={3}", Organization, FiscalYear, BusinessLine, DEFAULT_VALUE_BUDGET_ACTIVITY);

            cell_link_onclick = cell_link_onclick + "&vm={0}&bm={1}&gcd={2}');";

            //before drawing the table:
            //if the Organization value is empty - take the BusinessLine value,
            //otherwise - ignore BusinessLine value and build the report in Organization level:
            if (Organization != "")
            {
                BusinessLine = "";
            }

            HtmlTableRow tr;

            if (dsState == null || dsConfig == null)
            {
                dsState  = FSSummaryReport.GetSummaryState(FiscalYear, Organization, BusinessLine);
                dsConfig = FSDataServices.GetFSReportConfiguration();

                /*
                 * in case of report by Business Line the following should be recalculated and not taken from the database (State table):
                 * - projection
                 * - rwa
                 * - total obligations, etc
                 * because in calulation we use reference to paid days
                 * */
                dtState = dsState.Tables[0].Copy();
                //check the values and then decide if we need it:
                if (BusinessLine != "")
                {
                    dtState = FSSummaryReport.RecalculateSummaryValuesForBusinessLine(dtState, BusinessLine, FiscalYear);
                }
            }

            //add first row - months captions:
            tr = new HtmlTableRow();
            tr.AddReportRow();
            tr.Cells.AddHeaderCell(ReportHeader, "reportHeaderGreen", "center");

            HtmlTableCell td;
            string        month_name;

            foreach (var bm in month_arr)
            {
                month_name = DateTime.Parse(bm + "/01/" + FiscalYear).ToString("MMMM");

                if (!BuildReportForExcel)
                {
                    td           = new HtmlTableCell();
                    td.InnerText = month_name;
                    td.Align     = "center";
                    td.AddCssClass("reportHeaderGreenLink");
                    td.AddOnClick(String.Format(header_link_onclick, bm));
                    td.AddTitle(String.Format("Click here to see Fund Status Report for {0}", month_name));
                    td.AddOnMouseOver("this.className='reportHeaderGreenLinkHover'");
                    td.AddOnMouseOut("this.className='reportHeaderGreenLink'");
                    tr.Cells.Add(td);
                }
                else
                {
                    tr.Cells.AddHeaderCell(month_name, "reportHeaderGreen", "center");
                }
            }
            TableToDraw.Rows.Add(tr);

            decimal m_amount      = 0;
            var     arr_sum       = new decimal[13];
            var     arr_total_sum = new decimal[13];

            DataRow[] dr_col;

            foreach (DataRow drConfig in dsConfig.Tables[0].Rows)
            {
                if ((int)drConfig["OrderNumber"] != 0)
                {
                    tr = new HtmlTableRow();
                    tr.AddReportRow();
                    tr.Cells.AddHeaderCell(drConfig["Name"].ToString(), drConfig["CaptionStyle"].ToString(), "left");

                    foreach (var bm in month_arr)
                    {
                        td = null;

                        if ((int)drConfig["OrderNumber"] == 99)
                        {
                            //display sum totals for this section:
                            m_amount = arr_sum[Int32.Parse(bm)];
                            tr.Cells.AddDisplayedMoneyCell(m_amount, "reportTotal");
                            arr_sum[Int32.Parse(bm)] = 0;
                        }
                        else
                        {
                            dr_col = dtState.Select(String.Format("BookMonth='{0}' and GROUP_CD={1}", bm, (int)drConfig["GROUP_CD"]));
                            if (dr_col.Length > 0)
                            {
                                switch (SummaryReportViewType)
                                {
                                case (int)FundStatusSummaryReportView.svObligations:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Obligations"], "Decimal");
                                    if (!BuildReportForExcel)
                                    {
                                        td = DisplayedMoneyCell(m_amount, "reportAmountLink");
                                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvObligations, GetBookMonthList(bm), (int)drConfig["GROUP_CD"]));
                                    }
                                    break;

                                case (int)FundStatusSummaryReportView.svObligationsMonthly:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["ObligationsMonthly"], "Decimal");
                                    if (!BuildReportForExcel)
                                    {
                                        td = DisplayedMoneyCell(m_amount, "reportAmountLink");
                                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvObligations, bm, (int)drConfig["GROUP_CD"]));
                                    }
                                    break;

                                case (int)FundStatusSummaryReportView.svIncome:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Income"], "Decimal");
                                    if (!BuildReportForExcel)
                                    {
                                        td = DisplayedMoneyCell(m_amount, "reportAmountLink");
                                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvIncome, GetBookMonthList(bm), (int)drConfig["GROUP_CD"]));
                                    }
                                    break;

                                case (int)FundStatusSummaryReportView.svIncomeMonthly:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["IncomeMonthly"], "Decimal");
                                    if (!BuildReportForExcel)
                                    {
                                        td = DisplayedMoneyCell(m_amount, "reportAmountLink");
                                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvIncome, bm, (int)drConfig["GROUP_CD"]));
                                    }
                                    break;

                                case (int)FundStatusSummaryReportView.svAllowance:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Allowance"], "Decimal");
                                    break;

                                case (int)FundStatusSummaryReportView.svYearEndProjection:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Projection"], "Decimal");
                                    break;

                                case (int)FundStatusSummaryReportView.svProjectedBalance:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Allowance"], "Decimal") - (decimal)Utility.GetNotNullValue(dr_col[0]["Projection"], "Decimal");
                                    break;

                                case (int)FundStatusSummaryReportView.svProjectionVariance:
                                    m_amount = (decimal)Utility.GetNotNullValue(dr_col[0]["Allowance"], "Decimal");
                                    m_amount = (m_amount == 0) ? 0 : (m_amount - (decimal)Utility.GetNotNullValue(dr_col[0]["Projection"], "Decimal")) / m_amount;
                                    break;
                                }
                            }
                            else
                            {
                                m_amount = 0;
                            }

                            if (td == null)
                            {
                                td = DisplayedMoneyCell(m_amount, "reportAmount");
                            }
                            tr.Cells.Add(td);
                            arr_sum[Int32.Parse(bm)]       += m_amount;
                            arr_total_sum[Int32.Parse(bm)] += m_amount;
                        }
                    }
                    TableToDraw.Rows.Add(tr);
                }
            }

            tr = new HtmlTableRow();
            tr.AddReportRow();
            //display sum totals for the whole report:
            tr.Cells.AddHeaderCell("Grand Total", "reportHeaderBlueNAlign", "left");
            foreach (var bm in month_arr)
            {
                m_amount = arr_total_sum[Int32.Parse(bm)];
                tr.Cells.AddDisplayedMoneyCell(m_amount, "reportHeaderBlueNAlign");
            }
            TableToDraw.Rows.Add(tr);
        }