protected void btnOk_Click(object sender, EventArgs e) { if (txtUsuario.Text == "" || txtSenha.Text == "") this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>"); else { UsuarioController usuarioController = new UsuarioController(); UsuarioEntity usuario = usuarioController.Validar(txtUsuario.Text, txtSenha.Text); if (usuario.nomUsu != null) { Session["cpfUsu"] = usuario.cpfUsu; Session["nomUsu"] = usuario.nomUsu; Session["codCar"] = usuario.codCar; Session["nomCar"] = usuario.nomCar; Session["cnpjEmp"] = usuario.cnpjEmp; Session["nomEmp"] = usuario.nomEmp; Response.Write(Session["cpfUsu"]); Response.Write(Session["nomUsu"]); Response.Write(Session["codCar"]); Response.Write(Session["nomCar"]); Response.Write(Session["cnpjEmp"]); Response.Write(Session["nomEmp"]); Response.Redirect("~/Home.aspx"); } else this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Usuário ou senha inválidos!');</script>"); } }
protected void btnOk_Click(object sender, EventArgs e) { if (txtUsuario.Text == "" || txtSenha.Text == "") this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>"); else { UsuarioController usuarioController = new UsuarioController(); List<string> lista = usuarioController.Validar(txtUsuario.Text, txtSenha.Text); if (lista[0] != null) { Session["cpf"] = lista[0]; Session["nome"] = lista[1]; Session["cargo"] = lista[2]; Response.Write(Session["cpf"]); Response.Write(Session["nome"]); Response.Write(Session["cargo"]); Response.Redirect("~/Home.aspx"); } else this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Usuário ou senha inválidos!');</script>"); } }