Exemple #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            List <Episode> watchedEpisodes = new List <Episode>();

            Cursor.Current = Cursors.WaitCursor;
            for (int i = 0; i < dgvEpisodes.RowCount; ++i)
            {
                Episode episode = new Episode();
                int     num;
                if (int.TryParse(dgvEpisodes.Rows[i].Cells[0].Value.ToString(), out num))
                {
                    episode.EpisodeID = num;
                }
                bool boolean;
                if (bool.TryParse(dgvEpisodes.Rows[i].Cells[5].Value.ToString(), out boolean))
                {
                    episode.Watched = boolean;
                }
                watchedEpisodes.Add(episode);
            }
            _dbManager.OpenConnection();
            _dbManager.BeginTransaction();
            _dbManager.UpdateWatchedEpisodes(watchedEpisodes);
            _dbManager.Commit();
            _dbManager.CloseConnection();
            Cursor.Current = Cursors.Default;
            MessageBox.Show("Saved!");
        }
Exemple #2
0
        private void chkWatched_Click(object sender, EventArgs e)
        {
            if (chkWatched.Checked)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to mark this episode as watched?", "Mark as Watched", MessageBoxButtons.YesNo);
                switch (result)
                {
                case System.Windows.Forms.DialogResult.Yes:
                    lastSelectedEpisode.Watched = true;
                    _dbManager.OpenConnection();
                    _dbManager.BeginTransaction();
                    _dbManager.UpdateWatchedEpisodes(new List <Episode> {
                        lastSelectedEpisode
                    });
                    _dbManager.Commit();
                    _dbManager.CloseConnection();
                    _items[lastSelectedEpisode.EpisodeID].ApplyColor(Color.FromArgb(0, 192, 192, 192));
                    break;

                case System.Windows.Forms.DialogResult.No:
                    chkWatched.Checked = false;
                    break;

                default:
                    break;
                }
            }
            else
            {
                DialogResult result = MessageBox.Show("Are you sure you want to mark this episode as unwatched?", "Mark as Unwatched", MessageBoxButtons.YesNo);
                switch (result)
                {
                case System.Windows.Forms.DialogResult.Yes:
                    lastSelectedEpisode.Watched = false;
                    _dbManager.OpenConnection();
                    _dbManager.BeginTransaction();
                    _dbManager.UpdateWatchedEpisodes(new List <Episode> {
                        lastSelectedEpisode
                    });
                    _dbManager.Commit();
                    _dbManager.CloseConnection();
                    if (lastSelectedEpisode.FirstAired <= DateTime.Now)
                    {
                        _items[lastSelectedEpisode.EpisodeID].ApplyColor(Color.FromArgb(0, 255, 0, 0));
                    }
                    else
                    {
                        _items[lastSelectedEpisode.EpisodeID].RemoveColors();
                    }
                    break;

                case System.Windows.Forms.DialogResult.No:
                    chkWatched.Checked = true;
                    break;

                default:
                    break;
                }
            }
            calendar1.Items.Clear();
            PlaceItems();
        }