protected void Page_Load(object sender, EventArgs e) { SecretariosBO sBO = new SecretariosBO(); Secretario s = Secretario.NewSecretario("2424", "Biba", @"*****@*****.**"); sBO.InsertPessoa(s, "aaaa", "bbb"); }
protected void cuwCriarUsuario(object sender, EventArgs e) { if (rblRoles.SelectedValue == "Admin") { MembershipCreateStatus resultado; string pass = txtConfirmarSenha.Text; Membership.CreateUser(this.UserName, pass, this.Email, "question", "answer", true, out resultado); Roles.AddUserToRole(this.UserName, "Admin"); if (resultado != MembershipCreateStatus.Success) { throw new MembershipCreateUserException(resultado.ToString()); } } else if (rblRoles.SelectedValue == "Secretario") { try { Secretario sec = Secretario.NewSecretario(txtLogin.Text, txtNome.Text, txtEmail.Text); try { MembershipFactory fabricaMembership = MembershipFactory.GetInstance(); PessoaBaseBO pessoaBaseBO = fabricaMembership.CreatePessoaBase(sec); if (ckbSenha.Checked) { pessoaBaseBO.InsertPessoa(sec, "Uma Pergunta?", "Uma Resposta."); } else { pessoaBaseBO.InsertPessoa(sec, txtSenha.Text, "Uma Pergunta?", "Uma Resposta."); } rblRoles.SelectedIndex = -1; } catch (BusinessData.DataAccess.DataAccessException ex) { Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message); } catch (SecurityException ex) { Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message); } } catch (System.Configuration.Provider.ProviderException) { throw new Exception("Impossivel adicionar usuario ao papel selecionado"); } } }