Пример #1
0
        private void delete_Click(object sender, RoutedEventArgs e)
        {
            DataRowView dataRow = CustomerView.SelectedItem as DataRowView;

            if (dataRow != null)
            {
                CustomerData.Id = dataRow.Row[0].ToString();
            }
            if (dataRow == null)
            {
                errM.Message = "Please select a row or Customer from the table to delete it.";
                errM.Show();
            }
            else
            {
                //giveing a warning message
                var response = System.Windows.MessageBox.Show("Do you really want to delete this customer", "Delete",
                                                              MessageBoxButton.YesNo, MessageBoxImage.Stop);

                if (response == MessageBoxResult.No)
                {
                    e.Handled = true;
                }
                else
                {
                    CustomerLocgic.SetCustomerDeleteStatusToOne(CustomerData.Id);
                    //refresh the datasource to pull all items status with status zero
                    //into datagrid
                    CustomerView.ItemsSource = null;
                    CustomerView.ItemsSource = new CustomerLocgic().GetAllCustomers().DefaultView;
                    sm.Message = "Customer is successfully deleted from Customer list.";
                    sm.Show();
                }
            }
        }