protected void btnGravar_Click(object sender, EventArgs e) { // Cria a instância UsuarioEntity usuario = new UsuarioEntity(); UsuarioController usuarioController = new UsuarioController(); if (txtNome.Text == "" || txtCpf.Text == "" || txtPermissao.SelectedValue == "0") this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Preencha todos os campos!');</script>"); else { string cpfUsu = null; try { cpfUsu = Request.QueryString["cpfUsu"].ToString(); usuario = usuarioController.Obter(cpfUsu); } catch { } // Chama método if (cpfUsu != null) { if (usuarioController.AtualizarContrato(usuario.cpfUsu, usuario.cnpjEmp, Convert.ToInt32(txtPermissao.SelectedValue))) this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Permissão alterada com sucesso!'); window.location.href='Permissao.aspx';</script>"); else this.ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script>alert('Erro na alteração do registro!');</script>"); } } }
private void preencheCampos(string cpfUsu) { UsuarioController usuarioController = new UsuarioController(); UsuarioEntity usuario = usuarioController.Obter(cpfUsu); txtCpf.Text = usuario.cpfUsu; txtNome.Text = usuario.nomUsu; txtPermissao.Items.FindByValue(usuario.codCar.ToString()).Selected = true; }
private void PreencheCampos() { try { string cpfUsu = Request.QueryString["cpfUsu"].ToString(); UsuarioController usuarioController = new UsuarioController(); UsuarioEntity usuario = usuarioController.Obter(cpfUsu); txtCpf.Text = usuario.cpfUsu; txtNome.Text = usuario.nomUsu; txtCargo.Items.FindByValue(usuario.codCar.ToString()).Selected = true; } catch { } }
private void preencheCampos(string cpfUsu) { UsuarioController usuarioController = new UsuarioController(); UsuarioEntity usuario = usuarioController.Obter(cpfUsu); txtCpf.Text = usuario.cpfUsu; txtNome.Text = usuario.nomUsu; txtEndereco.Text = usuario.endUsu; try { txtUf.Items.FindByText(usuario.ufUsu).Selected = true; txtUf_SelectedIndexChanged(null, null); txtCidade.Items.FindByText(usuario.cidUsu).Selected = true; } catch { } txtSexo.Items.FindByValue(usuario.sexUsu).Selected = true; txtTelefone.Text = usuario.telUsu; txtEmail.Text = usuario.emaUsu; txtSenha.Text = usuario.senUsu; txtGraduacao.Items.FindByValue(usuario.codGra.ToString()).Selected = true; }