Пример #1
0
        void ContactDetails_ChangeContainerSet()
        {
            Contact model = null;
            if (_contactId < 0) {
                model = new Contact();
                model.ContactID = _contactId;
                RegisterUniquePendingChange(new InsertContactCommand(model));
            } else {
                var service = new LoanService(User);
                model = service.GetContact(_contactId);
            }

            _viewModel = new ContactViewModel(model);

            if (model != null && !string.IsNullOrEmpty(model.StreetAddress)) {
                if (model.StreetAddress.Equals(model.PostalAddress, StringComparison.CurrentCultureIgnoreCase)) {
                    _viewModel.PostalSameAsStreet = true;
                }
            }

            tabContact.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Contact, _viewModel));
            tabContact.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Contact, _viewModel));

            txtInstituion.BindUser(User, "tblContact", "vchrInstitution");

            _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged);

            this.DataContext = _viewModel;
            this.WindowTitle = string.Format("Contact detail: {0} [{1}]", _viewModel.FullName, _viewModel.ContactID);
        }
Пример #2
0
        public void LoadPage(string range)
        {
            lblPageHeader.Content = string.Format("Contacts - {0}", range);

            string[] bits = range.Split('-');
            _model.Clear();
            if (bits.Length == 2) {
                string from = bits[0];
                string to = bits[1];

                var service = new LoanService(User);
                var list = service.ListContactsRange(from, to);
                foreach (Contact contact in list) {
                    _model.Add(new ContactViewModel(contact));
                }

            }
        }
Пример #3
0
        private void DoFind()
        {
            var searchTerm = txtFind.Text;
            var what = cmbWhat.SelectedItem as Pair<string, string>;
            lblResults.Content = "";

            if (string.IsNullOrWhiteSpace(searchTerm) || what == null) {
                lvw.ItemsSource = new ObservableCollection<LoanViewModel>();
                return;
            }

            var service = new LoanService(User);

            if (!searchTerm.EndsWith("*") && !searchTerm.EndsWith("%")) {
                searchTerm += "*";
            }

            if (!searchTerm.StartsWith("*") && !searchTerm.StartsWith("%")) {
                searchTerm = "*" + searchTerm;
            }

            var list = service.FindLoans(searchTerm, what.Second, chkFindOnlyOpenLoans.IsChecked.ValueOrFalse());
            _model = new ObservableCollection<LoanViewModel>(list.Select((m) => {
                return new LoanViewModel(m);
            }));

            lblResults.Content = String.Format("{0} matching loans found", list.Count);

            lvw.ItemsSource = _model;
        }
Пример #4
0
        private void GenerateLoanForm(int mmID)
        {
            var service = new LoanService(User);
            var loan = service.GetLoan(LoanID);
            var loanMaterial = service.GetLoanMaterial(LoanID);
            // var loanCorrespondence = service.GetLoanCorrespondence(LoanID);

            var supportSevice = new SupportService(User);
            var loanTraits = supportSevice.GetTraits(TraitCategoryType.Loan.ToString(), LoanID);

            var originator = loan.OriginatorID != 0 ? service.GetContact(loan.OriginatorID) : null;
            var requestor = loan.RequestorID != 0 ? service.GetContact(loan.RequestorID) : null;
            var receiver = loan.ReceiverID != 0 ? service.GetContact(loan.ReceiverID) : null;

            var template = supportSevice.GetMultimedia(mmID);

            var generator = LoanFormGeneratorFactory.GetLoanFormGenerator(template);

            if (generator != null) {
                var outputFile = generator.GenerateLoanForm(template, loan, loanMaterial, loanTraits, originator, requestor, receiver);
                if (outputFile != null) {
                    var filename = ChooseFilename(loan, template);
                    if (!string.IsNullOrWhiteSpace(filename)) {
                        outputFile.CopyTo(filename, true);
                        SystemUtils.ShellExecute(filename);
                        Close();
                    }
                }

            } else {
                ErrorMessage.Show("Unable to generate loan form - unrecognized template extension: {0}", template.FileExtension);
            }
        }
Пример #5
0
        void OverdueLoansControl_Loaded(object sender, RoutedEventArgs e)
        {
            var service = new LoanService(User);
            var list = service.GetRemindersDue(DateTime.Now);
            var model = new ObservableCollection<LoanReminderExViewModel>(list.Select((m) => {
                return new LoanReminderExViewModel(m);
            }));

            lvw.ItemsSource = model;
            lblStatus.Content = string.Format("{0} reminders retreived.", model.Count);
        }