Beispiel #1
0
        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) { }
            }
        }