Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!(validateUI(btnDelete)))
            {
                return;
            }

            try
            {
                Genre myGenre = new Genre();
                myGenre.id   = txtID.Text.Trim();
                myGenre.name = txtName.Text.Trim();

                bool status = GenreDB.DeleteGenre(myGenre);
                if (status) //returns true
                {
                    MessageBox.Show("Genre ID has been deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Automatically refresh the data grid
                    this.btnBrowse_Click(null, null);
                }
                else //returns false
                {
                    MessageBox.Show("Genre ID was not deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (GenreDB.DeleteGenre(GetGenreObjFromUI()))
     {
         MessageBox.Show("Delete Successful.");
     }
     else
     {
         MessageBox.Show("Delete Failed.");
     }
 }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Validate the UI
            if (string.IsNullOrEmpty(txtGenreID.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre id.");
                txtGenreID.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtGenreName.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre name.");
                txtGenreID.Focus();
                return;
            }

            Genre objGenre = new Genre();

            objGenre.ID   = Convert.ToInt32(txtGenreID.Text.Trim());
            objGenre.Name = txtGenreName.Text.Trim();
            try
            {
                bool status = GenreDB.DeleteGenre(objGenre);
                if (status) //You can use this syntax as well..if (status ==true)
                {
                    Reload_Data();
                    MessageBox.Show("Genre was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Genre was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }