Пример #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) { }
            }
        }
Пример #2
0
        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("РЕЗУЛЬТАТ ПОИСКА В БАЗАХ", "Результатов нет");
            }
        }