Exemple #1
0
        /// <summary>
        /// Display the theme dialog. With an ID property of 0, the dialog goes into "new theme" mode. Setting the ID > 0 the dialog goes into "theme edit" mode.
        /// </summary>
        public void AddTheme()
        {
            statusLabel.Text = "Creating new theme...";
            ThemeDialog  myThemeDialog = new ThemeDialog();
            DialogResult result        = myThemeDialog.ShowDialog();

            // Dialog, go into "new theme" mode.
            myThemeDialog.FolderID = 0;

            if (result == DialogResult.OK)
            {
                try
                {
                    rssDataSet.FolderRow theme = rssDataSet.Folder.NewFolderRow();
                    theme.FolderName = myThemeDialog.FolderName;
                    int rowsAffected = folderTableAdapter.Update(theme);
                    rssDataSet.Folder.AddFolderRow(theme);
                    SqlConnection     cn = new SqlConnection();
                    SqlDataAdapter    da;
                    SqlCommandBuilder cmdBuilder;
                    cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["RSSReader.Properties.Settings.rssConnectionString"].ConnectionString;
                    cn.Open();
                    da         = new SqlDataAdapter("select * from Folder order by FolderId", cn);
                    cmdBuilder = new SqlCommandBuilder(da);
                    var submit = cmdBuilder.GetUpdateCommand().CommandText;
                    da.Update(rssDataSet, "Folder");
                    statusLabel.Text = "New theme created - '" + myThemeDialog.FolderName + "'";
                    Logging.WriteLog("New theme created - '" + myThemeDialog.FolderName + "'", Logging.LogType.Information, Logging.LogCaller.MainForm);
                }
                catch (Exception ex)
                {
                    statusLabel.Text = "Problem creating new theme. Could not save into database.";
                    MessageBox.Show("Problem creating new theme: " + ex.Message);
                    Logging.WriteLog(ex.Message, Logging.LogType.Error, Logging.LogCaller.MainForm);
                }
            }
            else
            {
                statusLabel.Text = "New folder operation cancelled.";
            }

            myThemeDialog = null;
        }
Exemple #2
0
        /// <summary>
        /// Edit the chosen theme.
        /// </summary>
        public void EditTheme()
        {
            statusLabel.Text = "Editing theme...";
            int          themeID       = (int)folderComboBox.SelectedValue;
            ThemeDialog  myThemeDialog = new ThemeDialog();
            DialogResult result        = myThemeDialog.ShowDialog();

            rssDataSet.FolderRow folder = rssDataSet.Folder.FindByFolderID(themeID);
            myThemeDialog.FolderID   = themeID;
            myThemeDialog.FolderName = folder.FolderName;

            if (result == DialogResult.OK)
            {
                int rowsAffected = folderTableAdapter.Update(folder);

                try
                {
                    folder.BeginEdit();
                    folder.FolderName = myThemeDialog.FolderName;
                    folder.EndEdit();

                    if (rowsAffected > 0)
                    {
                        statusLabel.Text = "Folder edited successfully: '" + folder.FolderName + "'";
                    }
                    else
                    {
                        statusLabel.Text = "Problem updating folder.  Could not save into the database.";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Problem editing folder: " + ex.Message);
                }
            }
            else
            {
                statusLabel.Text = "Edit folder operation cancelled.";
            }
            myThemeDialog = null;
        }
Exemple #3
0
        /// <summary>
        /// Delete the chosen theme.
        /// </summary>
        public void DeleteTheme()
        {
            statusLabel.Text = "Deleting theme...";

            DialogResult result = MessageBox.Show("Are you sure you want to delete the current theme? Doing so will also delete all the channels and messages contained in that folder.",
                                                  "Delete theme?",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question,
                                                  MessageBoxDefaultButton.Button2,
                                                  MessageBoxOptions.DefaultDesktopOnly,
                                                  false);

            if (result == DialogResult.Yes)
            {
                int rowsAffected = folderTableAdapter.Update(rssDataSet);
                try
                {
                    // Delete all the Channels for the current theme.
                    int folderID = (int)folderComboBox.SelectedValue;
                    DeleteChannels(folderID);
                    // Delete the folder itself, containing the theme.
                    rssDataSet.FolderRow folder = rssDataSet.Folder.FindByFolderID(folderID);
                    folder.Delete();

                    if (rowsAffected > 0)
                    {
                        statusLabel.Text = "Theme successfully deleted.";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Problem deleting theme:" + ex.Message);
                }
            }
            else
            {
                statusLabel.Text = "Delete theme operation cancelled.";
            }
        }