Example #1
0
        private HtmlTableCell GetNewCellMoneyLink(decimal Amount, string BookMonth, string Func, string OC)
        {
            var td = new HtmlTableCell();

            if (Amount >= 0)
            {
                td.InnerText = String.Format("{0:$0,0.00}", Amount);
            }
            else
            {
                td.InnerText = String.Format("{0:($0,0.00)}", Decimal.Negate(Amount));
            }

            td.Align = CELL_ALIGN_RIGHT;
            td.AddCssClass("tableLink");
            td.AddOnClick("get_link('" + String.Format(CellLinkOnClick, BookMonth, Func, OC) + "');");

            return(td);
        }
Example #2
0
    public static void AddMoneyCellLink(this HtmlTableCellCollection Cells, decimal Amount, string BookMonth, string Func, string OC, string CellLinkOnClick, string Align = "right")
    {
        var td = new HtmlTableCell();

        if (Amount >= 0)
        {
            td.InnerText = String.Format("{0:$0,0.00}", Amount);
        }
        else
        {
            td.InnerText = String.Format("{0:($0,0.00)}", Decimal.Negate(Amount));
        }

        td.Align = Align;
        td.AddCssClass("tableLink");
        td.AddOnClick("get_link('" + String.Format(CellLinkOnClick, BookMonth, Func, OC) + "');");

        Cells.Add(td);
    }
Example #3
0
        private void DrawTable()
        {
            var cell_link_onclick = String.Format("javascript:get_link('FundSearch.aspx?org={0}&fy={1}&bm={2}&bl={3}&ba={4}", Organization, FiscalYear, GetBookMonthList(BookMonth), BusinessLine, DEFAULT_VALUE_BUDGET_ACTIVITY);

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

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

            //link to user data entry screen:
            var cell_popup_onclick = String.Format("open_popup('org={0}&fy={1}&bm={2}&bl={3}", Organization, FiscalYear, BookMonth, BusinessLine);

            cell_popup_onclick = cell_popup_onclick + "&t={0}&gcd={1}&adj={2}');";

            HtmlTableRow  tr;
            HtmlTableCell td;

            var dsState  = FSSummaryReport.GetMonthState(FiscalYear, BookMonth, Organization, BusinessLine);
            var 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
             * */
            var dtState = dsState.Tables[0].Copy();

            if (BusinessLine != "")
            {
                dtState = FSSummaryReport.RecalculateValuesForBusinessLine(dtState, BusinessLine, FiscalYear, BookMonth);
            }

            decimal obligations      = 0;
            decimal income           = 0;
            decimal rwa              = 0;
            decimal adjustments      = 0;
            decimal totalobligations = 0;
            decimal overunderaccrued = 0;
            decimal projection       = 0;
            decimal allowance        = 0;
            decimal balance          = 0;
            decimal onetimeadj       = 0;
            decimal expbyend         = 0;
            decimal variance         = 0;

            var overunder_desc  = "";
            var onetimeadj_desc = "";
            var expbyend_desc   = "";

            decimal sum_obligations      = 0;
            decimal sum_income           = 0;
            decimal sum_adjustments      = 0;
            decimal sum_totalobligations = 0;
            decimal sum_projection       = 0;
            decimal sum_allowance        = 0;
            decimal sum_balance          = 0;
            decimal sum_variance         = 0;

            decimal total_obligations      = 0;
            decimal total_income           = 0;
            decimal total_adjustments      = 0;
            decimal total_totalobligations = 0;
            decimal total_projection       = 0;
            decimal total_allowance        = 0;
            decimal total_balance          = 0;
            var     total_variance         = 0;

            decimal q_projection  = 0;
            decimal q_allowance   = 0;
            decimal q_balance     = 0;
            decimal q_adjustments = 0;

            decimal sum_q_projection   = 0;
            decimal sum_q_allowance    = 0;
            decimal sum_q_balance      = 0;
            decimal total_q_projection = 0;
            decimal total_q_allowance  = 0;
            decimal total_q_balance    = 0;

            DataRow[] dr_col;

            //first part of Report:
            /*****************************************************************************************/
            tr = new HtmlTableRow();
            //1 column
            td = new HtmlTableCell();
            td.AddReportHeaderBlue();
            //td.Width = "300";
            tr.Cells.Add(td);
            //2,3,4,5 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 4;
            td.InnerText = String.Format("{0:MMMM}", DateTime.Parse(BookMonth + "/01/2010"));
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            //6,7,8 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 3;
            td.InnerText = "Quarterly Projection";
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            //9,10,11,12 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 4;
            td.InnerText = "End-of-Year Projection";
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            TableToDraw.Rows.Add(tr);

            //headers row:
            tr = new HtmlTableRow();
            tr.Cells.AddHeaderCell("FUNCTIONS:", "reportHeaderBlueNAlign", "left");
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_OBLIGATIONS, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_OBLIGATIONS));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_INCOME, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_INCOME));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_ADJUSTMENTS, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_ADJUSTMENTS));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_TOTAL_OBLIGATIONS, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_TOTAL_OBLIGATIONS));

            tr.Cells.AddHeaderCellWithTooltip(CAPTION_Q_PROJECTION, "reportHeaderYellow", BuildReportForExcel, AddTooltipPopup(CAPTION_Q_PROJECTION));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_Q_ALLOWANCE, "reportHeaderYellow", BuildReportForExcel, AddTooltipPopup(CAPTION_Q_ALLOWANCE));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_Q_BALANCE, "reportHeaderYellow", BuildReportForExcel, AddTooltipPopup(CAPTION_Q_BALANCE));

            tr.Cells.AddHeaderCellWithTooltip(CAPTION_PROJECTION, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_PROJECTION));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_ALLOWANCE, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_ALLOWANCE));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_BALANCE, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_BALANCE));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_VARIANCE, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_VARIANCE));
            TableToDraw.Rows.Add(tr);

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

                if ((int)drConfig["OrderNumber"] == 0)
                {
                    //complete empty row:
                    td           = new HtmlTableCell();
                    td.ColSpan   = 11;
                    td.InnerText = "";
                    tr.Cells.Add(td);
                }
                else if ((int)drConfig["OrderNumber"] == 99)
                {
                    //complete row with summary numbers:
                    tr.Cells.AddDisplayedMoneyCell(sum_obligations, "reportTotal");
                    tr.Cells.AddDisplayedMoneyCell(sum_income, "reportTotal");
                    tr.Cells.AddDisplayedMoneyCell(sum_adjustments, "reportTotal");
                    tr.Cells.AddDisplayedMoneyCell(sum_totalobligations, "reportTotal");

                    tr.Cells.AddDisplayedMoneyCell(sum_q_projection, "reportTotal");
                    tr.Cells.AddDisplayedMoneyCell(sum_q_allowance, "reportTotal");
                    sum_q_balance = sum_q_allowance - sum_q_projection;
                    tr.Cells.AddDisplayedMoneyCell(sum_q_balance, "reportTotal");

                    tr.Cells.AddDisplayedMoneyCell(sum_projection, "reportTotal");
                    tr.Cells.AddDisplayedMoneyCell(sum_allowance, "reportTotal");
                    sum_balance = sum_allowance - sum_projection;
                    tr.Cells.AddDisplayedMoneyCell(sum_balance, "reportTotal");
                    sum_variance = (sum_allowance == 0) ? 0 : sum_balance / sum_allowance * 100;
                    tr.Cells.AddTextCell(string.Format("{0:0}%", sum_variance), "reportTotal");

                    sum_obligations      = 0;
                    sum_income           = 0;
                    sum_adjustments      = 0;
                    sum_totalobligations = 0;
                    sum_q_projection     = 0;
                    sum_q_allowance      = 0;
                    sum_q_balance        = 0;
                    sum_projection       = 0;
                    sum_allowance        = 0;
                    sum_balance          = 0;
                    sum_variance         = 0;
                }
                else
                {
                    dr_col = dtState.Select(String.Format("GROUP_CD={0}", (int)drConfig["GROUP_CD"]));
                    if (dr_col.Length == 0)
                    {
                        obligations      = 0;
                        income           = 0;
                        adjustments      = 0;
                        totalobligations = 0;
                        projection       = 0;
                        allowance        = 0;
                        balance          = 0;
                        variance         = 0;
                        q_projection     = 0;
                        q_allowance      = 0;
                        q_balance        = 0;
                    }
                    else
                    {
                        obligations      = (decimal)dr_col[0]["Obligations"];
                        income           = (decimal)dr_col[0]["Income"];
                        adjustments      = (decimal)dr_col[0]["Adjustments"];
                        totalobligations = (decimal)dr_col[0]["TotalObligations"];
                        projection       = (decimal)dr_col[0]["Projection"];
                        allowance        = (decimal)dr_col[0]["Allowance"];
                        balance          = allowance - projection;
                        variance         = (allowance == 0) ? 0 : balance / allowance * 100;
                        q_projection     = (decimal)dr_col[0]["Projection_Q"];
                        q_allowance      = (decimal)dr_col[0]["Allowance_Q"];
                        q_balance        = q_allowance - q_projection;
                    }

                    sum_obligations        += obligations;
                    total_obligations      += obligations;
                    sum_income             += income;
                    total_income           += income;
                    sum_adjustments        += adjustments;
                    total_adjustments      += adjustments;
                    sum_totalobligations   += totalobligations;
                    total_totalobligations += totalobligations;
                    sum_projection         += projection;
                    total_projection       += projection;
                    sum_allowance          += allowance;
                    total_allowance        += allowance;

                    sum_q_projection   += q_projection;
                    sum_q_allowance    += q_allowance;
                    total_q_projection += q_projection;
                    total_q_allowance  += q_allowance;

                    //complete the row:
                    if (!BuildReportForExcel)
                    {
                        td = DisplayedMoneyCell(obligations, "reportAmountLink");
                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvObligations, (int)drConfig["GROUP_CD"]));
                        tr.Cells.Add(td);
                    }
                    else
                    {
                        tr.Cells.AddDisplayedMoneyCell(obligations, "reportAmount");
                    }
                    if (!BuildReportForExcel)
                    {
                        td = DisplayedMoneyCell(income, "reportAmountLink");
                        td.AddOnClick(String.Format(cell_link_onclick, (int)FundsReviewViewMode.fvIncome, (int)drConfig["GROUP_CD"]));
                        tr.Cells.Add(td);
                    }
                    else
                    {
                        tr.Cells.AddDisplayedMoneyCell(income, "reportAmount");
                    }
                    tr.Cells.AddDisplayedMoneyCell(adjustments, "reportAmount");
                    tr.Cells.AddDisplayedMoneyCell(totalobligations, "reportAmount");

                    tr.Cells.AddDisplayedMoneyCell(q_projection, "reportAmount");
                    tr.Cells.AddDisplayedMoneyCell(q_allowance, "reportAmount");
                    tr.Cells.AddDisplayedMoneyCell(q_balance, "reportAmount");

                    tr.Cells.AddDisplayedMoneyCell(projection, "reportAmount");
                    tr.Cells.AddDisplayedMoneyCell(allowance, "reportAmount");
                    tr.Cells.AddDisplayedMoneyCell(balance, "reportAmount");
                    tr.Cells.AddTextCell(String.Format("{0:0}%", variance), "reportAmount");
                }
                TableToDraw.Rows.Add(tr);
            }
            /*****************************************************************************************/
            //add Grand Total row:
            tr = new HtmlTableRow();
            tr.AddReportRow();
            //display sum totals for the whole report:
            tr.Cells.AddHeaderCell("Grand Total", "reportHeaderBlueNAlign", "left");
            tr.Cells.AddDisplayedMoneyCell(total_obligations, "reportHeaderBlueNAlign", "right");
            tr.Cells.AddDisplayedMoneyCell(total_income, "reportHeaderBlueNAlign", "right");
            tr.Cells.AddDisplayedMoneyCell(total_adjustments, "reportHeaderBlueNAlign", "right");
            tr.Cells.AddDisplayedMoneyCell(total_totalobligations, "reportHeaderBlueNAlign", "right");

            tr.Cells.AddDisplayedMoneyCell(total_q_projection, "reportHeaderBlueNAlign", "right");
            tr.Cells.AddDisplayedMoneyCell(total_q_allowance, "reportHeaderBlueNAlign", "right");
            total_q_balance = total_q_allowance - total_q_projection;
            tr.Cells.AddDisplayedMoneyCell(total_q_balance, "reportHeaderBlueNAlign", "right");

            tr.Cells.AddDisplayedMoneyCell(total_projection, "reportHeaderBlueNAlign", "right");
            tr.Cells.AddDisplayedMoneyCell(total_allowance, "reportHeaderBlueNAlign", "right");
            total_balance = total_allowance - total_projection;
            tr.Cells.AddDisplayedMoneyCell(total_balance, "reportHeaderBlueNAlign", "right");
            total_variance = (int)((total_allowance == 0) ? 0 : total_balance / total_allowance * 100);
            tr.Cells.AddHeaderCell(String.Format("{0:0}%", total_variance), "reportHeaderBlueNAlign", "right");

            TableToDraw.Rows.Add(tr);
            /*****************************************************************************************/

            tr = new HtmlTableRow();
            tr.AddReportRow();
            //complete empty row:
            td           = new HtmlTableCell();
            td.ColSpan   = 12;
            td.Height    = "8";
            td.InnerText = "";
            tr.Cells.Add(td);
            TableToDraw.Rows.Add(tr);


            //second part of Report:
            /*****************************************************************************************/
            tr = new HtmlTableRow();
            //1 column
            td = new HtmlTableCell();
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            //2,3,4,5 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 4;
            td.InnerText = "RWA and Over/Under Accrued Entries";
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            //6,7,8,9 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 4;
            td.InnerText = "One-Time Adjustments";
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            //10,11,12 columns
            td           = new HtmlTableCell();
            td.ColSpan   = 3;
            td.InnerText = "Expected by Year End";
            td.Align     = "center";
            td.AddReportHeaderBlue();
            tr.Cells.Add(td);
            TableToDraw.Rows.Add(tr);

            //headers row:
            tr = new HtmlTableRow();
            tr.Cells.AddHeaderCell("Adjustments:", "reportHeaderBlueNAlign", "left");
            td = HeaderCellWithTooltip(CAPTION_RWA, "reportHeaderGreen");
            if (!BuildReportForExcel)
            {
                td.AddOnClick(String.Format("open_rwa_popup('org={0}&fy={1}&bm={2}&bl={3}');", Organization, FiscalYear, BookMonth, BusinessLine));
            }
            tr.Cells.Add(td);
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_OVERUNDERACCRUED, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_OVERUNDERACCRUED));
            td           = new HtmlTableCell();
            td.ColSpan   = 2;
            td.InnerText = CAPTION_EXPLANATION;
            td.Align     = "center";
            td.AddReporHeaderGreen();
            tr.Cells.Add(td);

            tr.Cells.AddHeaderCellWithTooltip(CAPTION_ONETIMEADJ, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_ONETIMEADJ));
            td           = new HtmlTableCell();
            td.ColSpan   = 3;
            td.InnerText = CAPTION_EXPLANATION;
            td.Align     = "center";
            td.AddReporHeaderGreen();
            tr.Cells.Add(td);
            //tr.Cells.Add(HeaderCellWithTooltip(CAPTION_EXPLANATION, "reportHeaderGreen"));
            tr.Cells.AddHeaderCellWithTooltip(CAPTION_EXPBYYEAREND, "reportHeaderGreen", BuildReportForExcel, AddTooltipPopup(CAPTION_EXPBYYEAREND));
            td           = new HtmlTableCell();
            td.ColSpan   = 2;
            td.InnerText = CAPTION_EXPLANATION;
            td.Align     = "center";
            td.AddReporHeaderGreen();
            tr.Cells.Add(td);
            //tr.Cells.Add(HeaderCellWithTooltip(CAPTION_EXPLANATION, "reportHeaderGreen"));
            TableToDraw.Rows.Add(tr);

            /*****************************************************************************************/
            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());

                    //complete empty row:
                    td = new HtmlTableCell();
                    td.AddReportTable();
                    td.ColSpan   = 11;
                    td.InnerText = "";
                    tr.Cells.Add(td);

                    TableToDraw.Rows.Add(tr);
                }
                else if ((int)drConfig["OrderNumber"] != 99)
                //skip the 'Totals' row in this part!
                {
                    tr = new HtmlTableRow();
                    tr.AddReportRow();
                    tr.Cells.AddHeaderCell(drConfig["Name"].ToString(), drConfig["CaptionStyle"].ToString());

                    dr_col = dtState.Select(String.Format("GROUP_CD={0}", (int)drConfig["GROUP_CD"]));
                    if (dr_col.Length == 0)
                    {
                        rwa = 0;
                        overunderaccrued = 0;
                        onetimeadj_desc  = "";
                        onetimeadj       = 0;
                        onetimeadj_desc  = "";
                        expbyend         = 0;
                        expbyend_desc    = "";
                        q_adjustments    = 0;
                    }
                    else
                    {
                        rwa = (decimal)dr_col[0]["RWA"];
                        overunderaccrued = (decimal)dr_col[0]["OverUnderAccrued"];
                        onetimeadj       = (decimal)dr_col[0]["OneTimeAdjustments"];
                        expbyend         = (decimal)dr_col[0]["ExpByYearEnd"];
                        q_adjustments    = (decimal)dr_col[0]["Adjustments_Q"];
                        //no description for BusinessLine
                        if (BusinessLine == "")
                        {
                            overunder_desc  = (string)Utility.GetNotNullValue(dr_col[0]["OverUnderAccrDesc"], "String");
                            onetimeadj_desc = (string)Utility.GetNotNullValue(dr_col[0]["OneTimeAdjDesc"], "String");
                            expbyend_desc   = (string)Utility.GetNotNullValue(dr_col[0]["ExpByYearEndDesc"], "String");
                        }
                        else
                        {
                            overunder_desc  = "";
                            onetimeadj_desc = "";
                            expbyend_desc   = "";
                        }
                    }

                    //complete the row:
                    tr.Cells.AddDisplayedMoneyCell(rwa, "reportAmount");

                    td = DisplayedMoneyCell(overunderaccrued, "reportAmountLink");
                    if (!BuildReportForExcel)
                    {
                        td.AddOnClick(String.Format(cell_popup_onclick, (int)FundsStatusUserEntryType.ueOverUnderAccrued, (int)drConfig["GROUP_CD"], ""));
                    }
                    tr.Cells.Add(td);
                    td           = new HtmlTableCell();
                    td.ColSpan   = 2;
                    td.InnerText = overunder_desc;
                    tr.Cells.Add(td);

                    td = DisplayedMoneyCell(onetimeadj, "reportAmountLink");
                    if (!BuildReportForExcel)
                    {
                        td.AddOnClick(String.Format(cell_popup_onclick, (int)FundsStatusUserEntryType.ueOneTimeAdjustment, (int)drConfig["GROUP_CD"], (string)Utility.GetNotNullValue(drConfig["AddAdjustment"], "String")));
                    }
                    tr.Cells.Add(td);
                    td           = new HtmlTableCell();
                    td.ColSpan   = 3;
                    td.InnerText = onetimeadj_desc;
                    tr.Cells.Add(td);

                    td = DisplayedMoneyCell(expbyend, "reportAmountLink");
                    if (!BuildReportForExcel)
                    {
                        td.AddOnClick(String.Format(cell_popup_onclick, (int)FundsStatusUserEntryType.ueExpectedByYearEnd, (int)drConfig["GROUP_CD"], ""));
                    }
                    tr.Cells.Add(td);
                    td           = new HtmlTableCell();
                    td.ColSpan   = 2;
                    td.InnerText = expbyend_desc;
                    tr.Cells.Add(td);

                    TableToDraw.Rows.Add(tr);
                }
            }
            tr = new HtmlTableRow();
            tr.AddReportHeaderBlue();
            //complete empty row:
            td           = new HtmlTableCell();
            td.ColSpan   = 12;
            td.Height    = "8";
            td.InnerText = "";
            tr.Cells.Add(td);
            TableToDraw.Rows.Add(tr);

            /*****************************************************************************************/
        }
Example #4
0
        private void DrawTable()
        {
            decimal total_amount = 0;
            var     read_only    = true;

            if (User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) && Organization != "")
            {
                read_only = false;
            }
            else if (!User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()))
            {
                var user_role = Users.UserAuthorizedForFSReports(CurrentUserID, BusinessLineCode, Organization);
                if (user_role <= 0)
                {
                    throw new Exception("You are not authorized to visit this page.");
                }
                else
                if (user_role == (int)UserRoles.urFSOrgAdminWR && Organization != "")
                {
                    read_only = false;
                }
            }

            var _add_awards   = (AdjustmentsAdditional == "award") ? true : false;
            var _add_training = (AdjustmentsAdditional == "training") ? true : false;
            var _add_travel   = (AdjustmentsAdditional == "travel") ? true : false;

            //get the data:
            var ds = FSDataServices.GetUserEntryData(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, _add_awards, _add_training, _add_travel, false);

            HtmlTableRow  tr = null;
            HtmlTableCell td = null;
            int           entry_id;
            string        doc_number;
            decimal       amount;
            string        explanation;
            string        entry_month;

            //remove first column if there is no permission for edit or delete:
            if (read_only)
            {
                tblData.Rows[0].Cells[0].InnerText = "BookMonth";
            }
            //tblData.Rows[0].Cells[0].AddDisplayNone();

            var iRowCount = 0;

            ds.Tables[0].Columns["Amount"].ColumnName = "$ Amount";
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                entry_id      = (int)dr["EntryID"];
                entry_month   = String.Format("{0:MMMM}", DateTime.Parse(dr["BookMonth"].ToString() + "/" + dr["FiscalYear"].ToString()));
                doc_number    = (string)Utility.GetNotNullValue(dr["DocNumber"], "String");
                amount        = (decimal)dr["$ Amount"];
                total_amount += amount;
                explanation   = (string)Utility.GetNotNullValue(dr["Explanation"], "String");

                tr = new HtmlTableRow();
                tr.AddCssClass((iRowCount++) % 2 > 0 ? "tRowAlt" : "tRow");
                if (entry_id >= 0 && !read_only && dr["BookMonth"].ToString() == BookMonth)
                {
                    td = new HtmlTableCell();
                    var btnEdit = new HtmlInputImage();
                    btnEdit.ID  = "edit_ctrl_" + entry_id.ToString();
                    btnEdit.Src = "../images/note.gif";
                    btnEdit.Alt = "Edit record";
                    btnEdit.AddOnClick("return edit_row(this," + entry_id.ToString() + "," + DataEntryType.ToString() + ");");
                    td.Controls.Add(btnEdit);
                    tr.Cells.Add(td);

                    td = new HtmlTableCell();
                    var btnDelete = new HtmlInputImage();
                    btnDelete.ID  = "delete_ctrl_" + entry_id.ToString();
                    btnDelete.Src = "../images/btn_contact_delete.gif";
                    btnDelete.Alt = "Delete record";
                    btnDelete.AddOnClick("return delete_row(this," + entry_id.ToString() + "," + DataEntryType.ToString() + ");");
                    td.Controls.Add(btnDelete);
                    tr.Cells.Add(td);
                }
                else
                {
                    td           = new HtmlTableCell();
                    td.ColSpan   = 2;
                    td.InnerText = entry_month;
                    tr.Cells.Add(td);
                }

                td = new HtmlTableCell();
                if (entry_id < 0)
                {
                    td.InnerHtml = "<font color='green'>Show Details</font>";
                    td.AddOnClick("Expand(this)");
                    td.AddTitle("Expand");
                    td.Style.Add("cursor", "pointer");
                }
                else
                {
                    td.InnerHtml = doc_number != "" ? doc_number : "&nbsp;";
                }
                tr.Cells.Add(td);

                td           = new HtmlTableCell();
                td.InnerText = amount == 0 ? "0" : String.Format("{0:0,0}", Convert.ToInt64(amount));
                td.Align     = "right";
                tr.Cells.Add(td);

                td           = new HtmlTableCell();
                td.InnerHtml = explanation != "" ? explanation : "&nbsp;";
                tr.Cells.Add(td);

                tblData.Rows.Add(tr);
                if (entry_id < 0)   //expanded table
                {
                    tr = new HtmlTableRow();
                    tr.Style.Add("display", "none");
                    td = new HtmlTableCell();
                    tr.Cells.Add(td);
                    td         = new HtmlTableCell();
                    td.ColSpan = 4;

                    var mg = new MultiGrid();
                    mg = (MultiGrid)Page.LoadControl("..\\Controls\\MultiGrid.ascx");
                    td.Controls.Add(mg);
                    tr.Cells.Add(td);
                    tblData.Rows.Add(tr);

                    var dtO = FundStatus.GetUserEntryDataList(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, entry_id).Tables[0];
                    var dt  = dtO.Clone();
                    dt.Columns["Amount"].DataType = typeof(string);
                    foreach (DataRow r in dtO.Rows)
                    {
                        dt.ImportRow(r);
                    }
                    dt.Columns["Amount"].ColumnName = "$ Amount";
                    foreach (DataRow r in dt.Rows)
                    {
                        r["Month"]    = Month[Convert.ToInt32(r["Month"]) - 1];
                        r["$ Amount"] = String.Format("{0:0,0}", Convert.ToInt64(Convert.ToDecimal(r["$ Amount"])));
                        if (r["$ Amount"].ToString() == "00")
                        {
                            r["$ Amount"] = "0";
                        }
                    }
                    mg.Table          = dt;
                    mg.TblCSSClass    = "eTbl";
                    mg.TblBorderClass = "eBorder";
                    mg.HeaderCSSClass = "reportHeaderGreen";
                    mg.ItemCSSClass   = "eRow";
                    mg.Height         = Unit.Pixel(dt.Rows.Count * 18 + 19);
                    //make it not scrollable by setting full height
                }
            }
            //add row for insert record - if applicable
            if (!read_only)
            {
                HtmlInputText txt;

                tr = new HtmlTableRow();
                tr.AddCssClass((iRowCount++) % 2 > 0 ? "tRowAlt" : "tRow");

                td = new HtmlTableCell();
                var btnCancel = new HtmlInputImage();
                btnCancel.ID  = "cancel_ctrl_new";
                btnCancel.Src = "../images/back.gif";
                btnCancel.Alt = "Cancel changes";
                btnCancel.AddWidth(12);
                btnCancel.AddHeight(12);
                btnCancel.AddOnClick("return cancel_edit(this);");
                td.Controls.Add(btnCancel);
                tr.Cells.Add(td);

                td = new HtmlTableCell();
                var btnEdit = new HtmlInputImage();
                btnEdit.ID  = "save_ctrl_new";
                btnEdit.Src = "../images/save.gif";
                btnEdit.Alt = "Save new record";
                btnEdit.AddWidth(12);
                btnEdit.AddHeight(12);
                btnEdit.AddOnClick("return save_row(this,0," + DataEntryType.ToString() + ");");
                td.Controls.Add(btnEdit);
                tr.Cells.Add(td);

                td = new HtmlTableCell();
                td.AddStyle("padding-left:5px;padding-right:5px");
                txt = new HtmlInputText();
                txt.AddStyle("width:100%;height:15px;text-align:center;");
                td.Controls.Add(txt);
                tr.Cells.Add(td);

                td = new HtmlTableCell();
                td.AddStyle("padding-left:5px;padding-right:5px");
                txt = new HtmlInputText();
                txt.AddStyle("width:100%;height:15px;text-align:center;");
                txt.AddOnMouseOut("extractNumber(this,0,true,9999999999);");
                txt.AddOnKeyUp("extractNumber(this,0,true,9999999999);");
                txt.AddKeyPressBlockNonNumbers();
                td.Controls.Add(txt);
                tr.Cells.Add(td);

                td = new HtmlTableCell();
                td.AddStyle("padding-left:5px;padding-right:5px");
                txt = new HtmlInputText();
                txt.AddStyle("width:100%;height:15px;text-align:center;");
                td.Controls.Add(txt);
                tr.Cells.Add(td);

                tblData.Rows.Add(tr);
            }
            lblAmount.Text = total_amount == 0 ? "0" : String.Format("{0:$0,0}", Convert.ToInt64(total_amount));
        }
Example #5
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);
        }