Ejemplo n.º 1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (codUsuarioSelecionado < 0)
            {
                MessageBox.Show("Clique em um registro na grid antes de prosseguir!");
            }
            else
            {
                Usuario USU = new Usuario();
                USU.Id_Nome   = codUsuarioSelecionado;
                USU.Nome      = txbNome.Text;
                USU.Email     = txbEmail.Text;
                USU.Login     = txbLogin.Text;
                USU.Senha     = txbSenha.Text;
                USU.Id_Perfil = Convert.ToInt32(cbxPerfil.SelectedValue);

                int retorno = new BLL.UsuarioBLL().EditarUsuario(USU);
                if (retorno > 0)
                {
                    MessageBox.Show("Alterado com Sucesso");
                    codUsuarioSelecionado = -1;
                    carregaGridUsuario();
                    txbNome.Text   = "";
                    txbEmail.Text  = "";
                    txbLogin.Text  = "";
                    txbSenha.Text  = "";
                    cbxPerfil.Text = "";
                }
            }
        }
Ejemplo n.º 2
0
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            if (codUsuarioSelecionado < 0)
            {
                MessageBox.Show("Clique em um registro na grid antes de prosseguir!");
            }
            else
            {
                Usuario USU = new Usuario();
                USU.Id_Nome = codUsuarioSelecionado;

                int retorno = new BLL.UsuarioBLL().DeletarUsuario(USU);
                if (retorno > 0)
                {
                    MessageBox.Show("Excluído com Sucesso");
                    codUsuarioSelecionado = -1;
                    carregaGridUsuario();
                    txbNome.Text   = "";
                    txbEmail.Text  = "";
                    txbLogin.Text  = "";
                    txbSenha.Text  = "";
                    cbxPerfil.Text = "";
                }
            }
        }
Ejemplo n.º 3
0
        private void btnInserir_Click(object sender, EventArgs e)
        {
            if (txbNome.Text == "" || txbEmail.Text == "" || txbLogin.Text == "" || txbSenha.Text == "" || cbxPerfil.Text == "")
            {
                MessageBox.Show("Por favor, preencha os campos obrigatórios...");
            }
            else
            {
                Usuario USU = new Usuario();
                USU.Nome      = txbNome.Text;
                USU.Email     = txbEmail.Text;
                USU.Login     = txbLogin.Text;
                USU.Senha     = txbSenha.Text;
                USU.Id_Perfil = Convert.ToInt32(cbxPerfil.SelectedValue);

                int retorno = new BLL.UsuarioBLL().InsereUsuario(USU);
                if (retorno > 0)
                {
                    MessageBox.Show("Gravado com Sucesso");
                    codUsuarioSelecionado = -1;
                    carregaGridUsuario();
                    txbNome.Text   = "";
                    txbEmail.Text  = "";
                    txbLogin.Text  = "";
                    txbSenha.Text  = "";
                    cbxPerfil.Text = "";
                }
            }
        }