/// <summary> /// Print or reprint the posting report for this batch. /// </summary> public static void PrintPostingRegister(Int32 ALedgerNumber, Int32 ABatchNumber, Boolean AEditTemplate = false) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Batch Posting Register"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(ALedgerNumber, ABatchNumber); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = BatchTDS.ALedger[0]; //Call RegisterData to give the data to the template ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch"); ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal"); ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction"); Calc.AddParameter("param_batch_number_i", ABatchNumber); Calc.AddParameter("param_ledger_number_i", ALedgerNumber); String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerName); if (AEditTemplate) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary>Helper for the report printing ClientTask</summary> /// <param name="ReportName"></param> /// <param name="paramStr"></param> public static void PrintReportNoUi(String ReportName, String paramStr) { String[] Params = paramStr.Split(','); Int32 LedgerNumber = -1; Int32 BatchNumber = -1; /* * String Msg = ReportName + "\n"; * foreach (String param in Params) * { * Msg += (param + "\n"); * } * MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi"); */ FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } Dictionary <String, TVariant>paramsDictionary = new Dictionary <string, TVariant>(); TRptCalculator Calc = new TRptCalculator(); // // Copy paramters to report: foreach (String param in Params) { String[] term = param.Split('='); if (term.Length > 1) { if (term[1][0] == '"') // This is a string { String val = term[1].Substring(1, term[1].Length - 2); Calc.AddStringParameter(term[0], val); paramsDictionary.Add(term[0], new TVariant(val)); } else // This is a number - Int32 assumed. { Int32 IntTerm; if (Int32.TryParse(term[1], out IntTerm)) { Calc.AddParameter(term[0], IntTerm); paramsDictionary.Add(term[0], new TVariant(IntTerm)); // // As I'm adding these values, I'll keep a note of any that may be useful later.. switch (term[0]) { case "param_ledger_number_i": { LedgerNumber = IntTerm; break; } case "param_batch_number_i": { BatchNumber = IntTerm; break; } } } else { MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi"); } } } else { MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi"); } } // foreach param // // Get Data for report: switch (ReportName) { case "Batch Posting Register": { if ((LedgerNumber != -1) && (BatchNumber != -1)) { ReportingEngine.RegisterBatchPostingData(Calc, LedgerNumber, BatchNumber); } else { MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi"); } break; } case "Gift Batch Detail": { DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary); ReportingEngine.RegisterData(ReportTable, "GiftBatchDetail"); break; } } // switch // I'm not in the User Interface thread, so I can use an invoke here: Application.OpenForms[0].Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); }); } // PrintReportNoUi
} // AutoEmailReports /// <summary> /// /// </summary> /// <param name="ReportName"></param> /// <param name="paramStr"></param> public static void PrintReportNoUi(String ReportName, String paramStr) { String[] Params = paramStr.Split(','); Int32 LedgerNumber = -1; Int32 BatchNumber = -1; /* * String Msg = ReportName + "\n"; * foreach (String param in Params) * { * Msg += (param + "\n"); * } * MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi"); */ FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } TRptCalculator Calc = new TRptCalculator(); // // Copy paramters to report: foreach (String param in Params) { String[] term = param.Split('='); if (term.Length > 1) { if (term[1][0] == '"') // This is a string { Calc.AddStringParameter(term[0], term[1].Substring(1, term[1].Length - 2)); } else // This is a number - Int32 assumed. { Int32 IntTerm; if (Int32.TryParse(term[1], out IntTerm)) { Calc.AddParameter(term[0], IntTerm); // // As I'm adding these values, I'll keep a note of any that may be useful later.. switch (term[0]) { case "param_ledger_number_i": { LedgerNumber = IntTerm; break; } case "param_batch_number_i": { BatchNumber = IntTerm; break; } } } else { MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi"); } } } else { MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi"); } } // foreach // // Get Data for report: switch (ReportName) { case "Batch Posting Register": { if ((LedgerNumber != -1) && (BatchNumber != -1)) { GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(LedgerNumber, BatchNumber); ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch"); ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal"); ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction"); } else { MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi"); } break; } } // switch ReportingEngine.GenerateReport(Calc); } // PrintReportNoUi
/// <summary> /// Print out the Hierarchy using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Account Hierarchy"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } if (!FMainDS.AAccount.Columns.Contains("AccountPath")) { FMainDS.AAccount.Columns.Add("AccountPath", typeof(String)); FMainDS.AAccount.Columns.Add("AccountLevel", typeof(Int32)); } DataView PathView = new DataView(FMainDS.AAccountHierarchyDetail); PathView.Sort = "a_reporting_account_code_c"; DataView AccountView = new DataView(FMainDS.AAccount); AccountView.Sort = "a_account_code_c"; // I need to make the "AccountPath" field that will be used to sort the table for printout: foreach (DataRowView rv in PathView) { DataRow Row = rv.Row; String AccountCode = Row["a_reporting_account_code_c"].ToString(); String Path = Row["a_report_order_i"] + "-" + AccountCode + '~'; Int32 Level = 0; String ReportsTo = Row["a_account_code_to_report_to_c"].ToString(); while (ReportsTo != "") { Int32 ParentIdx = PathView.Find(ReportsTo); if (ParentIdx >= 0) { DataRow ParentRow = PathView[ParentIdx].Row; ReportsTo = ParentRow["a_account_code_to_report_to_c"].ToString(); Path = ParentRow["a_report_order_i"] + "-" + ParentRow["a_reporting_account_code_c"].ToString() + "~" + Path; Level++; if (Level > 100) // Surely this is a fault. If I just break here, { break; // the report will print and I should be able to see what the fault is. } } else { ReportsTo = ""; } } Int32 AccountIdx = AccountView.Find(AccountCode); DataRow AccountRow = AccountView[AccountIdx].Row; AccountRow["AccountPath"] = Path; AccountRow["AccountLevel"] = Level; } AccountView.Sort = "AccountPath"; DataTable SortedByPath = AccountView.ToTable(); ReportingEngine.RegisterData(SortedByPath, "AccountHierarchy"); ReportingEngine.RegisterData(FMainDS.AAnalysisAttribute, "AnalysisAttribute"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
} // AutoEmailReports /// <summary>Helper for the report printing ClientTask</summary> /// <remarks>This way of printing reports shows some reliability concerns so it is not currently used.</remarks> /// <param name="ReportName"></param> /// <param name="paramStr"></param> public static void PrintReportNoUi(String ReportName, String paramStr) { String[] Params = paramStr.Split(','); Int32 ledgerNumber = -1; Int32 batchNumber = -1; FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); TRptCalculator Calc = new TRptCalculator(); // // Copy paramters to report: foreach (String param in Params) { String[] term = param.Split('='); if (term.Length > 1) { if (term[1][0] == '"') // This is a string { String val = term[1].Substring(1, term[1].Length - 2); Calc.AddStringParameter(term[0], val); paramsDictionary.Add(term[0], new TVariant(val)); } else // This is a number - Int32 assumed. { Int32 IntTerm; if (Int32.TryParse(term[1], out IntTerm)) { Calc.AddParameter(term[0], IntTerm); paramsDictionary.Add(term[0], new TVariant(IntTerm)); // // As I'm adding these values, I'll keep a note of any that may be useful later.. switch (term[0]) { case "param_ledger_number_i": { ledgerNumber = IntTerm; break; } case "param_batch_number_i": { batchNumber = IntTerm; break; } } } else { MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi"); } } } else { MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi"); } } // foreach param // I'm not in the User Interface thread, so I can use an invoke here: TFormsList.GFormsList.MainMenuForm.Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); }); } // PrintReportNoUi
// // New methods using the Fast-reports DLL: // This form generates a clutch of different reports. // In this method, a new FastReportsWrapper is used for each selected report type. private void GenerateAllSelectedReports(TRptCalculator ACalc) { FStatusMsg = ""; if (chkHOSA.Enabled && chkHOSA.Checked) { FStatusMsg += Catalog.GetString("\r\nAll HOSAs:"); MyFastReportsPlugin = new FastReportsWrapper("HOSA"); MyFastReportsPlugin.SetDataGetter(LoadHosaReportData); MyFastReportsPlugin.GenerateReport(ACalc); } if (chkStewardship.Enabled && chkStewardship.Checked) { FStatusMsg += Catalog.GetString("\r\nStewardship Report:"); MyFastReportsPlugin = new FastReportsWrapper("Stewardship"); MyFastReportsPlugin.SetDataGetter(LoadStewardshipReportData); MyFastReportsPlugin.GenerateReport(ACalc); } if (chkFees.Enabled && chkFees.Checked) { FStatusMsg += Catalog.GetString("\r\nFees Report:"); MyFastReportsPlugin = new FastReportsWrapper("Fees"); MyFastReportsPlugin.SetDataGetter(LoadFeesReportData); MyFastReportsPlugin.GenerateReport(ACalc); } // complex way of stepping around the Windows non-thread-safe controls problem! FStatusMsg += Catalog.GetString("\r\n\r\nReport generation complete."); this.Invoke(new CrossThreadUpdate(ShowReportStatus)); }
} // AutoEmailReports /// <summary> /// /// </summary> /// <param name="ReportName"></param> /// <param name="paramStr"></param> public static void PrintReportNoUi(String ReportName, String paramStr) { String[] Params = paramStr.Split(','); Int32 LedgerNumber = -1; Int32 BatchNumber = -1; /* * String Msg = ReportName + "\n"; * foreach (String param in Params) * { * Msg += (param + "\n"); * } * MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi"); */ FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } TRptCalculator Calc = new TRptCalculator(); // // Copy paramters to report: foreach (String param in Params) { String[] term = param.Split('='); if (term.Length > 1) { if (term[1][0] == '"') // This is a string { Calc.AddStringParameter(term[0], term[1].Substring(1, term[1].Length - 2)); } else // This is a number - Int32 assumed. { Int32 IntTerm; if (Int32.TryParse(term[1], out IntTerm)) { Calc.AddParameter(term[0], IntTerm); // // As I'm adding these values, I'll keep a note of any that may be useful later.. switch (term[0]) { case "param_ledger_number_i": { LedgerNumber = IntTerm; break; } case "param_batch_number_i": { BatchNumber = IntTerm; break; } } } else { MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi"); } } } else { MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi"); } } // foreach // // Get Data for report: switch (ReportName) { case "Batch Posting Register": { if ((LedgerNumber != -1) && (BatchNumber != -1)) { GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(LedgerNumber, BatchNumber); ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch"); ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal"); ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction"); } else { MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi"); } break; } } // switch ReportingEngine.GenerateReport(Calc); } // PrintReportNoUi
/// <summary> /// Print out the Hierarchy using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { TLogging.Log("CostCentreHierarchy.File Print.."); FastReportsWrapper ReportingEngine = new FastReportsWrapper("Cost Centre Hierarchy"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } if (!FMainDS.ACostCentre.Columns.Contains("CostCentrePath")) { FMainDS.ACostCentre.Columns.Add("CostCentrePath", typeof(String)); FMainDS.ACostCentre.Columns.Add("CostCentreLevel", typeof(Int32)); } DataView PathView = new DataView(FMainDS.ACostCentre); PathView.Sort = "a_cost_centre_code_c"; TLogging.Log("CostCentreHierarchy.File Print calculating paths.."); // I need to make the "CostCentrePath" field that will be used to sort the table for printout: foreach (DataRowView rv in PathView) { DataRow Row = rv.Row; String Path = Row["a_cost_centre_code_c"].ToString() + '~'; Int32 Level = 0; String ReportsTo = Row["a_cost_centre_to_report_to_c"].ToString(); while (ReportsTo != "") { Int32 ParentIdx = PathView.Find(ReportsTo); if (ParentIdx >= 0) { DataRow ParentRow = PathView[ParentIdx].Row; ReportsTo = ParentRow["a_cost_centre_to_report_to_c"].ToString(); Path = ParentRow["a_cost_centre_code_c"].ToString() + "~" + Path; Level++; if (Level > 100) // Surely this is a fault. If I just break here, { break; // the report will print and I should be able to see what the fault is. } } else { ReportsTo = ""; } } Row["CostCentrePath"] = Path; Row["CostCentreLevel"] = Level; } PathView.Sort = "CostCentrePath"; DataTable SortedByPath = PathView.ToTable(); TLogging.Log("CostCentreHierarchy.File Print paths all done."); ReportingEngine.RegisterData(SortedByPath, "CostCentreHierarchy"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_nunmber", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); TLogging.Log("CostCentreHierarchy.File Print calling FastReport..."); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary> /// Print out the Motivation Details using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } // Add in the Fees applicable for each row: if (!FMainDS.AMotivationDetail.Columns.Contains("Fees")) { FMainDS.AMotivationDetail.Columns.Add("Fees", typeof(String)); FMainDS.AMotivationDetail.Columns.Add("KeyMin", typeof(String)); } foreach (AMotivationDetailRow Row in FMainDS.AMotivationDetail.Rows) { FMainDS.AMotivationDetailFee.DefaultView.RowFilter = String.Format( "a_motivation_group_code_c='{0}' AND a_motivation_detail_code_c='{1}'", Row.MotivationGroupCode, Row.MotivationDetailCode); String Fees = ""; foreach (DataRowView rv in FMainDS.AMotivationDetailFee.DefaultView) { AMotivationDetailFeeRow FeeRow = (AMotivationDetailFeeRow)rv.Row; if (Fees != "") { Fees += ", "; } Fees += FeeRow.FeeCode; } Row["Fees"] = Fees; if (Row.RecipientKey != 0) { String mPartnerShortName; TPartnerClass mPartnerClass; if (TServerLookup.TMPartner.GetPartnerShortName(Row.RecipientKey, out mPartnerShortName, out mPartnerClass, true)) { Row["KeyMin"] = mPartnerShortName; } } } // foreach // // Ensure the proper sorting for the printout: FMainDS.AMotivationDetail.DefaultView.Sort = "a_motivation_group_code_c, a_motivation_detail_code_c"; ReportingEngine.RegisterData(FMainDS.AMotivationDetail.DefaultView.ToTable(), "MotivationDetail"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); Calc.AddParameter("param_TD", FTaxDeductiblePercentageEnabled); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary>Helper for the report printing ClientTask</summary> /// <param name="ReportName"></param> /// <param name="paramStr"></param> public static void PrintReportNoUi(String ReportName, String paramStr) { String[] Params = paramStr.Split(','); Int32 LedgerNumber = -1; Int32 BatchNumber = -1; /* * String Msg = ReportName + "\n"; * foreach (String param in Params) * { * Msg += (param + "\n"); * } * MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi"); */ FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); TRptCalculator Calc = new TRptCalculator(); // // Copy paramters to report: foreach (String param in Params) { String[] term = param.Split('='); if (term.Length > 1) { if (term[1][0] == '"') // This is a string { String val = term[1].Substring(1, term[1].Length - 2); Calc.AddStringParameter(term[0], val); paramsDictionary.Add(term[0], new TVariant(val)); } else // This is a number - Int32 assumed. { Int32 IntTerm; if (Int32.TryParse(term[1], out IntTerm)) { Calc.AddParameter(term[0], IntTerm); paramsDictionary.Add(term[0], new TVariant(IntTerm)); // // As I'm adding these values, I'll keep a note of any that may be useful later.. switch (term[0]) { case "param_ledger_number_i": { LedgerNumber = IntTerm; break; } case "param_batch_number_i": { BatchNumber = IntTerm; break; } } } else { MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi"); } } } else { MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi"); } } // foreach param // // Get Data for report: switch (ReportName) { case "Batch Posting Register": { if ((LedgerNumber != -1) && (BatchNumber != -1)) { ReportingEngine.RegisterBatchPostingData(Calc, LedgerNumber, BatchNumber); } else { MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi"); } break; } case "Gift Batch Detail": { DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary); ReportingEngine.RegisterData(ReportTable, "GiftBatchDetail"); break; } } // switch // I'm not in the User Interface thread, so I can use an invoke here: TFormsList.GFormsList.MainMenuForm.Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); }); //Application.OpenForms[0].Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); }); } // PrintReportNoUi
// // New methods using the Fast-reports DLL: // This form generates a clutch of different reports. // In this method, a new FastReportsWrapper is used for each selected report type. private void GenerateAllSelectedReports(TRptCalculator ACalc) { // "Stewardship"; MyFastReportsPlugin = new FastReportsWrapper("Stewardship"); MyFastReportsPlugin.SetDataGetter(LoadStewardshipReportData); MyFastReportsPlugin.GenerateReport(ACalc); }
/// <summary> /// Print out the Hierarchy using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Duplicate Address Check"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } ReportingEngine.RegisterData(FDuplicateLocations, "DuplicateLocations"); TRptCalculator Calc = new TRptCalculator(); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary> /// Print out the Motivation Details using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } ReportingEngine.RegisterData(FMainDS.AMotivationDetail, "MotivationDetail"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }