private void InitializeCommands() { EditClientCommand = new RelayCommand(p => { if (selectedclient != null) { EditClientWindow window = new EditClientWindow(selectedclient); OnPropertyChanged(nameof(Allclients)); if (window.ShowDialog() == true) { OnPropertyChanged(nameof(Allclients)); //Allclients = this.GetAll(); } else { Allclients = this.GetAll(); } } }); AddClientCommand = new RelayCommand(p => { AddNewClientWindow window = new AddNewClientWindow(); if (window.ShowDialog() == true) { Allclients = this.GetAll(); } }); DeleteClientCommand = new RelayCommand(p => { if (selectedclient != null) { var result = MessageBox.Show("Вы уверены?", "Удалить запись", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { DeleteClient(selectedclient); Allclients = this.GetAll(); } } }); AddOrderCommand = new RelayCommand(p => { if (selectedclient != null) { AddNewOrderWindow window = new AddNewOrderWindow(selectedclient); if (window.ShowDialog() == true) { Allclients = this.GetAll(); } } else { MessageBox.Show("Выберите клиента!"); } } ); }
private void OpenAddNewClientWindowExecute(object obj, RoutedEventArgs e) { AddNewClientWindow addNewClientWindow = new AddNewClientWindow(); AddNewClientWindowViewModel addNewClientWindowViewModel = new AddNewClientWindowViewModel(); ViewService.RegisterView(addNewClientWindowViewModel.GetType(), addNewClientWindow.GetType()); ViewService.AddMainWindowToOpened(addNewClientWindowViewModel, addNewClientWindow); ViewService.ShowDialog(addNewClientWindowViewModel); }