public CategoryDetailForm(SymbolDataSet.LocalizedCategoryRow currentLocalizedCategoryRow) { InitializeComponent(); // Set up the SoundPlayer object. player = new SoundPlayer(); if (currentLocalizedCategoryRow.RowState == DataRowState.Added) { categoryId = 0; this.BindingContext[this.categoryDetailDataSet, CATEGORY].AddNew(); DataRowView rowView = this.BindingContext[this.categoryDetailDataSet, CATEGORY].Current as DataRowView; CategoryDetailDataSet.CategoryRow currentCategoryRow = rowView.Row as CategoryDetailDataSet.CategoryRow; rowView.BeginEdit(); currentCategoryRow.Name = Guid.NewGuid(); currentCategoryRow.IsActive = true; rowView.EndEdit(); } else { categoryId = currentLocalizedCategoryRow.CategoryId; } this.categoryDetailDataSet.Merge(currentLocalizedCategoryRow.Table.DataSet.Tables[LOCALIZED_CATEGORY]); this.cultureName = Properties.Settings.Default.CultureName; }
private void buttonEditCategory_Click(object sender, EventArgs e) { ListView.SelectedListViewItemCollection selectedItems = this.listViewCategory.SelectedItems; SymbolDataSet.LocalizedCategoryRow currentCategoryRow = selectedItems[0].Tag as SymbolDataSet.LocalizedCategoryRow; CategoryDetailForm detailForm = new CategoryDetailForm(currentCategoryRow); if (DialogResult.OK == detailForm.ShowDialog(this)) { this.LoadDataSet(); } }
private void buttonAddCategory_Click(object sender, EventArgs e) { SymbolDataSet.LocalizedCategoryRow currentCategoryRow = this.symbolDataSet.LocalizedCategory.NewLocalizedCategoryRow(); this.symbolDataSet.LocalizedCategory.AddLocalizedCategoryRow(currentCategoryRow); CategoryDetailForm detailForm = new CategoryDetailForm(currentCategoryRow); if (DialogResult.OK == detailForm.ShowDialog(this)) { this.LoadDataSet(); } else { this.symbolDataSet.LocalizedCategory.RejectChanges(); } }
private void buttonDeleteCategory_Click(object sender, EventArgs e) { ListView.SelectedListViewItemCollection selectedItems = this.listViewCategory.SelectedItems; SymbolDataSet.LocalizedCategoryRow currentCategoryRow = selectedItems[0].Tag as SymbolDataSet.LocalizedCategoryRow; // Initializes the variables to pass to the MessageBox.Show method. string message = string.Format(Resources.ConfirmDeletionMessage, currentCategoryRow.Name); string caption = Resources.ConfirmDeletionCaption; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { LocalizedCategoryTableAdapter categoryAdapter = new LocalizedCategoryTableAdapter(); categoryAdapter.Connection.Open(); SqlCommand sqlUpdateCommand = new SqlCommand(); sqlUpdateCommand.Connection = categoryAdapter.Connection; sqlUpdateCommand.CommandText = @"UPDATE Symbol SET IsActive = 'false' WHERE (CategoryId = @CategoryId) "; sqlUpdateCommand.Parameters.Add(new SqlParameter("@CategoryId", System.Data.SqlDbType.Int, 0, "CategoryId")); sqlUpdateCommand.Parameters["@CategoryId"].Value = currentCategoryRow.CategoryId; sqlUpdateCommand.ExecuteNonQuery(); sqlUpdateCommand.CommandText = @"UPDATE Category SET IsActive = 'false' WHERE (CategoryId = @CategoryId) "; sqlUpdateCommand.ExecuteNonQuery(); categoryAdapter.Connection.Close(); this.LoadDataSet(); } catch (Exception ex) { ReportError(ex.Message.ToString()); } } }
private void buttonAddSymbol_Click(object sender, EventArgs e) { ListView.SelectedListViewItemCollection selectedItems = this.listViewCategory.SelectedItems; SymbolDataSet.LocalizedCategoryRow currentCategoryRow = selectedItems[0].Tag as SymbolDataSet.LocalizedCategoryRow; SymbolDataSet.LocalizedSymbolRow currentSymbolRow = this.symbolDataSet.LocalizedSymbol.NewLocalizedSymbolRow(); currentSymbolRow.CategoryId = currentCategoryRow.CategoryId; this.symbolDataSet.LocalizedSymbol.AddLocalizedSymbolRow(currentSymbolRow); SymbolDetailForm detailForm = new SymbolDetailForm(currentSymbolRow); if (DialogResult.OK == detailForm.ShowDialog(this)) { this.LoadDataSet(); } else { this.symbolDataSet.LocalizedSymbol.RejectChanges(); } }