Ejemplo n.º 1
0
        private void bAdd_Click(object sender, EventArgs e)
        {
            FormGenre    addForm = new FormGenre(null, sess);
            DialogResult result  = addForm.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            //if (DBFunction.GenreAdd(addForm.tbName.Text, addForm.tbDescription.Text, TabCon))
            if (dbAdd.GenreAdd(addForm.genre, TabCon))
            {
                MessageBox.Show("Новый объект добавлен");
            }
            else
            {
                MessageBox.Show("Ай-ай");
            }
        }
Ejemplo n.º 2
0
        private void bEdit_Click(object sender, EventArgs e)
        {
            if (dGVGenreList.SelectedRows.Count > 0)
            {
                int  index     = dGVGenreList.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dGVGenreList[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }

                Genres    genres   = TabCon.Genres.Find(id);
                FormGenre editForm = new FormGenre(genres, sess);

                DialogResult result = editForm.ShowDialog(this);

                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.Abort:
                    dbDelete.GenreDel(editForm.genre, TabCon);
                    dGVGenreList.Refresh();
                    break;

                case DialogResult.OK:
                    dbEdit.GenreEdit(genres, editForm.genre, TabCon);
                    dGVGenreList.Refresh();
                    break;

                default:
                    Console.WriteLine("Ой-ой");
                    break;
                }
            }
        }