public void NotifyCustomerEdited(Klant klant)
 {
     Customers.Remove(Customers.FirstOrDefault(k => k.Id == klant.Id));
     Customers.Add(new KlantVM(klant));
     _editCustomerWindow.Close();
     _editCustomerWindow = null;
 }
 private void UpdateKlant()
 {
     //TODO: Functioneel maken
     _editCustomerWindow       = new EditCustomerWindow();
     _editCustomerWindow.Owner = Application.Current.MainWindow;
     _editCustomerWindow.Show();
 }
        private void btnCustomerEdit_Click(object sender, RoutedEventArgs e)
        {
            EditCustomerWindow editCustomerWindow = new EditCustomerWindow();

            editCustomerWindow.Customer = Customer;
            editCustomerWindow.Owner    = RibbonApp.Database.Configuration.MainWindow;
            editCustomerWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            editCustomerWindow.ShowDialog();
        }
Exemple #4
0
        private void ModifyCustomer(object parameter)
        {
            var oldCustomer = parameter as Customer;
            var newCustomer = new EditCustomerWindow().Edit(oldCustomer);

            if (newCustomer != null)
            {
                DBConnector.GetInstance().ModifyCustomerAsync(oldCustomer, GetModifications(oldCustomer, newCustomer));
            }
        }
        private void DataOperation(object sender)
        {
            // create an event listener to refresh info on database updates
            DatabaseOperations.DataUpdateComplete += UpdateAllData;

            var btn = sender as Button;

            //todo_done cleanup repeated code.
            if (btn.Name == "btnEditMovie")
            {
                var editDialog = new EditMovieWindow(MovieNames.SelectedItem as MovieModel);
                editDialog.ShowDialog();
            }
            else if (btn.Name == "btnNewMovie")
            {
                var addDialog = new AddNewMovieWindow();
                addDialog.ShowDialog();
            }
            else if (btn.Name == "btnEditCust")
            {
                var editCustDialog = new EditCustomerWindow(CustomerNames.SelectedItem as CustomerModel);
                editCustDialog.ShowDialog();
            }
            else if (btn.Name == "btnNewCustomer")
            {
                var addDialog = new NewCustomerWindow();
                addDialog.ShowDialog();
            }
            else if (btn.Name == "btnDeleteMovie")
            {
                var movie  = MovieNames.SelectedItem as MovieModel;
                var choice = MessageBox.Show($"Are you sure you want to delete \"{movie.Title}\"?", "Confirm Delete", MessageBoxButton.OKCancel);
                if (choice == MessageBoxResult.OK)
                {
                    new DatabaseOperations().DeleteMovieFromTable(movie);
                }
            }
            else if (btn.Name == "btnDeleteCust")
            {
                var cust   = CustomerNames.SelectedItem as CustomerModel;
                var choice = MessageBox.Show($"Are you sure you want to delete \"{cust.FullName}\"?", "Confirm Delete", MessageBoxButton.OKCancel);
                if (choice == MessageBoxResult.OK)
                {
                    new DatabaseOperations().DeleteCustomerFromTable(cust);
                }
            }

            // since the event is static (to make it global), detach listener to avoid duplicate event triggers
            DatabaseOperations.DataUpdateComplete -= UpdateAllData;
        }
        private void Edit()
        {
            if (EditWindow == null)
            {
                EditWindow = new EditCustomerWindow(selecItem);
                EditWindow.EditCustomerViewModel.PersonelEdit += EditCustomerViewModelSaved;
                EditWindow.Closing += EditCustomerWindowClosing;
                EditWindow.Show();
            }

            else
            {
                EditWindow.Focus();
            }
        }
 public void NotifyEditCancelled()
 {
     _editCustomerWindow.Close();
     _editCustomerWindow = null;
 }
 private void EditCustomerWindowClosing(object sender, CancelEventArgs e)
 {
     EditWindow.Dispose();
     EditWindow = null;
 }