private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_all_partners", rbtAllPartners.Checked); ACalc.AddParameter("param_extract", rbtExtract.Checked); if (rbtExtract.Checked) { ACalc.AddParameter("param_extract_name", txtExtract.Text); } ACalc.AddParameter("param_recipientkey", txtRecipient.Text); if ((txtMotivationDetail.Text.Length == 0) || (txtMotivationDetail.Text == "*")) { ACalc.AddParameter("param_motivation_detail", "%"); } else { ACalc.AddParameter("param_motivation_detail", txtMotivationDetail.Text.Replace('*', '%')); } if ((txtMotivationGroup.Text.Length == 0) || (txtMotivationGroup.Text == "*")) { ACalc.AddParameter("param_motivation_group", "%"); } else { ACalc.AddParameter("param_motivation_group", txtMotivationGroup.Text.Replace('*', '%')); } int NumDays = Convert.ToInt32(txtToleranceDays.Text); DateTime SelectionStartDate = dtpEndDate.Date.Value.AddDays(-NumDays); DateTime SelectionEndDate = dtpEndDate.Date.Value.AddDays(NumDays); ACalc.AddParameter("param_selection_start_date", SelectionStartDate); ACalc.AddParameter("param_selection_end_date", SelectionEndDate); int ColumnNumbers = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); for (int Counter = 0; Counter < ColumnNumbers; ++Counter) { String ParameterName = ACalc.GetParameters().Get("param_calculation", Counter).ToString(); if (ParameterName == "Gift this year") { ACalc.AddParameter("ColumnCaption", dtpEndDate.Date.Value.Year.ToString(), Counter); ACalc.AddParameter("param_gift_amount_column", Counter); } else if (ParameterName == "Gift year - 1") { ACalc.AddParameter("ColumnCaption", (dtpEndDate.Date.Value.Year - 1).ToString(), Counter); ACalc.AddParameter("param_gift_amount_column1", Counter); } else if (ParameterName == "Gift year - 2") { ACalc.AddParameter("ColumnCaption", (dtpEndDate.Date.Value.Year - 2).ToString(), Counter); ACalc.AddParameter("param_gift_amount_column2", Counter); } } }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { 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.ContainsKey(p.name))) { paramsDictionary.Add(p.name, p.value); } } Int32 ParamNestingDepth = 3; String DepthOption = paramsDictionary["param_depth"].ToString(); if (DepthOption == "summary") { ParamNestingDepth = 1; } paramsDictionary.Add("param_nesting_depth", new TVariant(ParamNestingDepth)); String RootCostCentre = "[" + FLedgerNumber + "]"; paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre)); ACalc.AddParameter("param_current_period", uco_GeneralSettings.GetCurrentPeiod()); // // The table contains extra rows for "headers" and "footers", facilitating the hierarchical printout. DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("BalanceSheet", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "BalanceSheet"); // // I need to get the name of the current ledger.. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } ACalc.AddStringParameter("param_ledger_name", LedgerName); return(true); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_batch_number_i", FBatchNumber); }
/// <summary> /// read the values from the controls and give them to the calculator /// </summary> /// <param name="ACalculator"></param> /// <param name="AReportAction"></param> public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction) { if (rbtConference.Checked) { ACalculator.AddParameter("param_conferenceselection", "one conference"); } else if (rbtAllConferences.Checked) { ACalculator.AddParameter("param_conferenceselection", "all conferences"); } if (rbtAllAttendees.Checked) { ACalculator.AddParameter("param_attendeeselection", "all attendees"); } else if (rbtExtract.Checked) { ACalculator.AddParameter("param_attendeeselection", "from extract"); } else if (rbtOneAttendee.Checked) { ACalculator.AddParameter("param_attendeeselection", "one attendee"); } ACalculator.AddParameter("param_partnerkey", txtOneAttendee.Text); ACalculator.AddParameter("param_conferencekey", txtConference.Text); ACalculator.AddParameter("param_conferencename", txtConference.LabelText); ACalculator.AddParameter("param_extractname", txtExtract.Text); TVerificationResult VerificationResult; if ((AReportAction == TReportActionEnum.raGenerate) && (rbtExtract.Checked) && (txtExtract.Text.Length == 0)) { VerificationResult = new TVerificationResult(Catalog.GetString("Select an extract for running the report."), Catalog.GetString("No extract was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && (rbtOneAttendee.Checked) && (txtOneAttendee.Text == "0000000000")) { VerificationResult = new TVerificationResult(Catalog.GetString("Select a partner for whom to run the report."), Catalog.GetString("No partner was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && (rbtConference.Checked)) { if (txtConference.Text == "0000000000") { VerificationResult = new TVerificationResult(Catalog.GetString("Select a conference to run the report against to."), Catalog.GetString("No conference was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } else { if (!TRemote.MConference.Conference.WebConnectors.ConferenceExists(Convert.ToInt64(txtConference.Text))) { VerificationResult = new TVerificationResult(Catalog.GetString("Select a conference to run the report against to."), Catalog.GetString( "Partner Key in 'Conference' is not for a conference! Select a Conference using the 'Find' Button or enter a Partner Key of a Conference manually."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } } if (FShowSelectOutreachOptionsDialog && (AReportAction == TReportActionEnum.raGenerate) && (rbtConference.Checked) && (FPetraUtilsObject.GetVerificationResultCount() == 0)) { List <KeyValuePair <long, string> > ConferenceList; DialogResult DlgResult = TFrmSelectOutreachOption.OpenSelectOutreachOptionDialog( Convert.ToInt64(txtConference.Text), FPetraUtilsObject.GetForm(), true, out ConferenceList); if (((DlgResult != DialogResult.OK) || (ConferenceList.Count == 0)) && (DlgResult != DialogResult.None)) { VerificationResult = new TVerificationResult( Catalog.GetString("You must chose at least one outreach option from the \"Select Outreach Option\" Dialog."), Catalog.GetString("No outreach option was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } string OutreachOptions = ""; string OutreachOptionsCode = ""; foreach (KeyValuePair <long, string> OutreachOption in ConferenceList) { OutreachOptions = OutreachOptions + OutreachOption.Key.ToString() + ","; OutreachOptionsCode = OutreachOptionsCode + OutreachOption.Value + ","; } if (OutreachOptions.Length > 0) { // Remove the last comma OutreachOptions = OutreachOptions.Remove(OutreachOptions.Length - 1); OutreachOptionsCode = OutreachOptionsCode.Remove(OutreachOptionsCode.Length - 1); } else { OutreachOptions = txtConference.Text; OutreachOptionsCode = txtConference.LabelText; } ACalculator.AddStringParameter("param_conferenceoptions", OutreachOptions); ACalculator.AddParameter("param_conferenceoptionscode", OutreachOptionsCode); } }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { 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.ContainsKey(p.name))) { paramsDictionary.Add(p.name, p.value); } } Int32 ParamNestingDepth = 99; String DepthOption = paramsDictionary["param_depth"].ToString(); if (DepthOption == "Summary") { ParamNestingDepth = 2; } if (DepthOption == "Standard") { ParamNestingDepth = 3; } paramsDictionary.Add("param_nesting_depth", new TVariant(ParamNestingDepth)); // // The table contains Actual and Budget figures, both this period and YTD, also last year and budget last year. // It does not contain any variance (actual / budget) figures - these are calculated in the report. DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("IncomeExpense", paramsDictionary); if (this.IsDisposed) // There's no cancel function as such - if the user has pressed Esc the form is closed! { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "IncomeExpense"); // // I need to get the name of the current ledger.. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddStringParameter("param_linked_partner_cc", ""); // I may want to use this for auto_email, but usually it's unused. // // For reports that must be sent on email, one page at a time, // I'm calling the FastReports plugin multiple times, // and then I'm going to return false, which will prevent the default action using this dataset. Shared.MReporting.TParameterList pm = ACalc.GetParameters(); if ((pm.Get("param_auto_email").ToBool()) && !pm.Get("param_design_template").ToBool() ) { String CostCentreFilter = ""; String CostCentreOptions = pm.Get("param_costcentreoptions").ToString(); if (CostCentreOptions == "SelectedCostCentres") { String CostCentreList = pm.Get("param_cost_centre_codes").ToString(); CostCentreList = CostCentreList.Replace(",", "','"); // SQL IN List items in single quotes CostCentreFilter = " AND a_cost_centre_code_c in ('" + CostCentreList + "')"; } if (CostCentreOptions == "CostCentreRange") { CostCentreFilter = " AND a_cost_centre_code_c >='" + pm.Get("param_cost_centre_code_start").ToString() + "' AND a_cost_centre_code_c >='" + pm.Get("param_cost_centre_code_end").ToString() + "'"; } String Status = FastReportsWrapper.AutoEmailReports(FPetraUtilsObject, FPetraUtilsObject.FFastReportsPlugin, ACalc, FLedgerNumber, CostCentreFilter); MessageBox.Show(Status, Catalog.GetString("Income Expense Report")); return(false); } return(true); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { ACalc.AddParameter("param_field_sending", txtFieldSending.Text); ACalc.AddParameter("param_field_receiving", txtFieldReceiving.Text); ACalc.AddParameter("param_all_partners", rbtAllPartners.Checked); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { ACalc.AddColumnLayout(0, 0, 0, 19); ACalc.SetMaxDisplayColumns(1); ACalc.AddColumnCalculation(0, "Personal Data"); }
/// <summary>Called from generated code</summary> public void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { }
/// <summary> /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter. /// </summary> /// <returns>Status string that should be shown to the user</returns> public static String AutoEmailReports(TFrmPetraReportingUtils FormUtils, FastReportsWrapper ReportEngine, TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter) { Int32 SuccessfulCount = 0; String NoEmailAddr = ""; String FailedAddresses = ""; String SendReport = "Auto Email\r\n"; // // FastReport will use a temporary folder to store HTML files. // I need to ensure that the CurrectDirectory is somewhere writable: String prevCurrentDir = Directory.GetCurrentDirectory(); //Get a path in the Public Documents folder String newDir = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.CommonDocuments), "OpenPetraOrg"); //Check it exists, and if not create it if (!Directory.Exists(newDir)) { try { Directory.CreateDirectory(newDir); } catch (Exception ex) { //could not create the path so return useful debugging information: SendReport += Catalog.GetString("\r\nError - could not create directory: " + newDir); SendReport += Catalog.GetString("\r\n" + newDir); SendReport += ex.Message; return SendReport; } } Directory.SetCurrentDirectory(newDir); // // I need to find the email addresses for the linked partners I'm sending to. DataTable LinkedPartners = null; LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter); LinkedPartners.DefaultView.Sort = "CostCentreCode"; foreach (DataRowView rv in LinkedPartners.DefaultView) { DataRow LinkedPartner = rv.Row; if (LinkedPartner["EmailAddress"].ToString() != "") { ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString()); FormUtils.WriteToStatusBar("Generate " + ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"]); MemoryStream ReportStream = ReportEngine.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html); // in OpenSource OpenPetra, we do not have and use the FastReport dlls // if (ReportEngine.FfastReportInstance.ReportInfo.Description == "Empty") // { // continue; // Don't send an empty report // } ReportStream.Position = 0; // 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)) { return Catalog.GetString( "Cannot send email because 'smtpHost' and/or 'smtpPort' are not configured in the OP server configuration file."); } TSmtpSender EmailSender = new TSmtpSender(smtpHost, smtpPort, smtpUseSSL, smtpUsername, smtpPassword, ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { return String.Format( Catalog.GetString( "Failed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned : \"{0}\""), EmailSender.FErrorStatus); } String EmailBody = ""; if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment")) { EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(ReportStream, ReportEngine.FReportName + ".html"); } else { StreamReader sr = new StreamReader(ReportStream); EmailBody = sr.ReadToEnd(); } Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), LinkedPartner["EmailAddress"].ToString(), ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"], EmailBody); if (SentOk) { SuccessfulCount++; } else // Email didn't send for some reason { SendReport += String.Format( Catalog.GetString("\r\nFailed to send to {0}. Message returned: \"{1}\"."), LinkedPartner["EmailAddress"], EmailSender.FErrorStatus ); FailedAddresses += ("\r\n " + LinkedPartner["EmailAddress"]); } } else // No Email Address for this Partner { NoEmailAddr += ("\r\n " + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]); } } if (SuccessfulCount > 0) { SendReport += String.Format(Catalog.GetString("\r\n{0} emailed to {1} addresses."), ReportEngine.FReportName, SuccessfulCount) + "\r\n\r\n"; } else { SendReport += Catalog.GetString("\r\nError - no page had a linked email address."); } if (NoEmailAddr != "") { SendReport += (Catalog.GetString("\r\nThese Partners have no email addresses:") + NoEmailAddr + "\r\n"); } if (FailedAddresses != "") { SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n"); } FormUtils.WriteToStatusBar(""); Directory.SetCurrentDirectory(prevCurrentDir); return SendReport; } // AutoEmailReports
/// <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
/// <summary> /// Called from a delegate set up by me. /// </summary> /// <param name="ACalc"></param> public void GenerateExtract(TRptCalculator ACalc) { ACalc.GetParameters().Add("param_design_template", false); if (FDataGetter == null) { MessageBox.Show(Catalog.GetString("Fault: No Data Table available."), Catalog.GetString("GenerateExtract")); return; } if (!FDataGetter(ACalc)) { return; } FExtractPartnerKeyName = SelectColumnNameForExract(FClientDataTable, FExtractPartnerKeyName); if (FExtractPartnerKeyName == "") { return; } Int32 partnerKeyColumnNum = FClientDataTable.Columns[FExtractPartnerKeyName].Ordinal; TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(FPetraUtilsObject.GetForm()); string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); FPetraUtilsObject.GetForm().UseWaitCursor = true; // Create extract with given name and description and store it int ExtractId = 0; IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract(); Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys( ExtractName, ExtractDescription, out ExtractId, FClientDataTable, partnerKeyColumnNum, false); FPetraUtilsObject.GetForm().UseWaitCursor = false; if (CreateOk) { MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."), FClientDataTable.Rows.Count), Catalog.GetString("Generate Extract")); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// <summary> /// Called from a delegate set up by my constructor. /// Or if you're not using a reporting UI, you can call this directly, once the data and params have been set up. /// </summary> /// <param name="ACalc"></param> public void DesignReport(TRptCalculator ACalc) { ACalc.GetParameters().Add("param_design_template", true); if (FSelectedTemplate != null) { if (FDataGetter != null) { if (!FDataGetter(ACalc)) { return; } } FFastReportType.GetMethod("LoadFromString", new Type[] { FSelectedTemplate.XmlText.GetType() }).Invoke(FfastReportInstance, new object[] { FSelectedTemplate.XmlText }); LoadReportParams(ACalc); FFastReportType.GetMethod("Design", new Type[0]).Invoke(FfastReportInstance, null); // // The user can change the report template - if it's changed I'll update the server // (unless the template is read-only, in which case I'll need to make a copy.) object ret = FFastReportType.GetMethod("SaveToString", new Type[0]).Invoke(FfastReportInstance, null); String XmlString = (String)ret; // // I only want to check part of the report to assess whether it's changed, otherwise it always detects a change // (the modified date is changed, and the parameters may also be different.) Boolean TemplateChanged = false; Int32 Page1Pos = XmlString.IndexOf("<ReportPage"); Int32 PrevPage1Pos = FSelectedTemplate.XmlText.IndexOf("<ReportPage"); if ((Page1Pos < 1) || (PrevPage1Pos < 1)) { TemplateChanged = true; } else { if (XmlString.Substring(Page1Pos) != FSelectedTemplate.XmlText.Substring(PrevPage1Pos)) { TemplateChanged = true; } } if (TemplateChanged) { Boolean MakeACopy = false; if (FSelectedTemplate.Readonly) { if (MessageBox.Show( String.Format(Catalog.GetString("{0} cannot be ovewritten.\r\nMake a copy instead?"), FSelectedTemplate.ReportVariant), Catalog.GetString("Design Template"), MessageBoxButtons.YesNo) == DialogResult.No) { return; } MakeACopy = true; } else { if (MessageBox.Show( String.Format(Catalog.GetString("Save changes to {0}?"), FSelectedTemplate.ReportVariant), Catalog.GetString("Design Template"), MessageBoxButtons.YesNo) == DialogResult.No) { return; } } SReportTemplateTable TemplateTable = new SReportTemplateTable(); SReportTemplateRow NewRow = TemplateTable.NewRowTyped(); DataUtilities.CopyAllColumnValues(FSelectedTemplate, NewRow); TemplateTable.Rows.Add(NewRow); if (MakeACopy) { String currentUser = UserInfo.GUserInfo.UserID; NewRow.TemplateId = -1; // The value will come from the sequence NewRow.ReportVariant = String.Format(Catalog.GetString("{0} copy of {1}"), currentUser, TemplateTable[0].ReportVariant); NewRow.Author = currentUser; NewRow.Readonly = false; NewRow.Default = false; NewRow.PrivateDefault = false; } else { TemplateTable.AcceptChanges(); // Don't allow this one-row table to be seen as "new" } NewRow.XmlText = XmlString; SReportTemplateTable Tbl = TRemote.MReporting.WebConnectors.SaveTemplates(TemplateTable); Tbl.AcceptChanges(); SetTemplate(Tbl[0]); } } if (FPetraUtilsObject != null) { FPetraUtilsObject.UpdateParentFormEndOfReport(); } }
// // Called on Cancel button: private void CancelReportGeneration(TRptCalculator ACalc) { TRemote.MReporting.WebConnectors.CancelDataTableGeneration(); }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { 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.ContainsKey(p.name))) { paramsDictionary.Add(p.name, p.value); } } DataTable ReportTable = new DataTable(); ReportTable.Columns.Add("DonorKey", typeof(Int64)); ReportTable.Columns.Add("DonorShortName", typeof(String)); ReportTable.Columns.Add("DonorAddress", typeof(String)); ReportTable.Columns.Add("RecipientKey", typeof(Int64)); ReportTable.Columns.Add("RecipientShortName", typeof(String)); ReportTable.Columns.Add("RecipientAddress", typeof(String)); ReportTable.Columns.Add("MailingCode", typeof(Int32)); ReportTable.Columns.Add("CodeWithSpaces", typeof(String)); ReportTable.Columns.Add("CodeForOcr", typeof(String)); Int32 Copies; Boolean numbersOk = true; if (txtDonorKey.Enabled) { numbersOk &= txtDonorKey.FValueIsValid; } if (txtExtract.Enabled) { numbersOk &= txtExtract.FValueIsValid; } numbersOk &= txtRecipientKey.FValueIsValid; numbersOk &= Int32.TryParse(txtCopies.Text, out Copies); if (!numbersOk) { MessageBox.Show( Catalog.GetString("Please ensure that Donor, Recipient, and Copies are correctly set."), Catalog.GetString("ESR Inpayment Slip") ); return(false); } Int64 RecipientKey = Convert.ToInt64(txtRecipientKey.Text); Int32 MailingCode = 8; // If the mailing code box is left empty, I'll accept that. if (txtMailingCode.Text.Length > 0) { numbersOk = Int32.TryParse(txtMailingCode.Text, out MailingCode); if (!numbersOk) { MessageBox.Show( Catalog.GetString("For ESR, Mailing Code must be numeric."), Catalog.GetString("ESR Inpayment Slip") ); return(false); } } String MailingCodeString = MailingCode.ToString(); MailingCodeString = (MailingCodeString + "8888888").Substring(0, 6); if (rbtExtract.Checked) { Int32 ExtractId = TRemote.MPartner.Partner.WebConnectors.GetExtractId(txtExtract.Text); if (ExtractId < 0) { MessageBox.Show( Catalog.GetString("Extract with this name does not exist."), Catalog.GetString("ESR Inpayment Slip"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } ExtractTDSMExtractTable ExtractDT = TRemote.MPartner.Partner.WebConnectors.GetExtractRowsWithPartnerData(ExtractId); foreach (ExtractTDSMExtractRow Row in ExtractDT.Rows) { AddRowToTable(ReportTable, Row.PartnerKey, RecipientKey, MailingCodeString, Copies); } } else // Otherwise just a single donor was selected: { Int64 DonorKey = Convert.ToInt64(txtDonorKey.Text); AddRowToTable(ReportTable, DonorKey, RecipientKey, MailingCodeString, Copies); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "EsrInpaymentSlip"); return(true); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { String paramFields = clbFields.GetCheckedStringList(true); if (AReportAction == TReportActionEnum.raGenerate) { if (rbtSelectedFields.Checked && (paramFields.Length == 0)) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Please select at least one field."), Catalog.GetString("No fields selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if (rbtAllFields.Checked) { paramFields = clbFields.GetAllStringList(true); } if (!dtpFromDate.ValidDate() || !dtpToDate.ValidDate()) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Date format problem"), Catalog.GetString("Please check the date entry."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if (dtpFromDate.Date > dtpToDate.Date) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } paramFields = paramFields.Replace("\"", "'"); // single quotes for SQL field names. ACalc.AddParameter("param_clbFields", paramFields); ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); // // I need to get the name of the current ledger.. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } ACalc.AddStringParameter("param_ledger_name", LedgerName); ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber); ALedgerRow Row = LedgerDetailsTable[0]; Int32 LedgerYear = Row.CurrentFinancialYear; Int32 NumPeriods = Row.NumberOfAccountingPeriods; String CurrencyName = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency; ACalc.AddStringParameter("param_currency_name", CurrencyName); ACalc.AddParameter("param_year0", DateTime.Today.Year); ACalc.AddParameter("param_year1", DateTime.Today.Year - 1); ACalc.AddParameter("param_year2", DateTime.Today.Year - 2); ACalc.AddParameter("param_year3", DateTime.Today.Year - 3); } // Read Controls Manual
// parameters to be passed to Gift Statement screens private TParameterList GiftStatementParameters(TFrmDonorGiftStatement ADonor = null) { TParameterList ReturnValue = new TParameterList(); // if btnDonorGiftStatement was clicked if (ADonor != null) { ReturnValue.Add("param_donor", "One Donor"); ReturnValue.Add("param_donorkey", FDonorKey); TRptCalculator Calc = new TRptCalculator(); ADonor.ReadControls(Calc, TReportActionEnum.raLoad); ReturnValue.Add("param_min_amount", Calc.GetParameters().GetParameter("param_min_amount").value); ReturnValue.Add("param_max_amount", Calc.GetParameters().GetParameter("param_max_amount").value); } else { ReturnValue.Add("param_recipient", "One Recipient"); ReturnValue.Add("param_recipientkey", FRecipientKey); } DateTime FromDate = DateTime.MaxValue; DateTime ToDate = DateTime.MinValue; // if no dates are enter use the earliest and latest dates available in the dataset if (string.IsNullOrEmpty(FDateFrom) || string.IsNullOrEmpty(FDateTo)) { foreach (DataRow Row in FMainDS.Tables[TEMP_TABLE_NAME].Rows) { if ((DateTime)Row["DateEntered"] < FromDate) { FromDate = (DateTime)Row["DateEntered"]; } if ((DateTime)Row["DateEntered"] > ToDate) { ToDate = (DateTime)Row["DateEntered"]; } } } if (!string.IsNullOrEmpty(FDateFrom)) { ReturnValue.Add("param_from_date", Convert.ToDateTime(FDateFrom)); } else { ReturnValue.Add("param_from_date", FromDate); } if (!string.IsNullOrEmpty(FDateTo)) { ReturnValue.Add("param_to_date", Convert.ToDateTime(FDateTo)); } else { ReturnValue.Add("param_to_date", ToDate); } return(ReturnValue); }
/// <summary> /// Reads the selected values from the controls, /// and stores them into the parameter system of FCalculator /// /// </summary> /// <param name="AColumnParameters">List with the current columns</param> /// <param name="ACalculator"></param> /// <returns>the MaxDisplayColumns number</returns> public static System.Int32 ReadControls(ref TParameterList AColumnParameters, ref TRptCalculator ACalculator) { System.Int32 MaxDisplayColumns; MaxDisplayColumns = AColumnParameters.Get("MaxDisplayColumns").ToInt(); ACalculator.GetParameters().Add("MaxDisplayColumns", MaxDisplayColumns); for (int Counter = 0; Counter <= MaxDisplayColumns - 1; Counter += 1) { ACalculator.GetParameters().Copy(AColumnParameters, Counter, -1, eParameterFit.eExact, Counter); if (!ACalculator.GetParameters().Exists("param_ytd", Counter)) { // if param_ytd is not set for the column then add it. ACalculator.GetParameters().Add("param_ytd", new TVariant(false), Counter); } } ACalculator.SetMaxDisplayColumns(MaxDisplayColumns); return(MaxDisplayColumns); }
} // 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
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { int Years = Convert.ToInt16(txtYears.Text); if ((AReportAction == TReportActionEnum.raGenerate) && ((Years > 4) || (Years < 1))) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Set the year range between 1 and 4"), Catalog.GetString("Wrong year range entered"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_YearBlock", DateTime.Today.Year); ACalc.AddParameter("param_NumberOfYears", Convert.ToInt32(txtYears.Text)); int ColumnCounter = 0; // ACalc.AddParameter("param_calculation", "MonthName", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthWorker", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthWorkerTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthWorkerCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthField", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthFieldTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthFieldCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "MonthTotal", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; // MonthTotalTaxDeduct if (FTaxDeductiblePercentageEnabled) { ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; } // ACalc.AddParameter("param_calculation", "MonthTotalCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "YearMonthlyAverage", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)3.0, ColumnCounter); ++ColumnCounter; // ACalc.AddParameter("param_calculation", "YearMonthlyAverageCount", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); /* * ++ColumnCounter; * ACalc.SetMaxDisplayColumns(ColumnCounter); */ }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (rbtPartner.Checked && (txtRecipient.Text == "0000000000"))) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No recipient selected."), Catalog.GetString("Please select a recipient."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtExtract.Checked && (txtExtract.Text == "")) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Enter an extract name."), Catalog.GetString("No extract name entered!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtSelectedFields.Checked && (clbFields.GetCheckedStringList().Length == 0)) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Please select at least one field."), Catalog.GetString("No fields selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtSelectedTypes.Checked && (clbTypes.GetCheckedStringList().Length == 0)) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Please select at least one type."), Catalog.GetString("No types selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_recipient_key", txtRecipient.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); DateTime FromDateThisYear = new DateTime(DateTime.Today.Year, 1, 1); DateTime ToDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 12, 31); DateTime FromDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 1, 1); ACalc.AddParameter("Year0", DateTime.Today.Year); ACalc.AddParameter("Year1", DateTime.Today.Year - 1); ACalc.AddParameter("Year2", DateTime.Today.Year - 2); ACalc.AddParameter("Year3", DateTime.Today.Year - 3); ACalc.AddParameter("param_to_date_0", DateTime.Today); ACalc.AddParameter("param_from_date_0", FromDateThisYear); ACalc.AddParameter("param_to_date_1", ToDatePreviousYear); ACalc.AddParameter("param_from_date_1", FromDatePreviousYear); ACalc.AddParameter("param_to_date_2", ToDatePreviousYear.AddYears(-1)); ACalc.AddParameter("param_from_date_2", FromDatePreviousYear.AddYears(-1)); ACalc.AddParameter("param_to_date_3", ToDatePreviousYear.AddYears(-2)); ACalc.AddParameter("param_from_date_3", FromDatePreviousYear.AddYears(-2)); int ColumnCounter = 0; ACalc.AddParameter("param_calculation", "PartnerKey", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.5, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "DonorName", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)6.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "DonorClass", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-0", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-1", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-2", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-3", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.SetMaxDisplayColumns(ColumnCounter); }
private void grdReciprocalRelationship_ReadControls(TRptCalculator ACalc, TReportActionEnum AReportAction) { }
/// <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); } }
private void ReadControlsVerify(TRptCalculator ACalc, TReportActionEnum AReportAction) { // make sure that for each group one radio button is selected uco_Selection.VerifyRadioButtonSelection(FPetraUtilsObject); TFrmPetraReportingUtils.VerifyRadioButtonSelection(rgrFormatCurrency, FPetraUtilsObject); }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { // // I need to get the name of the current ledger.. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } if (!Int32.TryParse(txtBatchNumber.Text, out FBatchNumber)) { MessageBox.Show( Catalog.GetString("Fault: No valid Batch number"), Catalog.GetString("Gift Batch Detail")); return(false); } ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddStringParameter("param_linked_partner_cc", ""); // I may want to use this for auto_email, but usually it's unused. if (ACalc.GetParameters().Exists("param_currency") && (ACalc.GetParameters().Get("param_currency").ToString() == Catalog.GetString("Transaction"))) { ACalc.RemoveParameter("param_currency_name"); ACalc.AddParameter("param_currency_name", TRemote.MFinance.Reporting.WebConnectors.GetTransactionCurrency(FLedgerNumber, FBatchNumber)); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_batch_number_i", FBatchNumber); 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.ContainsKey(p.name))) { paramsDictionary.Add(p.name, p.value); } } DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary); if (this.IsDisposed) // There's no cancel function as such - if the user has pressed Esc the form is closed! { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "GiftBatchDetail"); return(true); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if ((AReportAction == TReportActionEnum.raGenerate) && (rbtPartner.Checked && (txtRecipient.Text == "0000000000"))) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No recipient selected."), Catalog.GetString("Please select a recipient."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && rbtExtract.Checked && (txtExtract.Text == "")) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Enter an extract name."), Catalog.GetString("No extract name entered!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } if ((!dtpFromDate.Date.HasValue) || (!dtpToDate.Date.HasValue)) { if (AReportAction == TReportActionEnum.raGenerate) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Invalid dates."), Catalog.GetString("Provide values for From date and To date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } else { if ((AReportAction == TReportActionEnum.raGenerate) && (dtpFromDate.Date > dtpToDate.Date)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("From date is later than to date."), Catalog.GetString("Please change from date or to date."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && (dtpFromDate.Date.Value.Year != dtpToDate.Date.Value.Year)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Year value in from-date is different than from year value in to-date."), Catalog.GetString("Please use the same year."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalc.AddParameter("param_year", dtpFromDate.Date.Value.Year); ACalc.AddParameter("param_months", dtpToDate.Date.Value.Month - dtpFromDate.Date.Value.Month + 1); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_recipient_key", txtRecipient.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); if (this.cmbCurrency.SelectedItem == null) { this.cmbCurrency.SelectedIndex = 0; // I don't mind what you select - just don't select nothing! } int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); for (int Counter = 0; Counter <= MaxColumns; ++Counter) { String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString(); ACalc.AddParameter(ColumnName, Counter); } }