protected void ExistsOrganizationCustomValidator_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = false; OrganizationBLL theBLL = new OrganizationBLL(); Organization organization = null; try { organization = theBLL.GetOrganizationByName(OrganizationName.Text); } catch { return; } if (organization == null) { args.IsValid = true; } }
protected void AddOrganization_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } //Verify if exists with the same name OrganizationBLL theBLL = new OrganizationBLL(); Organization theOrg = null; try { theOrg = theBLL.GetOrganizationByName(OrganizationName.Text); } catch {} if (theOrg != null) { SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNameExists); return; } //Create the organizacion in the database int organizationId = 0; try { organizationId = OrganizationBLL.InsertOrganization(OrganizationName.Text); } catch (Exception exc) { SystemMessages.DisplaySystemErrorMessage(exc.Message); return; } SystemMessages.DisplaySystemMessage(Resources.Organization.MessageCreateOk); Response.Redirect("~/Organization/ListOrganizations.aspx"); }