Example #1
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 #2
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);
        }