private bool PreDeleteManual(ACurrencyRow ARowToDelete, ref string ADeletionQuestion) { ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2}, {3} {4})", Environment.NewLine, lblDetailCurrencyCode.Text, txtDetailCurrencyCode.Text, lblDetailCurrencyName.Text, txtDetailCurrencyName.Text); return true; }
private bool PreDeleteManual(ACurrencyRow ARowToDelete, ref string ADeletionQuestion) { ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2}, {3} {4})", Environment.NewLine, lblDetailCurrencyCode.Text, txtDetailCurrencyCode.Text, lblDetailCurrencyName.Text, txtDetailCurrencyName.Text); return(true); }
private void FocusedRowChanged(System.Object sender, SourceGrid.RowEventArgs e) { DataRowView[] SelectedGridRow = grdPayments.SelectedDataRowsAsDataRowView; if (SelectedGridRow.Length >= 1) { FSelectedPaymentRow = (AccountsPayableTDSAApPaymentRow)SelectedGridRow[0].Row; if (!FSelectedPaymentRow.IsSupplierKeyNull()) { AApSupplierRow supplier = TFrmAPMain.GetSupplier(FMainDS.AApSupplier, FSelectedPaymentRow.SupplierKey); txtCurrency.Text = supplier.CurrencyCode; if (FCurrencyTable != null) { ACurrencyRow row = (ACurrencyRow)FCurrencyTable.Rows.Find(supplier.CurrencyCode); txtTotalAmount.CurrencyCode = row.CurrencyCode; txtAmountToPay.CurrencyCode = row.CurrencyCode; } /* * decimal CurrentRate = TExchangeRateCache.GetDailyExchangeRate(supplier.CurrencyCode, * FLedgerRow.BaseCurrency, * DateTime.Today, * false); */ txtExchangeRate.NumberValueDecimal = FSelectedPaymentRow.ExchangeRateToBase; cmbPaymentType.SetSelectedString(supplier.PaymentType); if (txtCurrency.Text == FLedgerRow.BaseCurrency) { txtExchangeRate.Enabled = false; btnLookupExchangeRate.Enabled = false; } else { txtExchangeRate.Enabled = true; btnLookupExchangeRate.Enabled = true; } } cmbBankAccount.SetSelectedString(FSelectedPaymentRow.BankAccount, -1); FMainDS.AApDocumentPayment.DefaultView.RowFilter = AccountsPayableTDSAApDocumentPaymentTable.GetPaymentNumberDBName() + " = " + FSelectedPaymentRow.PaymentNumber.ToString(); grdDocuments.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.AApDocumentPayment.DefaultView); grdDocuments.Refresh(); grdDocuments.Selection.SelectRow(1, true); FocusedRowChangedDetails(null, null); } }
private void RunOnceOnActivationManual() { // We need to set the number of decimal places for the Mailing Cost // We check all the ledgers to see which one has the highest number of decimal places. ALedgerTable ledgers = TRemote.MFinance.Setup.WebConnectors.GetAvailableLedgers(); ACurrencyTable currencyTable = (ACurrencyTable)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList); int numDecimalPlaces = 0; if (ledgers.Count == 0) { txtDetailMailingCost.CurrencyCode = "USD"; } else { for (int i = 0; i < ledgers.Count; i++) { string code = ledgers[i].BaseCurrency; ACurrencyRow row = (ACurrencyRow)currencyTable.Rows.Find(code); if (row != null) { int decimals = StringHelper.DecimalPlacesForCurrency(code); if (decimals > numDecimalPlaces) { numDecimalPlaces = decimals; } } } if (numDecimalPlaces == 0) { txtDetailMailingCost.CurrencyCode = TTxtCurrencyTextBox.CURRENCY_STANDARD_0_DP; } else { txtDetailMailingCost.CurrencyCode = TTxtCurrencyTextBox.CURRENCY_STANDARD_2_DP; } } FPetraUtilsObject.DataSaved += FPetraUtilsObject_DataSaved; }
private void NewRowManual(ref ACurrencyRow ARow) { string newCode = Catalog.GetString("NEWCODE"); Int32 countNewDetail = 0; if (FMainDS.ACurrency.Rows.Find(new object[] { newCode }) != null) { while (FMainDS.ACurrency.Rows.Find(new object[] { newCode + countNewDetail.ToString() }) != null) { countNewDetail++; } newCode += countNewDetail.ToString(); } ARow.CurrencyCode = newCode; ARow.CurrencySymbol = String.Empty; ARow.CountryCode = "99"; ARow.CurrencyName = Catalog.GetString("New Currency"); ARow.DisplayFormat = "->>>,>>>,>>>,>>9.99"; }
/// <summary> /// Constructor which automatically loads the table and sets the value of /// the base currency table and foreign currency table. /// </summary> /// <param name="ABaseCurrencyCode">Base currency code</param> /// <param name="AForeignCurrencyCode">foreign Currency Code</param> public TCurrencyInfo(string ABaseCurrencyCode, string AForeignCurrencyCode) { LoadDatabase(); baseCurrencyRow = SetRowToCode(ABaseCurrencyCode); foreignCurrencyRow = SetRowToCode(AForeignCurrencyCode); }
/// <summary> /// Constructor which automatically loads the table and sets the value of the /// currency table. /// </summary> /// <param name="ACurrencyCode">Three digit description to define the /// base currency.</param> public TCurrencyInfo(string ACurrencyCode) { LoadDatabase(); baseCurrencyRow = SetRowToCode(ACurrencyCode); }
/// <summary> /// Validates the GL Journal data. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AGLSetupDSRef">A GLSetupTDS reference with a populated ATransactionTypeTable. A reference to this DataSet is REQUIRED when importing - optional otherwise</param> /// <param name="ACurrencyTableRef">A reference to the Currency table. A reference to this table is REQUIRED when importing - optional otherwise</param> /// <param name="ACorporateExchangeTableRef">Corporate exchange rate table. A reference to this table is REQUIRED when importing - optional otherwise</param> /// <param name="ABaseCurrency">Ledger base currency. Required when importing</param> /// <param name="AIntlCurrency">Ledger international currency. Required when importing</param> /// <returns>True if the validation found no data validation errors, otherwise false.</returns> public static bool ValidateGLJournalManual(object AContext, AJournalRow ARow, ref TVerificationResultCollection AVerificationResultCollection, GLSetupTDS AGLSetupDSRef = null, ACurrencyTable ACurrencyTableRef = null, ACorporateExchangeRateTable ACorporateExchangeTableRef = null, String ABaseCurrency = null, String AIntlCurrency = null) { DataColumn ValidationColumn; TScreenVerificationResult VerificationResult; string ValidationContext; int VerifResultCollAddedCount = 0; // Don't validate deleted or posted DataRows if ((ARow.RowState == DataRowState.Deleted) || (ARow.JournalStatus == MFinanceConstants.BATCH_POSTED)) { return(true); } bool isImporting = AContext.ToString().Contains("Importing"); // 'Exchange Rate' must be greater than 0 ValidationColumn = ARow.Table.Columns[AJournalTable.ColumnExchangeRateToBaseId]; ValidationContext = ARow.JournalNumber.ToString() + " of Batch Number: " + ARow.BatchNumber.ToString(); if (true) { VerificationResult = (TScreenVerificationResult)TNumericalChecks.IsPositiveDecimal(ARow.ExchangeRateToBase, String.Empty + (isImporting ? String.Empty : " of Journal Number: " + ValidationContext.ToString()), AContext, ValidationColumn); // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult)) { VerifResultCollAddedCount++; } // Exchange rate must be 1.00 if the currency is the base ledger currency if ((ABaseCurrency != null) && (!ARow.IsExchangeRateToBaseNull()) && (ARow.TransactionCurrency == ABaseCurrency) && (ARow.ExchangeRateToBase != 1.00m)) { if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, new TVerificationResult(ValidationContext, Catalog.GetString("A journal in the ledger base currency must have exchange rate of 1.00."), TResultSeverity.Resv_Critical))) { VerifResultCollAddedCount++; } } } // Transaction currency must be valid bool isValidTransactionCurrency = true; if (isImporting && (ACurrencyTableRef != null)) { ValidationColumn = ARow.Table.Columns[AJournalTable.ColumnTransactionCurrencyId]; if (true) { ACurrencyRow foundRow = (ACurrencyRow)ACurrencyTableRef.Rows.Find(ARow.TransactionCurrency); isValidTransactionCurrency = (foundRow != null); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString("'{0}' is not a valid currency."), ARow.TransactionCurrency), TResultSeverity.Resv_Critical))) { VerifResultCollAddedCount++; } } } if ((ACorporateExchangeTableRef != null) && isValidTransactionCurrency && (ABaseCurrency != null) && (AIntlCurrency != null) && !ARow.IsDateEffectiveNull() && (ABaseCurrency != AIntlCurrency)) { // For ledgers where the base currency and intl currency differ there must be a corporate exchange rate to the international currency ValidationColumn = ARow.Table.Columns[AJournalTable.ColumnTransactionCurrencyId]; ValidationContext = ARow.JournalNumber.ToString() + " of Batch Number: " + ARow.BatchNumber.ToString(); if (true) { DateTime firstOfMonth; if (TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriod(ARow.LedgerNumber, ARow.DateEffective, out firstOfMonth)) { ACorporateExchangeRateRow foundRow = (ACorporateExchangeRateRow)ACorporateExchangeTableRef.Rows.Find( new object[] { ABaseCurrency, AIntlCurrency, firstOfMonth }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString( "There is no Corporate Exchange Rate defined for '{0}' to '{1}' for the month starting on '{2}'."), ABaseCurrency, AIntlCurrency, StringHelper.DateToLocalizedString(firstOfMonth)), TResultSeverity.Resv_Noncritical))) { VerifResultCollAddedCount++; } } } } // Sub-system code must exist in the transaction type table if (isImporting && (AGLSetupDSRef.ATransactionType != null)) { ValidationColumn = ARow.Table.Columns[AJournalTable.ColumnSubSystemCodeId]; if (true) { ATransactionTypeRow foundRow = (ATransactionTypeRow)AGLSetupDSRef.ATransactionType.Rows.Find( new object[] { ARow.LedgerNumber, ARow.SubSystemCode, ARow.TransactionTypeCode }); if ((foundRow == null) && AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, String.Format(Catalog.GetString( "The combination of Transaction Type of '{0}' and Sub-system Code of '{1}' is not valid for journals in Ledger {2}."), ARow.TransactionTypeCode, ARow.SubSystemCode, ARow.LedgerNumber), TResultSeverity.Resv_Critical))) { VerifResultCollAddedCount++; } } } // Journal description must not be null if (isImporting) { ValidationColumn = ARow.Table.Columns[AJournalTable.ColumnJournalDescriptionId]; if (true) { if ((ARow.JournalDescription == null) || (ARow.JournalDescription.Length == 0)) { if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove( AContext, new TVerificationResult(ValidationContext, Catalog.GetString("The journal description must not be empty."), TResultSeverity.Resv_Critical))) { VerifResultCollAddedCount++; } } } } return(VerifResultCollAddedCount == 0); }