private void btnUpdate_Click(object sender, EventArgs e) { if (!(validateUI(btnUpdate))) { return; } try { Genre myGenre = new Genre(); myGenre.id = txtID.Text.Trim(); myGenre.name = txtName.Text.Trim(); bool status = GenreDB.UpdateGenre(myGenre); if (status) //returns true { MessageBox.Show("Genre ID has been updated in 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 update in the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Update_Click(object sender, EventArgs e) { if (GenreDB.UpdateGenre(GetGenreObjFromUI())) { MessageBox.Show("Update Successful."); } else { MessageBox.Show("Update Failed."); } }
private void btnUpdate_Click_1(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.UpdateGenre(objGenre); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Genre has been updated.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Genre was not updated in database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }