Example #1
0
 private void toolStripButtonUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         FormFilm formFilm = new FormFilm(listViewProducers.Items.Count)
         {
             Film = (Film)listViewFilms.SelectedItems[0].Tag
         };
         if (formFilm.ShowDialog() == DialogResult.OK)
         {
             listViewFilms.SelectedItems[0].SubItems[1].Text = formFilm.Film.Title;
             listViewFilms.SelectedItems[0].SubItems[2].Text = formFilm.Film.ProdusserId.ToString();
             listViewFilms.SelectedItems[0].SubItems[3].Text = formFilm.Film.Year.ToString();
             Film.Update(_connection, formFilm.Film);
         }
     }
     catch (System.ArgumentOutOfRangeException ex)
     {
         MessageBox.Show("Аргумент не выбран", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Example #2
0
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            FormFilm formFilm = new FormFilm(listViewProducers.Items.Count)
            {
                Film = new Film()
            };

            if (formFilm.ShowDialog() == DialogResult.OK)
            {
                ListViewItem listListViewItem = new ListViewItem(formFilm.Film.FilmId.ToString());
                listListViewItem.Tag = formFilm.Film;
                listListViewItem.SubItems.Add(formFilm.Film.Title);
                listListViewItem.SubItems.Add(formFilm.Film.ProdusserId.ToString());
                listListViewItem.SubItems.Add(formFilm.Film.Year.ToString());
                listViewFilms.Items.Add(listListViewItem);
                listViewFilms.SelectedItems.Clear();
                listViewFilms.Items[listViewFilms.Items.Count - 1].Selected = true;


                Film.Insert(_connection, formFilm.Film);
            }
        }