private void ReadControlsManually(TRptCalculator ACalc, TReportActionEnum AReportAction) { int ColumnCounter = 0; bool DatesAreValid = (dtpFromDate.ValidDate(false) && dtpToDate.ValidDate(false)); ACalc.AddParameter("param_calculation", "Room", ColumnCounter++); if (DatesAreValid) { TimeSpan CheckLength = dtpToDate.Date.Value.Subtract(dtpFromDate.Date.Value); // Add the days as columns for (int Counter = 0; Counter <= CheckLength.Days; ++Counter) { DateTime currentDate = dtpFromDate.Date.Value.AddDays(Counter); ACalc.AddParameter("param_calculation", "CheckDate", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)1.3, ColumnCounter); ACalc.AddParameter("ColumnCaption", currentDate.ToString("MMM-d"), ColumnCounter); ColumnCounter++; } } if (!rbtDetailReport.Checked) { // Don't show the cost column if we have a detailed report ACalc.AddParameter("param_calculation", "Cost", ColumnCounter); ACalc.AddParameter("ColumnWidth", "2.0", ColumnCounter++); } ACalc.AddParameter("MaxDisplayColumns", ColumnCounter); if (rbtBriefReport.Checked) { ACalc.AddParameter("param_report_detail", "Brief"); } else if (rbtFullReport.Checked) { ACalc.AddParameter("param_report_detail", "Full"); } else { ACalc.AddParameter("param_report_detail", "Detail"); } if ((AReportAction == TReportActionEnum.raGenerate) && DatesAreValid) { if (dtpFromDate.Date > dtpToDate.Date) { TVerificationResult VerificationResult = new TVerificationResult( "Change From-Date or To-Date", "From Date must be earlier than To Date", TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } } if (!DatesAreValid) { TVerificationResult VerificationResult = new TVerificationResult( "Enter valid From-Date and To-Date.", "Dates must be valid", TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
/// <summary> /// Sets the Text of the Gift Destination. /// </summary> /// <param name="AGiftDestination">Gift Destination.</param> public void SetGiftDestinationText(String AGiftDestination) { txtGiftDestination.Text = AGiftDestination; FPetraUtilsObject.SetStatusBarText(txtGiftDestination, AGiftDestination); }
/// <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 TSubmitChangesResult StoreManualCode(ref CorporateExchangeSetupTDS ASubmitChanges, out TVerificationResultCollection AVerificationResult) { AVerificationResult = null; int TransactionsChanged; TSubmitChangesResult Result = TRemote.MFinance.Setup.WebConnectors.SaveCorporateExchangeSetupTDS( ref ASubmitChanges, out TransactionsChanged, out AVerificationResult); if ((Result == TSubmitChangesResult.scrOK) && (TransactionsChanged > 0) && (FPetraUtilsObject.GetCallerForm() != null)) { MessageBox.Show(string.Format(Catalog.GetPluralString( "{0} GL Transaction was automatically updated with the new corporate exchange rate.", "{0} GL Transactions were automatically updated with the new corporate exchange rate.", TransactionsChanged, true), TransactionsChanged), Catalog.GetString("Save Corporate Exchange Rates"), MessageBoxButtons.OK); } return(Result); }
/// <summary> /// Reads the selected values from the controls, /// and stores them into the parameter system of FCalculator /// /// </summary> /// <param name="ACalculator"></param> /// <param name="AReportAction"></param> /// <returns>void</returns> public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction) { if (rbtSelectedCostCentres.Checked && (clbCostCentres.GetCheckedStringList().Length == 0) && (AReportAction == TReportActionEnum.raGenerate)) { TVerificationResult VerificationResult = new TVerificationResult(Catalog.GetString("Selected Cost Centres"), Catalog.GetString("No cost centre was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } /* cost centre options */ if (rbtAccountLevel.Checked) { ACalculator.AddParameter("param_costcentreoptions", "AccountLevel"); } else if (rbtAllCostCentres.Checked) { ACalculator.AddParameter("param_costcentreoptions", "AllCostCentres"); } else if (rbtAllActiveCostCentres.Checked) { ACalculator.AddParameter("param_costcentreoptions", "AllActiveCostCentres"); } else if (rbtSelectedCostCentres.Checked) { ACalculator.AddParameter("param_costcentreoptions", "SelectedCostCentres"); } ACalculator.AddParameter("param_paginate", chkPaginate.Checked); ACalculator.AddParameter("param_auto_email", chkAutoEmail.Checked); String CostCentreListTitle; if (rbtAllCostCentres.Checked || rbtAllActiveCostCentres.Checked) { CostCentreListTitle = clbCostCentres.GetAllStringList(false); } else { CostCentreListTitle = clbCostCentres.GetCheckedStringList(); } ACalculator.AddStringParameter("param_cost_centre_codes", CostCentreListTitle); CostCentreListTitle = CostCentreListTitle.Replace("\"", ""); if (CostCentreListTitle.Length > 25) { CostCentreListTitle = "Selected Cost Centres"; } ACalculator.AddParameter("param_cost_centre_list_title", CostCentreListTitle); ACalculator.AddParameter("param_cost_centre_summary", chkCostCentreBreakdown.Checked); ACalculator.AddParameter("param_cost_centre_breakdown", chkCostCentreBreakdown.Checked); ACalculator.AddParameter("ExcludeInactiveCostCentres", chkExcludeInactiveCostCentres.Checked); /* Level of Detail */ if (this.rbtDetail.Checked) { ACalculator.AddParameter("param_depth", "Detail"); } else if (this.rbtStandard.Checked) { ACalculator.AddParameter("param_depth", "Standard"); } else { ACalculator.AddParameter("param_depth", "Summary"); } }
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(ARecurringBatchRow ARowToDelete, ref string ACompletionMessage) { bool DeletionSuccessful = false; ACompletionMessage = string.Empty; if (ARowToDelete == null) { return(false); } //Notify of deletion process TFrmRecurringGLBatch MainForm = (TFrmRecurringGLBatch)this.ParentForm; int CurrentBatchNumber = ARowToDelete.BatchNumber; bool CurrentBatchJournalsLoadedAndCurrent = false; bool CurrentBatchTransactionsLoadedAndCurrent = false; //Backup the Dataset for reversion purposes GLBatchTDS BackupMainDS = null; //Reject any changes which may fail validation ARowToDelete.RejectChanges(); ShowDetails(ARowToDelete); try { this.Cursor = Cursors.WaitCursor; MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.DELETING; //Backup the changes to allow rollback BackupMainDS = (GLBatchTDS)FMainDS.GetChangesTyped(false); //Don't run an inactive fields check on this batch MainForm.GetBatchControl().UpdateRecurringBatchDictionary(CurrentBatchNumber); //Check if current batch journals and transactions are loaded and being viewed in their tab CurrentBatchJournalsLoadedAndCurrent = (MainForm.GetJournalsControl().FBatchNumber == CurrentBatchNumber); CurrentBatchTransactionsLoadedAndCurrent = (MainForm.GetTransactionsControl().FBatchNumber == CurrentBatchNumber); //Save and check for inactive values FPetraUtilsObject.SetChangedFlag(); if (!MainForm.SaveChangesManual(MainForm.FCurrentGLBatchAction, !CurrentBatchJournalsLoadedAndCurrent, !CurrentBatchTransactionsLoadedAndCurrent)) { MainForm.GetBatchControl().UpdateRecurringBatchDictionary(); string msg = String.Format(Catalog.GetString("Recurring Batch {0} has not been deleted."), CurrentBatchNumber); MessageBox.Show(msg, Catalog.GetString("Recurring GL Batch Deletion"), MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } //Remove any changes to current batch that may cause validation issues PrepareBatchDataForDeleting(CurrentBatchNumber, true); //Clear the journal and trans tabs if current batch data is displayed there if (CurrentBatchJournalsLoadedAndCurrent) { //Clear any transactions currently being edited in the Transaction Tab MainForm.GetJournalsControl().ClearCurrentSelection(CurrentBatchNumber); } if (CurrentBatchTransactionsLoadedAndCurrent) { //Clear any transactions currently being edited in the Transaction Tab MainForm.GetTransactionsControl().ClearCurrentSelection(CurrentBatchNumber); } //Delete transactions MainForm.GetTransactionsControl().DeleteRecurringTransactionData(CurrentBatchNumber); //Delete Journals MainForm.GetJournalsControl().DeleteRecurringJournalData(CurrentBatchNumber); // Delete the recurring batch row. ARowToDelete.Delete(); ACompletionMessage = String.Format(Catalog.GetString("Recurring Batch no.: {0} deleted successfully."), CurrentBatchNumber); DeletionSuccessful = true; } catch (Exception ex) { MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE; //Revert to previous state RevertDataSet(FMainDS, BackupMainDS); TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } finally { this.Cursor = Cursors.Default; } UpdateRecordNumberDisplay(); return(DeletionSuccessful); }
private bool OnDeleteRowManual(GiftBatchTDSAGiftDetailRow ARowToDelete, ref string ACompletionMessage) { bool DeletionSuccessful = false; string OriginatingDetailRef = string.Empty; ACompletionMessage = string.Empty; if (ARowToDelete == null) { return(DeletionSuccessful); } bool RowToDeleteIsNew = (ARowToDelete.RowState == DataRowState.Added); if (!RowToDeleteIsNew) { try { // temporarily disable New Donor Warning ((TFrmGiftBatch)this.ParentForm).NewDonorWarning = false; //Return modified row to last saved state to avoid validation failures ARowToDelete.RejectChanges(); ShowDetails(ARowToDelete); if (!((TFrmGiftBatch)this.ParentForm).SaveChanges()) { MessageBox.Show(Catalog.GetString("Error in trying to save prior to deleting current gift detail!"), Catalog.GetString("Deletion Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(DeletionSuccessful); } } finally { ((TFrmGiftBatch)this.ParentForm).NewDonorWarning = true; } } //Backup the Dataset for reversion purposes GiftBatchTDS BackupMainDS = (GiftBatchTDS)FMainDS.Copy(); BackupMainDS.Merge(FMainDS); //To be used later....Pass copy to delete method. //GiftBatchTDS TempDS = (GiftBatchTDS)FMainDS.Copy(); //TempDS.Merge(FMainDS); int SelectedDetailNumber = ARowToDelete.DetailNumber; int GiftToDeleteTransNo = 0; string FilterAllGiftsOfBatch = String.Empty; string FilterAllGiftDetailsOfBatch = String.Empty; int DetailRowCount = FGiftDetailView.Count; try { this.Cursor = Cursors.WaitCursor; //Speeds up deletion of larger gift sets FMainDS.EnforceConstraints = false; if (ARowToDelete.ModifiedDetailKey != null) { OriginatingDetailRef = ARowToDelete.ModifiedDetailKey; } //Delete current detail row ARowToDelete.Delete(); //If there existed (before the delete row above) more than one detail row, then no need to delete gift header row if (DetailRowCount > 1) { FGiftSelectedForDeletion = false; foreach (DataRowView rv in FGiftDetailView) { GiftBatchTDSAGiftDetailRow row = (GiftBatchTDSAGiftDetailRow)rv.Row; if (row.DetailNumber > SelectedDetailNumber) { row.DetailNumber--; } } FGift.LastDetailNumber--; FPetraUtilsObject.SetChangedFlag(); } else { GiftToDeleteTransNo = FGift.GiftTransactionNumber; // Reduce all Gift Detail row Transaction numbers by 1 if they are greater then gift to be deleted FilterAllGiftDetailsOfBatch = String.Format("{0}={1} And {2}>{3}", AGiftDetailTable.GetBatchNumberDBName(), FBatchNumber, AGiftDetailTable.GetGiftTransactionNumberDBName(), GiftToDeleteTransNo); DataView giftDetailView = new DataView(FMainDS.AGiftDetail); giftDetailView.RowFilter = FilterAllGiftDetailsOfBatch; giftDetailView.Sort = String.Format("{0} ASC", AGiftDetailTable.GetGiftTransactionNumberDBName()); foreach (DataRowView rv in giftDetailView) { GiftBatchTDSAGiftDetailRow row = (GiftBatchTDSAGiftDetailRow)rv.Row; row.GiftTransactionNumber--; } //Cannot delete the gift row, just copy the data of rows above down by 1 row // and then mark the top row for deletion //In other words, bubble the gift row to be deleted to the top FilterAllGiftsOfBatch = String.Format("{0}={1} And {2}>={3}", AGiftTable.GetBatchNumberDBName(), FBatchNumber, AGiftTable.GetGiftTransactionNumberDBName(), GiftToDeleteTransNo); DataView giftView = new DataView(FMainDS.AGift); giftView.RowFilter = FilterAllGiftsOfBatch; giftView.Sort = String.Format("{0} ASC", AGiftTable.GetGiftTransactionNumberDBName()); AGiftRow giftRowToReceive = null; AGiftRow giftRowToCopyDown = null; AGiftRow giftRowCurrent = null; int currentGiftTransNo = 0; foreach (DataRowView gv in giftView) { giftRowCurrent = (AGiftRow)gv.Row; currentGiftTransNo = giftRowCurrent.GiftTransactionNumber; if (currentGiftTransNo > GiftToDeleteTransNo) { giftRowToCopyDown = giftRowCurrent; //Copy column values down for (int j = 3; j < giftRowToCopyDown.Table.Columns.Count; j++) { //Update all columns except the pk fields that remain the same if (!giftRowToCopyDown.Table.Columns[j].ColumnName.EndsWith("_text")) { giftRowToReceive[j] = giftRowToCopyDown[j]; } } } if (currentGiftTransNo == FBatchRow.LastGiftNumber) { //Mark last record for deletion giftRowCurrent.GiftStatus = MFinanceConstants.MARKED_FOR_DELETION; } //Will always be previous row giftRowToReceive = giftRowCurrent; } FPreviouslySelectedDetailRow = null; FPetraUtilsObject.SetChangedFlag(); FGiftSelectedForDeletion = true; FBatchRow.LastGiftNumber--; } //Check if deleting a reversed gift detail if (OriginatingDetailRef.StartsWith("|")) { bool ok = TRemote.MFinance.Gift.WebConnectors.ReversedGiftReset(FLedgerNumber, OriginatingDetailRef); if (!ok) { throw new Exception("Error in trying to reset Modified Detail field of the originating gift detail."); } } //Try to save changes if (((TFrmGiftBatch)this.ParentForm).SaveChangesManual()) { //Clear current batch's gift data and reload from server RefreshCurrentBatchGiftData(FBatchNumber); } else { throw new Exception("Unable to save after deleting a gift!"); } ACompletionMessage = Catalog.GetString("Gift row deleted successfully!"); DeletionSuccessful = true; } catch (Exception ex) { ACompletionMessage = ex.Message; MessageBox.Show(ex.Message, "Gift Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Revert to previous state FMainDS.Merge(BackupMainDS); } finally { FMainDS.EnforceConstraints = true; SetGiftDetailDefaultView(); FFilterAndFindObject.ApplyFilter(); this.Cursor = Cursors.Default; } UpdateRecordNumberDisplay(); return(DeletionSuccessful); }
/// <summary> /// auto populate new gift recipient info using the donor's last gift /// </summary> /// <param name="ADonorKey"></param> /// <param name="APartnerShortName"></param> /// <param name="AGiftTransactionNumber"></param> private void AutoPopulateGiftDetail(Int64 ADonorKey, String APartnerShortName, Int32 AGiftTransactionNumber) { FAutoPopulatingGiftInProcess = true; bool IsSplitGift = false; DateTime LatestUnpostedGiftDateEntered = new DateTime(1900, 1, 1); try { //Check for Donor in loaded gift batches // and record most recent date entered AGiftTable DonorRecentGiftsTable = new AGiftTable(); GiftBatchTDSAGiftDetailTable GiftDetailTable = new GiftBatchTDSAGiftDetailTable(); AGiftRow MostRecentLoadedGiftForDonorRow = null; DataView giftDV = new DataView(FMainDS.AGift); giftDV.RowStateFilter = DataViewRowState.CurrentRows; giftDV.RowFilter = string.Format("{0}={1} And Not ({2}={3} And {4}={5})", AGiftTable.GetDonorKeyDBName(), ADonorKey, AGiftTable.GetBatchNumberDBName(), FBatchNumber, AGiftTable.GetGiftTransactionNumberDBName(), AGiftTransactionNumber); giftDV.Sort = String.Format("{0} DESC, {1} DESC", AGiftTable.GetDateEnteredDBName(), AGiftTable.GetGiftTransactionNumberDBName()); if (giftDV.Count > 0) { //Take first row = most recent date entered value MostRecentLoadedGiftForDonorRow = (AGiftRow)giftDV[0].Row; LatestUnpostedGiftDateEntered = MostRecentLoadedGiftForDonorRow.DateEntered; DonorRecentGiftsTable.Rows.Add((object[])MostRecentLoadedGiftForDonorRow.ItemArray.Clone()); } //Check for even more recent saved gifts on server (i.e. not necessarily loaded) GiftDetailTable = TRemote.MFinance.Gift.WebConnectors.LoadDonorLastPostedGift(ADonorKey, FLedgerNumber, LatestUnpostedGiftDateEntered); if (((GiftDetailTable != null) && (GiftDetailTable.Count > 0))) { //UnLoaded/Saved gift from donor is more recent IsSplitGift = (GiftDetailTable.Count > 1); } else if (MostRecentLoadedGiftForDonorRow != null) { //Loaded/unsaved gift from donor is more recent DataView giftDetailDV = new DataView(FMainDS.AGiftDetail); giftDetailDV.RowStateFilter = DataViewRowState.CurrentRows; giftDetailDV.RowFilter = string.Format("{0}={1} And {2}={3}", AGiftDetailTable.GetBatchNumberDBName(), MostRecentLoadedGiftForDonorRow.BatchNumber, AGiftDetailTable.GetGiftTransactionNumberDBName(), MostRecentLoadedGiftForDonorRow.GiftTransactionNumber); foreach (DataRowView drv in giftDetailDV) { GiftBatchTDSAGiftDetailRow gDR = (GiftBatchTDSAGiftDetailRow)drv.Row; GiftDetailTable.Rows.Add((object[])gDR.ItemArray.Clone()); } IsSplitGift = (GiftDetailTable.Count > 1); } else { //nothing to autocopy return; } // if the last gift was a split gift (multiple details) then ask the user if they would like this new gift to also be split if (IsSplitGift) { GiftDetailTable.DefaultView.Sort = GiftBatchTDSAGiftDetailTable.GetDetailNumberDBName() + " ASC"; string Message = string.Format(Catalog.GetString( "The last gift from this donor was a split gift.{0}{0}Here are the details:{0}"), "\n"); int DetailNumber = 1; foreach (DataRowView dvr in GiftDetailTable.DefaultView) { GiftBatchTDSAGiftDetailRow Row = (GiftBatchTDSAGiftDetailRow)dvr.Row; Message += DetailNumber + ") "; if (Row.RecipientKey > 0) { Message += string.Format(Catalog.GetString("Recipient: {0} ({1}); Motivation Group: {2}; Motivation Detail: {3}; Amount: {4}"), Row.RecipientDescription, Row.RecipientKey, Row.MotivationGroupCode, Row.MotivationDetailCode, StringHelper.FormatUsingCurrencyCode(Row.GiftTransactionAmount, GetBatchRow().CurrencyCode) + " " + FBatchRow.CurrencyCode) + "\n"; } DetailNumber++; } Message += "\n" + Catalog.GetString("Do you want to create the same split gift again?"); if (!(MessageBox.Show(Message, Catalog.GetString( "Create Split Gift"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { if (cmbDetailMethodOfGivingCode.CanFocus) { cmbDetailMethodOfGivingCode.Focus(); } else if (txtDetailReference.CanFocus) { txtDetailReference.Focus(); } return; } } this.Cursor = Cursors.WaitCursor; GiftBatchTDSAGiftDetailRow giftDetailRow = (GiftBatchTDSAGiftDetailRow)GiftDetailTable.DefaultView[0].Row; // Handle first row, which is FPreviouslySelectedDetailRow txtDetailDonorKey.Text = String.Format("{0:0000000000}", ADonorKey); txtDetailRecipientKey.Text = String.Format("{0:0000000000}", giftDetailRow.RecipientKey); cmbDetailMotivationGroupCode.SetSelectedString(giftDetailRow.MotivationGroupCode); txtDetailMotivationDetailCode.Text = giftDetailRow.MotivationDetailCode; cmbMotivationDetailCode.SetSelectedString(giftDetailRow.MotivationDetailCode); chkDetailConfidentialGiftFlag.Checked = giftDetailRow.ConfidentialGiftFlag; // Change #5481 chkDetailChargeFlag.Checked = true; cmbDetailMethodOfPaymentCode.SetSelectedString(FBatchMethodOfPayment, -1); cmbDetailMethodOfGivingCode.SetSelectedString(giftDetailRow.MethodOfGivingCode, -1); //Handle mailing code if (FSETAutoCopyIncludeMailingCodeFlag) { cmbDetailMailingCode.SetSelectedString(giftDetailRow.MailingCode, -1); } else { cmbDetailMailingCode.SelectedIndex = -1; } //Copy the comments and comment types if required if (FSETAutoCopyIncludeCommentsFlag) { txtDetailGiftCommentOne.Text = giftDetailRow.GiftCommentOne; cmbDetailCommentOneType.SetSelectedString(giftDetailRow.CommentOneType); txtDetailGiftCommentTwo.Text = giftDetailRow.GiftCommentTwo; cmbDetailCommentTwoType.SetSelectedString(giftDetailRow.CommentTwoType); txtDetailGiftCommentThree.Text = giftDetailRow.GiftCommentThree; cmbDetailCommentThreeType.SetSelectedString(giftDetailRow.CommentThreeType); } //Handle tax fields on current row if (FSETUseTaxDeductiblePercentageFlag) { bool taxDeductible = (giftDetailRow.IsTaxDeductibleNull() ? true : giftDetailRow.TaxDeductible); giftDetailRow.TaxDeductible = taxDeductible; try { FPetraUtilsObject.SuppressChangeDetection = true; chkDetailTaxDeductible.Checked = taxDeductible; EnableTaxDeductibilityPct(taxDeductible); } finally { FPetraUtilsObject.SuppressChangeDetection = false; } if (!IsSplitGift) { //Most commonly not a split gift (?) if (!taxDeductible) { txtDeductiblePercentage.NumberValueDecimal = 0.0m; } txtTaxDeductAmount.NumberValueDecimal = 0.0m; txtNonDeductAmount.NumberValueDecimal = 0.0m; } else { if (taxDeductible) { //In case the tax percentage has changed or null values in amount fields ReconcileTaxDeductibleAmounts(giftDetailRow); } else { //Changing this will update the unbound amount textboxes txtDeductiblePercentage.NumberValueDecimal = 0.0m; } } } //Process values that are not bound to a control giftDetailRow.ReceiptPrinted = false; giftDetailRow.ReceiptNumber = 0; //Now process other gift details if they exist if (IsSplitGift) { //Only copy amount to first row if copying split gifts txtDetailGiftTransactionAmount.NumberValueDecimal = giftDetailRow.GiftTransactionAmount; // clear previous validation errors. // otherwise we get an error if the user has changed the control immediately after changing the donor key. FPetraUtilsObject.VerificationResultCollection.Clear(); bool SelectEndRow = (FBatchRow.LastGiftNumber == FPreviouslySelectedDetailRow.GiftTransactionNumber); //Just retain other details to add giftDetailRow.Delete(); GiftDetailTable.AcceptChanges(); foreach (DataRowView drv in GiftDetailTable.DefaultView) { GiftBatchTDSAGiftDetailRow detailRow = (GiftBatchTDSAGiftDetailRow)drv.Row; //______________________ //Update basic field values detailRow.LedgerNumber = FLedgerNumber; detailRow.BatchNumber = FBatchNumber; detailRow.GiftTransactionNumber = AGiftTransactionNumber; detailRow.DetailNumber = ++FGift.LastDetailNumber; detailRow.DonorName = APartnerShortName; detailRow.DonorClass = FPreviouslySelectedDetailRow.DonorClass; detailRow.DateEntered = FGift.DateEntered; detailRow.MethodOfPaymentCode = FPreviouslySelectedDetailRow.MethodOfPaymentCode; detailRow.ReceiptPrinted = false; detailRow.ReceiptNumber = 0; // Change #5481 detailRow.ChargeFlag = true; if (!FSETAutoCopyIncludeMailingCodeFlag) { detailRow.MailingCode = string.Empty; } //______________________ //process recipient details to get most recent data Int64 partnerKey = detailRow.RecipientKey; string partnerShortName = string.Empty; TPartnerClass partnerClass; bool recipientIsValid = true; if (TServerLookup.TMPartner.GetPartnerShortName(partnerKey, out partnerShortName, out partnerClass)) { detailRow.RecipientDescription = partnerShortName; detailRow.RecipientClass = partnerClass.ToString(); if (partnerClass == TPartnerClass.FAMILY) { detailRow.RecipientLedgerNumber = TRemote.MFinance.Gift.WebConnectors.GetRecipientFundNumber(partnerKey, FGift.DateEntered); detailRow.RecipientField = detailRow.RecipientLedgerNumber; detailRow.RecipientKeyMinistry = string.Empty; } else { //Class - UNIT Int64 field; string keyMinName; recipientIsValid = TFinanceControls.GetRecipientKeyMinData(partnerKey, out field, out keyMinName); detailRow.RecipientLedgerNumber = field; detailRow.RecipientField = field; detailRow.RecipientKeyMinistry = keyMinName; if (!recipientIsValid) { string msg = String.Format(Catalog.GetString( "Gift: {0}, Detail: {1} has a recipient: '{2}-{3}' that is an inactive Key Ministry!"), AGiftTransactionNumber, detailRow.DetailNumber, partnerKey, keyMinName); MessageBox.Show(msg, Catalog.GetString( "Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { recipientIsValid = false; string msg = String.Format(Catalog.GetString("Gift: {0}, Detail: {1} has an invalid Recipient key: '{2}'!"), AGiftTransactionNumber, detailRow.DetailNumber, partnerKey); MessageBox.Show(msg, Catalog.GetString("Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } //______________________ //Process motivation if (string.IsNullOrEmpty(detailRow.MotivationGroupCode)) { detailRow.MotivationGroupCode = string.Empty; string msg = String.Format(Catalog.GetString("Gift: {0}, Detail: {1} has no Motivation Group!"), AGiftTransactionNumber, detailRow.DetailNumber); MessageBox.Show(msg, Catalog.GetString("Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (string.IsNullOrEmpty(detailRow.MotivationDetailCode)) { detailRow.MotivationDetailCode = string.Empty; string msg = String.Format(Catalog.GetString("Gift: {0}, Detail: {1} has no Motivation Detail!"), AGiftTransactionNumber, detailRow.DetailNumber); MessageBox.Show(msg, Catalog.GetString("Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { AMotivationDetailRow motivationDetailRow = null; string motivationGroup = detailRow.MotivationGroupCode; string motivationDetail = detailRow.MotivationDetailCode; motivationDetailRow = (AMotivationDetailRow)FMainDS.AMotivationDetail.Rows.Find( new object[] { FLedgerNumber, motivationGroup, motivationDetail }); if (motivationDetailRow != null) { if (partnerKey > 0) { bool partnerIsMissingLink = false; detailRow.CostCentreCode = TRemote.MFinance.Gift.WebConnectors.RetrieveCostCentreCodeForRecipient(FLedgerNumber, partnerKey, detailRow.RecipientLedgerNumber, detailRow.DateEntered, motivationGroup, motivationDetail, out partnerIsMissingLink); } else { if (motivationGroup != MFinanceConstants.MOTIVATION_GROUP_GIFT) { detailRow.RecipientDescription = motivationGroup; } else { detailRow.RecipientDescription = string.Empty; } detailRow.CostCentreCode = motivationDetailRow.CostCentreCode; } detailRow.AccountCode = motivationDetailRow.AccountCode; if (FSETUseTaxDeductiblePercentageFlag && string.IsNullOrEmpty(motivationDetailRow.TaxDeductibleAccountCode)) { detailRow.TaxDeductibleAccountCode = string.Empty; string msg = String.Format(Catalog.GetString( "Gift: {0}, Detail: {1} has Motivation Detail: {2} which has no Tax Deductible Account!" + "This can be added in Finance / Setup / Motivation Details.{3}{3}" + "Unless this is changed it will be impossible to assign a Tax Deductible Percentage to this gift."), AGiftTransactionNumber, detailRow.DetailNumber, motivationDetail, Environment.NewLine); MessageBox.Show(msg, Catalog.GetString( "Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { detailRow.TaxDeductibleAccountCode = motivationDetailRow.TaxDeductibleAccountCode; } } else { string msg = String.Format(Catalog.GetString( "Gift: {0}, Detail: {1} has Motivation Group and Detail codes ('{2} : {3}') not found in the database!"), AGiftTransactionNumber, detailRow.DetailNumber, motivationGroup, motivationDetail); MessageBox.Show(msg, Catalog.GetString("Copying Previous Split Gift"), MessageBoxButtons.OK, MessageBoxIcon.Warning); detailRow.TaxDeductible = false; } } //______________________ //Handle tax fields detailRow.TaxDeductiblePct = RetrieveTaxDeductiblePct((recipientIsValid ? detailRow.RecipientKey : 0), detailRow.TaxDeductible); AGiftDetailRow giftDetails = (AGiftDetailRow)detailRow; TaxDeductibility.UpdateTaxDeductibiltyAmounts(ref giftDetails); //______________________ //Process comments if (!FSETAutoCopyIncludeCommentsFlag) { detailRow.SetCommentOneTypeNull(); detailRow.SetCommentTwoTypeNull(); detailRow.SetCommentThreeTypeNull(); detailRow.SetGiftCommentOneNull(); detailRow.SetGiftCommentTwoNull(); detailRow.SetGiftCommentThreeNull(); } detailRow.AcceptChanges(); detailRow.SetAdded(); } //Add in the new records (latter two arguments put in to parallel recurring form) FMainDS.AGiftDetail.Merge(GiftDetailTable, false, MissingSchemaAction.Ignore); int indexOfLatestRow = FMainDS.AGiftDetail.Rows.Count - 1; //Select last row added if (SelectEndRow) { grdDetails.SelectRowInGrid(grdDetails.Rows.Count - 1); } else if (!SelectDetailRowByDataTableIndex(indexOfLatestRow)) { if (!FFilterAndFindObject.IsActiveFilterEqualToBase) { MessageBox.Show( MCommonResourcestrings.StrNewRecordIsFiltered, MCommonResourcestrings.StrAddNewRecordTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); FFilterAndFindObject.FilterPanelControls.ClearAllDiscretionaryFilters(); if (FFilterAndFindObject.FilterFindPanel.ShowApplyFilterButton != TUcoFilterAndFind.FilterContext.None) { FFilterAndFindObject.ApplyFilter(); } SelectDetailRowByDataTableIndex(indexOfLatestRow); } } ClearKeyMinistries(); cmbMotivationDetailCode.Clear(); mniRecipientHistory.Enabled = false; btnDeleteAll.Enabled = btnDelete.Enabled; UpdateRecordNumberDisplay(); FLastDonor = -1; } else { txtDetailDonorKey.FocusTextBoxPartAfterFindScreenCloses = false; txtDetailGiftTransactionAmount.Focus(); } FPetraUtilsObject.SetChangedFlag(); } finally { this.Cursor = Cursors.Default; FAutoPopulatingGiftInProcess = false; } }
private void InitializeManualCode() { FGiftDetailFindObject = TRemote.MFinance.Finance.UIConnectors.GiftDetailFind(); // remove from the combobox all ledger numbers which the user does not have permission to access DataView cmbLedgerDataView = (DataView)cmbLedger.cmbCombobox.DataSource; for (int i = 0; i < cmbLedgerDataView.Count; i++) { string LedgerNumberStr; // postgresql if (cmbLedgerDataView[i].Row[0].GetType().Equals(typeof(int))) { LedgerNumberStr = ((int)cmbLedgerDataView[i].Row[0]).ToString("0000"); } else // sqlite { LedgerNumberStr = ((Int64)cmbLedgerDataView[i].Row[0]).ToString("0000"); } if (!UserInfo.GUserInfo.IsInModule("LEDGER" + LedgerNumberStr)) { cmbLedgerDataView.Delete(i); i--; } } // add event to combobox (this is the best moment to do this) cmbLedger.SelectedValueChanged += new System.EventHandler(this.OnCmbLedgerChange); // add divider line (can't currently do this in YAML) DevAge.Windows.Forms.Line linCriteriaDivider = new DevAge.Windows.Forms.Line(); linCriteriaDivider.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); linCriteriaDivider.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; linCriteriaDivider.FirstColor = System.Drawing.SystemColors.ControlDark; linCriteriaDivider.LineStyle = DevAge.Windows.Forms.LineStyle.Horizontal; linCriteriaDivider.Location = new System.Drawing.Point(grpFindCriteria.Location.Y + 6, btnSearch.Location.Y - 2); linCriteriaDivider.Name = "linCriteriaDivider"; linCriteriaDivider.SecondColor = System.Drawing.SystemColors.ControlLightLight; linCriteriaDivider.Size = new System.Drawing.Size(grpFindCriteria.Size.Width - 12, 2); grpFindCriteria.Controls.Add(linCriteriaDivider); // pnlBlankSearchResult pnlBlankSearchResult.BackColor = System.Drawing.SystemColors.ControlLightLight; pnlBlankSearchResult.Size = grdResult.Size; lblSearchInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); // lblSearchInfo this.lblSearchInfo.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblSearchInfo.ForeColor = System.Drawing.SystemColors.ControlDarkDark; lblSearchInfo.Size = grdResult.Size; lblSearchInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // remove '0' from these textboxes txtGiftBatchNumber.NumberValueInt = null; txtGiftTransactionNumber.NumberValueInt = null; txtReceiptNumber.NumberValueInt = null; txtMinimumAmount.NumberValueInt = null; txtMaximumAmount.NumberValueInt = null; // set button to be on the very right of the screen (can't make this work in YAML) btnClear.Location = new System.Drawing.Point(linCriteriaDivider.Location.X + linCriteriaDivider.Width - btnClear.Width, btnClear.Location.Y); // set to blank initially lblRecordCounter.Text = ""; // event fired on screen close this.Closed += new System.EventHandler(this.TGiftDetailFindScreen_Closed); // catch enter on all controls, to trigger search or accept (could use this.AcceptButton, but we have several search buttons etc) this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CatchEnterKey); // catch enter on grid to view the selected transaction this.grdResult.EnterKeyPressed += new Ict.Common.Controls.TKeyPressedEventHandler(this.BtnView_Click); // fix tab order int Temp = txtDonor.TabIndex; txtDonor.TabIndex = cmbMotivationGroup.TabIndex; cmbMotivationGroup.TabIndex = txtRecipient.TabIndex; txtRecipient.TabIndex = dtpDateTo.TabIndex; dtpDateTo.TabIndex = txtMinimumAmount.TabIndex; txtMinimumAmount.TabIndex = txtComment1.TabIndex; txtComment1.TabIndex = dtpDateFrom.TabIndex; dtpDateFrom.TabIndex = cmbMotivationDetail.TabIndex; cmbMotivationDetail.TabIndex = txtReceiptNumber.TabIndex; txtReceiptNumber.TabIndex = txtGiftTransactionNumber.TabIndex; txtGiftTransactionNumber.TabIndex = Temp; this.ActiveControl = txtGiftBatchNumber; // set statusbar messages FPetraUtilsObject.SetStatusBarText(cmbLedger, Catalog.GetString("Select a ledger")); FPetraUtilsObject.SetStatusBarText(txtGiftBatchNumber, Catalog.GetString("Enter a Gift Batch Number")); FPetraUtilsObject.SetStatusBarText(txtGiftTransactionNumber, Catalog.GetString("Enter a Gift Transaction Number")); FPetraUtilsObject.SetStatusBarText(txtReceiptNumber, Catalog.GetString("Enter a Gift Receipt Number")); FPetraUtilsObject.SetStatusBarText(cmbMotivationGroup, Catalog.GetString("Select a Motivation Group")); FPetraUtilsObject.SetStatusBarText(cmbMotivationDetail, Catalog.GetString("Select a Motivation Detail")); FPetraUtilsObject.SetStatusBarText(txtComment1, Catalog.GetString("Enter a Comment")); FPetraUtilsObject.SetStatusBarText(txtDonor, Catalog.GetString("Enter a Donor's Partner Key")); FPetraUtilsObject.SetStatusBarText(txtRecipient, Catalog.GetString("Enter a Recipient's Partner Key")); FPetraUtilsObject.SetStatusBarText(dtpDateFrom, Catalog.GetString("Enter a date for which gifts must have been entered on or after")); FPetraUtilsObject.SetStatusBarText(dtpDateTo, Catalog.GetString("Enter a date for which gifts must have been entered on or before")); FPetraUtilsObject.SetStatusBarText(txtMinimumAmount, Catalog.GetString("Enter an amount for which gifts must have an amount equal or greater than")); FPetraUtilsObject.SetStatusBarText(txtMaximumAmount, Catalog.GetString("Enter an amount for which gifts must have an amount equal or less than")); FPetraUtilsObject.SetStatusBarText(btnSearch, Catalog.GetString("Searches the OpenPetra database with above criteria")); FPetraUtilsObject.SetStatusBarText(btnClear, Catalog.GetString("Clears the search criteria fields and the search result")); FPetraUtilsObject.SetStatusBarText(btnView, Catalog.GetString("Views the selected Gift")); FinishButtonPanelSetup(); }
private void DeleteAllGifts(System.Object sender, EventArgs e) { string completionMessage = string.Empty; int BatchNumberToClear = FBatchNumber; if ((FPreviouslySelectedDetailRow == null) || (FBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { return; } else if (!FFilterAndFindObject.IsActiveFilterEqualToBase) { MessageBox.Show(Catalog.GetString("Please remove the filter before attempting to delete all gifts in this batch."), Catalog.GetString("Delete All Gifts")); return; } if (MessageBox.Show(String.Format(Catalog.GetString( "You have chosen to delete all gifts from batch ({0}).{1}{1}Are you sure you want to delete all?"), BatchNumberToClear, Environment.NewLine), Catalog.GetString("Confirm Delete All"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { try { //Normally need to set the message parameters before the delete is performed if requiring any of the row values completionMessage = String.Format(Catalog.GetString("All gifts and details deleted successfully."), FPreviouslySelectedDetailRow.BatchNumber); //clear any transactions currently being editied in the Transaction Tab ClearCurrentSelection(false); //Clear out the gift data for the current batch without marking the records for deletion // and then reload from server RefreshCurrentBatchGiftData(BatchNumberToClear); //Now delete all gift data for current batch DeleteCurrentBatchGiftData(BatchNumberToClear); FBatchRow.BatchTotal = 0; // Be sure to set the last gift number in the parent table before saving all the changes SetBatchLastGiftNumber(); FPetraUtilsObject.SetChangedFlag(); // save first, then post if (!((TFrmGiftBatch)ParentForm).SaveChangesManual()) { SelectRowInGrid(1); // saving failed, therefore do not try to cancel MessageBox.Show(Catalog.GetString("The emptied batch failed to save!")); } else { MessageBox.Show(completionMessage, "All Gifts Deleted.", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { completionMessage = ex.Message; MessageBox.Show(ex.Message, "Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Return FMainDS to original state FMainDS.RejectChanges(); } } if (grdDetails.Rows.Count < 2) { ShowDetails(null); UpdateControlsProtection(); } UpdateRecordNumberDisplay(); }
/// <summary> /// Switch to the given tab /// </summary> /// <param name="ATab"></param> /// <param name="AAllowRepeatEvent"></param> public void SelectTab(TGLBatchEnums.eGLTabs ATab, bool AAllowRepeatEvent = false) { //Between the tab changing and seleted events changes are incorrectly detected on Journal controls // TODO: find cause but use this field for now if (!FChangesDetected && FPetraUtilsObject.HasChanges) { FPetraUtilsObject.DisableSaveButton(); } else if (FChangesDetected && !FPetraUtilsObject.HasChanges) { FChangesDetected = false; } try { this.Cursor = Cursors.WaitCursor; if (ATab == TGLBatchEnums.eGLTabs.Batches) { if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches) && !AAllowRepeatEvent) { //Repeat event return; } FPreviouslySelectedTab = TGLBatchEnums.eGLTabs.Batches; this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringBatches; this.tpgRecurringJournals.Enabled = (ucoRecurringBatches.GetSelectedDetailRow() != null); this.tabRecurringGLBatch.TabStop = this.tpgRecurringJournals.Enabled; ucoRecurringBatches.AutoEnableTransTabForBatch(); ucoRecurringBatches.SetInitialFocus(); } else if (ATab == TGLBatchEnums.eGLTabs.Journals) { if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Journals) && !AAllowRepeatEvent) { //Repeat event return; } if (this.tpgRecurringJournals.Enabled) { FPreviouslySelectedTab = TGLBatchEnums.eGLTabs.Journals; this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringJournals; LoadJournals(ucoRecurringBatches.GetSelectedDetailRow()); this.tpgRecurringTransactions.Enabled = (ucoRecurringJournals.GetSelectedDetailRow() != null); this.ucoRecurringJournals.UpdateHeaderTotals(ucoRecurringBatches.GetSelectedDetailRow()); } } else if (ATab == TGLBatchEnums.eGLTabs.Transactions) { if ((FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Transactions) && !AAllowRepeatEvent) { //Repeat event return; } if (this.tpgRecurringTransactions.Enabled) { bool batchWasPreviousTab = (FPreviouslySelectedTab == TGLBatchEnums.eGLTabs.Batches); FPreviouslySelectedTab = TGLBatchEnums.eGLTabs.Transactions; // Note!! This call may result in this (SelectTab) method being called again (but no new transactions will be loaded the second time) this.tabRecurringGLBatch.SelectedTab = this.tpgRecurringTransactions; if (batchWasPreviousTab) { //This only happens when the user clicks from Batch to Transactions, // which is only allowed when one journal exists //Need to make sure that the Journal is loaded LoadJournals(ucoRecurringBatches.GetSelectedDetailRow()); } LoadTransactions(ucoRecurringJournals.GetSelectedDetailRow().BatchNumber, ucoRecurringJournals.GetSelectedDetailRow().JournalNumber, ucoRecurringJournals.GetSelectedDetailRow().TransactionCurrency, batchWasPreviousTab); } } } finally { this.Cursor = Cursors.Default; this.Refresh(); } }
void tabRecurringGLBatch_GotFocus(object sender, EventArgs e) { FPetraUtilsObject.WriteToStatusBar(Catalog.GetString( "Use the left or right arrow keys to switch between Batches, Journals and Transactions")); }
// // 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 using the AutoEmailReports method which calls 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() + "'"; } List <String> Status = FastReportsWrapper.AutoEmailReports(FPetraUtilsObject, FPetraUtilsObject.FFastReportsPlugin, ACalc, FLedgerNumber, CostCentreFilter); MessageBox.Show(String.Join("\n", Status), Catalog.GetString("Auto Email") + " " + Catalog.GetString("Income Expense Report")); return(false); } return(true); }
/// <summary> /// Reads the selected values from the controls, /// and stores them into the parameter system of FCalculator /// /// </summary> /// <param name="ACalculator"></param> /// <param name="AReportAction"></param> /// <returns>void</returns> public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction) { TVerificationResult VerificationResult; if (rbtAllAccounts.Checked) { ACalculator.AddParameter("param_rgrAccounts", "AllAccounts"); ACalculator.AddParameter("param_account_list_title", "All Accounts"); } else if (rbtAccountFromList.Checked) { String SelectedAccountCodes = clbAccountCodes.GetCheckedStringList(); if ((SelectedAccountCodes.Length == 0) && (AReportAction == TReportActionEnum.raGenerate)) { VerificationResult = new TVerificationResult(Catalog.GetString("Select Account Codes"), Catalog.GetString("No Account Code was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalculator.AddStringParameter("param_account_codes", SelectedAccountCodes); if (SelectedAccountCodes.Length > 25) { SelectedAccountCodes = "Selected Accounts"; } // need to set NOTUSED, // otherwise the report generator complains about the missing parameter // *NOTUSED* is used as an invalid value, there is no account with this name ACalculator.AddParameter("param_account_list_title", SelectedAccountCodes); ACalculator.AddParameter("param_account_code_start", "*NOTUSED*"); ACalculator.AddParameter("param_account_code_end", "*NOTUSED*"); ACalculator.AddParameter("param_rgrAccounts", "AccountList"); } else { ACalculator.AddParameter("param_account_list_title", cmbFromAccountCode.GetSelectedString() + " To " + cmbToAccountCode.GetSelectedString()); ACalculator.AddParameter("param_account_codes", "*NOTUSED*"); ACalculator.AddParameter("param_account_code_start", cmbFromAccountCode.GetSelectedString()); ACalculator.AddParameter("param_account_code_end", cmbToAccountCode.GetSelectedString()); ACalculator.AddParameter("param_rgrAccounts", "AccountRange"); VerificationResult = TStringChecks.FirstLesserOrEqualThanSecondString( cmbFromAccountCode.GetSelectedString(), cmbToAccountCode.GetSelectedString(), Catalog.GetString("Account Range From"), Catalog.GetString("Account Range To")); if (VerificationResult != null) { FPetraUtilsObject.AddVerificationResult(VerificationResult); } } if (rbtAllCostCentres.Checked) { ACalculator.AddParameter("param_cost_centre_list_title", "All Cost Centres"); ACalculator.AddParameter("param_rgrCostCentres", "AllCostCentres"); } else if (rbtCostCentreFromList.Checked) { VerificationResult = TGuiChecks.ValidateCheckedListBoxVersatile(clbCostCentres); if (VerificationResult != null) { VerificationResult = new TVerificationResult(Catalog.GetString("Select CostCentre Codes from list"), Catalog.GetString("No cost centre was selected!"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } String CostCentreListTitle = clbCostCentres.GetCheckedStringList(); ACalculator.AddStringParameter("param_cost_centre_codes", CostCentreListTitle); CostCentreListTitle = CostCentreListTitle.Replace("\"", ""); if (CostCentreListTitle.Length > 25) { CostCentreListTitle = "Selected Cost Centres"; } // need to set NOTUSED, // otherwise the report generator complains about the missing parameter // NOTUSED is used as an invalid value, there is no Cost Centre with this name ACalculator.AddParameter("param_cost_centre_list_title", CostCentreListTitle); ACalculator.AddParameter("param_cost_centre_code_start", "*NOTUSED*"); ACalculator.AddParameter("param_cost_centre_code_end", "*NOTUSED*"); ACalculator.AddParameter("param_rgrCostCentres", "CostCentreList"); } else { ACalculator.AddParameter("param_cost_centre_list_title", cmbFromCostCentre.GetSelectedString() + " To " + cmbToCostCentre.GetSelectedString()); ACalculator.AddParameter("param_cost_centre_codes", "*NOTUSED*"); ACalculator.AddParameter("param_cost_centre_code_start", cmbFromCostCentre.GetSelectedString()); ACalculator.AddParameter("param_cost_centre_code_end", cmbToCostCentre.GetSelectedString()); VerificationResult = TStringChecks.FirstLesserOrEqualThanSecondString( cmbFromCostCentre.GetSelectedString(), cmbToCostCentre.GetSelectedString(), Catalog.GetString("Cost Centre Range From"), Catalog.GetString("Cost Centre Range To")); if (VerificationResult != null) { FPetraUtilsObject.AddVerificationResult(VerificationResult); } ACalculator.AddParameter("param_rgrCostCentres", "CostCentreRange"); } ACalculator.AddParameter("param_depth", "standard"); // I don't want this, but I'll keep it for a while... }
/// <summary> /// Creates a new Gift or Gift detail depending upon the parameter /// </summary> /// <param name="ACompletelyNewGift"></param> private void CreateANewGift(bool ACompletelyNewGift) { // Using a button's keyboard shortcut results in a different sequence of Events from clicking it with the mouse. If the current control is in pnlDetails, // then when the New or Delete button's processing attempts to save the current record and calls TFrmPetraUtils.ForceOnLeaveForActiveControl(), // it inadvertently re-raises the pnlDetails.Enter event which activates BeginEditMode() at a point when it's not supposed to be activated, putting // TCmbAutoComplete controls in a state they're not supposed to be in, resulting in a NullReferenceException from FPreviouslySelectedDetailRow // in UC_GiftTransactions.Motivation.ManualCode.cs, MotivationDetailChanged(). // To fix it, put the focus outside pnlDetails, preventing the whole chain of events from happening. grdDetails.Focus(); AGiftRow CurrentGiftRow = null; bool IsEmptyGrid = (grdDetails.Rows.Count == 1); bool HasChanges = FPetraUtilsObject.HasChanges; bool SelectEndRow = false; bool FPrevRowIsNull = (FPreviouslySelectedDetailRow == null); bool CopyDetails = false; bool AutoSaveSuccessful = FSETAutoSaveFlag && HasChanges && ((TFrmGiftBatch)ParentForm).SaveChangesManual(); FNewGiftInProcess = true; try { //May need to copy values down if a new detail row inside current gift int giftTransactionNumber = 0; string donorName = string.Empty; string donorClass = string.Empty; bool confidentialGiftFlag = false; bool chargeFlag = false; bool taxDeductible = false; string motivationGroupCode = string.Empty; string motivationDetailCode = string.Empty; if (AutoSaveSuccessful || ((!FSETAutoSaveFlag || !HasChanges) && ValidateAllData(true, TErrorProcessingMode.Epm_IgnoreNonCritical))) { if (!ACompletelyNewGift) //i.e. a gift detail { ACompletelyNewGift = IsEmptyGrid; } CopyDetails = (!ACompletelyNewGift && !FPrevRowIsNull); if (CopyDetails) { //Allow for possibility that FPrev... may have some null column values giftTransactionNumber = FPreviouslySelectedDetailRow.GiftTransactionNumber; donorName = FPreviouslySelectedDetailRow.IsDonorNameNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorName; donorClass = FPreviouslySelectedDetailRow.IsDonorClassNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorClass; confidentialGiftFlag = FPreviouslySelectedDetailRow.IsConfidentialGiftFlagNull() ? false : FPreviouslySelectedDetailRow.ConfidentialGiftFlag; chargeFlag = FPreviouslySelectedDetailRow.IsChargeFlagNull() ? true : FPreviouslySelectedDetailRow.ChargeFlag; taxDeductible = FPreviouslySelectedDetailRow.IsTaxDeductibleNull() ? true : FPreviouslySelectedDetailRow.TaxDeductible; motivationGroupCode = FPreviouslySelectedDetailRow.IsMotivationGroupCodeNull() ? string.Empty : FPreviouslySelectedDetailRow. MotivationGroupCode; motivationDetailCode = FPreviouslySelectedDetailRow.IsMotivationDetailCodeNull() ? string.Empty : FPreviouslySelectedDetailRow. MotivationDetailCode; } //Set previous row to Null. FPreviouslySelectedDetailRow = null; if (ACompletelyNewGift) { //Run this if a new gift is requested or required. SelectEndRow = true; // we create the row locally, no dataset AGiftRow giftRow = FMainDS.AGift.NewRowTyped(true); giftRow.LedgerNumber = FBatchRow.LedgerNumber; giftRow.BatchNumber = FBatchRow.BatchNumber; giftRow.GiftTransactionNumber = ++FBatchRow.LastGiftNumber; giftRow.MethodOfPaymentCode = FBatchRow.MethodOfPaymentCode; giftRow.LastDetailNumber = 1; giftRow.DateEntered = FBatchRow.GlEffectiveDate; FMainDS.AGift.Rows.Add(giftRow); CurrentGiftRow = giftRow; mniDonorHistory.Enabled = false; //Reset textboxes to zero txtGiftTotal.NumberValueDecimal = 0; } else { CurrentGiftRow = GetGiftRow(giftTransactionNumber); CurrentGiftRow.LastDetailNumber++; //If adding detail to current last gift, then new detail will be bottom row in grid if (FBatchRow.LastGiftNumber == giftTransactionNumber) { SelectEndRow = true; } } //New gifts will require a new detail anyway, so this code always runs GiftBatchTDSAGiftDetailRow newRow = FMainDS.AGiftDetail.NewRowTyped(true); newRow.LedgerNumber = FBatchRow.LedgerNumber; newRow.BatchNumber = FBatchRow.BatchNumber; newRow.GiftTransactionNumber = CurrentGiftRow.GiftTransactionNumber; newRow.DetailNumber = CurrentGiftRow.LastDetailNumber; newRow.MethodOfPaymentCode = CurrentGiftRow.MethodOfPaymentCode; newRow.MethodOfGivingCode = CurrentGiftRow.MethodOfGivingCode; newRow.DonorKey = CurrentGiftRow.DonorKey; if (CopyDetails) { newRow.DonorName = donorName; newRow.DonorClass = donorClass; newRow.ConfidentialGiftFlag = confidentialGiftFlag; newRow.ChargeFlag = chargeFlag; newRow.TaxDeductible = taxDeductible; newRow.MotivationGroupCode = motivationGroupCode; newRow.MotivationDetailCode = motivationDetailCode; // set the auto-populate comment if needed AMotivationDetailRow motivationDetail = (AMotivationDetailRow)FMainDS.AMotivationDetail.Rows.Find( new object[] { FLedgerNumber, newRow.MotivationGroupCode, newRow.MotivationDetailCode }); if ((motivationDetail != null) && motivationDetail.Autopopdesc) { newRow.GiftCommentOne = motivationDetail.MotivationDetailDesc; } } else { newRow.MotivationGroupCode = MFinanceConstants.MOTIVATION_GROUP_GIFT; newRow.MotivationDetailCode = MFinanceConstants.GROUP_DETAIL_SUPPORT; } newRow.DateEntered = CurrentGiftRow.DateEntered; newRow.ReceiptPrinted = false; newRow.ReceiptNumber = 0; cmbMotivationDetailCode.SetSelectedString(newRow.MotivationDetailCode, -1); txtDetailMotivationDetailCode.Text = newRow.MotivationDetailCode; if (FSETUseTaxDeductiblePercentageFlag) { newRow.TaxDeductiblePct = newRow.TaxDeductible ? 100.0m : 0.0m; //Set unbound textboxes to 0 txtTaxDeductAmount.NumberValueDecimal = 0.0m; txtNonDeductAmount.NumberValueDecimal = 0.0m; } FMainDS.AGiftDetail.Rows.Add(newRow); FPetraUtilsObject.SetChangedFlag(); if (!SelectEndRow && !SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1)) { if (!FFilterAndFindObject.IsActiveFilterEqualToBase) { MessageBox.Show( MCommonResourcestrings.StrNewRecordIsFiltered, MCommonResourcestrings.StrAddNewRecordTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); FFilterAndFindObject.FilterPanelControls.ClearAllDiscretionaryFilters(); if (FFilterAndFindObject.FilterFindPanel.ShowApplyFilterButton != TUcoFilterAndFind.FilterContext.None) { FFilterAndFindObject.ApplyFilter(); } SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1); } } btnDeleteAll.Enabled = btnDelete.Enabled; UpdateRecordNumberDisplay(); FLastDonor = -1; //Select end row if (SelectEndRow) { grdDetails.SelectRowInGrid(grdDetails.Rows.Count - 1); } //Focus accordingly if (ACompletelyNewGift) { txtDetailDonorKey.Focus(); } else { txtDetailRecipientKey.Focus(); } //FPreviouslySelectedDetailRow should now be pointing to the newly added row UpdateRecipientKeyText(0, FPreviouslySelectedDetailRow, cmbDetailMotivationGroupCode.GetSelectedString(), cmbMotivationDetailCode.GetSelectedString()); ClearKeyMinistries(); mniRecipientHistory.Enabled = false; } } finally { FNewGiftInProcess = false; if (AutoSaveSuccessful) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataSuccessful); } } }
/// <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 (rbtFromExtract.Checked) { ACalculator.AddParameter("param_source", "Extract"); } else { ACalculator.AddParameter("param_source", "Event"); } if (rbtThisEventOnly.Checked) { ACalculator.AddParameter("param_event_selection", "this"); } else if (rbtRelatedOptions.Checked) { // Event and related options ACalculator.AddParameter("param_event_selection", "related"); } else { // all events ACalculator.AddParameter("param_event_selection", "all"); } ACalculator.AddParameter("param_event_code", txtEventCode.Text); ACalculator.AddParameter("param_event_name", lblEventName.Text); ACalculator.AddParameter("param_extract_name", txtExtract.Text); if (txtEventCode.Text.Length > 5) { ACalculator.AddParameter("param_conference_code", txtEventCode.Text.Substring(0, 5) + "%"); } else { ACalculator.AddParameter("param_conference_code", txtEventCode.Text); } ACalculator.AddParameter("param_unit_key", FSelectedUnitKey.ToString()); if (chkAccepted.Checked) { ACalculator.AddParameter("param_application_status_accepted", "true"); } else { ACalculator.AddParameter("param_application_status_accepted", "false"); } if (chkCancelled.Checked) { ACalculator.AddParameter("param_application_status_cancelled", "true"); } else { ACalculator.AddParameter("param_application_status_cancelled", "false"); } if (chkEnquiry.Checked) { ACalculator.AddParameter("param_application_status_enquiry", "true"); } else { ACalculator.AddParameter("param_application_status_enquiry", "false"); } if (chkHold.Checked) { ACalculator.AddParameter("param_application_status_hold", "true"); } else { ACalculator.AddParameter("param_application_status_hold", "false"); } if (chkRejected.Checked) { ACalculator.AddParameter("param_application_status_rejected", "true"); } else { ACalculator.AddParameter("param_application_status_rejected", "false"); } TVerificationResult VerificationResult; if ((AReportAction == TReportActionEnum.raGenerate) && (!rbtAllEvents.Checked) && (txtEventCode.Text.Length == 0)) { // Error: an event must be selected when we generate the report // But we allow saving even if no event is selected VerificationResult = new TVerificationResult("Select an event to run the report against to.", "No event was selected!", TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if ((AReportAction == TReportActionEnum.raGenerate) && (!chkAccepted.Checked && !chkCancelled.Checked && !chkEnquiry.Checked && !chkHold.Checked && !chkRejected.Checked)) { // Error: at least one status must be checked VerificationResult = new TVerificationResult("Select at least one application status.", "No application status selected!", TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } }
/// <summary> /// save the changes on the screen (code is copied from auto-generated code) /// </summary> /// <returns></returns> public bool SaveChanges() { bool ReturnValue = false; FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs()); if (FPetraUtilsObject.VerificationResultCollection.Count == 0) { foreach (DataRow InspectDR in FMainDS.MExtract.Rows) { InspectDR.EndEdit(); } if (!FPetraUtilsObject.HasChanges) { return(true); } else { FPetraUtilsObject.WriteToStatusBar("Saving data..."); this.Cursor = Cursors.WaitCursor; TSubmitChangesResult SubmissionResult; //Ict.Common.Data.TTypedDataTable SubmitDT = FMainDS.MExtract.GetChangesTyped(); MExtractTable SubmitDT = new MExtractTable(); ExtractTDSMExtractTable ChangesDT = FMainDS.MExtract.GetChangesTyped(); if (ChangesDT != null) { SubmitDT.Merge(ChangesDT); } else { SubmitDT = null; } if (SubmitDT == null) { // There is nothing to be saved. // Update UI FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("There is nothing to be saved.")); this.Cursor = Cursors.Default; // We don't have unsaved changes anymore FPetraUtilsObject.DisableSaveButton(); return(true); } // Submit changes to the PETRAServer try { SubmissionResult = TRemote.MPartner.Partner.WebConnectors.SaveExtract (FExtractId, ref SubmitDT); } catch (ESecurityDBTableAccessDeniedException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgSecurityException(Exp, this.GetType()); ReturnValue = false; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return(ReturnValue); } catch (EDBConcurrencyException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgDBConcurrencyException(Exp, this.GetType()); ReturnValue = false; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return(ReturnValue); } catch (Exception) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); throw; } switch (SubmissionResult) { case TSubmitChangesResult.scrOK: // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server FMainDS.MExtract.AcceptChanges(); // Merge back with data from the Server (eg. for getting Sequence values) FMainDS.MExtract.Merge(SubmitDT, false); // need to accept the new modification ID FMainDS.MExtract.AcceptChanges(); // Update UI FPetraUtilsObject.WriteToStatusBar("Data successfully saved."); this.Cursor = Cursors.Default; // TODO EnableSave(false); // We don't have unsaved changes anymore FPetraUtilsObject.DisableSaveButton(); SetPrimaryKeyReadOnly(true); // refresh extract master screen if it is open TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated); BroadcastMessage.SetMessageDataName(ExtractName); TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage); this.Focus(); // keeps the focus on the current form // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return(true); case TSubmitChangesResult.scrError: // TODO scrError this.Cursor = Cursors.Default; break; case TSubmitChangesResult.scrNothingToBeSaved: // TODO scrNothingToBeSaved this.Cursor = Cursors.Default; return(true); case TSubmitChangesResult.scrInfoNeeded: // TODO scrInfoNeeded this.Cursor = Cursors.Default; break; } } } return(false); }
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 void Import(System.Object sender, EventArgs e) { if (ValidateAllData(true, TErrorProcessingMode.Epm_All)) { TVerificationResultCollection results = FPetraUtilsObject.VerificationResultCollection; int nRowsImported = TImportExchangeRates.ImportCurrencyExRates(FMainDS.ACorporateExchangeRate, "Corporate", results); if (results.Count > 0) { string formatter; if (nRowsImported == 0) { formatter = MCommonResourcestrings.StrExchRateImportNoRows; } else if (nRowsImported == 1) { formatter = MCommonResourcestrings.StrExchRateImportOneRow; } else { formatter = MCommonResourcestrings.StrExchRateImportMultiRow; } formatter += "{0}{0}{1}{0}{0}{3}{0}{0}{4}"; TFrmExtendedMessageBox messageBox = new TFrmExtendedMessageBox(this); messageBox.ShowDialog(String.Format( formatter, Environment.NewLine, results[0].ResultText, nRowsImported, results[0].ResultSeverity == TResultSeverity.Resv_Critical ? MCommonResourcestrings.StrExchRateImportTryAgain : String.Empty, results[0].ResultCode), MCommonResourcestrings.StrExchRateImportTitle, String.Empty, TFrmExtendedMessageBox.TButtons.embbOK, results[0].ResultSeverity == TResultSeverity.Resv_Critical ? TFrmExtendedMessageBox.TIcon.embiError : TFrmExtendedMessageBox.TIcon.embiInformation); results.Clear(); } else if (nRowsImported == 0) { MessageBox.Show(MCommonResourcestrings.StrExchRateImportNoRows, MCommonResourcestrings.StrExchRateImportTitle); } else if (nRowsImported == 1) { MessageBox.Show(MCommonResourcestrings.StrExchRateImportOneRowSuccess, MCommonResourcestrings.StrExchRateImportTitle); } else { MessageBox.Show(String.Format(MCommonResourcestrings.StrExchRateImportMultiRowSuccess, nRowsImported), MCommonResourcestrings.StrExchRateImportTitle); } if (nRowsImported > 0) { FPetraUtilsObject.SetChangedFlag(); } } }
private void AddPartner(System.Object sender, EventArgs e) { ExtractTDSMExtractRow NewRow; System.Int64 PartnerKey = 0; string PartnerShortName; TPartnerClass?PartnerClass; TPartnerClass PartnerClass2; TLocationPK ResultLocationPK; DataRow[] ExistingPartnerDataRows; ExtractTDSMExtractRow ExisitingPartnerRow; // If the delegate is defined, the host form will launch a Modal Partner Find screen for us if (TCommonScreensForwarding.OpenPartnerFindScreen != null) { // delegate IS defined try { TCommonScreensForwarding.OpenPartnerFindScreen.Invoke ("", out PartnerKey, out PartnerShortName, out PartnerClass, out ResultLocationPK, this.ParentForm); if (PartnerKey != -1) { ExistingPartnerDataRows = FMainDS.MExtract.Select(ExtractTDSMExtractTable.GetPartnerKeyDBName() + " = " + PartnerKey.ToString()); if (ExistingPartnerDataRows.Length > 0) { // check if partner already exists in extract MessageBox.Show(Catalog.GetString("A record for this partner already exists in this extract"), Catalog.GetString("Add Partner to Extract"), MessageBoxButtons.OK, MessageBoxIcon.Information); // select the already existing partner record in the grid so the user can see it ExisitingPartnerRow = (ExtractTDSMExtractRow)ExistingPartnerDataRows[0]; SelectByPartnerKey(PartnerKey, ExisitingPartnerRow.SiteKey); return; } TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName( PartnerKey, out PartnerShortName, out PartnerClass2); // add new record to extract NewRow = FMainDS.MExtract.NewRowTyped(); NewRow.ExtractId = FExtractId; NewRow.PartnerKey = PartnerKey; NewRow.PartnerShortName = PartnerShortName; NewRow.PartnerClass = SharedTypes.PartnerClassEnumToString(PartnerClass2); NewRow.SiteKey = ResultLocationPK.SiteKey; NewRow.LocationKey = ResultLocationPK.LocationKey; FMainDS.MExtract.Rows.Add(NewRow); // Refresh DataGrid to show the added partner record grdDetails.Refresh(); // select the added partner record in the grid so the user can see the change SelectByPartnerKey(PartnerKey, ResultLocationPK.SiteKey); // enable save button on screen FPetraUtilsObject.SetChangedFlag(); } } catch (Exception exp) { throw new EOPAppException("Exception occured while calling PartnerFindScreen Delegate!", exp); } // end try } }
private void InitializeManualCode() { string ConferenceName; // load data into dataset FMainDS.Clear(); FMainDS.Merge(TRemote.MConference.Conference.WebConnectors.LoadConferenceSettings(FPartnerKey, out ConferenceName)); // display conference name this.Text = this.Text + " [" + ConferenceName + "]"; txtConferenceName.Text = ConferenceName; // display campaign code prefix txtCampaignPrefixCode.Text = ((PcConferenceRow)FMainDS.PcConference.Rows[0]).OutreachPrefix; // display start/end dates dtpStartDate.Date = ((PPartnerLocationRow)FMainDS.PPartnerLocation.Rows[0]).DateEffective; dtpEndDate.Date = ((PPartnerLocationRow)FMainDS.PPartnerLocation.Rows[0]).DateGoodUntil; // enable dtps only if date is null if ((dtpStartDate.Date == null) || (dtpStartDate.Date == DateTime.MinValue)) { dtpStartDate.ReadOnly = false; dtpStartDate.TabStop = true; } if ((dtpEndDate.Date == null) || (dtpEndDate.Date == DateTime.MinValue)) { dtpEndDate.ReadOnly = false; dtpEndDate.TabStop = true; } // display currency (if currency code in PUnit has changed then use that over the currency code in PcConference) if (FMainDS.PUnit.Rows.Count == 0) { cmbCurrency.SetSelectedString(((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode, -1); } else { // There is a PUnit row if ((((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode != ((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode) && (((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode != String.Empty)) { // It is probably more up to date cmbCurrency.SetSelectedString(((PUnitRow)FMainDS.PUnit.Rows[0]).OutreachCostCurrencyCode, -1); } else { cmbCurrency.SetSelectedString(((PcConferenceRow)FMainDS.PcConference.Rows[0]).CurrencyCode, -1); } } // set radio buttons and checkbox Boolean ChargeCampaign = true; Boolean AddAccommodationCosts = false; foreach (PcConferenceOptionRow CurrentRow in FMainDS.PcConferenceOption.Rows) { if ((CurrentRow.OptionTypeCode == "COST_PER_NIGHT") && (CurrentRow.OptionSet == true)) { ChargeCampaign = false; rbtNight.Checked = true; } else if ((CurrentRow.OptionTypeCode == "COST_PER_DAY") && (CurrentRow.OptionSet == true)) { ChargeCampaign = false; rbtDay.Checked = true; } else if ((CurrentRow.OptionTypeCode == "ADD_ACCOMM_COST_FOR_TOTAL") && (CurrentRow.OptionSet == true)) { AddAccommodationCosts = true; } } if (ChargeCampaign == true) { rbtCampaign.Checked = true; chkAddAccommodationCosts.Enabled = false; } else if (AddAccommodationCosts == true) { chkAddAccommodationCosts.Checked = true; txtSpecialRolePreAccommodation.ReadOnly = false; txtVolunteerPreAccommodation.ReadOnly = false; txtParticipantPreAccommodation.ReadOnly = false; txtSpecialRoleAccommodation.ReadOnly = false; txtVolunteerAccommodation.ReadOnly = false; txtSpecialRoleCampaignAccommodation.ReadOnly = false; txtSpecialRolePreAccommodation.TabStop = true; txtVolunteerPreAccommodation.TabStop = true; txtParticipantPreAccommodation.TabStop = true; txtSpecialRoleAccommodation.TabStop = true; txtVolunteerAccommodation.TabStop = true; txtSpecialRoleCampaignAccommodation.TabStop = true; } // display conference discounts foreach (PcDiscountRow CurrentRow in FMainDS.PcDiscount.Rows) { if (CurrentRow.CostTypeCode == "CONFERENCE") { if (CurrentRow.Validity == "PRE") { if (CurrentRow.DiscountCriteriaCode == "ROLE") { txtSpecialRolePreAttendance.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "VOL") { txtVolunteerPreAttendance.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "OTHER") { txtParticipantPreAttendance.NumberValueInt = (int)CurrentRow.Discount; } } else if (CurrentRow.Validity == "CONF") { if (CurrentRow.DiscountCriteriaCode == "ROLE") { txtSpecialRoleAttendance.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "VOL") { txtVolunteerAttendance.NumberValueInt = (int)CurrentRow.Discount; } } else if ((CurrentRow.Validity == "POST") && (CurrentRow.DiscountCriteriaCode == "ROLE")) { txtSpecialRoleCampaignAttendance.NumberValueInt = (int)CurrentRow.Discount; } } else if (CurrentRow.CostTypeCode == "ACCOMMODATION") { if (CurrentRow.Validity == "PRE") { if (CurrentRow.DiscountCriteriaCode == "ROLE") { txtSpecialRolePreAccommodation.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "VOL") { txtVolunteerPreAccommodation.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "OTHER") { txtParticipantPreAccommodation.NumberValueInt = (int)CurrentRow.Discount; } } else if (CurrentRow.Validity == "CONF") { if (CurrentRow.DiscountCriteriaCode == "ROLE") { txtSpecialRoleAccommodation.NumberValueInt = (int)CurrentRow.Discount; } else if (CurrentRow.DiscountCriteriaCode == "VOL") { txtVolunteerAccommodation.NumberValueInt = (int)CurrentRow.Discount; } } else if ((CurrentRow.Validity == "POST") && (CurrentRow.DiscountCriteriaCode == "ROLE")) { txtSpecialRoleCampaignAccommodation.NumberValueInt = (int)CurrentRow.Discount; } } } // display grid containing venue details grdVenues.Columns.Clear(); grdVenues.AddPartnerKeyColumn(Catalog.GetString("Venue Key"), FMainDS.PcConferenceVenue.ColumnVenueKey); grdVenues.AddTextColumn(Catalog.GetString("Venue Name"), FMainDS.PcConferenceVenue.ColumnVenueName); DataView MyDataView = FMainDS.PcConferenceVenue.DefaultView; MyDataView.Sort = "p_venue_name_c ASC"; MyDataView.AllowNew = false; grdVenues.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); FPetraUtilsObject.ApplySecurity(TSecurityChecks.SecurityPermissionsSetupScreensEditingAndSaving); }
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) { 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); } if ((AReportAction == TReportActionEnum.raGenerate) && (dtpFromDate.Date.Value.Year != dtpToDate.Date.Value.Year)) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Date problem."), Catalog.GetString("From Date and To Date must be in 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_extract_name", txtExtract.Text); TParameterList Params = ACalc.GetParameters(); String RecipientType = Params.Get("param_recipient").ToString(); if (RecipientType == "Extract") { RecipientType = ("Recipients from extract: " + Params.Get("param_extract_name").ToString()); } if (RecipientType == "One Recipient") { RecipientType = ("One Recipient: " + txtRecipient.Text + " " + txtRecipient.LabelText); ACalc.AddParameter("param_recipientkey", txtRecipient.Text); } ACalc.AddParameter("param_recipient_title", RecipientType); 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); * } */ }
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); //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries 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)3.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 RunOnceOnActivationManual() { // Set up the window title if (String.Compare(Context, "Bank", true) == 0) { this.Text += Catalog.GetString(" For Bank"); } else if (String.Compare(Context, "Church", true) == 0) { this.Text += Catalog.GetString(" For Church"); } else if (String.Compare(Context, "Family", true) == 0) { this.Text += Catalog.GetString(" For Family"); } else if (String.Compare(Context, "Organisation", true) == 0) { this.Text += Catalog.GetString(" For Organisation"); } else if (String.Compare(Context, "Person", true) == 0) { this.Text += Catalog.GetString(" For Person"); } else if (String.Compare(Context, "Unit", true) == 0) { this.Text += Catalog.GetString(" For Unit"); } else if (String.Compare(Context, "Venue", true) == 0) { this.Text += Catalog.GetString(" For Venue"); } else if (String.Compare(Context, "LongTermApp", true) == 0) { this.Text += Catalog.GetString(" For Long Term Applications"); } else if (String.Compare(Context, "ShortTermApp", true) == 0) { this.Text += Catalog.GetString(" For Short Term Applications"); } else if (String.Compare(Context, "Personnel", true) == 0) { this.Text += Catalog.GetString(" For Personnel"); } // Initialize 'Helper Class' for handling the Indexes of the DataRows. FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper( grdDetails, PDataLabelUseTable.ColumnIdx1Id, btnDemote, btnPromote, delegate { FPetraUtilsObject.SetChangedFlag(); }); // Load the Extra Data from DataLabel table Type DataTableType; FExtraDS.PDataLabel = new PDataLabelTable(); DataTable CacheDT = TDataCache.GetCacheableDataTableFromCache("DataLabelList", String.Empty, null, out DataTableType); FExtraDS.PDataLabel.Merge(CacheDT); // Extend our main DataLabelUse table int NameOrdinal = FMainDS.PDataLabelUse.Columns.Add("Name", typeof(String)).Ordinal; int GroupOrdinal = FMainDS.PDataLabelUse.Columns.Add("GroupHeading", typeof(String)).Ordinal; int DescriptionOrdinal = FMainDS.PDataLabelUse.Columns.Add("Description", typeof(String)).Ordinal; // Take each row of our main dataset and populate the new columns with relevant data // from the DataLabelUse table foreach (PDataLabelUseRow useRow in FMainDS.PDataLabelUse.Rows) { PDataLabelRow labelRow = (PDataLabelRow)FExtraDS.PDataLabel.Rows.Find(new object[] { useRow.DataLabelKey }); useRow[NameOrdinal] = labelRow.Text; useRow[GroupOrdinal] = labelRow.Group; useRow[DescriptionOrdinal] = labelRow.Description; } // Add columns to the grid for the label details grdDetails.AddTextColumn(Catalog.GetString("Name"), FMainDS.PDataLabelUse.Columns[NameOrdinal]); grdDetails.AddTextColumn(Catalog.GetString("Group Heading"), FMainDS.PDataLabelUse.Columns[GroupOrdinal]); grdDetails.AddTextColumn(Catalog.GetString("Description"), FMainDS.PDataLabelUse.Columns[DescriptionOrdinal]); grdDetails.Selection.SelectionChanged += HandleSelectionChanged; // Remove the first column. We added this in the YAML so that the auto-generator had something to do grdDetails.Columns.Remove(0); grdDetails.SetHeaderTooltip(0, Catalog.GetString("Name")); grdDetails.SetHeaderTooltip(1, Catalog.GetString("Group Heading")); grdDetails.SetHeaderTooltip(2, Catalog.GetString("Description")); // Create a view that will only show the rows applicable to our currentContext DataView contextView = new DataView(FMainDS.PDataLabelUse, "p_use_c='" + Context + "'", "p_idx1_i", DataViewRowState.CurrentRows); contextView.AllowNew = false; // Bind the view to our grid grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(contextView); grdDetails.Refresh(); grdDetails.AutoResizeGrid(); SelectRowInGrid(1); }
private void UpdateBatchPeriod(object sender, EventArgs e) { if ((FPetraUtilsObject == null) || FPetraUtilsObject.SuppressChangeDetection || (FPreviouslySelectedDetailRow == null)) { return; } bool UpdateTransactionDates = false; Int32 PeriodNumber = 0; Int32 YearNumber = 0; string EffectiveDateString = string.Empty; DateTime EffectiveDateValue; try { bool rowDataHasChanged = false; EffectiveDateString = dtpDetailDateEffective.Date.ToString(); if (DateTime.TryParse(EffectiveDateString, out EffectiveDateValue)) { if ((EffectiveDateValue == FCurrentEffectiveDate) || (EffectiveDateValue < FStartDateCurrentPeriod) || (EffectiveDateValue > FEndDateLastForwardingPeriod)) { return; } //GetDetailsFromControls will do this automatically if the user tabs // passed the last control, but not if they click on another control FCurrentEffectiveDate = EffectiveDateValue; if (FPreviouslySelectedDetailRow.DateEffective != EffectiveDateValue) { FPreviouslySelectedDetailRow.DateEffective = EffectiveDateValue; rowDataHasChanged = true; } //Check if new date is in a different Batch period to the current one if (GetAccountingYearPeriodByDate(FLedgerNumber, EffectiveDateValue, out YearNumber, out PeriodNumber)) { if (FPreviouslySelectedDetailRow.BatchPeriod != PeriodNumber) { FPreviouslySelectedDetailRow.BatchPeriod = PeriodNumber; rowDataHasChanged = true; //Update the Transaction effective dates UpdateTransactionDates = true; if (FLoadAndFilterLogicObject.YearIndex != 0) { FLoadAndFilterLogicObject.YearIndex = 0; FLoadAndFilterLogicObject.PeriodIndex = 1; dtpDetailDateEffective.Date = EffectiveDateValue; dtpDetailDateEffective.Focus(); } else if (FLoadAndFilterLogicObject.PeriodIndex != 1) { FLoadAndFilterLogicObject.PeriodIndex = 1; dtpDetailDateEffective.Date = EffectiveDateValue; dtpDetailDateEffective.Focus(); } } } if (rowDataHasChanged) { FPetraUtilsObject.SetChangedFlag(); } ((TFrmGLBatch)ParentForm).GetTransactionsControl().UpdateTransactionTotals(TGLBatchEnums.eGLLevel.Batch, UpdateTransactionDates); } } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } }
/// <summary> /// Creates a new gift or gift detail depending upon the parameter /// </summary> /// <param name="ACompletelyNewGift"></param> private void CreateANewGift(bool ACompletelyNewGift) { AGiftRow CurrentGiftRow = null; bool IsEmptyGrid = (grdDetails.Rows.Count == 1); FCreatingNewGift = true; try { if (ValidateAllData(true, true)) { if (!ACompletelyNewGift) //i.e. a gift detail { ACompletelyNewGift = IsEmptyGrid; } if (ACompletelyNewGift) { //Run this if a new gift is requested or required. // we create the table locally, no dataset AGiftRow giftRow = FMainDS.AGift.NewRowTyped(true); giftRow.DateEntered = FBatchRow.GlEffectiveDate; giftRow.LedgerNumber = FBatchRow.LedgerNumber; giftRow.BatchNumber = FBatchRow.BatchNumber; giftRow.GiftTransactionNumber = ++FBatchRow.LastGiftNumber; giftRow.MethodOfPaymentCode = FBatchRow.MethodOfPaymentCode; giftRow.LastDetailNumber = 1; FMainDS.AGift.Rows.Add(giftRow); CurrentGiftRow = giftRow; mniDonorHistory.Enabled = false; } else { CurrentGiftRow = GetGiftRow(FPreviouslySelectedDetailRow.GiftTransactionNumber); CurrentGiftRow.LastDetailNumber++; } //New gifts will require a new detail anyway, so this code always runs GiftBatchTDSAGiftDetailRow newRow = FMainDS.AGiftDetail.NewRowTyped(true); newRow.LedgerNumber = FBatchRow.LedgerNumber; newRow.BatchNumber = FBatchRow.BatchNumber; newRow.GiftTransactionNumber = CurrentGiftRow.GiftTransactionNumber; newRow.DetailNumber = CurrentGiftRow.LastDetailNumber; newRow.MethodOfPaymentCode = CurrentGiftRow.MethodOfPaymentCode; newRow.MethodOfGivingCode = CurrentGiftRow.MethodOfGivingCode; newRow.DonorKey = CurrentGiftRow.DonorKey; if (!ACompletelyNewGift && (FPreviouslySelectedDetailRow != null)) { newRow.DonorName = FPreviouslySelectedDetailRow.DonorName; newRow.ConfidentialGiftFlag = FPreviouslySelectedDetailRow.ConfidentialGiftFlag; newRow.ChargeFlag = FPreviouslySelectedDetailRow.ChargeFlag; newRow.TaxDeductible = FPreviouslySelectedDetailRow.TaxDeductible; newRow.MotivationGroupCode = FPreviouslySelectedDetailRow.MotivationGroupCode; newRow.MotivationDetailCode = FPreviouslySelectedDetailRow.MotivationDetailCode; } else { newRow.MotivationGroupCode = MFinanceConstants.MOTIVATION_GROUP_GIFT; newRow.MotivationDetailCode = MFinanceConstants.GROUP_DETAIL_SUPPORT; } newRow.DateEntered = CurrentGiftRow.DateEntered; if (FTaxDeductiblePercentageEnabled) { newRow.TaxDeductiblePct = 100; } FMainDS.AGiftDetail.Rows.Add(newRow); FPetraUtilsObject.SetChangedFlag(); if (!SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1)) { if (!FFilterAndFindObject.IsActiveFilterEqualToBase) { MessageBox.Show( MCommonResourcestrings.StrNewRecordIsFiltered, MCommonResourcestrings.StrAddNewRecordTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); FFilterAndFindObject.FilterPanelControls.ClearAllDiscretionaryFilters(); if (FFilterAndFindObject.FilterFindPanel.ShowApplyFilterButton != TUcoFilterAndFind.FilterContext.None) { FFilterAndFindObject.ApplyFilter(); } SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1); } } btnDeleteAll.Enabled = btnDelete.Enabled && (FFilterAndFindObject.IsActiveFilterEqualToBase); UpdateRecordNumberDisplay(); FLastDonor = -1; //Focus accordingly if (ACompletelyNewGift) { txtDetailDonorKey.Focus(); } else { txtDetailRecipientKey.Focus(); } TUC_GiftTransactions_Recipient.UpdateRecipientKeyText(0, FPreviouslySelectedDetailRow, cmbDetailMotivationGroupCode.GetSelectedString(), cmbDetailMotivationDetailCode.GetSelectedString()); cmbKeyMinistries.Clear(); mniRecipientHistory.Enabled = false; } } finally { FCreatingNewGift = false; } }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { if (AReportAction == TReportActionEnum.raGenerate) { if (rbtPartner.Checked && (txtDonor.Text == "0000000000")) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("No donor selected."), Catalog.GetString("Please select a donor."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } if (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 (txtMinAmount.NumberValueInt > txtMaxAmount.NumberValueInt) { TVerificationResult VerificationResult = new TVerificationResult( Catalog.GetString("Gift Limit wrong."), Catalog.GetString("Minimum Amount can't be greater than Maximum Amount."), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationResult); } 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 ((cmbReportType.SelectedItem.ToString() == "Complete") && (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); } } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); ACalc.AddParameter("param_donorkey", txtDonor.Text); ACalc.AddParameter("param_extract_name", txtExtract.Text); //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries 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("param_end_date_this_year", DateTime.Today); ACalc.AddParameter("param_start_date_this_year", FromDateThisYear); ACalc.AddParameter("param_end_date_previous_year", ToDatePreviousYear); ACalc.AddParameter("param_start_date_previous_year", FromDatePreviousYear); if (cmbReportType.SelectedItem.ToString() == "Totals") { DateTime FromDate = new DateTime(DateTime.Today.Year - 3, 1, 1); ACalc.RemoveParameter("param_from_date"); ACalc.RemoveParameter("param_to_date"); ACalc.AddParameter("param_from_date", FromDate); ACalc.AddParameter("param_to_date", DateTime.Today); ACalc.AddParameter("Month0", 1); ACalc.AddParameter("Month1", 2); 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); int ColumnCounter = 0; ACalc.AddParameter("param_calculation", "Month", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)3.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-0", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Count-0", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-1", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Count-1", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-2", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Count-2", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Year-3", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter); ++ColumnCounter; ACalc.AddParameter("param_calculation", "Count-3", ColumnCounter); ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter); ++ColumnCounter; ACalc.SetMaxDisplayColumns(ColumnCounter); } else { int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt(); for (int Counter = 0; Counter <= MaxColumns; ++Counter) { String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString(); if (ColumnName == "Gift Amount") { ACalc.AddParameter("param_gift_amount_column", Counter); } } } }
/// <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); } } }