示例#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 async void AddNewDepositCommandAction(object obj)
        {
            var form     = new AddNewDepositView();
            var viemodel = new AddNewDepositViewModel(SelectedCustomer)
            {
                WindowClose = form.Close
            };

            form.DataContext = viemodel;
            form.ShowDialog();
            if (viemodel.Saved)
            {
                DepositSource.Add((Deposit)viemodel);
                SelectedCustomer.SisaSaldo = await context.GetSisaSaldo(SelectedCustomer.Id);
            }
            DepositViewSource.Refresh();
        }
示例#3
0
        private async void LoadDataSelectedCustomer()
        {
            try
            {
                await Task.Delay(200);

                var datas = await context.GetDepositsOfCustomer(SelectedCustomer);

                DepositSource.Clear();
                foreach (var item in datas)
                {
                    DepositSource.Add(item);
                }
                DepositViewSource.Refresh();
                DebetDepositGetData(SelectedCustomer.Id);
                SelectedCustomer.SisaSaldo = await context.GetSisaSaldo(SelectedCustomer.Id);
            }
            catch (Exception ex)
            {
                Helpers.ShowErrorMessage(ex.Message);
            }
        }