private void SelectStatuses_Click(System.Object sender, EventArgs e) { // open dialog to select detailed statuses string ApplicationStatusList; DialogResult DlgResult = TFrmApplicationStatusDialog.OpenApplicationStatusDialog( FDetailedStatuses, FPetraUtilsObject.GetForm(), out ApplicationStatusList); if ((DlgResult == DialogResult.OK) && (FDetailedStatuses != ApplicationStatusList)) { SetDetailedStatuses(ApplicationStatusList); } // update the grid with the new filter FilterChange(sender, e); }
private void ExportBatches(System.Object sender, System.EventArgs e) { if (FPetraUtilsObject.HasChanges) { // without save the server does not have the current changes, so forbid it. MessageBox.Show(Catalog.GetString("Please save changed Data before the Export!"), Catalog.GetString("Export Error")); return; } TFrmGiftBatchExport exportForm = new TFrmGiftBatchExport(FPetraUtilsObject.GetForm()); exportForm.LedgerNumber = FLedgerNumber; exportForm.Show(); }
private void btnEventClicked(object sender, EventArgs e) { TFrmSelectEvent SelectEventForm = new TFrmSelectEvent(FPetraUtilsObject.GetForm()); if (SelectEventForm.ShowDialog() == DialogResult.OK) { txtEventCode.Text = SelectEventForm.FSelectedOutreachCode; lblEventName.Text = SelectEventForm.FSelectedUnitName; FSelectedUnitKey = SelectEventForm.FSelectedPartnerKey; } else { // should we reset the values or keep the old values? // For now, just keep the old values. } }
private void ExportBatches(object sender, EventArgs e) { if (FPetraUtilsObject.HasChanges && !((TFrmGLBatch)this.ParentForm).SaveChanges()) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString("Please correct and save changed data before the export!"), Catalog.GetString("Export Error")); return; } TFrmGLBatchExport gl = new TFrmGLBatchExport(FPetraUtilsObject.GetForm()); gl.LedgerNumber = FLedgerNumber; gl.MainDS = FMainDS; gl.Show(); }
// display the partner edit screen, open to the Contact Log tab and display the contact log that has been selected in the grid private void ViewPartner(object Sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; // get data for contact log to display DataRow CurrentRow = GetCurrentDataRow(); Int64 PartnerKey = Convert.ToInt64(CurrentRow["p_partner_key_n"]); string ContactLogID = CurrentRow["p_contact_log_id_i"].ToString(); TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm()); frm.SetParameters(TScreenMode.smEdit, PartnerKey, TPartnerEditTabPageEnum.petpContacts); frm.Show(); frm.SelectContactLog(ContactLogID); this.Cursor = Cursors.Default; }
private void ShowDetailsManual(ExtractTDSMExtractRow ARow) { ucoPartnerInfo.ClearControls(); btnEdit.Enabled = false; if (ARow != null) { ucoPartnerInfo.PassPartnerDataNone(ARow.PartnerKey); btnEdit.Enabled = true; } btnDeleteRow.Enabled = pnlDetails.Enabled && !FFrozen; bool gotRows = grdDetails.Rows.Count > 1; ((TFrmExtractMaintain)FPetraUtilsObject.GetForm()).ActionEnabledEvent(null, new ActionEventArgs("actPrintUsingWord", gotRows)); ((TFrmExtractMaintain)FPetraUtilsObject.GetForm()).ActionEnabledEvent(null, new ActionEventArgs("actPrintUsingExcel", gotRows)); }
/// <summary> /// Print the screen data using Word or Excel /// </summary> /// <param name="APrintUsing">The print application</param> /// <param name="APreviewOnly"></param> public void PrintFormData(TStandardFormPrint.TPrintUsing APrintUsing, bool APreviewOnly) { if (ValidateAllData(true, TErrorProcessingMode.Epm_All) && FPetraUtilsObject.IsDataSaved()) { TStandardFormPrint.PrintGrid(APrintUsing, APreviewOnly, FPetraUtilsObject.GetForm().Text, grdDetails, new int[] { 0, 2, 1, 3 }, new int[] { ExtractTDSMExtractTable.ColumnPartnerKeyId, ExtractTDSMExtractTable.ColumnPartnerShortNameId, ExtractTDSMExtractTable.ColumnPartnerClassId, ExtractTDSMExtractTable.ColumnLocationKeyId }); } }
/// <summary> /// Will be called by TFormsList to inform any Form that is registered in TFormsList /// about any 'Forms Messages' that are broadcasted. /// </summary> /// <remarks>The Partner Edit 'listens' to such 'Forms Message' broadcasts by /// implementing this virtual Method. This Method will be called each time a /// 'Forms Message' broadcast occurs. /// </remarks> /// <param name="AFormsMessage">An instance of a 'Forms Message'. This can be /// inspected for parameters in the Method Body and the Form can use those to choose /// to react on the Message, or not.</param> /// <returns>Returns True if the Form reacted on the specific Forms Message, /// otherwise false.</returns> public bool ProcessFormsMessage(TFormsMessage AFormsMessage) { bool MessageProcessed = false; if (AFormsMessage.MessageClass == TFormsMessageClassEnum.mcExtractCreated) { if (FDelegateRefreshExtractList()) { // this is required as extracts are created on a different thread if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate() { // show filter panel MniFilterFind_Click(GetPetraUtilsObject().GetForm(), null); // show the screen in case it has been hidden (TExtractMasterScreenManager.OpenFormHidden) FPetraUtilsObject.GetForm().Show(); // filter results to show the new extract ((TextBox)FFilterAndFindObject.FilterPanelControls.FindControlByName("txtExtractName")).Text = ((TFormsMessage.FormsMessageName)AFormsMessage.MessageObject).Name; }); } else { // show filter panel MniFilterFind_Click(GetPetraUtilsObject().GetForm(), null); // show the screen in case it has been hidden (TExtractMasterScreenManager.OpenFormHidden) FPetraUtilsObject.GetForm().Show(); // filter results to show the new extract ((TextBox)FFilterAndFindObject.FilterPanelControls.FindControlByName("txtExtractName")).Text = ((TFormsMessage.FormsMessageName)AFormsMessage.MessageObject).Name; } } MessageProcessed = true; } return(MessageProcessed); }
/// <summary> /// button was pressed to edit other partner in relationship record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditOtherPartner(System.Object sender, EventArgs e) { long RelationPartnerKey; if (GetSelectedDetailRow() == null) { return; } // depending on the relation select other partner to be edited if (GetSelectedDetailRow().PartnerKey == ((PPartnerRow)FMainDS.PPartner.Rows[0]).PartnerKey) { RelationPartnerKey = GetSelectedDetailRow().RelationKey; } else { RelationPartnerKey = GetSelectedDetailRow().PartnerKey; } if (RelationPartnerKey == 0) { return; } this.Cursor = Cursors.WaitCursor; try { TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm()); frm.SetParameters(TScreenMode.smEdit, RelationPartnerKey); frm.Show(); } finally { this.Cursor = Cursors.Default; } }
private void LookupExchangeRate(Object sender, EventArgs e) { TFrmSetupDailyExchangeRate setupDailyExchangeRate = new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm()); decimal selectedExchangeRate; DateTime selectedEffectiveDate; int selectedEffectiveTime; if (setupDailyExchangeRate.ShowDialog( FLedgerNumber, DateTime.Now, txtCurrency.Text, 1.0m, out selectedExchangeRate, out selectedEffectiveDate, out selectedEffectiveTime) == DialogResult.Cancel) { return; } txtExchangeRate.NumberValueDecimal = selectedExchangeRate; }
private void FPetraUtilsObject_DataSaved_NewDonorWarning(object Sender, TDataSavedEventArgs e) { // if data successfully saved then look for new donors and warn the user if (e.Success && (FGiftDetailTable != null) && FNewDonorWarning) { // this list contains a list of all new donors that were entered onto form List <Int64> NewDonorsList = ucoTransactions.NewDonorsList; foreach (GiftBatchTDSAGiftDetailRow Row in FGiftDetailTable.Rows) { // check changed data is either added or modified and that it is by a new donor if (((Row.RowState == DataRowState.Added) || (Row.RowState == DataRowState.Modified)) && (!Row.IsDonorKeyNull() && NewDonorsList.Contains(Row.DonorKey))) { if (MessageBox.Show(string.Format(Catalog.GetString( "{0} ({1}) is a new Donor.{2}Do you want to add subscriptions for them?{2}" + "(Note: this message can be disabled in the 'File' menu by unselecting the 'New Donor Warning' item.)"), Row.DonorName, Row.DonorKey, "\n\n"), Catalog.GetString("New Donor"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // Open the donor's Edit screen so subscriptions can be added TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm()); frm.SetParameters(TScreenMode.smEdit, Row.DonorKey, TPartnerEditTabPageEnum.petpSubscriptions); frm.ShowDialog(); } // ensures message is not displayed twice for one new donor with two gifts NewDonorsList.Remove(Row.DonorKey); } } ucoTransactions.NewDonorsList.Clear(); } }
private void SetExchangeRateValue(Object sender, EventArgs e) { TFrmSetupDailyExchangeRate setupDailyExchangeRate = new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm()); decimal selectedExchangeRate; DateTime selectedEffectiveDate; int selectedEffectiveTime; if (setupDailyExchangeRate.ShowDialog( FLedgerNumber, dtpEffectiveDate.Date.Value, txtCurrencyCodeFrom.Text, DEFAULT_CURRENCY_EXCHANGE, out selectedExchangeRate, out selectedEffectiveDate, out selectedEffectiveTime) == DialogResult.Cancel) { return; } FExchangeRateToBase = selectedExchangeRate; txtExchangeRateToBase.Text = FExchangeRateToBase.ToString(); }
private void SubmitBatch(System.Object sender, System.EventArgs e) { bool Success = false; bool LoadDialogVisible = false; TFrmStatusDialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); if ((GetSelectedRowIndex() < 0) || (FPreviouslySelectedDetailRow == null)) { MessageBox.Show(Catalog.GetString("Please select a Recurring Batch before submitting.")); return; } try { bool submittingAlreadyConfirmed = false; Cursor = Cursors.WaitCursor; dlgStatus.Show(); LoadDialogVisible = true; dlgStatus.Heading = String.Format(Catalog.GetString("Recurring Gift Batch {0}"), FSelectedBatchNumber); dlgStatus.CurrentStatus = Catalog.GetString("Loading gifts ready for submitting..."); if (!LoadAllBatchData(FSelectedBatchNumber)) { Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("The Recurring Gift Batch is empty!"), Catalog.GetString("Posting failed"), MessageBoxButtons.OK, MessageBoxIcon.Stop); dlgStatus.Close(); LoadDialogVisible = false; return; } dlgStatus.CurrentStatus = Catalog.GetString("Checking for inactive values..."); if (!AllowInactiveFieldValues(ref submittingAlreadyConfirmed)) { dlgStatus.Close(); LoadDialogVisible = false; return; } dlgStatus.Close(); LoadDialogVisible = false; Success = FSubmitLogicObject.SubmitBatch(FPreviouslySelectedDetailRow, txtDetailHashTotal, ref submittingAlreadyConfirmed); } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { if (LoadDialogVisible) { dlgStatus.Close(); LoadDialogVisible = false; } Cursor = Cursors.Default; } }
/// <summary> /// this supports the batch export files from Petra 2.x. /// Each line starts with a type specifier, B for batch, J for journal, T for transaction /// </summary> private void BtnOK_Click(object sender, EventArgs e) { FExportFileName = txtFilename.Text; String fileContents = string.Empty; Int32 budgetCount = 0; if (FExportFileName == String.Empty) { MessageBox.Show(Catalog.GetString("Please choose a location for the Export File."), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!FExportFileName.EndsWith(".csv", StringComparison.CurrentCultureIgnoreCase) && !FExportFileName.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase)) { FExportFileName += ".csv"; txtFilename.Text = FExportFileName; } if (!Directory.Exists(Path.GetDirectoryName(FExportFileName))) { MessageBox.Show(Catalog.GetString("Please select an existing directory for this file!"), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); FExportFileName = string.Empty; return; } if (File.Exists(FExportFileName)) { if (MessageBox.Show(Catalog.GetString("The file already exists. Is it OK to overwrite it?"), Catalog.GetString("Export Budget"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) { return; } try { File.Delete(FExportFileName); } catch (Exception ex) { MessageBox.Show(String.Format( Catalog.GetString( "Failed to delete the file. Maybe it is already open in another application? The system message was:{0}{1}"), Environment.NewLine, ex.Message), Catalog.GetString("Export Budget"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //Hashtable requestParams = new Hashtable(); //requestParams.Add("ALedgerNumber", FLedgerNumber); //requestParams.Add("Delimiter", ConvertDelimiter(cmbDelimiter.GetSelectedString(), false)); //requestParams.Add("DateFormatString", cmbDateFormat.GetSelectedString()); //requestParams.Add("NumberFormat", ConvertNumberFormat(cmbNumberFormat)); TVerificationResultCollection AMessages; string[] delims = new string[1]; delims[0] = ConvertDelimiter(cmbDelimiter.GetSelectedString(), false); TFrmStatusDialog dlgStatus = null; try { this.Cursor = Cursors.WaitCursor; dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); dlgStatus.Show(); dlgStatus.Heading = Catalog.GetString("Exporting Budgets"); dlgStatus.CurrentStatus = Catalog.GetString("Exporting budget data for this year and next..."); budgetCount = TRemote.MFinance.Budget.WebConnectors.ExportBudgets(FLedgerNumber, FExportFileName, delims, ref fileContents, ref FBudgetDS, out AMessages); dlgStatus.Close(); dlgStatus = null; this.Cursor = Cursors.Default; if ((AMessages != null) && (AMessages.Count > 0)) { if (!TVerificationHelper.IsNullOrOnlyNonCritical(AMessages)) { MessageBox.Show(AMessages.BuildVerificationResultString(), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); FExportFileName = string.Empty; return; } else { MessageBox.Show(AMessages.BuildVerificationResultString(), Catalog.GetString("Warnings"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } SaveUserDefaults(); if (budgetCount == 0) { MessageBox.Show(Catalog.GetString("There are no Budgets matching your criteria"), Catalog.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); FExportFileName = string.Empty; return; } StreamWriter sw1 = new StreamWriter(FExportFileName); sw1.Write(fileContents); sw1.Close(); } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { this.Cursor = Cursors.Default; if (dlgStatus != null) { dlgStatus.Close(); dlgStatus = null; } } bool ShowExportedFileInExplorer = false; // Offer the client the chance to open the file in Excel or whatever if (MessageBox.Show(String.Format(Catalog.GetString( "{0} Budget rows were exported successfully! Would you like to open the file in your default application?"), budgetCount.ToString()), Catalog.GetString("Budget Export"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { try { ProcessStartInfo si = new ProcessStartInfo(FExportFileName); si.UseShellExecute = true; si.Verb = "open"; Process p = new Process(); p.StartInfo = si; p.Start(); } catch { MessageBox.Show(Catalog.GetString( "Unable to launch the default application to open: '") + FExportFileName + "'!", Catalog.GetString( "Budget Export"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ShowExportedFileInExplorer = true; } } else { ShowExportedFileInExplorer = true; } if (ShowExportedFileInExplorer) { //If windows start Windows File Explorer TExecutingOSEnum osVersion = Utilities.DetermineExecutingOS(); if ((osVersion >= TExecutingOSEnum.eosWinXP) && (osVersion < TExecutingOSEnum.oesUnsupportedPlatform)) { try { Process.Start("explorer.exe", string.Format("/select,\"{0}\"", FExportFileName)); } catch { MessageBox.Show(Catalog.GetString( "Unable to launch Windows File Explorer to open: '") + FExportFileName + "'!", Catalog.GetString( "Budget Export"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } Close(); }
/// <summary> /// Saves any changed preferences to s_user_defaults /// </summary> /// <returns>void</returns> public DialogResult SaveGeneralTab() { // First, we need to show any dialogs that may result in Cancel if (chkSaveWindowProperties.Checked && !WasSaveWindowPropertiesInitiallyChecked) { // The user wants to start saving the window positions etc. // If we have some information about this that we stored previously, we can offer to use it again... string localAppDataPath = Path.Combine( TAppSettingsManager.GetLocalAppDataPath(), CommonFormsResourcestrings.StrFolderOrganisationName, System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductName); string settingsFileName = String.Format(CommonFormsResourcestrings.StrScreenPositionsFileName, UserInfo.GUserInfo.UserID); string settingsPath = Path.Combine(localAppDataPath, settingsFileName); if (File.Exists(settingsPath)) { string msg = String.Format("{0}{1}{1}{2}", CommonFormsResourcestrings.StrReuseScreenPositionsMessage1, Environment.NewLine, CommonFormsResourcestrings.StrReuseScreenPositionsMessage2); bool DoNotShowMessageBoxEverytime = false; TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm()); // customise button text extendedMessageBox.YesButtonText = Catalog.GetString("Keep"); extendedMessageBox.NoButtonText = Catalog.GetString("Discard"); extendedMessageBox.ShowDialog(msg, CommonFormsResourcestrings.StrReuseScreenPositionsTitle, string.Empty, TFrmExtendedMessageBox.TButtons.embbYesNoCancel, TFrmExtendedMessageBox.TIcon.embiQuestion); TFrmExtendedMessageBox.TResult result = extendedMessageBox.GetResult(out DoNotShowMessageBoxEverytime); if (result == TFrmExtendedMessageBox.TResult.embrCancel) { return(DialogResult.Cancel); } else if (result == TFrmExtendedMessageBox.TResult.embrNo) { try { // Delete the old file File.Delete(settingsPath); } catch (Exception ex) { TLogging.Log(String.Format("Exception occurred while deleting the window position file '{0}': {1}", settingsPath, ex.Message), TLoggingType.ToLogfile); } } else if (result == TFrmExtendedMessageBox.TResult.embrYes) { // Load the information we have already PetraUtilsObject.LoadWindowPositionsFromFile(); } } } if (LanguageChanged) { string LanguageCode = cmbLanguage.GetSelectedString(); string CultureCode = cmbCulture.GetSelectedString(); // send to server TRemote.MSysMan.Maintenance.WebConnectors.SetLanguageAndCulture(LanguageCode, CultureCode); // set local settings for client Catalog.Init(LanguageCode, CultureCode); // TODO: can we reload the main window with the new language? MessageBox.Show(Catalog.GetString("Please restart the OpenPetra client to see the new language"), Catalog.GetString("Restart the client"), MessageBoxButtons.OK, MessageBoxIcon.Information); } TUserDefaults.SetDefault(MSysManConstants.USERDEFAULT_NUMBEROFRECENTPARTNERS, nudNumberOfPartners.Value); TUserDefaults.SetDefault(TUserDefaults.NamedDefaults.USERDEFAULT_ESC_CLOSES_SCREEN, chkEscClosesScreen.Checked); TUserDefaults.SetDefault(TUserDefaults.NamedDefaults.USERDEFAULT_SAVE_WINDOW_POS_AND_SIZE, chkSaveWindowProperties.Checked); TUserDefaults.SetDefault(TUserDefaults.NamedDefaults.MODULE_TO_OPEN_AT_STARTUP, cmbInitialSelectedModule.GetSelectedString()); return(DialogResult.OK); }
private void SubmitBatch(System.Object sender, System.EventArgs e) { bool Success = false; if ((GetSelectedRowIndex() < 0) || (FPreviouslySelectedDetailRow == null)) { MessageBox.Show(Catalog.GetString("Please select a Recurring Gift Batch before submitting!")); return; } TFrmRecurringGiftBatch MainForm = (TFrmRecurringGiftBatch)ParentForm; TFrmStatusDialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); bool LoadDialogVisible = false; try { Cursor = Cursors.WaitCursor; MainForm.FCurrentGiftBatchAction = TExtraGiftBatchChecks.GiftBatchAction.SUBMITTING; dlgStatus.Show(); LoadDialogVisible = true; dlgStatus.Heading = String.Format(Catalog.GetString("Recurring Gift Batch {0}"), FSelectedBatchNumber); dlgStatus.CurrentStatus = Catalog.GetString("Loading gifts ready for submitting..."); if (!LoadAllBatchData(FSelectedBatchNumber)) { Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("The Recurring Gift Batch is empty!"), Catalog.GetString("Submit Gift Batch"), MessageBoxButtons.OK, MessageBoxIcon.Stop); dlgStatus.Close(); LoadDialogVisible = false; return; } dlgStatus.Close(); LoadDialogVisible = false; Success = FSubmitLogicObject.SubmitBatch(FPreviouslySelectedDetailRow, FWarnOfInactiveValuesOnSubmitting, FDonorZeroIsValid, FRecipientZeroIsValid); } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { if (LoadDialogVisible) { dlgStatus.Close(); LoadDialogVisible = false; } MainForm.FCurrentGiftBatchAction = TExtraGiftBatchChecks.GiftBatchAction.NONE; Cursor = Cursors.Default; } }
private void SubmitBatch(System.Object sender, EventArgs e) { if ((GetSelectedRowIndex() < 0) || (FPreviouslySelectedDetailRow == null)) { MessageBox.Show(Catalog.GetString("Please select a Recurring Batch before submitting!")); return; } TFrmRecurringGLBatch MainForm = (TFrmRecurringGLBatch)ParentForm; TFrmStatusDialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); TFrmRecurringGLBatchSubmit SubmitForm = null; bool LoadDialogVisible = false; try { Cursor = Cursors.WaitCursor; MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.SUBMITTING; dlgStatus.Show(); LoadDialogVisible = true; dlgStatus.Heading = String.Format(Catalog.GetString("Recurring GL Batch {0}"), FSelectedBatchNumber); dlgStatus.CurrentStatus = Catalog.GetString("Loading journals and transactions ready for submitting..."); if (!LoadAllBatchData()) { Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("The Recurring GL Batch is empty!"), Catalog.GetString("Submit GL Batch"), MessageBoxButtons.OK, MessageBoxIcon.Stop); dlgStatus.Close(); LoadDialogVisible = false; return; } dlgStatus.Close(); LoadDialogVisible = false; //Make sure that all control data is in dataset MainForm.GetLatestControlData(); //Save and check for inactive values if (FPetraUtilsObject.HasChanges) { //Keep this conditional check separate from the one above so that it only gets called // when necessary and doesn't result in the executon of the same method if (!MainForm.SaveChangesManual(MainForm.FCurrentGLBatchAction)) { return; } } else { //This has to be called here because if there are no changes then the DataSavingValidating // method which calls the method below, will not run. if (!MainForm.GetTransactionsControl().AllowInactiveFieldValues(FLedgerNumber, FSelectedBatchNumber, MainForm.FCurrentGLBatchAction)) { return; } } if ((FPreviouslySelectedDetailRow.BatchControlTotal != 0) && (FPreviouslySelectedDetailRow.BatchDebitTotal != FPreviouslySelectedDetailRow.BatchControlTotal)) { MessageBox.Show(String.Format(Catalog.GetString( "The recurring gl batch total ({0}) for batch {1} does not equal the hash total ({2})."), FPreviouslySelectedDetailRow.BatchDebitTotal, FPreviouslySelectedDetailRow.BatchNumber, FPreviouslySelectedDetailRow.BatchControlTotal)); txtDetailBatchControlTotal.Focus(); txtDetailBatchControlTotal.SelectAll(); return; } SubmitForm = new TFrmRecurringGLBatchSubmit(FPetraUtilsObject.GetForm()); ParentForm.ShowInTaskbar = false; GLBatchTDS submitRecurringDS = (GLBatchTDS)FMainDS.Clone(); int currentBatch = FPreviouslySelectedDetailRow.BatchNumber; submitRecurringDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringBatchAndRelatedTables(FLedgerNumber, FSelectedBatchNumber)); SubmitForm.SubmitMainDS = submitRecurringDS; SubmitForm.ShowDialog(); } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { if (LoadDialogVisible) { dlgStatus.Close(); LoadDialogVisible = false; } if (SubmitForm != null) { SubmitForm.Dispose(); ParentForm.ShowInTaskbar = true; } MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE; Cursor = Cursors.Default; } if (FPetraUtilsObject.HasChanges) { // save first, then submit if (!((TFrmRecurringGLBatch)ParentForm).SaveChanges()) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString( "The recurring batch was not submitted due to problems during saving; ") + Environment.NewLine + Catalog.GetString("Please fix the batch first and then submit it."), Catalog.GetString("Submit Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
private void EditPartner(System.Object sender, EventArgs e) { bool ServerCallSuccessful = false; bool VerifyPartnerAtLocationResult = false; if (CountSelectedRows() > 1) { MessageBox.Show(Catalog.GetString("Please select only one partner record that you want to edit"), Catalog.GetString("Edit Partner"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ExtractTDSMExtractRow SelectedRow = GetSelectedDetailRow(); // TODO: private partners // Check if partner is has "restricted" field set to be private and in that // case only let the owner access that partner. // Make use of SharedConstants.PARTNER_PRIVATE_USER while running the query. // Open Partner Edit Screen for selected partner if (SelectedRow != null) { bool CurrentAddress; bool MailingAddress; this.Cursor = Cursors.WaitCursor; try { Ict.Common.DB.TServerBusyHelper.CoordinatedAutoRetryCall("Extract Maintenance/Edit Partner", ref ServerCallSuccessful, delegate { VerifyPartnerAtLocationResult = TRemote.MPartner.Partner.ServerLookups.WebConnectors.VerifyPartnerAtLocation( SelectedRow.PartnerKey, new TLocationPK(SelectedRow.SiteKey, SelectedRow.LocationKey), out CurrentAddress, out MailingAddress); ServerCallSuccessful = true; }); if (!ServerCallSuccessful) { // ServerCallRetries must be equal to MAX_RETRIES when we get here! if (TServerBusyHelperGui.ShowServerBusyDialogWhenOpeningForm(Catalog.GetString("Partner Edit")) == DialogResult.Retry) { EditPartner(null, null); } return; } TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm()); if (!VerifyPartnerAtLocationResult) { MessageBox.Show(Catalog.GetString("Cannot find the location that was stored for this partner." + "\r\n" + "Will use any known location for this partner." + "\r\n" + "\r\n" + "(Fix with 'Verify and Update Extract')"), Catalog.GetString("Edit Partner"), MessageBoxButtons.OK, MessageBoxIcon.Warning); frm.SetParameters(TScreenMode.smEdit, SelectedRow.PartnerKey); } else { frm.SetParameters(TScreenMode.smEdit, SelectedRow.PartnerKey, SelectedRow.SiteKey, SelectedRow.LocationKey); } frm.Show(); } finally { this.Cursor = Cursors.Default; } } }
private bool AllowInactiveFieldValues(int ABatchNumber) { bool RetVal = false; TVerificationResultCollection VerificationResult = new TVerificationResultCollection(); string VerificationMessage = string.Empty; DataView TransDV = new DataView(FMainDS.ARecurringTransaction); DataView AttribDV = new DataView(FMainDS.ARecurringTransAnalAttrib); int TotalNumInactiveValues = 0; int NumInactiveAccounts = 0; int NumInactiveCostCentres = 0; int NumInactiveAccountTypes = 0; int NumInactiveAccountValues = 0; try { //Check for inactive account or cost centre codes TransDV.RowFilter = String.Format("{0}={1}", ARecurringTransactionTable.GetBatchNumberDBName(), ABatchNumber); TransDV.Sort = String.Format("{0} ASC, {1} ASC", ARecurringTransactionTable.GetJournalNumberDBName(), ARecurringTransactionTable.GetTransactionNumberDBName()); foreach (DataRowView drv in TransDV) { ARecurringTransactionRow transRow = (ARecurringTransactionRow)drv.Row; if (!AccountIsActive(transRow.AccountCode)) { VerificationMessage += String.Format(" Account '{0}' in Journal:{1} Transaction:{2}.{3}", transRow.AccountCode, transRow.JournalNumber, transRow.TransactionNumber, Environment.NewLine); NumInactiveAccounts++; } if (!CostCentreIsActive(transRow.CostCentreCode)) { VerificationMessage += String.Format(" Cost Centre '{0}' in Journal:{1} Transaction:{2}.{3}", transRow.CostCentreCode, transRow.JournalNumber, transRow.TransactionNumber, Environment.NewLine); NumInactiveCostCentres++; } } //Check anlysis attributes AttribDV.RowFilter = String.Format("{0}={1}", ARecurringTransAnalAttribTable.GetBatchNumberDBName(), ABatchNumber); AttribDV.Sort = String.Format("{0} ASC, {1} ASC, {2} ASC", ARecurringTransAnalAttribTable.GetJournalNumberDBName(), ARecurringTransAnalAttribTable.GetTransactionNumberDBName(), ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName()); foreach (DataRowView drv2 in AttribDV) { ARecurringTransAnalAttribRow analAttribRow = (ARecurringTransAnalAttribRow)drv2.Row; if (!AnalysisCodeIsActive(analAttribRow.AccountCode, analAttribRow.AnalysisTypeCode)) { VerificationMessage += String.Format(" Analysis Code '{0}' in Journal:{1} Transaction:{2}.{3}", analAttribRow.AnalysisTypeCode, analAttribRow.JournalNumber, analAttribRow.TransactionNumber, Environment.NewLine); NumInactiveAccountTypes++; } if (!AnalysisAttributeValueIsActive(analAttribRow.AnalysisTypeCode, analAttribRow.AnalysisAttributeValue)) { VerificationMessage += String.Format(" Analysis Value '{0}' in Journal:{1} Transaction:{2}.{3}", analAttribRow.AnalysisAttributeValue, analAttribRow.JournalNumber, analAttribRow.TransactionNumber, Environment.NewLine); NumInactiveAccountValues++; } } } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } TotalNumInactiveValues = (NumInactiveAccounts + NumInactiveCostCentres + NumInactiveAccountTypes + NumInactiveAccountValues); if (TotalNumInactiveValues > 0) { VerificationResult.Add(new TVerificationResult(string.Format(Catalog.GetString("Inactive Values:{0}"), Environment.NewLine), VerificationMessage, TResultSeverity.Resv_Noncritical)); StringBuilder errorMessages = new StringBuilder(); errorMessages.AppendFormat(Catalog.GetString("{0} inactive value(s) found in Recurring GL Batch {1}. Do you still want to submit?{2}"), TotalNumInactiveValues, ABatchNumber, Environment.NewLine); foreach (TVerificationResult message in VerificationResult) { errorMessages.AppendFormat("{0}{1}", Environment.NewLine, message.ResultText); } TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm()); RetVal = (extendedMessageBox.ShowDialog(errorMessages.ToString(), Catalog.GetString("Submit Batch"), string.Empty, TFrmExtendedMessageBox.TButtons.embbYesNo, TFrmExtendedMessageBox.TIcon.embiQuestion) == TFrmExtendedMessageBox.TResult.embrYes); } else { RetVal = true; } return(RetVal); }
private void SubmitBatch(System.Object sender, System.EventArgs e) { if (FPreviouslySelectedDetailRow == null) { MessageBox.Show(Catalog.GetString("Please select a Batch before submitting.")); return; } if (!LoadAllBatchData() || !AllowInactiveFieldValues()) { return; } GiftBatchTDSARecurringGiftDetailTable RecurringBatchGiftDetails = new GiftBatchTDSARecurringGiftDetailTable(); foreach (ARecurringGiftDetailRow Row in FMainDS.ARecurringGiftDetail.Rows) { if (Row.BatchNumber == FSelectedBatchNumber) { RecurringBatchGiftDetails.Rows.Add((object[])Row.ItemArray.Clone()); } } if (FPetraUtilsObject.HasChanges) { bool CancelledDueToExWorker; // save first, then submit if (!((TFrmRecurringGiftBatch)ParentForm).SaveChangesForSubmitting(RecurringBatchGiftDetails, out CancelledDueToExWorker)) { if (!CancelledDueToExWorker) { // saving failed, therefore do not try to submit MessageBox.Show(Catalog.GetString( "The recurring batch was not submitted due to problems during saving; ") + Environment.NewLine + Catalog.GetString("Please fix the batch first and then submit it."), Catalog.GetString("Submit Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } } if ((FPreviouslySelectedDetailRow.HashTotal != 0) && (FPreviouslySelectedDetailRow.BatchTotal != FPreviouslySelectedDetailRow.HashTotal)) { MessageBox.Show(String.Format(Catalog.GetString( "The recurring gift batch total ({0}) for batch {1} does not equal the hash total ({2})."), StringHelper.FormatUsingCurrencyCode(FPreviouslySelectedDetailRow.BatchTotal, FPreviouslySelectedDetailRow.CurrencyCode), FPreviouslySelectedDetailRow.BatchNumber, StringHelper.FormatUsingCurrencyCode(FPreviouslySelectedDetailRow.HashTotal, FPreviouslySelectedDetailRow.CurrencyCode)), "Submit Recurring Gift Batch"); txtDetailHashTotal.Focus(); txtDetailHashTotal.SelectAll(); return; } TFrmRecurringGiftBatchSubmit submitForm = new TFrmRecurringGiftBatchSubmit(FPetraUtilsObject.GetForm()); try { ParentForm.ShowInTaskbar = false; submitForm.MainDS = FMainDS; submitForm.BatchRow = FPreviouslySelectedDetailRow; submitForm.ShowDialog(); } finally { submitForm.Dispose(); ParentForm.ShowInTaskbar = true; } }
/// <summary> /// Open a dialog to select Contact Attributes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectAttributes(object sender, EventArgs e) { // open the contact attributes dialog TFrmContactAttributesDialog ContactAttributesDialog = new TFrmContactAttributesDialog(FPetraUtilsObject.GetForm()); ContactAttributesDialog.ContactID = -1; ContactAttributesDialog.SelectedContactAttributeTable = FAttributeTable; if (ContactAttributesDialog.ShowDialog() == DialogResult.OK) { PPartnerContactAttributeTable Changes = ContactAttributesDialog.SelectedContactAttributeTable.GetChangesTyped(); // if changes were made if (Changes != null) { FAttributeTable = ContactAttributesDialog.SelectedContactAttributeTable; // we do not need the deleted rows FAttributeTable.AcceptChanges(); ContactAttributesLogic.SetupContactAttributesGrid(ref grdSelectedAttributes, FAttributeTable, false); } } }
/// <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) && (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); } 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); } }
/// <summary> /// load the gifts into the grid /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="ABatchNumber"></param> /// <param name="ABatchStatus"></param> /// <param name="AForceLoadFromServer">Set to true to get data from the server even though it is apparently the current batch number and status</param> /// <returns>True if gift transactions were loaded from server, false if transactions had been loaded already.</returns> public bool LoadGifts(Int32 ALedgerNumber, Int32 ABatchNumber, string ABatchStatus, bool AForceLoadFromServer = false) { //Set key flags bool FirstGiftTransLoad = (FLedgerNumber == -1); bool SameCurrentBatch = ((FLedgerNumber == ALedgerNumber) && (FBatchNumber == ABatchNumber) && (FBatchStatus == ABatchStatus) && !AForceLoadFromServer); FBatchRow = GetBatchRow(); if ((FBatchRow == null) && (GetAnyBatchRow(ABatchNumber) == null)) { MessageBox.Show(String.Format("Cannot load transactions for Gift Batch {0} as the batch is not currently loaded!", ABatchNumber)); return(false); } //Set key values from Batch FLedgerNumber = ALedgerNumber; FBatchNumber = ABatchNumber; FBatchCurrencyCode = FBatchRow.CurrencyCode; FBatchMethodOfPayment = FBatchRow.MethodOfPaymentCode; FBatchStatus = ABatchStatus; FBatchUnpostedFlag = (FBatchStatus == MFinanceConstants.BATCH_UNPOSTED); if (FirstGiftTransLoad) { InitialiseControls(); } UpdateCurrencySymbols(FBatchCurrencyCode); //Check if the same batch is selected, so no need to apply filter if (SameCurrentBatch) { //Same as previously selected and we have not been asked to force a full refresh if (FBatchUnpostedFlag && (GetSelectedRowIndex() > 0)) { if (FGLEffectivePeriodHasChangedFlag) { //Just in case for the currently selected row, the date field has not been updated FGLEffectivePeriodHasChangedFlag = false; GetSelectedDetailRow().DateEntered = FBatchRow.GlEffectiveDate; dtpDateEntered.Date = FBatchRow.GlEffectiveDate; } GetDetailsFromControls(GetSelectedDetailRow()); } UpdateControlsProtection(); if (FBatchUnpostedFlag && ((FBatchCurrencyCode != FBatchRow.CurrencyCode) || (FBatchExchangeRateToBase != FBatchRow.ExchangeRateToBase))) { UpdateBaseAmount(false); } return(false); } //New Batch FCurrentGiftInBatch = 0; //New set of transactions to be loaded TFrmStatusDialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); if (FShowStatusDialogOnLoadFlag == true) { dlgStatus.Show(); FShowStatusDialogOnLoadFlag = false; dlgStatus.Heading = String.Format(Catalog.GetString("Batch {0}"), ABatchNumber); dlgStatus.CurrentStatus = Catalog.GetString("Loading transactions ..."); } FGiftTransactionsLoadedFlag = false; FSuppressListChangedFlag = false; //Apply new filter FPreviouslySelectedDetailRow = null; grdDetails.DataSource = null; // if this form is readonly, then we need all codes, because old (inactive) codes might have been used if (FirstGiftTransLoad || (FActiveOnlyFlag == (ViewMode || !FBatchUnpostedFlag))) { FActiveOnlyFlag = !(ViewMode || !FBatchUnpostedFlag); dlgStatus.CurrentStatus = Catalog.GetString("Initialising controls ..."); try { //Without this, the Save button enables even for Posted batches! FPetraUtilsObject.SuppressChangeDetection = true; TFinanceControls.InitialiseMotivationGroupList(ref cmbDetailMotivationGroupCode, FLedgerNumber, FActiveOnlyFlag); TFinanceControls.InitialiseMotivationDetailList(ref cmbMotivationDetailCode, FLedgerNumber, FActiveOnlyFlag); TFinanceControls.InitialiseMethodOfGivingCodeList(ref cmbDetailMethodOfGivingCode, FActiveOnlyFlag); TFinanceControls.InitialiseMethodOfPaymentCodeList(ref cmbDetailMethodOfPaymentCode, FActiveOnlyFlag); TFinanceControls.InitialisePMailingList(ref cmbDetailMailingCode, FActiveOnlyFlag); } finally { FPetraUtilsObject.SuppressChangeDetection = false; } } // This sets the incomplete filter but does check the panel enabled state ShowData(); // This sets the main part of the filter but excluding the additional items set by the user GUI // It gets the right sort order SetGiftDetailDefaultView(); // only load from server if there are no transactions loaded yet for this batch // otherwise we would overwrite transactions that have already been modified if (FMainDS.AGiftDetail.DefaultView.Count == 0) { dlgStatus.CurrentStatus = Catalog.GetString("Requesting transactions from server ..."); //Load all partners in Batch FMainDS.DonorPartners.Merge(TRemote.MFinance.Gift.WebConnectors.LoadAllPartnerDataForBatch(ALedgerNumber, ABatchNumber)); //LoadAllPartnerDataForBatch(); //Include Donor fields LoadGiftDataForBatch(ALedgerNumber, ABatchNumber); } //Check if need to update batch period in each gift if (FBatchUnpostedFlag) { dlgStatus.CurrentStatus = Catalog.GetString("Updating batch period ..."); ((TFrmGiftBatch)ParentForm).GetBatchControl().UpdateBatchPeriod(); } // Now we set the full filter FFilterAndFindObject.ApplyFilter(); UpdateRecordNumberDisplay(); FFilterAndFindObject.SetRecordNumberDisplayProperties(); SelectRowInGrid(1); UpdateControlsProtection(); dlgStatus.CurrentStatus = Catalog.GetString("Updating totals for the batch ..."); UpdateTotals(); if ((FPreviouslySelectedDetailRow != null) && (FBatchUnpostedFlag)) { bool disableSave = (FBatchRow.RowState == DataRowState.Unchanged && !FPetraUtilsObject.HasChanges); if (disableSave && FPetraUtilsObject.HasChanges && !DataUtilities.DataRowColumnsHaveChanged(FBatchRow)) { FPetraUtilsObject.DisableSaveButton(); } } FGiftTransactionsLoadedFlag = true; dlgStatus.Close(); return(true); }
/// <summary> /// show the form for the gift reversal/adjustment /// </summary> /// <param name="AFunctionName">Which function shall be called on the server</param> private void ShowRevertAdjustForm(GiftAdjustmentFunctionEnum AFunctionName) { TFrmGiftBatch ParentGiftBatchForm = (TFrmGiftBatch)ParentForm; bool ReverseWholeBatch = (AFunctionName == GiftAdjustmentFunctionEnum.ReverseGiftBatch); bool AdjustGift = (AFunctionName == GiftAdjustmentFunctionEnum.AdjustGift); if (!ParentGiftBatchForm.SaveChangesManual()) { return; } ParentGiftBatchForm.Cursor = Cursors.WaitCursor; AGiftBatchRow giftBatch = ((TFrmGiftBatch)ParentForm).GetBatchControl().GetSelectedDetailRow(); int BatchNumber = giftBatch.BatchNumber; if (giftBatch == null) { MessageBox.Show(Catalog.GetString("Please select a Gift Batch to Reverse.")); ParentGiftBatchForm.Cursor = Cursors.Default; return; } if (!giftBatch.BatchStatus.Equals(MFinanceConstants.BATCH_POSTED)) { MessageBox.Show(Catalog.GetString("This function is only possible when the selected batch is already posted.")); ParentGiftBatchForm.Cursor = Cursors.Default; return; } if (FPetraUtilsObject.HasChanges) { MessageBox.Show(Catalog.GetString("Please save first and than try again!")); ParentGiftBatchForm.Cursor = Cursors.Default; return; } if (ReverseWholeBatch && (FBatchNumber != BatchNumber)) { ParentGiftBatchForm.SelectTab(TFrmGiftBatch.eGiftTabs.Transactions, true); ParentGiftBatchForm.SelectTab(TFrmGiftBatch.eGiftTabs.Batches); ParentGiftBatchForm.Cursor = Cursors.WaitCursor; } if (!ReverseWholeBatch && (FPreviouslySelectedDetailRow == null)) { MessageBox.Show(Catalog.GetString("Please select a Gift to Adjust/Reverse.")); ParentGiftBatchForm.Cursor = Cursors.Default; return; } TFrmGiftRevertAdjust revertForm = new TFrmGiftRevertAdjust(FPetraUtilsObject.GetForm()); if (AdjustGift) { if (FSETUseTaxDeductiblePercentageFlag) { revertForm.CheckTaxDeductPctChange = true; } revertForm.CheckGiftDestinationChange = true; } try { ParentForm.ShowInTaskbar = false; revertForm.LedgerNumber = FLedgerNumber; revertForm.CurrencyCode = giftBatch.CurrencyCode; // put spaces inbetween words revertForm.Text = Regex.Replace(AFunctionName.ToString(), "([a-z])([A-Z])", @"$1 $2"); revertForm.AddParam("Function", AFunctionName); revertForm.AddParam("BatchNumber", giftBatch.BatchNumber); if (AdjustGift) { int workingTransactionNumber = FPreviouslySelectedDetailRow.GiftTransactionNumber; int workingDetailNumber = FPreviouslySelectedDetailRow.DetailNumber; revertForm.GiftDetailRow = (AGiftDetailRow)FMainDS.AGiftDetail.Rows.Find( new object[] { giftBatch.LedgerNumber, giftBatch.BatchNumber, workingTransactionNumber, workingDetailNumber }); } if (ReverseWholeBatch) { revertForm.GetGiftsForReverseAdjust(); // Added Feb '17 Tim Ingham - previously, reversing a whole batch didn't work. } if (!revertForm.IsDisposed && (revertForm.ShowDialog() == DialogResult.OK)) { ParentGiftBatchForm.Cursor = Cursors.WaitCursor; if ((revertForm.AdjustmentBatchNumber > 0) && (revertForm.AdjustmentBatchNumber != giftBatch.BatchNumber)) { // select the relevant batch ParentGiftBatchForm.InitialBatchNumber = revertForm.AdjustmentBatchNumber; } ParentGiftBatchForm.RefreshAll(); } } finally { ParentGiftBatchForm.Cursor = Cursors.WaitCursor; revertForm.Dispose(); ParentForm.ShowInTaskbar = true; ParentGiftBatchForm.Cursor = Cursors.Default; } if (AdjustGift && (ParentGiftBatchForm.ActiveTab() == TFrmGiftBatch.eGiftTabs.Transactions)) { //Select first row for adjusting, i.e. first +ve amount foreach (DataRowView drv in FMainDS.AGiftDetail.DefaultView) { AGiftDetailRow gdr = (AGiftDetailRow)drv.Row; if (gdr.GiftTransactionAmount > 0) { grdDetails.SelectRowInGrid(grdDetails.Rows.DataSourceRowToIndex(drv) + 1); } } } }
private void OpenRecipientHistory(System.Object sender, EventArgs e) { TCommonScreensForwarding.OpenDonorRecipientHistoryScreen(false, Convert.ToInt64(txtDetailRecipientKey.Text), FPetraUtilsObject.GetForm()); }
/// <summary> /// Deletes the current row and optionally populates a completion message /// </summary> /// <param name="ARowToDelete">the currently selected row to delete</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> /// <returns>true if row deletion is successful</returns> private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage) { bool DeletionSuccessful = false; if (ARowToDelete == null) { return(DeletionSuccessful); } int BatchNumber = ARowToDelete.BatchNumber; ACompletionMessage = string.Empty; bool RowToDeleteIsNew = (ARowToDelete.RowState == DataRowState.Added); //Backup the Dataset for reversion purposes GiftBatchTDS BackupMainDS = (GiftBatchTDS)FMainDS.Copy(); BackupMainDS.Merge(FMainDS); if (!RowToDeleteIsNew) { //Return modified row to last saved state to avoid validation failures ARowToDelete.RejectChanges(); ShowDetails(ARowToDelete); if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING)) { MessageBox.Show(Catalog.GetString("Error in trying to save prior to deleting current recurring gift batch!"), Catalog.GetString("Deletion Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(DeletionSuccessful); } } try { this.Cursor = Cursors.WaitCursor; ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."), BatchNumber); //clear any transactions currently being editied in the Transaction Tab ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection(); if (!RowToDeleteIsNew) { //Load tables afresh FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, BatchNumber)); } ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().DeleteCurrentRecurringBatchGiftData(BatchNumber); // Delete the recurring batch row. ARowToDelete.Delete(); FPreviouslySelectedDetailRow = null; DeletionSuccessful = true; } catch (Exception ex) { ACompletionMessage = ex.Message; MessageBox.Show(ACompletionMessage, "Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Revert to previous state FMainDS.Merge(BackupMainDS); } finally { this.Cursor = Cursors.Default; } UpdateRecordNumberDisplay(); return(DeletionSuccessful); }
/// <summary> /// Deletes the current row and optionally populates a completion message /// </summary> /// <param name="ARowToDelete">the currently selected row to delete</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> /// <returns>true if row deletion is successful</returns> private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage) { bool deletionSuccessful = false; int batchNumber = ARowToDelete.BatchNumber; bool newBatch = (ARowToDelete.RowState == DataRowState.Added); // first save any changes if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING)) { return(false); } try { ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."), batchNumber); //clear any transactions currently being editied in the Transaction Tab ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection(); if (!newBatch) { //Load tables afresh FMainDS.ARecurringGiftDetail.Clear(); FMainDS.ARecurringGift.Clear(); FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, batchNumber)); } //Delete transactions for (int i = FMainDS.ARecurringGiftDetail.Count - 1; i >= 0; i--) { FMainDS.ARecurringGiftDetail[i].Delete(); } for (int i = FMainDS.ARecurringGift.Count - 1; i >= 0; i--) { FMainDS.ARecurringGift[i].Delete(); } // Delete the recurring batch row. ARowToDelete.Delete(); //FMainDS.AcceptChanges(); FPreviouslySelectedDetailRow = null; deletionSuccessful = true; } catch (Exception ex) { ACompletionMessage = ex.Message; MessageBox.Show(ex.Message, "Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } UpdateRecordNumberDisplay(); return(deletionSuccessful); }
/// <summary> /// Open a dialog to select Contact Attributes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectAttributes(object sender, EventArgs e) { TFrmContactAttributesDialog ContactAttributesDialog = new TFrmContactAttributesDialog(FPetraUtilsObject.GetForm()); ContactAttributesDialog.ContactID = FContactDR.ContactLogId; ContactAttributesDialog.SelectedContactAttributeTable = FMainDS.PPartnerContactAttribute; if (ContactAttributesDialog.ShowDialog() == DialogResult.OK) { PPartnerContactAttributeTable Changes = ContactAttributesDialog.SelectedContactAttributeTable.GetChangesTyped(); // if changes were made or a previously added row (unsaved) was deleted if ((Changes != null) || ContactAttributesDialog.AddedAttributeDeleted) { FMainDS.PPartnerContactAttribute.Clear(); FMainDS.PPartnerContactAttribute.Merge(ContactAttributesDialog.SelectedContactAttributeTable); FGridTableDV = ContactAttributesLogic.SetupContactAttributesGrid(ref grdSelectedAttributes, FMainDS.PPartnerContactAttribute, true, FContactDR.ContactLogId); // only enable save if there are actual changes from the original datatable if (Changes != null) { FPetraUtilsObject.SetChangedFlag(); } } } }
private void SubmitBatch(System.Object sender, EventArgs e) { if (FPreviouslySelectedDetailRow == null) { MessageBox.Show(Catalog.GetString("Please select a Batch before submitting.")); return; } if (FPetraUtilsObject.HasChanges) { // save first, then submit if (!((TFrmRecurringGLBatch)ParentForm).SaveChanges()) { // saving failed, therefore do not try to post MessageBox.Show(Catalog.GetString( "The recurring batch was not submitted due to problems during saving; ") + Environment.NewLine + Catalog.GetString("Please fix the batch first and then submit it."), Catalog.GetString("Submit Failure"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if ((FPreviouslySelectedDetailRow.BatchControlTotal != 0) && (FPreviouslySelectedDetailRow.BatchDebitTotal != FPreviouslySelectedDetailRow.BatchControlTotal)) { MessageBox.Show(String.Format(Catalog.GetString( "The recurring gl batch total ({0}) for batch {1} does not equal the hash total ({2})."), FPreviouslySelectedDetailRow.BatchDebitTotal, FPreviouslySelectedDetailRow.BatchNumber, FPreviouslySelectedDetailRow.BatchControlTotal)); txtDetailBatchControlTotal.Focus(); txtDetailBatchControlTotal.SelectAll(); return; } if (!LoadAllBatchData() || !AllowInactiveFieldValues(FPreviouslySelectedDetailRow.BatchNumber)) { return; } TFrmRecurringGLBatchSubmit SubmitForm = new TFrmRecurringGLBatchSubmit(FPetraUtilsObject.GetForm()); try { ParentForm.ShowInTaskbar = false; GLBatchTDS submitRecurringDS = (GLBatchTDS)FMainDS.Clone(); int currentBatch = FPreviouslySelectedDetailRow.BatchNumber; submitRecurringDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringBatchAndContent(FLedgerNumber, currentBatch)); SubmitForm.SubmitMainDS = submitRecurringDS; SubmitForm.ShowDialog(); } finally { SubmitForm.Dispose(); ParentForm.ShowInTaskbar = true; } }