protected void btnSave_ServerClick(object sender, EventArgs e) { try { var rr = Result.Value.Split(new char[] { '|' }); for (var i = 0; i < rr.Length; i++) { var cc = rr[i].Split(new char[] { ';' }); var cnt = 1; var m1 = DateTime.Parse(cc[2] + "/2000").Month; var m2 = DateTime.Parse(cc[3] + "/2000").Month; var s = m1.ToString().Length < 2 ? "0" + m1.ToString() : m1.ToString(); while (m1 != m2) { m1 = m1 % 12 + 1; s += "," + (m1.ToString().Length < 2 ? "0" + m1.ToString() : m1.ToString()); cnt++; } var saveAllowanceReturn = FundAllowance.SaveFYAllowance(Convert.ToInt32(cc[0]), ddlFiscalYear.SelectedValue, GetDecimal(cc[1]), s, cnt, CurrentUserID); if (saveAllowanceReturn > 0) { History.InsertHistoryOnUpdateAllowance( cc[0] == "0" ? (int)HistoryActions.haAddNewAllowanceAmount : (int)HistoryActions.haUpdateAllowance, ddlFiscalYear.SelectedValue, cc[1], s, "", CurrentUserID); } } var dt = FundStatus.GetOrganizationList().ToDataSet().Tables[0]; for (var i = 0; i < dt.Rows.Count; i++) { FSSummaryReport.DataObsoleteFlag(ddlFiscalYear.SelectedValue, dt.Rows[i]["ORG_CD"].ToString()); } InitControls(); } catch (Exception ex) { AddError(ex); } finally { //if (Errors.Count > 0) // lblError.Text = GetErrors(); } }
private void BuildReport() { lblState.Text = ""; if (!(User.IsInRole(((int)UserRoles.urFSBDPowerReader).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAdminAllowanceRO).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAdminAllowanceWR).ToString()))) { if (Users.UserAuthorizedForFSReports(CurrentUserID, ctrlCriteria.BusinessLine, ctrlCriteria.Organization) <= 0) { throw new Exception("You are not authorized to see current report. Please select Business Line or Organization that you are allowed to review. Thank you."); } } //first check if the report data is valid: var status = FSSummaryReport.GetReportStateStatus(ctrlCriteria.FiscalYear, ctrlCriteria.Organization, ctrlCriteria.BusinessLine); if (status == (int)FundStatusReportStateStatus.rsDoesNotExist) { divReportState.Visible = true; lblState.Text = String.Format("Fund Status Report for Organization {0}, Fiscal Year {1} is not available at this moment. <p />The report data is updated by automated process every {2} minutes. <br />You can request the report immediately (it might take a few minutes). Thank you.", ctrlCriteria.Organization, ctrlCriteria.FiscalYear, Settings.Default.RebuildReportIntervalInMinutes); } else if (status == (int)FundStatusReportStateStatus.rsObsolete) { divReportState.Visible = true; lblState.Text = String.Format("Fund Status Report for Organization {0}, Fiscal Year {1} is obsolete. <p />The report data is updated by automated process every {2} minutes. <br />You can request the report immediately (it might take a few minutes). Thank you.", ctrlCriteria.Organization, ctrlCriteria.FiscalYear, Settings.Default.RebuildReportIntervalInMinutes); } else { divReportState.Visible = false; lblState.Text = ""; } if (status == (int)FundStatusReportStateStatus.rsObsolete || status == (int)FundStatusReportStateStatus.rsValid) { //draw the table tblData: var drawing_class = new FSReportUI(); drawing_class.FiscalYear = ctrlCriteria.FiscalYear; drawing_class.BookMonth = ctrlCriteria.BookMonth; drawing_class.Organization = ctrlCriteria.Organization; drawing_class.BusinessLine = ctrlCriteria.BusinessLine; drawing_class.TableToDraw = tblData; drawing_class.BuildHTMLTable(); tblData = drawing_class.TableToDraw; } }
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; } } }
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); /*****************************************************************************************/ }
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); }
private void BuildReport() { lblMessages.Text = ""; lblState.Text = ""; //divData.Attributes["style"] = "display:none;"; if (!(User.IsInRole(((int)UserRoles.urFSBDPowerReader).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAdminAllowanceRO).ToString()) || User.IsInRole(((int)UserRoles.urFSBDAdminAllowanceWR).ToString()))) { if (Users.UserAuthorizedForFSReports(CurrentUserID, ctrlCriteria.BusinessLine, ctrlCriteria.Organization) <= 0) { throw new Exception("You are not authorized to see current report. Please select Business Line or Organization that you are allowed to review. Thank you."); } } //first check if the report data is valid: var status = FSSummaryReport.GetReportStateStatus(ctrlCriteria.FiscalYear, ctrlCriteria.Organization, ctrlCriteria.BusinessLine); if (status == (int)FundStatusReportStateStatus.rsDoesNotExist) { divReportState.Visible = true; lblState.Text = String.Format("Fund Status Report for Organization {0}, Fiscal Year {1} is not available at this moment. <p />The report data is updated by automated process every {2} minutes. <br />You can request the report immediately (it might take a few minutes). Thank you.", ctrlCriteria.Organization, ctrlCriteria.FiscalYear, Settings.Default.RebuildReportIntervalInMinutes); } else if (status == (int)FundStatusReportStateStatus.rsObsolete) { divReportState.Visible = true; lblState.Text = String.Format("Fund Status Report for Organization {0}, Fiscal Year {1} is obsolete. <p />The report data is updated by automated process every {2} minutes. <br />You can request the report immediately (it might take a few minutes). Thank you.", ctrlCriteria.Organization, ctrlCriteria.FiscalYear, Settings.Default.RebuildReportIntervalInMinutes); } else { divReportState.Visible = false; lblState.Text = ""; } if (status == (int)FundStatusReportStateStatus.rsObsolete || status == (int)FundStatusReportStateStatus.rsValid) { if (status == (int)FundStatusReportStateStatus.rsValid) { lblMessages.Text = "TIP: click on the month header to enter Fund Status Report."; } draw = new FSSummaryUI(); draw.FiscalYear = ctrlCriteria.FiscalYear; draw.Organization = ctrlCriteria.Organization; draw.BusinessLine = ctrlCriteria.BusinessLine; CreateReportView((int)FundStatusSummaryReportView.svObligations, "Obligations", "Show/Hide Fund Status Summary Report - Obligations Info"); CreateReportView((int)FundStatusSummaryReportView.svObligationsMonthly, "Obligations - Monthly View", "Show/Hide Fund Status Summary Report - Obligations Monthly Amounts Info"); CreateReportView((int)FundStatusSummaryReportView.svIncome, "Income", "Show/Hide Fund Status Summary Report - Income Info"); CreateReportView((int)FundStatusSummaryReportView.svIncomeMonthly, "Income - Monthly View", "Show/Hide Fund Status Summary Report - Income Monthly Amounts Info"); CreateReportView((int)FundStatusSummaryReportView.svAllowance, "Allowance", "Show/Hide Fund Status Summary Report - Allowance Info"); CreateReportView((int)FundStatusSummaryReportView.svYearEndProjection, "Year End Projection", "Show/Hide Fund Status Summary Report - Year End Projection Info"); CreateReportView((int)FundStatusSummaryReportView.svProjectionVariance, "Projection Variance", "Show/Hide Fund Status Summary Report - Projection Variance Info"); CreateReportView((int)FundStatusSummaryReportView.svProjectedBalance, "Projected Balance", "Show/Hide Fund Status Summary Report - Projected Balance Info"); divData.Attributes["style"] = "display:inline;"; /* * StringBuilder sb = new StringBuilder(); * sb.Append("<script language='javascript'> "); * sb.Append("on_long_load(); "); * sb.Append("</script>"); * Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "load_back", sb.ToString()); */ } else { draw = null; } }
protected void Page_Load(object sender, EventArgs e) { var str_result = ""; var _page = new PageBase(); var user = _page.CurrentUserID; var obj_xml = new XmlDataDocument(); try { obj_xml.Load(Request.InputStream); if (obj_xml.DocumentElement.Name == "search_request") { Reports.InsertFSRequestResultsByEmail(_page.FundsSearchSelectedValues, user); } if (obj_xml.DocumentElement.Name == "update_data") { var node = obj_xml.DocumentElement.FirstChild; var entry_type = node.Attributes.GetNamedItem("type").Value.Trim(); var entry_id = node.Attributes.GetNamedItem("id").Value.Trim(); var organization = node.Attributes.GetNamedItem("org").Value.Trim(); var fiscal_year = node.Attributes.GetNamedItem("fy").Value.Trim(); var month = node.Attributes.GetNamedItem("bm").Value.Trim(); var group_code = node.Attributes.GetNamedItem("gcd").Value.Trim(); var amount = node.Attributes.GetNamedItem("amount").Value.Trim(); var doc_number = node.Attributes.GetNamedItem("doc").Value.Trim(); var explanation = node.Attributes.GetNamedItem("exp").Value.Trim(); var intEntryType = Int32.Parse(entry_type); var intEntryID = Int32.Parse(entry_id); var mAmount = Decimal.Parse(amount); var intGroupCode = Int32.Parse(group_code); //update data: FundStatus.UpdateUserEntryData(intEntryType, fiscal_year, month, organization, intGroupCode, intEntryID, doc_number, mAmount, explanation, user); //insert history log: var action_code = 0; switch (intEntryType) { case (int)FundsStatusUserEntryType.ueOverUnderAccrued: action_code = (int)HistoryActions.haUpdateOverUnderAccrued; break; case (int)FundsStatusUserEntryType.ueOneTimeAdjustment: action_code = (int)HistoryActions.haUpdateOneTimeAdjustment; break; case (int)FundsStatusUserEntryType.ueExpectedByYearEnd: action_code = (int)HistoryActions.haUpdateExpectedByYearEnd; break; } History.InsertHistoryOnUpdateFundStatusData(action_code, organization, fiscal_year, month, intGroupCode, doc_number, Utility.DisplayMoneyFormat(mAmount), explanation, user); //clear fund status report state: FSSummaryReport.DataObsoleteFlag(fiscal_year, organization); } if (obj_xml.DocumentElement.Name == "delete_entry") { var node = obj_xml.DocumentElement.FirstChild; var entry_type = node.Attributes.GetNamedItem("type").Value.Trim(); var entry_id = node.Attributes.GetNamedItem("id").Value.Trim(); var organization = node.Attributes.GetNamedItem("org").Value.Trim(); var fiscal_year = node.Attributes.GetNamedItem("fy").Value.Trim(); var month = node.Attributes.GetNamedItem("bm").Value.Trim(); var group_code = node.Attributes.GetNamedItem("gcd").Value.Trim(); var amount = node.Attributes.GetNamedItem("amount").Value.Trim(); var doc_number = node.Attributes.GetNamedItem("doc").Value.Trim(); var intEntryType = Int32.Parse(entry_type); var intEntryID = Int32.Parse(entry_id); var mAmount = Decimal.Parse(amount); //update data: FundStatus.DeleteUserEntryRecord(intEntryID, user); //insert history log: //insert history action as Update not as Delete because of displaying info message to user when last data update has been done. //if in future will be special request on separate history entries - will be changed. var action_code = 0; switch (intEntryType) { case (int)FundsStatusUserEntryType.ueOverUnderAccrued: action_code = (int)HistoryActions.haUpdateOverUnderAccrued; break; case (int)FundsStatusUserEntryType.ueOneTimeAdjustment: action_code = (int)HistoryActions.haUpdateOneTimeAdjustment; break; case (int)FundsStatusUserEntryType.ueExpectedByYearEnd: action_code = (int)HistoryActions.haUpdateExpectedByYearEnd; break; } History.InsertHistoryOnUpdateFundStatusData(action_code, organization, fiscal_year, month, Int32.Parse(group_code), doc_number, Utility.DisplayMoneyFormat(mAmount), "the record has been deleted", user); //clear fund status report state: FSSummaryReport.DataObsoleteFlag(fiscal_year, organization); } if (obj_xml.DocumentElement.Name == "recalc_report") { var node = obj_xml.DocumentElement.FirstChild; var business_line = node.Attributes.GetNamedItem("bl").Value; var organization = node.Attributes.GetNamedItem("org").Value; var fiscal_year = node.Attributes.GetNamedItem("fy").Value; //rebuild fund status report state: FundStatus.RecalculateFSReport(fiscal_year, organization, business_line); History.InsertHistoryOnRebuildFSReport(fiscal_year, organization, business_line, user); } if (obj_xml.DocumentElement.Name == "recalc_rwa") { var node = obj_xml.DocumentElement.FirstChild; var organization = node.Attributes.GetNamedItem("org").Value; var fiscal_year = node.Attributes.GetNamedItem("fy").Value; var month = node.Attributes.GetNamedItem("m").Value; var projection = node.Attributes.GetNamedItem("rwa").Value; if (FundStatus.UpdateRWAProjection(fiscal_year, month, organization, projection, user)) { FSSummaryReport.DataObsoleteFlag(fiscal_year, organization); History.InsertHistoryOnUpdateRWAProjection(organization, fiscal_year, month, projection, user); } } if (str_result == "") { str_result = "<ok/>"; } } catch (Exception ex) { str_result = "<error><err_msg msg='" + ex.Message + "' /></error>"; } Response.ContentType = "text/xml"; Response.Write(str_result); Response.Flush(); }