private void okButton_Click(object sender, EventArgs e) { if (ChannelID == 0) { rssDataSet.ChannelRow channel = rssDataSet.Channel.NewChannelRow(); channel.FolderID = int.Parse(folderComboBox.SelectedValue.ToString()); channel.Title = titleTextBox.Text; channel.URL = urlTextBox.Text; channel.LastUpdated = DateTime.Now; rssDataSet.Channel.AddChannelRow(channel); } else { // Find the existing channel rssDataSet.ChannelRow channel = rssDataSet.Channel.FindByChannelID(ChannelID); channel.BeginEdit(); channel.FolderID = int.Parse(folderComboBox.SelectedValue.ToString()); channel.Title = titleTextBox.Text; channel.URL = urlTextBox.Text; channel.LastUpdated = DateTime.Parse(lastUpdatedTextBox.Text); channel.EndEdit(); } Close(); }
/// <summary> /// Delete a chosen channel. /// </summary> public void DeleteChannel() { statusLabel.Text = "Deleting channel..."; DialogResult result = MessageBox.Show("Are you sure you want to delete the current Channel? Doing so will also delete all the News Items for that Channel.", "Delete Folder?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly, false); if (result == DialogResult.Yes) { int rowsAffected = channelTableAdapter.Update(rssDataSet); try { // Delete NewsItems associated with this Channel. int channelID = (int)channelsListBox.SelectedValue; DeleteNewsItems(channelID); // Delete the Channel. rssDataSet.ChannelRow channel = rssDataSet.Channel.FindByChannelID(channelID); channel.Delete(); if (rowsAffected > 0) { statusLabel.Text = "Channel deleted successfully."; } else { statusLabel.Text = "Problem deleting channel."; } } catch (Exception ex) { MessageBox.Show("Problem deleting channel: " + ex.Message); } } else { statusLabel.Text = "Delete channel operation cancelled."; } }