private void DefaultParametrs(ContractEF contract = null, bool refresh = false) { if (!refresh) { archiveManager = new ArchiveManager(dataManager); BanksList = DataBaseClient.ReadBanks(); ContractTypesList = DataBaseClient.ReadContractTypes(); CurrenciesList = DataBaseClient.ReadCurrencies(); BrokersList = DataBaseClient.ReadBrokers(); AuthorsList = DataBaseClient.ReadTraders(); RangeList = new List <string>(); RangeList.Add("От 1 "); RangeList.Add("От 20.000 тсч."); RangeList.Add("От 1.000.000 млн."); RangeList.Add("От 5.000.000 млн."); RangeList.Add("От 10.000.000 млн."); RangeList.Add("От 15.000.000 млн."); RangeList.Add("От 25.000.000 млн."); RangeList.Add("От 40.000.000 млн."); RangeList.Add("От 50.000.000 млн."); RangeList.Add("От 75.000.000 млн."); RangeList.Add("От 100.000.000 млн."); RangeList.Add("От 1.000.000.000 млрд."); SelectedRange = RangeList[0]; ScanTypesList = new List <string>(); ScanTypesList.Add("Копия"); ScanTypesList.Add("Оригинал"); } if (contract == null) { Contract = new ContractEF(); Contract.companyid = companyId; Contract.agreementdate = DateTime.Now; SelectedContractType = ContractTypesList[0]; SelectedCurrency = CurrenciesList[0]; SelectedScanType = ScanTypesList[0]; } else { try { if (contract.bankid != null) { SelectedBank = BanksList.Where(x => x.id == contract.bankid).FirstOrDefault(); SearchTxt = SelectedBank.name; } SelectedContractType = ContractTypesList.Where(x => x.id == (contract.contracttypeid == null ? 1 : contract.contracttypeid)).FirstOrDefault(); SelectedCurrency = CurrenciesList.Where(x => x.id == contract.currencyid).FirstOrDefault(); SelectedBroker = BrokersList.Where(x => x.id == contract.brokerid).FirstOrDefault(); RatesList = new ObservableCollection <RatesListEF>(DataBaseClient.ReadRatesList(Contract.id)); SelectedAuthor = AuthorsList.FirstOrDefault(a => a.id == (contract.authorid == null ? 1 : contract.authorid)); SelectedScanType = ScanTypesList[(contract.scantype == null ? 0 : (int)contract.scantype)]; } catch (Exception) { } } }
private async void addCurrency(CurrencyModel obj) { CurrencyModel.TxtRate = getCurrencyValue().ToString(); if (CurrencyModel.Currency.Rate != 0) { List <Currency> savedCurrenciesList = new List <Currency>(); Singleton.getDialogueBox().showSearch(ConfigurationManager.AppSettings["update_message"]); CurrencyModel.Currency.Date = DateTime.Now; if (CurrencyModel.Currency.ID == 0) { savedCurrenciesList = await Bl.BlOrder.InsertCurrencyAsync(new List <QOBDCommon.Entities.Currency> { CurrencyModel.Currency }); CurrenciesList = new List <CurrencyModel>(CurrenciesList.Concat(savedCurrenciesList.Select(x => new CurrencyModel { Currency = x }).ToList())); } else { savedCurrenciesList = await Bl.BlOrder.UpdateCurrencyAsync(new List <Currency> { CurrencyModel.Currency }); } if (savedCurrenciesList.Count > 0) { await Singleton.getDialogueBox().showAsync("Currency updated Successfully!"); } } else { CurrencyModel.IsDefault = false; Currency currencyFound = Bl.BlOrder.searchCurrency(new Currency { IsDefault = true }, ESearchOption.AND).SingleOrDefault(); if (currencyFound != null) { var currency = CurrenciesList.Where(x => x.Currency.ID == currencyFound.ID).SingleOrDefault(); if (currency != null) { currency.IsDefault = true; } } await Singleton.getDialogueBox().showAsync("Cannot set a currency with a rate of [0] !"); } clearNewCurrency(null); Singleton.getDialogueBox().IsDialogOpen = false; }
private decimal getCurrencyValue() { var defaultCurrency = CurrenciesList.Where(x => x.IsDefault).SingleOrDefault(); if (defaultCurrency != null) { return(ExchangeRateFromAPI(defaultCurrency.CurrencyEnum.ToString(), CurrencyModel.CurrencyEnum.ToString())); } else { return(ExchangeRateFromAPI(CurrencyModel.CurrencyEnum.ToString(), CurrencyModel.CurrencyEnum.ToString())); } }
public async void refreshCurrenciesRate(object obj) { var defaultCurrency = CurrenciesList.Where(x => x.IsDefault).SingleOrDefault(); if (defaultCurrency != null) { await Singleton.getDialogueBox().showAsync("We are refreshing the currencies rate, you can start working in the mean time!"); bool isUpdateValid = await refreshCurrenciesRateByDefault(defaultCurrency); if (!isUpdateValid) { await Singleton.getDialogueBox().showAsync("Error detected while updating the currencies rate!"); } Singleton.getDialogueBox().IsDialogOpen = false; } }
private async void updateDefaultCurrency(CurrencyModel obj) { var previousDefaultCurrency = CurrenciesList.Where(x => x.IsDefault).SingleOrDefault(); if (obj.Currency.Rate != 0 && await Singleton.getDialogueBox().showAsync("Do you confirm the update of the default currency?" + Environment.NewLine + "(Please note that all prices will be updated.)")) { Singleton.getDialogueBox().showSearch(ConfigurationManager.AppSettings["update_message"]); await refreshCurrenciesRateByDefault(obj); var savedCurrencies = await Bl.BlOrder.UpdateCurrencyAsync(new List <Currency> { obj.Currency }); if (savedCurrencies.Count > 0) { await Singleton.getDialogueBox().showAsync("The default currency has been successfully updated!" + Environment.NewLine + "You must restart the application."); } else { string errorMessage = "Error occurred while updating the default currency to [" + obj.TxtName + " (ID=" + obj.TxtID + ")]"; Log.error(errorMessage, EErrorFrom.REFERENTIAL); await Singleton.getDialogueBox().showAsync(errorMessage); } } else { obj.IsDefault = false; if (obj.Currency.Rate == 0) { await Singleton.getDialogueBox().showAsync("Cannot set a currency with a rate of [0] as a default currency!"); } else { if (previousDefaultCurrency != null) { previousDefaultCurrency.IsDefault = true; } } } clearNewCurrency(null); Singleton.getDialogueBox().IsDialogOpen = false; }
private async void GetContractFrom1C() { AppJournal.Write("Contract", "Get contract from 1c", true); CompanyEF Company = DataBaseClient.ReadCompany(companyId); string contractNum = await MessagesService.GetInput("ПОИСК В 1С", "Введите номер договора"); if (!string.IsNullOrEmpty(contractNum)) { try { Contracts = _1CTransport.SearchContract(Company.bin, contractNum, 1); if (Contracts != null) { SelectedBroker = BrokersList.Where(x => x.id == 1).First(); BankAccounts = _1CTransport.SearchBankAccount(Company.iik, Company.bin, 1); } else { Contracts = _1CTransport.SearchContract(Company.bin, contractNum, 2); if (Contracts != null) { SelectedBroker = BrokersList.Where(x => x.id == 2).First(); BankAccounts = _1CTransport.SearchBankAccount(Company.iik, Company.bin, 2); } else { Contracts = _1CTransport.SearchContract(Company.bin, contractNum, 3); if (Contracts != null) { SelectedBroker = BrokersList.Where(x => x.id == 4).First(); BankAccounts = _1CTransport.SearchBankAccount(Company.iik, Company.bin, 3); } } } if (Contracts != null) { Contract.agreementdate = Contracts.ContracDate; Contract.number = Contracts.ContractNumber; if (BankAccounts != null) { SelectedBank = BanksList.Where(x => x.company.bik == BankAccounts.BankBIК).First(); } if (Contracts.ContractType.ToUpper().Contains("ПРОЧЕЕ") || Contracts.ContractType.ToUpper().Contains("ПОКУПАТЕЛЕМ")) { SelectedContractType = ContractTypesList.Where(x => x.id == 1).First(); } else { SelectedContractType = ContractTypesList.Where(x => x.id == 2).First(); } SelectedCurrency = CurrenciesList.Where(x => x.code == Contracts.СontractСurrency).First(); Contract = Contract; } } catch (Exception ex) { Contracts = null; AppJournal.Write("Contract", "Get contract from 1c error :" + ex.ToString(), true); } } if (Contracts == null) { MessagesService.Show("РЕЗУЛЬТАТ ПОИСКА В БАЗАХ", "Результатов нет"); } }