Пример #1
0
        void ButtonCommitClick(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

            if (purpose == Purpose.addNewMovie)
            {
                string name = textBoxName.Text.Trim();
                if (name.Length < 1)
                {
                    MessageBox.Show("Sie müssen einem Namen angeben.");
                    textBoxName.BackColor = Color.Red;
                    return;
                }

                if (name.Length < 1)
                {
                    MessageBox.Show("Sie müssen einen Rating angeben.");
                    textBoxRating.BackColor = Color.Red;
                    return;
                }
            }

            if (textBoxLastSeenEpisode.Text.Length < 1)
            {
                MessageBox.Show("Sie müssen eine letzte Episode angeben.");
                textBoxLastSeenEpisode.BackColor = Color.Red;
                return;
            }

            if (textBoxLastSeenSeason.Text.Length < 1)
            {
                MessageBox.Show("Sie müssen eine letzte Staffel angeben.");
                textBoxLastSeenSeason.BackColor = Color.Red;
                return;
            }

            textBoxName.BackColor            = Color.White;
            textBoxLastSeenEpisode.BackColor = Color.White;
            textBoxLastSeenSeason.BackColor  = Color.White;
            textBoxRating.BackColor          = Color.White;

            Media media;

            if (purpose == Purpose.addRepDetails)
            {
                media = new Media(((NamePuffer)comboBoxSelectName.SelectedItem).ID);
            }
            else
            {
                media = new Media(-1);
            }

            media.Name  = textBoxName.Text;
            media.Type  = "Serie";
            media.Genre = null;
            media.KA    = (Media.KaEnum)comboBoxKA.SelectedItem;
            if (imageChanged)
            {
                media.Cover = pictureBoxImage.Image;
            }

            try
            {
                media.Rating = Int32.Parse(textBoxRating.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Sie müssen eine Ganzzahl eingeben.");
                textBoxLastSeenEpisode.BackColor = Color.Red;
                return;
            }

            Detail detail = new Detail(-1);

            detail.ViewLanguage = (Detail.Language)comboBoxLanguage.SelectedItem;
            try
            {
                detail.LastSeenEpisode = Int32.Parse(textBoxLastSeenEpisode.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Sie müssen eine Ganzzahl eingeben.");
                textBoxLastSeenEpisode.BackColor = Color.Red;
                return;
            }

            try
            {
                detail.LastSeenSeason = Int32.Parse(textBoxLastSeenSeason.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Sie müssen eine Ganzzahl eingeben.");
                textBoxLastSeenSeason.BackColor = Color.Red;
                return;
            }

            detail.AktivStatus            = (Detail.Status)comboBoxAktivStatus.SelectedItem;
            detail.LastSeenSeasonFinished = checkBoxSeasonFinished.Checked;

            if (purpose == Purpose.addRepDetails)
            {
                detail.isRepeat = true;
                media.addDetail(new Detail(-2));
                media.addDetail(detail);
                //database.addRepDetail(((NamePuffer)comboBoxSelectName.SelectedItem).ID, detail);
                this.aktMedia = media;
            }
            else if (purpose == Purpose.addNewMovie)
            {
                media.addDetail(detail);
                this.aktMedia = media;
            }

            this.DialogResult = DialogResult.OK;
        }
Пример #2
0
        /// <summary>
        /// Provides a filtered list of the content.
        /// </summary>
        public List <PictureListItem> getData(string category, List <int> type)
        {
            if (type.Count < 1)
            {
                return(null);
            }

            List <PictureListItem> ret = new List <PictureListItem>();

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                try
                {
                    connection.Open();

                    string typeString = "";
                    foreach (int item in type)
                    {
                        typeString += item + ",";
                    }
                    typeString = typeString.Substring(0, typeString.Length - 1);

                    using (SQLiteCommand command = new SQLiteCommand("SELECT * FROM Media WHERE Type = @type AND ID IN (SELECT DISTINCT MediaID FROM Details WHERE AktivStatus IN (" + typeString + "))", connection))
                    {
                        command.Parameters.AddWithValue("@type", category);
                        using (SQLiteDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                try
                                {
                                    Media item = createMediaFromReader(reader);

                                    using (SQLiteCommand detCommand = new SQLiteCommand("SELECT * FROM Details WHERE MediaID=@id", connection))
                                    {
                                        detCommand.Parameters.AddWithValue("@id", item.ID);
                                        using (SQLiteDataReader detailReader = detCommand.ExecuteReader())
                                        {
                                            while (detailReader.Read())
                                            {
                                                item.addDetail(createDetailFromReader(detailReader));
                                            }
                                        }

                                        ret.Add(new PictureListItem(item));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.ToString());
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Database.getData: " + ex);
                }
            }

            return(ret);
        }