private void buttonExport_Click(object sender, EventArgs e) { if (tableDialogs.SelectedItems == null || tableDialogs.SelectedItems.Length == 0) { return; } CategoryDataSet.CategoryRow row = ((CategoryDataSet.CategoryRow)tableDialogs.SelectedItems[0].Tag); DialogDataSet.DialogRow dialogRow; if (row == null) { dialogRow = GetDialogRowFromCategory(0); } else { dialogRow = GetDialogRowFromCategory(row.CategoryID); } if (dialogRow == null) { return; } SaveFileDialog fileDlg = new SaveFileDialog(); fileDlg.Filter = StringTable.XmlFileDialogFilter; if (fileDlg.ShowDialog(this) == DialogResult.OK) { File.WriteAllText(fileDlg.FileName, dialogRow.DialogXML); } }
private void UpdateWindowState() { buttonImport.Enabled = (tableDialogs.SelectedItems != null && tableDialogs.SelectedItems.Length > 0); bool hasDialog = false; if (tableDialogs.SelectedItems != null && tableDialogs.SelectedItems.Length > 0) { CategoryDataSet.CategoryRow row = ((CategoryDataSet.CategoryRow)tableDialogs.SelectedItems[0].Tag); DialogDataSet.DialogRow dialogRow; if (row == null) { dialogRow = GetDialogRowFromCategory(0); } else { dialogRow = GetDialogRowFromCategory(row.CategoryID); } if (dialogRow != null) { hasDialog = true; } } buttonExport.Enabled = hasDialog; buttonEdit.Enabled = hasDialog; buttonDelete.Enabled = hasDialog; }
public void Add(CategoryDataSet.CategoryRow category) { Category newCategory = new Category(); newCategory.CategoryID = category.CategoryID; newCategory.Name = category.Name; newCategory.Order = category.Order; this.Add(newCategory); }
private void buttonImport_Click(object sender, EventArgs e) { if (tableDialogs.SelectedItems == null || tableDialogs.SelectedItems.Length == 0) { return; } CategoryDataSet.CategoryRow row = ((CategoryDataSet.CategoryRow)tableDialogs.SelectedItems[0].Tag); DialogDataSet.DialogRow dialogRow; if (row == null) { dialogRow = GetDialogRowFromCategory(0); } else { dialogRow = GetDialogRowFromCategory(row.CategoryID); } OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.Filter = StringTable.XmlFileDialogFilter; if (fileDlg.ShowDialog(this) == DialogResult.OK) { // Prüfen, ob es sich um einen Dialog handelt string xmlDialog = File.ReadAllText(fileDlg.FileName); string errorMessage = ""; if (!MainCDUserControl.IsHitbaseDialog(xmlDialog, ref errorMessage)) { MessageBox.Show(StringTable.NoHitbaseDialog, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogTableAdapter ta = new DialogTableAdapter(dataBase); if (dialogRow == null) // Neu { DialogDataSet ds = new DialogDataSet(); dialogRow = ds.Dialog.AddDialogRow(row.CategoryID, xmlDialog); } else { dialogRow.DialogXML = xmlDialog; } ta.Update(dialogRow); LoadDialogs(); FillList(); } }
private void buttonDelete_Click(object sender, EventArgs e) { if (tableDialogs.SelectedItems == null || tableDialogs.SelectedItems.Length == 0) { return; } CategoryDataSet.CategoryRow row = ((CategoryDataSet.CategoryRow)tableDialogs.SelectedItems[0].Tag); if (row == null) { // Der Standarddialog kann nicht gelöscht werden MessageBox.Show(StringTable.CanNotDeleteStandardDialog, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string question = string.Format(StringTable.QueryDeleteDialog, row.Name); if (MessageBox.Show(question, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DialogDataSet.DialogRow dialogRow; dialogRow = GetDialogRowFromCategory(row.CategoryID); if (dialogRow == null) { MessageBox.Show(StringTable.ErrorDeleteDialog, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogTableAdapter ta = new DialogTableAdapter(dataBase); ta.Delete(dialogRow.DialogID); LoadDialogs(); FillList(); } }
public ListBoxItem(CategoryDataSet.CategoryRow category) { Category = category; }