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(); } } }
private void Save_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(UpdateFullName.Text) || string.IsNullOrEmpty(UpdatePhone.Text)) { errM.Message = "All Feilds mark with asterisk(*) Are Required"; errM.Show(); } else { CustomerLocgic.UpdateCustomer(UpdateFullName.Text, UpdatePhone.Text, UpdateAddress.Text, UpdateEmail.Text, CustomerListGUI.CustomerData.Id.ToString()); sm.Message = "Customer details saved successfully"; sm.Show(); // MessageBox.Show(CustomerListGUI.CustomerData.Id.ToString()); Hide(); } }
//saving data into the customer table private void Save_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(FullName.Text) || string.IsNullOrEmpty(Phone.Text)) { errM.Message = "All Feilds mark with asterisk(*) Are Required"; errM.Show(); } else { CustomerLocgic.AddCustomer(FullName.Text, Phone.Text, Address.Text, Email.Text); sm.Message = "New customer details saved successfully"; sm.Show(); Hide(); //ShowInTaskbar = false; //new AddCustomer().ShowDialog(); } }