Example #1
0
        protected override void PageLoadEvent(object sender, System.EventArgs e)
        {
            try
            {
                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "JS"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "JS",
                                                                "<script language='javascript' src='include/RWAProjection.js'></script>");
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "JS_OnLoad",
                                                            "<script FOR=window EVENT=onload language='javascript'>Page_OnLoad()</script>");
                }
                if (!IsPostBack)
                {
                    if (!(User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) || User.IsInRole(((int)UserRoles.urFSBDPowerReader).ToString()) ||
                          User.IsInRole(((int)UserRoles.urFSOrgAdminWR).ToString()) || User.IsInRole(((int)UserRoles.urFSOrgAdminRO).ToString())))
                    {
                        throw new Exception("You are not authorized to visit this page.");
                    }

                    var org           = Request.QueryString["org"];
                    var business_line = Request.QueryString["bl"];
                    var fiscal_year   = Request.QueryString["fy"];
                    var book_month    = Request.QueryString["bm"];
                    //int business_line_code = Int32.Parse(business_line);

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

                    var label_text = "Distribution of RWA Income - Over/Under";
                    if (org != "")
                    {
                        label_text += "<br />by Function Code for Organization " + org;
                    }
                    else if (business_line != "0")
                    {
                        label_text += "<br />by Organization for Buisness Line " + business_line; //replace to the BL name
                    }
                    label_text  += "<br />starting " + String.Format("{0:MMMM}", DateTime.Parse(book_month + "/" + fiscal_year));
                    label_text  += " FY " + fiscal_year;
                    lblMain.Text = label_text;

                    var ds = FSDataServices.GetPaidDaysReference(fiscal_year, book_month);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        label_text       = String.Format("PAID DAYS: {0}.  <br />DAYS IN YEAR: {1}.", ds.Tables[0].Rows[0]["CummDays"].ToString(), ds.Tables[0].Rows[0]["DaysInYear"].ToString());
                        lblPaidDays.Text = label_text;
                        lblD.Value       = ds.Tables[0].Rows[0]["CummDays"].ToString();
                        lblDD.Value      = ds.Tables[0].Rows[0]["DaysInYear"].ToString();
                    }

                    DataSet dsIncome;
                    DataSet dsProjection;
                    if (org != "")
                    {
                        dsIncome     = FSSummaryReport.GetSummaryState(fiscal_year, org, "");
                        dsProjection = FSDataServices.GetRWAProjection(fiscal_year, org, "");
                    }
                    else
                    {
                        dsIncome     = FSSummaryReport.GetSummaryState(fiscal_year, "", business_line);
                        dsProjection = FSDataServices.GetRWAProjection(fiscal_year, "", business_line);
                    }



                    //build Distribution Table:
                    var obj = new RWAProjectionUI();
                    obj.FiscalYear      = fiscal_year;
                    obj.Organization    = org;
                    obj.BusinessLine    = business_line;
                    obj.BookMonth       = book_month;
                    obj.IncomeTable     = dsIncome.Tables[0];
                    obj.ProjectionTable = dsProjection.Tables[0];
                    obj.ChartTable      = tblData;
                    obj.ReadOnly        = read_only;
                    obj.DrawDistributionTable();
                    tblData = obj.ChartTable;

                    if (read_only)
                    {
                        btnApply.Disabled = true;
                    }

                    //get History:.
                    ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateRWADistribution, org, fiscal_year, "", 0, business_line);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        lblMessage.Text = String.Format("Last updated by {0} on {1}.",
                                                        ds.Tables[0].Rows[0]["UpdateUserName"].ToString(),
                                                        String.Format("{0:MMMM dd, yyyy}", ds.Tables[0].Rows[0]["ActionDate"]));
                    }
                }
                else
                {
                    lblError.Visible = false;
                }
            }
            catch (Exception ex)
            {
                AddError(ex);
            }
            finally
            {
                if (Errors.Count > 0)
                {
                    lblError.Text    = GetErrors();
                    lblError.Visible = true;
                }
            }
        }
Example #2
0
        private void InitProperties()
        {
            if (!(User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) || User.IsInRole(((int)UserRoles.urFSBDPowerReader).ToString()) ||
                  User.IsInRole(((int)UserRoles.urFSOrgAdminWR).ToString()) || User.IsInRole(((int)UserRoles.urFSOrgAdminRO).ToString())))
            {
                throw new Exception("You are not authorized to visit this page.");
            }

            Organization          = Request.QueryString["org"];
            BusinessLineCode      = Request.QueryString["bl"];
            FiscalYear            = Request.QueryString["fy"];
            BookMonth             = Request.QueryString["bm"];
            ReportGroupCode       = Int32.Parse(Request.QueryString["gcd"]);
            AdjustmentsAdditional = Request.QueryString["adj"];

            txtBookMonth.Value   = BookMonth;
            lblOrganization.Text = Organization;
            lblMonth.Text        = String.Format("{0:MMMM}", DateTime.Parse(BookMonth + "/" + FiscalYear));
            lblFiscalYear.Text   = FiscalYear;
            var dst = FSDataServices.GetFSReportConfiguration();

            if (dst != null && dst.Tables[0] != null && dst.Tables[0].Rows.Count > 0)
            {
                var dr_col = dst.Tables[0].Select("GROUP_CD=" + ReportGroupCode.ToString());
                if (dr_col.Length > 0)
                {
                    lblReportGroup.Text = dr_col[0]["Name"].ToString();
                }
            }
            lblReportGroupCode.Text = ReportGroupCode.ToString();
            var data_type = 0;

            if (!Int32.TryParse(Request.QueryString["t"], out data_type))
            {
                throw new Exception("Error. Missing parameters.");
            }
            DataEntryType = data_type;

            switch (DataEntryType)
            {
            case (int)FundsStatusUserEntryType.ueOneTimeAdjustment:
                lblTitle.Text = "One Time Adjustments";
                break;

            case (int)FundsStatusUserEntryType.ueOverUnderAccrued:
                lblTitle.Text = "Over/Under Accrued";
                break;

            case (int)FundsStatusUserEntryType.ueExpectedByYearEnd:
                lblTitle.Text = "Expected by Year End";
                break;

            default:
                throw new Exception("Error. Missing parameters.");
            }

            //DisplayLastUpdateInfo
            DataSet ds = null;

            switch (DataEntryType)
            {
            case (int)FundsStatusUserEntryType.ueOneTimeAdjustment:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateOneTimeAdjustment, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;

            case (int)FundsStatusUserEntryType.ueOverUnderAccrued:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateOverUnderAccrued, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;

            case (int)FundsStatusUserEntryType.ueExpectedByYearEnd:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateExpectedByYearEnd, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;
            }
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                var user_name   = ds.Tables[0].Rows[0]["UpdateUserName"].ToString();
                var update_date = String.Format("{0:MMMM dd, yyyy}", ds.Tables[0].Rows[0]["ActionDate"]);
                lblMessage.Text = String.Format("Last updated by {0} on {1}.", user_name, update_date);
            }
        }
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 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);
        }
Example #5
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 #6
0
 //revised
 public static DataTable GetYearDistributionForOrganization(string sFiscalYear, string sOrgCode)
 {
     return(FSDataServices.GetYearDistributionForOrganization(sFiscalYear, sOrgCode).Tables[0]);
 }
Example #7
0
 //revised
 public static DataTable GetYearDistributionForBusinessLine(string sFiscalYear, string sBusinessLine)
 {
     return(FSDataServices.GetYearDistributionForBusinessLine(sFiscalYear, sBusinessLine).Tables[0]);
 }
Example #8
0
 //revised
 public static DataTable GetYearDistribution(string sFiscalYear)
 {
     return(FSDataServices.GetYearDistribution(sFiscalYear).Tables[0]);
 }
Example #9
0
        public void DrawDistributionTable()
        {
            HtmlTableRow  tr;
            HtmlTableCell td;
            HtmlInputText txt;

            var    ds = FSDataServices.GetFSReportConfiguration();
            int    group_cd;
            string row_name;

            foreach (DataRow drConfig in ds.Tables[0].Rows)
            {
                //skip headers and totals rows
                if ((int)drConfig["GROUP_CD"] != 0)
                {
                    group_cd = (int)drConfig["GROUP_CD"];
                    row_name = (string)drConfig["Name"];

                    tr = new HtmlTableRow();
                    tr.AddReportRow();
                    tr.Cells.AddCell(row_name, "reportCaption");

                    var dr = IncomeTable.Select(String.Format("GROUP_CD={0} and BookMonth='{1}'", group_cd, BookMonth));
                    if (dr.Length > 0)
                    {
                        td = DisplayedMoneyCell((decimal)Utility.GetNotNullValue(dr[0]["Income"], "Decimal"), "reportTotal", "right");
                    }
                    else
                    {
                        td = DisplayedMoneyCell(0, "reportTotal", "right");
                    }
                    td.Attributes.Add("alt", group_cd.ToString());
                    tr.Cells.Add(td);

                    td  = new HtmlTableCell();
                    txt = new HtmlInputText();
                    td.Controls.Add(txt);
                    txt.AddStyle("width:90px;height:15px;text-align:right");
                    if (!ReadOnly)
                    {
                        txt.AddOnMouseOut("extractNumber(this,0,false,0);");
                        txt.AddOnKeyUp("extractNumber(this,0,false,0);");
                        txt.AddKeyPressBlockNonNumbers();
                    }
                    else
                    {
                        txt.SetReadOnly();
                    }
                    dr = ProjectionTable.Select(String.Format("GROUP_CD={0} and BookMonth='{1}'", group_cd, BookMonth));
                    if (dr.Length > 0)
                    {
                        txt.Value = String.Format("{0:0}", (decimal)Utility.GetNotNullValue(dr[0]["Amount"], "Decimal"));
                    }
                    tr.Cells.Add(td);

                    tr.Cells.AddDisplayedMoneyCell(0, "reportTotal", "right");

                    ChartTable.Rows.Add(tr);
                }
            }
        }
Example #10
0
        private void FundsEntryDataReport()
        {
            var Organization          = Request.QueryString["org"];
            var FiscalYear            = Request.QueryString["fy"];
            var BookMonth             = Request.QueryString["bm"];
            var ReportGroupCode       = Int32.Parse(Request.QueryString["gcd"]);
            var BusinessLineCode      = Request.QueryString["bl"];
            var AdjustmentsAdditional = Request.QueryString["adj"];

            //check if user's role allows to get this report:
            if (!(User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) || User.IsInRole(((int)UserRoles.urFSBDPowerReader).ToString()) ||
                  User.IsInRole(((int)UserRoles.urFSOrgAdminWR).ToString()) || User.IsInRole(((int)UserRoles.urFSOrgAdminRO).ToString())))
            {
                if (Users.UserAuthorizedForFSReports((new PageBase()).CurrentUserID, BusinessLineCode, Organization) <= 0)
                {
                    throw new Exception("You are not authorized to review this data.");
                }
            }

            HtmlTableRow  tr;
            HtmlTableCell td;
            var           DataEntryType = 0;

            if (!Int32.TryParse(Request.QueryString["t"], out DataEntryType))
            {
                throw new Exception("Error. Missing parameters.");
            }
            var sTitle = "";

            switch (DataEntryType)
            {
            case (int)FundsStatusUserEntryType.ueOneTimeAdjustment:
                sTitle = "One Time Adjustments";
                break;

            case (int)FundsStatusUserEntryType.ueOverUnderAccrued:
                sTitle = "Over/Under Accrued";
                break;

            case (int)FundsStatusUserEntryType.ueExpectedByYearEnd:
                sTitle = "Expected by Year End";
                break;

            default:
                throw new Exception("Error. Missing parameters.");
            }
            tr = new HtmlTableRow();
            tr.Cells.AddCellLeft(sTitle, "title", 9);
            Sheet.Rows.Add(tr);

            tr = new HtmlTableRow();
            tr.Cells.AddCell("", "", 9);
            Sheet.Rows.Add(tr);

            tr = new HtmlTableRow();
            tr.Cells.AddCell(Organization, "title2", 2);
            tr.Cells.AddCell(String.Format("{0:MMMM}", DateTime.Parse(BookMonth + "/" + FiscalYear)), "title2", 2);
            tr.Cells.AddCellLeft("Fiscal Year: " + FiscalYear, "title2", 5);
            Sheet.Rows.Add(tr);

            tr = new HtmlTableRow();
            //td = null;
            var dst = FSDataServices.GetFSReportConfiguration();

            if (dst != null && dst.Tables[0] != null && dst.Tables[0].Rows.Count > 0)
            {
                var dr_col = dst.Tables[0].Select("GROUP_CD=" + ReportGroupCode.ToString());
                if (dr_col.Length > 0)
                {
                    tr.Cells.AddCell(dr_col[0]["Name"].ToString(), "title2", 2);
                }
                else
                {
                    tr.Cells.AddCell("", "title2", 2);
                }
            }
            else
            {
                tr.Cells.AddCell("", "title2", 2);
            }
            //tr.Cells.Add(td);
            tr.Cells.AddCell("", "title2", 2);
            tr.Cells.AddCell("", "title2", 5);
            Sheet.Rows.Add(tr);

            //DisplayLastUpdateInfo
            DataSet ds = null;

            switch (DataEntryType)
            {
            case (int)FundsStatusUserEntryType.ueOneTimeAdjustment:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateOneTimeAdjustment, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;

            case (int)FundsStatusUserEntryType.ueOverUnderAccrued:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateOverUnderAccrued, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;

            case (int)FundsStatusUserEntryType.ueExpectedByYearEnd:
                ds = History.GetFundStatusDataUpdateHistory((int)HistoryActions.haUpdateExpectedByYearEnd, Organization, FiscalYear, BookMonth, ReportGroupCode, BusinessLineCode);
                break;

            default:
                throw new Exception("Error. Missing parameters.");
            }
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                var user_name   = ds.Tables[0].Rows[0]["UpdateUserName"].ToString();
                var update_date = String.Format("{0:MMMM dd, yyyy}", ds.Tables[0].Rows[0]["ActionDate"]);
                tr = new HtmlTableRow();
                tr.Cells.AddCell(String.Format("Last updated by {0} on {1}.", user_name, update_date), "reportCaption", 9);
                Sheet.Rows.Add(tr);
            }

            decimal total_amount  = 0;
            var     _add_awards   = (AdjustmentsAdditional == "award") ? true : false;
            var     _add_training = (AdjustmentsAdditional == "training") ? true : false;
            var     _add_travel   = (AdjustmentsAdditional == "travel") ? true : false;
            int     entry_id;
            string  doc_number;
            decimal amount;
            string  explanation;
            string  entry_month;

            tr = new HtmlTableRow();
            tr.Cells.AddCell("BookMonth", "reportHeaderBlue", 2);
            tr.Cells.AddCell("DocNumber", "reportHeaderBlue", 2);
            tr.Cells.AddCell("$ Amount", "reportHeaderBlue", 1);
            tr.Cells.AddCell("Explanation", "reportHeaderBlue", 4);
            Sheet.Rows.Add(tr);

            ds = FSDataServices.GetUserEntryData(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, _add_awards, _add_training, _add_travel, false);
            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.Cells.AddCell(entry_month, "extRow", 2);
                tr.Cells.AddCell(doc_number, "extRow", 2);
                tr.Cells.AddCell((Convert.ToInt64(amount)).ToString(), "ExtNumber", 1);
                tr.Cells.AddCell(explanation, "extRow", 4);
                Sheet.Rows.Add(tr);
                if (entry_id < 0)   //expanded table
                {
                    var dt = FundStatus.GetUserEntryDataList(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, entry_id).Tables[0];
                    dt.Columns["Amount"].ColumnName = "$ Amount";
                    if (dt == null || dt.Columns.Count == 0)
                    {
                        continue;
                    }
                    tr = new HtmlTableRow();
                    tr.Cells.AddCell("", "", 1);
                    for (var i = 0; i < dt.Columns.Count; i++)
                    {
                        tr.Cells.AddCell(dt.Columns[i].ToString(), "reportHeaderGreen", 1);
                    }
                    Sheet.Rows.Add(tr);
                    foreach (DataRow r in dt.Rows)
                    {
                        tr = new HtmlTableRow();
                        tr.Cells.AddCell("", "", 1);
                        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";
                        }
                        for (var i = 0; i < dt.Columns.Count; i++)
                        {
                            if (dt.Columns[i].ColumnName == "$ Amount")
                            {
                                tr.Cells.AddCell((Convert.ToInt64(r["$ Amount"])).ToString(), "IntNumber", "");
                            }
                            else
                            {
                                tr.Cells.AddCell(r[i].ToString(), "intRow", 1);
                            }
                        }
                        Sheet.Rows.Add(tr);
                    }
                }
            }
            Sheet.Rows[3].Cells[2].InnerText = "Amount: " + (total_amount == 0 ? "0" : String.Format("{0:$0,0}", Convert.ToInt64(total_amount)));
            p_iHeaderLines = 5;
        }