public static ACurrencyLanguageRow GetCurrencyLanguage(string ACurrencyCode) { ACurrencyLanguageRow ReturnValue = null; string Language = TUserDefaults.GetStringDefault(MSysManConstants.USERDEFAULT_UILANGUAGE); if (Language.Length > 2) { // need to get the two digit language code of p_language: de-DE => DE, en-EN => EN Language = Language.Substring(Language.Length - 2).ToUpper(); } TDBTransaction Transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("GetCurrencyLanguage"); db.ReadTransaction( ref Transaction, delegate { ACurrencyLanguageTable CurrencyLanguageTable = ACurrencyLanguageAccess.LoadByPrimaryKey(ACurrencyCode, Language, Transaction); if ((CurrencyLanguageTable != null) && (CurrencyLanguageTable.Rows.Count > 0)) { ReturnValue = CurrencyLanguageTable[0]; } }); db.CloseDBConnection(); return(ReturnValue); }
public static ACurrencyLanguageRow GetCurrencyLanguage(string ACurrencyCode) { ACurrencyLanguageRow ReturnValue = null; string Language = TUserDefaults.GetStringDefault(MSysManConstants.USERDEFAULT_UILANGUAGE); if (Language.Length > 2) { // need to get the two digit language code of p_language: de-DE => DE, en-EN => EN Language = Language.Substring(Language.Length - 2).ToUpper(); } TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { ACurrencyLanguageTable CurrencyLanguageTable = ACurrencyLanguageAccess.LoadByPrimaryKey(ACurrencyCode, Language, Transaction); if ((CurrencyLanguageTable != null) && (CurrencyLanguageTable.Rows.Count > 0)) { ReturnValue = CurrencyLanguageTable[0]; } }); return(ReturnValue); }
private void ShowDetailsManual(ACurrencyLanguageRow ARow) { if (ARow == null) { return; } // deal with our own conversion. Words is the default so must be last in the 'if' sequence if (String.Compare(ARow.DecimalOptions, "None", true) == 0) { rbtNone.Checked = true; } else if (String.Compare(ARow.DecimalOptions, "Numeric", true) == 0) { rbtNumeric.Checked = true; } else if (String.Compare(ARow.DecimalOptions, "PerHundred", true) == 0) { rbtPerHundred.Checked = true; } else { rbtWords.Checked = true; } }
public static ACurrencyLanguageRow GetCurrencyLanguage(string ACurrencyCode) { ACurrencyLanguageRow ReturnValue = null; string Language = TUserDefaults.GetStringDefault(MSysManConstants.USERDEFAULT_UILANGUAGE); TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { ACurrencyLanguageTable CurrencyLanguageTable = ACurrencyLanguageAccess.LoadByPrimaryKey(ACurrencyCode, Language, Transaction); if ((CurrencyLanguageTable != null) && (CurrencyLanguageTable.Rows.Count > 0)) { ReturnValue = CurrencyLanguageTable[0]; } }); return(ReturnValue); }
private void GetDetailDataFromControlsManual(ACurrencyLanguageRow ARow) { // Set the actual values that will go in the database column for DecimalOptions if (rbtWords.Checked) { ARow.DecimalOptions = "Words"; } if (rbtNumeric.Checked) { ARow.DecimalOptions = "Numeric"; } if (rbtPerHundred.Checked) { ARow.DecimalOptions = "PerHundred"; } if (rbtNone.Checked) { ARow.DecimalOptions = "None"; } }
private void NewRowManual(ref ACurrencyLanguageRow ARow) { // Deal with primary key. CurrencyCode (varchar(16)) and LanguageCode (varchar(20)) are unique. if (FMainDS.ACurrencyLanguage.Rows.Count == 0) { // Our first row is always USD/EN ARow.CurrencyCode = "USD"; ARow.LanguageCode = "EN"; return; } else { // We already have some rows, so we use the currently selected language in the comboBox as a starter // This may or may not be the most recently added language depending on how the main data set has been sorted // But once we have started adding rows it should remain the 'active' row string prevLanguage = cmbDetailLanguageCode.cmbCombobox.Text; // Try and find some popular or at least likely currencies // Remember that we will almost certainly select a currency that the user does NOT want in their language // So this will be the one we always propose!!!! string[] tryCurrencies = { "USD", "GBP", "EUR", "INR", "AUD", "CAD", "CHF", "CNY", "JPY", "NZD", "PHP", "PKR", "ZAR" }; int nTryCurrency = 0; bool bFoundCurrency = true; while (FMainDS.ACurrencyLanguage.Rows.Find(new object[] { tryCurrencies[nTryCurrency], prevLanguage }) != null) { if (++nTryCurrency == tryCurrencies.Length) { // We have exhausted our popular choices bFoundCurrency = false; break; } } if (bFoundCurrency) { ARow.CurrencyCode = tryCurrencies[nTryCurrency]; ARow.LanguageCode = prevLanguage; return; } // So we have tried all the popular currencies in the current language // Now we fall back to trying all currencies in the current languages. // Remember that we will almost certainly select a currency that the user does NOT want in their language // So this will be the one we always propose!!!! Type DataTableType; ACurrencyTable allCurrencies = new ACurrencyTable(); DataTable CacheDT = TDataCache.GetCacheableDataTableFromCache("CurrencyCodeList", String.Empty, null, out DataTableType); allCurrencies.Merge(CacheDT); nTryCurrency = 0; bFoundCurrency = true; while (FMainDS.ACurrencyLanguage.Rows.Find(new object[] { allCurrencies.Rows[nTryCurrency][0].ToString(), prevLanguage }) != null) { if (++nTryCurrency == tryCurrencies.Length) { bFoundCurrency = false; break; } } if (bFoundCurrency) { ARow.CurrencyCode = allCurrencies.Rows[nTryCurrency][0].ToString(); ARow.LanguageCode = prevLanguage; } // We could at this point start trying other languages - but there seems little point since the currency list contains // currencies that will never be used since they no longer exist!! It is therefore assumed that by this time // the user has gone on to a different langauge where we will have started again with USD .... } }