private void EventSetter_OnHandler(object sender, MouseButtonEventArgs e) { object source = e.OriginalSource; string isAction = ((DataGridCell)sender).Column.Header.ToString().ToUpperInvariant(); DataGridRow dgrSelectedRow = FindParent <DataGridRow>(sender as DependencyObject); Vendor selectedVendor = (Vendor)dgrSelectedRow.DataContext; if (source.GetType() == typeof(Image) && isAction == "DELETE") { DataAccess objDataAccess = new DataAccess(); bool isVendorDeleted = objDataAccess.DeleteVendor(selectedVendor.VendorCode); if (isVendorDeleted) { MessageBox.Show("Vendor Deleted Successfully"); } else { MessageBox.Show("Vendor Deletion Failed!!!"); } LoadVendors(); } if (source.GetType() == typeof(Image) && isAction == "EDIT") { VendorScreen objVendorScreen = new VendorScreen(); objVendorScreen.EditVendor = selectedVendor; objVendorScreen.DataChanged += ObjVendorScreen_DataChanged; objVendorScreen.ShowDialog(); } }
private void VendorAdd_Click(object sender, RoutedEventArgs e) { VendorScreen objVendorScreen = new VendorScreen(); objVendorScreen.DataChanged += ObjVendorScreen_DataChanged; objVendorScreen.ShowDialog(); }