private void btnInsert_Click(object sender, EventArgs e) { try { if (gv.ValidateGenre(txtGenreCreate.Text.Trim())) { ge = new Genre(); ge._Genre = txtGenreCreate.Text.Trim(); ge.InsBy = FormLoggedUser.Id; int error = genBLL.Add(ge); if (error == 0) { this.Close(); } else { MessageBox.Show("Genre name should be uniqe, please if this material type is deactivated update it"); } } else { throw new FormatException(); } } catch (FormatException) { MessageBox.Show("Genre is not valid"); } catch (Exception) { MessageBox.Show("Genre is not inserted please contact your administrator"); } }
public ActionResult AddGenre(Genre genre) { if (ModelState.IsValid) { genreBLL.Add(genre); return(RedirectToAction("Index")); } else { return(View("Register", genre)); } }