private void ButtonEditRecipients(object sender, RoutedEventArgs e) { try { string buttonTag = (sender as Button).Tag as string; WindowRecipientsListView windowRecipientsListView = new WindowRecipientsListView(null, true) { Owner = this, Title = buttonTag }; windowRecipientsListView.ShowDialog(); } catch (Exception exc) { MessageBox.Show(this, exc.Message, string.Empty, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ButtonItemReport_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; CustomReports.ItemReport itemReport = button.DataContext as CustomReports.ItemReport; if (itemReport == null) { MessageBox.Show(this, "ItemReport is null", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } string tag = button.Tag as string; if (string.IsNullOrEmpty(tag)) { MessageBox.Show(this, "Button.Tag is null", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } Window windowToShow = null; if (tag.Equals("CleanFolderToSave")) { itemReport.FolderToSave = string.Empty; } else if (tag.Equals("EditFolderToSave")) { CommonOpenFileDialog dlg = new CommonOpenFileDialog { Title = "Выбор пути сохранения", IsFolderPicker = true, AddToMostRecentlyUsedList = false, AllowNonFileSystemItems = false, EnsureFileExists = true, EnsurePathExists = true, EnsureReadOnly = false, EnsureValidNames = true, Multiselect = false, ShowPlacesList = true }; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { itemReport.FolderToSave = dlg.FileName; } } else if (tag.Equals("EditQuery")) { windowToShow = new WindowSqlQueryView(itemReport); } else if (tag.Equals("EditRecipients")) { windowToShow = new WindowRecipientsListView(itemReport); } else { MessageBox.Show(this, "Button.Tag unknown: " + tag, "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (windowToShow != null) { windowToShow.Owner = this; windowToShow.ShowDialog(); } }