示例#1
0
        private void BtnEditGenre_Click(object sender, EventArgs e)
        {
            if (_selectedGenre == null)
            {
                MessageBox.Show("Please select genre", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(TxbEditGenre.Text))
            {
                LblErr.Visible = true;
                return;
            }
            LblErr.Visible = false;
            DialogResult r = MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


            if (r == DialogResult.Yes)
            {
                _selectedGenre.Name = TxbEditGenre.Text;

                _context.SaveChanges();
                ClearGenres();
                FillGenres();
                TxbEditGenre.Clear();
            }
            if (r == DialogResult.No)
            {
                return;
            }
            ;
            TxbEditGenre.Clear();
        }
示例#2
0
        //Delete Genre
        private void BtnDeleteGenre_Click(object sender, EventArgs e)
        {
            if (_selectedGenre == null)
            {
                MessageBox.Show("Please select genre", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult r = MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (r == DialogResult.Yes)
            {
                _context.Genres.Remove(_selectedGenre);

                _context.SaveChanges();
                ClearGenres();
                FillGenres();
            }
            else if (r == DialogResult.No)
            {
                return;
            }
            TxbEditGenre.Clear();
        }