private void EditItemCategory(object sender, RoutedEventArgs e) { if (dg_asortyment.SelectedIndex > -1) { DataRowView dr = (DataRowView)dg_asortyment.SelectedItem; if (dr != null) { CategoryEditWindow cw = new CategoryEditWindow(dr, categoryService, this); cw.ShowDialog(); } } }
private void btnCategoryEdit_Click(object sender, RoutedEventArgs e) { DataRowView currentRow = (DataRowView)((Button)e.Source).DataContext; CategoryEditWindow categoryEditWindow; if (string.IsNullOrEmpty(currentRow["Category"].ToString())) { categoryEditWindow = new CategoryEditWindow(currentRow["Category"].ToString(), MonthDisplayed); } else { currentRow["Category"] = currentRow["Category"].ToString().TrimStart(' '); categoryEditWindow = new CategoryEditWindow(currentRow, MonthDisplayed, toBeBudgeted); } categoryEditWindow.Owner = this; categoryEditWindow.Show(); categoryEditWindow.Owner = null; this.Close(); }