예제 #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) { }
            }
        }
        public void UploadDocumentParams(Document document)
        {
            this.document = document;

            DocumentName         = document.name;
            DocumentNumber       = document.number;
            SelectedDocumentType = DocumentTypesList.First(d => d.id == document.type);
            SelectedBroker       = BrokersList.First(b => b.ShortName == document.broker);

            if (CompaniesStorageList.Count(c => c.name.ToLower().Contains(document.company.ToLower())) > 0)
            {
                SelectedCompany = CompaniesStorageList.First(c => c.name.ToLower().Contains(document.company.ToLower()));
            }

            SearchCompanyTxt = document.company;
            SelectedAuthor   = AuthorsList.FirstOrDefault(a => a.name == document.author);

            if (SelectedAuthor == null)
            {
                SelectedAuthor = AuthorsList.First(a => a.name.ToLower().Contains("не наз"));
            }

            DocumentDate        = document.createdDate;
            DocumentDescription = document.description;

            if (CurrentPresentation == PresentationEnum.Archive)
            {
                DocumentYear         = document.year;
                DocumentCase         = document.case_;
                DocumentVolume       = document.volume;
                DocumentSerialNumber = document.serialNumber == null ? 0 : (int)document.serialNumber;
            }

            AttachedDocument = DataManagerService.Instanse().ReadDocumentLink(document.id);

            if (!string.IsNullOrEmpty(AttachedDocument))
            {
                IsAttach = true;
            }
        }