Пример #1
0
        public CustomerDepositViewModel()
        {
            MyTitle       = "CUSTOMER DEPOSIT";
            PrintRekening = new CommandHandler {
                CanExecuteAction = x => SelectedCustomer != null && SelectedDate <= DateTime.Now, ExecuteAction = PrintRekeningKoran
            };
            AddNewDepositCommand = new CommandHandler {
                CanExecuteAction = x => SelectedCustomer != null, ExecuteAction = AddNewDepositCommandAction
            };
            RefreshCommand = new CommandHandler {
                CanExecuteAction = x => true, ExecuteAction = RefreshCommandaction
            };
            AddNewCustomerCommand = new CommandHandler {
                CanExecuteAction = AddNewCustomerCommandValidate, ExecuteAction = AddNewCustomerCommandAction
            };
            CancelCommand = new CommandHandler {
                CanExecuteAction = x => true, ExecuteAction = CancelCommandaction
            };
            EditCustomerCommand = new CommandHandler {
                CanExecuteAction = x => SelectedCustomer != null, ExecuteAction = x => {
                    var form = new Views.AddNewCustomerDeposit();
                    form.DataContext = new AddNewCustomerDepositViewModel(SelectedCustomer)
                    {
                        WindowClose = form.Close
                    };
                    form.ShowDialog();
                }
            };



            PrintKwitansiCommand = new CommandHandler {
                CanExecuteAction = x => SelectedDeposite != null, ExecuteAction = PrintKwitansiAction
            };


            SendEmail = new CommandHandler {
                CanExecuteAction = SendemailValidate, ExecuteAction = SendEmailAction
            };
            Source     = new ObservableCollection <customer>();
            SourceView = (CollectionView)CollectionViewSource.GetDefaultView(Source);
            SourceView.Refresh();

            DepositSource     = new ObservableCollection <Deposit>();
            DepositViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DepositSource);
            DepositViewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription {
                Direction = System.ComponentModel.ListSortDirection.Descending, PropertyName = "TanggalBayar"
            });

            DebetDepositSource     = new ObservableCollection <DebetDeposit>();
            DebetDepositViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DebetDepositSource);
            DebetDepositViewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription {
                Direction = System.ComponentModel.ListSortDirection.Descending, PropertyName = "CreatedDate"
            });

            DepositViewSource.Refresh();
            RefreshCommand.Execute(null);
            SelectedCustomer = null;
            SelectedDate     = DateTime.Now;
        }
Пример #2
0
        private void AddNewCustomerCommandAction(object obj)
        {
            var form      = new Views.AddNewCustomerDeposit();
            var viewmodel = new AddNewCustomerDepositViewModel()
            {
                WindowClose = form.Close
            };

            form.DataContext = viewmodel;
            form.ShowDialog();

            if (viewmodel.Saved)
            {
                customer cust = (customer)viewmodel;
                Source.Add(cust);
                SourceView.Refresh();
            }
        }