/// <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> /// 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); } }
private Boolean LoadStewardshipReportData(TRptCalculator ACalc) { Shared.MReporting.TParameterList pm = ACalc.GetParameters(); pm.Add("param_ledger_number_i", FLedgerNumber); ArrayList reportParam = pm.Elems; Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); foreach (Shared.MReporting.TParameter p in reportParam) { if (p.name.StartsWith("param") && (p.name != "param_calculation")) { paramsDictionary.Add(p.name, p.value); } } // pm.Add("param_current_period", uco_GeneralSettings.GetCurrentPeiod()); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship"); // // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter.. String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber); ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddStringParameter("param_currency_formatter", "0,0.000"); Boolean HasData = (ReportTable.Rows.Count > 0); if (!HasData) { MessageBox.Show(Catalog.GetString("No Stewardship entries found for selected Run Number."), "Stewardship"); } return(HasData); }
/// <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 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); } }
/// <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> /// Data loader for HOSA data, /// Made static so it can be called from Stewardship Reports /// </summary> public static Boolean LoadReportDataStaticInner(Form ParentForm, TFrmPetraReportingUtils UtilsObject, FastReportsWrapper ReportingEngine, TRptCalculator ACalc) { Shared.MReporting.TParameterList pm = ACalc.GetParameters(); String Csv = ""; // // My "a_transaction" table forms the lower half of the HOSA: // All transactions for all the "Expense" accounts for the selected Cost Centre within the selected dates or periods. String LedgerFilter = "a_ledger_number_i=" + pm.Get("param_ledger_number_i").ToInt32(); String TranctDateFilter = ""; // Optional Date Filter, as periods or dates String CostCentreCodes = pm.Get("param_cost_centre_codes").ToString(); if (CostCentreCodes == String.Empty) { MessageBox.Show(Catalog.GetString("Please select one or more Cost Centres."), "HOSA"); return(false); } String CostCentreFilter = ""; if (CostCentreCodes == "ALL") { CostCentreFilter = " AND a_cost_centre.a_cost_centre_type_c='Foreign' "; } else { CostCentreCodes = CostCentreCodes.Replace('"', '\''); ACalc.AddStringParameter("param_cost_centre_codes", CostCentreCodes); CostCentreFilter = " AND a_cost_centre.a_cost_centre_code_c IN (" + CostCentreCodes + ") "; } if (pm.Get("param_period").ToBool() == true) { Int32 PeriodStart = pm.Get("param_start_period_i").ToInt32(); Int32 PeriodEnd = pm.Get("param_end_period_i").ToInt32(); DateTime DateStart = pm.Get("param_start_date").ToDate(); DateTime DateEnd = pm.Get("param_end_date").ToDate(); ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails); ALedgerRow LedgerRow = LedgerDetailsTable[0]; Boolean IsClosed = (!pm.Get("param_current_financial_year").ToBool() || (PeriodEnd < LedgerRow.CurrentPeriod)); ACalc.AddParameter("param_period_closed", IsClosed); Boolean IsCurrent = (pm.Get("param_current_financial_year").ToBool() && (PeriodEnd == LedgerRow.CurrentPeriod)); ACalc.AddParameter("param_period_current", IsCurrent); String PeriodTitle = " (" + DateStart.ToString("dd-MMM-yyyy") + " - " + DateEnd.ToString("dd-MMM-yyyy") + ")"; if (PeriodEnd > PeriodStart) { PeriodTitle = String.Format("{0} - {1}", PeriodStart, PeriodEnd) + PeriodTitle; } else { PeriodTitle = String.Format("{0}", PeriodStart) + PeriodTitle; } pm.Add("param_date_title", PeriodTitle); } else { String PeriodTitle = " " + pm.Get("param_start_date").DateToString("yyyy-MM-dd") + " - " + pm.Get("param_end_date").DateToString("yyyy-MM-dd"); pm.Add("param_date_title", PeriodTitle); } TranctDateFilter = "a_transaction_date_d>='" + pm.Get("param_start_date").DateToString("yyyy-MM-dd") + "' AND a_transaction_date_d<='" + pm.Get("param_end_date").DateToString("yyyy-MM-dd") + "'"; Csv = StringHelper.AddCSV(Csv, "AAccount/SELECT * FROM a_account WHERE " + LedgerFilter + " AND a_posting_status_l=true AND a_account_active_flag_l=true"); Csv = StringHelper.AddCSV(Csv, "ACostCentre/SELECT * FROM a_cost_centre WHERE " + LedgerFilter + CostCentreFilter + " AND a_posting_cost_centre_flag_l=true AND a_cost_centre_active_flag_l=true"); Csv = StringHelper.AddCSV( Csv, "ATransaction/SELECT a_transaction.* FROM a_transaction, a_cost_centre WHERE a_transaction." + LedgerFilter + " AND " + TranctDateFilter + " AND NOT (a_system_generated_l = true AND (a_narrative_c LIKE 'Gifts received - Gift Batch%' OR a_narrative_c LIKE 'GB - Gift Batch%' OR a_narrative_c LIKE 'Year end re-allocation%'))" + " AND a_transaction.a_ledger_number_i = a_cost_centre.a_ledger_number_i " + " AND a_transaction.a_cost_centre_code_c = a_cost_centre.a_cost_centre_code_c " + CostCentreFilter + " ORDER BY a_account_code_c, a_transaction_date_d"); GLReportingTDS ReportDs = TRemote.MReporting.WebConnectors.GetReportingDataSet(Csv); ArrayList reportParam = ACalc.GetParameters().Elems; Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); foreach (Shared.MReporting.TParameter p in reportParam) { if (p.name.StartsWith("param") && (p.name != "param_calculation")) { paramsDictionary.Add(p.name, p.value); } } DataTable GiftsTable = TRemote.MReporting.WebConnectors.GetReportDataTable("HOSA", paramsDictionary); DataTable KeyMinGiftsTable = TRemote.MReporting.WebConnectors.GetReportDataTable("FieldGifts", paramsDictionary); // // I'm going to get rid of any Cost Centres that saw no activity in the requested period: for (Int32 Idx = ReportDs.ACostCentre.Rows.Count - 1; Idx >= 0; Idx--) { ACostCentreRow Row = ReportDs.ACostCentre[Idx]; ReportDs.ATransaction.DefaultView.RowFilter = String.Format("a_cost_centre_code_c='{0}'", Row.CostCentreCode); GiftsTable.DefaultView.RowFilter = String.Format("CostCentre='{0}'", Row.CostCentreCode); if ((ReportDs.ATransaction.DefaultView.Count == 0) && (GiftsTable.DefaultView.Count == 0)) { ReportDs.ACostCentre.Rows.Remove(Row); } } if (ParentForm.IsDisposed) { return(false); } if (GiftsTable == null) { UtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } ReportingEngine.RegisterData(GiftsTable, "Gifts"); ReportingEngine.RegisterData(KeyMinGiftsTable, "FieldGifts"); ReportingEngine.RegisterData(ReportDs.AAccount, "a_account"); ReportingEngine.RegisterData(ReportDs.ACostCentre, "a_costCentre"); ReportingEngine.RegisterData(ReportDs.ATransaction, "a_transaction"); Boolean HasData = (ReportDs.ATransaction.Rows.Count > 0) || (GiftsTable.Rows.Count > 0); if (!HasData) { MessageBox.Show(Catalog.GetString("No Transactions found for selected Cost Centres."), "HOSA"); } return(HasData); }
} // Load Hosa Report Data private Boolean LoadStewardshipReportData(TRptCalculator ACalc) { Dictionary <String, TVariant> paramsDictionary = InitialiseDictionary(ACalc); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship"); Boolean HasData = (ReportTable.Rows.Count > 0); if (!HasData) { FStatusMsg += Catalog.GetString("No Stewardship entries found for selected Run Number."); } TParameterList Params = ACalc.GetParameters(); if ((!Params.Get("param_design_template").ToBool()) && (rbtEmailStewardship.Checked)) { // This gets email defaults from the user settings table TUC_EmailPreferences.LoadEmailDefaults(); // This gets some of the settings from the server configuration. We no longer get these items from local PC. // SmtpUsername and SmtpPassword will usually be null string smtpHost, smtpUsername, smtpPassword; int smtpPort; bool smtpUseSSL; TRemote.MSysMan.Application.WebConnectors.GetServerSmtpSettings(out smtpHost, out smtpPort, out smtpUseSSL, out smtpUsername, out smtpPassword); if ((smtpHost == string.Empty) || (smtpPort < 0)) { FStatusMsg += Catalog.GetString( "\r\nCannot send email because 'smtpHost' and/or 'smtpPort' are not configured in the OP server configuration file."); return(false); } TSmtpSender EmailSender = new TSmtpSender(smtpHost, smtpPort, smtpUseSSL, smtpUsername, smtpPassword, ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { FStatusMsg += String.Format( Catalog.GetString( "\r\nFailed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned: \"{0}\""), EmailSender.FErrorStatus ); return(false); } String MyCostCentreCode = String.Format("{0:##00}00", FLedgerNumber); String PeriodEnd = Params.Get("param_end_date").ToDate().ToString("dd/MM/yyyy"); Int32 RunNumber = Params.Get("param_cmbICHNumber").ToInt32(); String CsvAttachment = String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5}\n", // "** Header **",30/11/2014,\"0200\",09/12/2014,\"USD\",0" "** Header **", // software originator and version ID PeriodEnd, MyCostCentreCode, // Field Cost Centre Code DateTime.Now.ToString("dd/MM/yyyy"), FLedgerRow.BaseCurrency, // Stewardship Report CSV always in Base Currency RunNumber // Run number ); foreach (DataRow Row in ReportTable.Rows) { CsvAttachment += String.Format("\"{0}\",{1},{2},{3}\n", Row["CostCentreCode"].ToString(), Convert.ToDecimal(Row["Income"]).ToString("0.00", CultureInfo.InvariantCulture), // Stewardship Report CSV always in Base Currency Convert.ToDecimal(Row["Expense"]).ToString("0.00", CultureInfo.InvariantCulture), Convert.ToDecimal(Row["Xfer"]).ToString("0.00", CultureInfo.InvariantCulture) ); } // Andrea wants this systemj default to be manually added to database when we are ready for a system to send ICH emails if (!TSystemDefaults.IsSystemDefaultDefined(STEWARDSHIP_EMAIL_ADDRESS)) { FStatusMsg += Catalog.GetString("\r\n Stewardship email address not configured in System Defaults."); return(false); } String EmailRecipient = TSystemDefaults.GetStringDefault(STEWARDSHIP_EMAIL_ADDRESS); String EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(new MemoryStream(Encoding.ASCII.GetBytes(CsvAttachment)), "Stewardship_" + MyCostCentreCode + ".csv"); Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), EmailRecipient, //[email protected] "Stewardship Report [" + MyCostCentreCode + "] Period end: " + PeriodEnd + " Run#: " + RunNumber, EmailBody); if (SentOk) { FStatusMsg += Catalog.GetString("\r\nStewardship report emailed to ICH."); } else { FStatusMsg += Catalog.GetString("\r\nFailed to send Stewardship email to ICH."); } return(false); } return(HasData); } // Load Stewardship Report Data
} // Load Hosa Report Data private Boolean LoadStewardshipReportData(TRptCalculator ACalc) { Dictionary <String, TVariant> paramsDictionary = InitialiseDictionary(ACalc); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship"); Boolean HasData = (ReportTable.Rows.Count > 0); if (!HasData) { FStatusMsg += Catalog.GetString("No Stewardship entries found for selected Run Number."); } TParameterList Params = ACalc.GetParameters(); if ((!Params.Get("param_design_template").ToBool()) && (rbtEmailStewardship.Checked)) { TUC_EmailPreferences.LoadEmailDefaults(); TSmtpSender EmailSender = new TSmtpSender( TUserDefaults.GetStringDefault("SmtpHost"), TUserDefaults.GetInt16Default("SmtpPort"), TUserDefaults.GetBooleanDefault("SmtpUseSsl"), TUserDefaults.GetStringDefault("SmtpUser"), TUserDefaults.GetStringDefault("SmtpPassword"), ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { FStatusMsg += String.Format( Catalog.GetString( "\r\nFailed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned: \"{0}\""), EmailSender.FErrorStatus ); return(false); } String MyCostCentreCode = String.Format("{0:##00}00", FLedgerNumber); String PeriodEnd = Params.Get("param_end_date").ToDate().ToString("dd/MM/yyyy"); Int32 RunNumber = Params.Get("param_cmbICHNumber").ToInt32(); String CsvAttachment = String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5}\n", // "OP:1",30/11/2014,\"0200\",09/12/2014,\"USD\",0" "OP:1", // software originator and version ID PeriodEnd, MyCostCentreCode, // Field Cost Centre Code DateTime.Now.ToString("dd/MM/yyyy"), FLedgerRow.BaseCurrency, // Stewardship Report CSV always in Base Currency RunNumber // Run number ); foreach (DataRow Row in ReportTable.Rows) { CsvAttachment += String.Format("\"{0}\",{1},{2},{3}\n", Row["CostCentreCode"].ToString(), Convert.ToDecimal(Row["Income"]).ToString("0.00", CultureInfo.InvariantCulture), // Stewardship Report CSV always in Base Currency Convert.ToDecimal(Row["Expense"]).ToString("0.00", CultureInfo.InvariantCulture), Convert.ToDecimal(Row["Xfer"]).ToString("0.00", CultureInfo.InvariantCulture) ); } String EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(new MemoryStream(Encoding.ASCII.GetBytes(CsvAttachment)), "Stewardship_" + MyCostCentreCode + ".csv"); Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), "*****@*****.**", //[email protected] "Stewardship Report [" + MyCostCentreCode + "] Period end: " + PeriodEnd + " Run#: " + RunNumber, EmailBody); if (SentOk) { FStatusMsg += Catalog.GetString("\r\nStewardship report emailed to ICH."); } else { FStatusMsg += Catalog.GetString("\r\nFailed to send Stewardship email to ICH."); } return(false); } return(HasData); } // Load Stewardship Report Data