Beispiel #1
0
 private void BtnDeletar_Click(object sender, EventArgs e)
 {
     if (TxtIdUsuario.Text == "")
     {
         MessageBox.Show("Favor Digitar Id Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         try
         {
             conn.Open();
             SqlCommand comando = new SqlCommand(@"DELETE FROM Usuario  where (Id_Usuario='" + TxtIdUsuario.Text + "')", conn)
             {
                 CommandType = System.Data.CommandType.Text
             };
             comando.ExecuteNonQuery();
             LimpaDados();
             TxtIdUsuario.Clear();
             MessageBox.Show("Usuário Excluído com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             MessageBox.Show("Erro ao Excluir Usuário", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     conn.Close();
     LimpaDados();
     BtnCadastrar.Enabled = true;
     BtnAlterar.Enabled   = false;
     BtnDeletar.Enabled   = false;
     TxtIdUsuario.Enabled = false;
     TxtNome.Focus();
 }
Beispiel #2
0
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtNome.Text.Trim().Equals(String.Empty))
                {
                    TxtNome.Text = "";
                    TxtNome.Focus();
                    throw new CampoNaoInformadoException("Banco", "Nome", true);
                }

                Banco lBanco = null;
                string mensagem = "";
                if (Request.QueryString["id"] != null)
                {
                    lBanco = BancoBLL.Instance.BuscarPorId(Convert.ToInt32(Request.QueryString["id"]));
                    mensagem = "Banco alterada com sucesso.";
                }
                else
                {
                    lBanco = new Banco();
                    mensagem = "Banco cadastrado com sucesso.";
                }
                lBanco.Nome = TxtNome.Text.Trim();
                lBanco.Codigo = TxtCodigo.Text.Trim();
                BancoBLL.Instance.Persistir(lBanco);
                Web.ExibeAlerta(Page, mensagem, "Listar.aspx");
            }
            catch (BusinessException ex)
            {
                Web.ExibeAlerta(Page, ex.Message);
            }
        }
Beispiel #3
0
 private void BtnAlterar_Click_1(object sender, EventArgs e)
 {
     if (TxtCodCliente.Text == "")
     {
         MessageBox.Show("Digite um Código Válido!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TxtCodCliente.Focus();
     }
     else
     {
         try
         {
             conn.Open();
             SqlCommand comando = new SqlCommand(@"UPDATE CLIENTES SET Nome='" + TxtNome.Text + "',Sexo='" + CboSexo.Text + "',Endereco='" + TxtEndereco.Text + "',Bairro='" + TxtBairro.Text + "',Cidade='" + TxtCidade.Text + "',Cep='" + MktCep.Text + "',Estado='" + CmbEstado.Text + "',FoneFixo='" + MktFoneFixo.Text + "',FoneComercial='" + MkFoneComercial.Text + "',Celular='" + MktCelular.Text + "',Rg='" + TxtRG.Text + "',Email='" + TxtEmail.Text + "',CPF='" + MktCPF.Text + "',DataNascimento='" + dataNasc.Value.ToString("dd/MM/yyyy") + "'  where (Id_Cliente='" + TxtCodCliente.Text + "')", conn)
             {
                 CommandType = CommandType.Text
             };
             comando.ExecuteNonQuery();
             LimpaDados();
             CboCadPor.Enabled = true;
             MessageBox.Show("Cliente Atualizado Com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             MessageBox.Show("Erro ao Atualizar Cliente!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     conn.Close();
     LimpaDados();
     TxtCodCliente.Enabled = false;
     BtnCadastrar.Enabled  = true;
     BtnAlterar.Enabled    = false;
     BtnDeletar.Enabled    = false;
     TxtNome.Focus();
     CboCadPor.Enabled = true;
 }
Beispiel #4
0
 protected void btnNovo_Click(object sender, EventArgs e)
 {
     TxtNome.Text        = "";
     TxtIntegrantes.Text = "";
     IdH.Value           = "0";
     TxtNome.Focus();
 }
Beispiel #5
0
        private void BtnDeletar_Click_1(object sender, EventArgs e)
        {
            if (TxtCodCliente.Text == "")
            {
                MessageBox.Show("Favor Digitar Código Cliente!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    conn.Open();
                    SqlCommand comando = new SqlCommand(@"DELETE FROM CLIENTES  where (Id_Cliente='" + TxtCodCliente.Text + "')", conn)
                    {
                        CommandType = CommandType.Text
                    };
                    comando.ExecuteNonQuery();
                    TxtCodCliente.Clear();
                    MessageBox.Show("Cliente Excluído com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                catch
                {
                    MessageBox.Show("Erro ao Excluir Cliente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            conn.Close();
            LimpaDados();
            BtnCadastrar.Enabled  = true;
            BtnAlterar.Enabled    = false;
            BtnDeletar.Enabled    = false;
            TxtCodCliente.Enabled = false;
            TxtNome.Focus();
        }
        private void BtExcluir_Click(object sender, EventArgs e)
        {
            var resultado = MessageBox.Show(this, "Tem certeza que deseja excluir este registo"
                                            + TxtId.Text + " - " + TxtNome.Text + " ? ", "LTPV",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question,
                                            MessageBoxDefaultButton.Button2);

            if (resultado == DialogResult.No)
            {
                return;
            }

            IProfessorService service = Program.container.GetInstance <IProfessorService>();

            int id = Convert.ToInt32(TxtId.Text);

            if (service.Excluir(id))
            {
                PreencherGrid();

                MessageBox.Show(this, "Professor excluido com sucesso!",
                                "LTPV",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                LimparComponentes();
            }
            else
            {
                TxtNome.Focus();
                MessageBox.Show(this, "Não foi possivel excluir as informações! \n\n " + service.ObterNotificacoes(), "LTP5", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void Btncadastro_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            if (con.State == System.Data.ConnectionState.Open)
            {
                //string q = "INSERT INTO Cadastro(MATRICULA,NOME)VALUES('" + txtMatricula.Text.ToString() + "','" + TxtNome.Text.ToString() + "')";

                string q = "INSERT INTO Cadastro(MATRICULA,CPF,NOME, DEPARTAMENTO,FUNCAO, EMPRESA,CD)VALUES('" + txtMatricula.Text.ToString() + "','" + mTxtcpf.Text.ToString() + "','" + TxtNome.Text.ToString() + "','" + TxtDepartamento.Text.ToString() + "','" + CBfUNCAO.Text.ToString() + "','" + cbEmpresa.Text.ToString() + "','" + cbLocal.Text.ToString() + "')";



                SqlCommand cmd = new SqlCommand(q, con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Os dados foram salvo no banco de dados com sucesso .!!!!");
                // AQUI LIMPA OS CAMPOS APOS INSERIR OS DADOS
                txtMatricula.Text    = String.Empty;
                mTxtcpf.Text         = String.Empty;
                TxtDepartamento.Text = String.Empty;
                TxtNome.Text         = String.Empty;
                cbEmpresa.Text       = String.Empty;
                cbLocal.Text         = String.Empty;
                CBfUNCAO.Text        = String.Empty;



                TxtNome.Focus();
            }
        }
        // Verificar se um campo está vazio
        //desabilitar espaços como informações
        private void BtnSalvar_Click(object sender, EventArgs e)
        {
            if (TxtNome.Text.ToString().Trim() == "")
            {
                TxtNome.Text = "";
                MessageBox.Show("Preencha o Nome!", "Campo Vazio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtNome.Focus();
                return;
            }

            if (TxtCPF.Text == "   .   .   -")
            {
                MessageBox.Show("Preencha o CPF!", "Campo Vazio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtCPF.Focus();
                return;
            }


            //Código do botão para salvar

            MessageBox.Show("Registro Salvo com Sucesso!", "Dados Salvos", MessageBoxButtons.OK, MessageBoxIcon.Information);
            BtnNovo.Enabled   = true;
            BtnSalvar.Enabled = false;
            LimparCampos();
            DesabilitarCampos();
        }
Beispiel #9
0
        private void BtnEditar_Click(object sender, EventArgs e)
        {
            if (TxtNome.Text.ToString().Trim() == "")
            {
                TxtNome.Text = "";
                MessageBox.Show("Preencha o Nome!", "Campo Vazio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtNome.Focus();
                return;
            }

            if (TxtValor.Text == "")
            {
                MessageBox.Show("Preencha o Valor!", "Campo Vazio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtValor.Focus();
                return;
            }


            //CÓDIGO DO BOTÃO EDITAR

            MessageBox.Show("Registro Editado com Sucesso!", "Dados Salvos", MessageBoxButtons.OK, MessageBoxIcon.Information);
            BtnNovo.Enabled    = true;
            BtnEditar.Enabled  = false;
            BtnExcluir.Enabled = false;
            LimparCampos();
            DesabilitarCampos();
        }
Beispiel #10
0
        // FALTA IMPLEMENTAR
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtNome.Text.Trim().Equals(String.Empty))
                {
                    TxtNome.Text = "";
                    TxtNome.Focus();
                    throw new CampoNaoInformadoException("Cidade", "Nome", true);
                }

                Cidade lCidade  = null;
                string mensagem = "";
                if (Request.QueryString["id"] != null)
                {
                    lCidade  = CidadeBLL.Instance.BuscarPorId(Convert.ToInt32(Request.QueryString["id"]));
                    mensagem = "Cidade alterada com sucesso.";
                }
                else
                {
                    lCidade  = new Cidade();
                    mensagem = "Cidade cadastrada com sucesso.";
                }
                UnidadeFederativa lUf = new UnidadeFederativa();
                lUf          = UnidadeFederativaBLL.Instance.BuscarPorId(Convert.ToInt32(DropDownUf.SelectedValue));
                lCidade.Nome = TxtNome.Text.Trim();
                lCidade.Uf   = lUf;
                CidadeBLL.Instance.Persistir(lCidade);
                Web.ExibeAlerta(Page, mensagem, "Listar.aspx");
            }
            catch (BusinessException ex)
            {
                Web.ExibeAlerta(Page, ex.Message);
            }
        }
Beispiel #11
0
 private void ResetaForm()
 {
     TxtId.Clear();
     TxtNome.Clear();
     TxtAutor.Clear();
     TxtEditora.Clear();
     TxtNome.Focus();
 }
Beispiel #12
0
 private void Reset()
 {
     TxtNome.Clear();
     BtnAlterar.Enabled = false;
     BtnExcluir.Enabled = false;
     BtnGravar.Enabled  = true;
     TxtNome.Focus();
 }
 protected void btnNovo_Click(object sender, EventArgs e)
 {
     TxtNome.Text     = "";
     TxtTelefone.Text = "";
     TxtEndereco.Text = "";
     IdH.Value        = "0";
     TxtNome.Focus();
 }
Beispiel #14
0
        private void TxtCodCliente_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (TxtCodCliente.Text == "")
                {
                    TxtNome.Focus();
                    TxtCodCliente.Enabled = false;
                    BtnDeletar.Enabled    = false;
                    BtnAlterar.Enabled    = false;
                    BtnCadastrar.Enabled  = true;
                    TxtCodCliente.Enabled = false;
                    MessageBox.Show("Nenhum Código Digitado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    conn.Open();
                    string        cadSql = "SELECT * from Clientes inner join usuario on clientes.id_usuario=usuario.Id_usuario where Id_Cliente='" + TxtCodCliente.Text + "'";
                    SqlCommand    comand = new SqlCommand(cadSql, conn);
                    SqlDataReader ler    = comand.ExecuteReader();
                    if (ler.Read() == true)
                    {
                        TxtNome.Text          = ler["Nome"].ToString();
                        CboSexo.Text          = ler["Sexo"].ToString();
                        TxtEndereco.Text      = ler["Endereco"].ToString();
                        TxtBairro.Text        = ler["Bairro"].ToString();
                        TxtCidade.Text        = ler["Cidade"].ToString();
                        MktCep.Text           = ler["Cep"].ToString();
                        CmbEstado.Text        = ler["Estado"].ToString();
                        MktFoneFixo.Text      = ler["FoneFixo"].ToString();
                        MkFoneComercial.Text  = ler["FoneComercial"].ToString();
                        MktCelular.Text       = ler["Celular"].ToString();
                        TxtRG.Text            = ler["Rg"].ToString();
                        TxtEmail.Text         = ler["Email"].ToString();
                        MktCPF.Text           = ler["CPF"].ToString();
                        dataNasc.Text         = ler["DataNascimento"].ToString();
                        CboCadPor.Text        = ler["Usuario"].ToString();
                        DataCad.Text          = ler["DataCad"].ToString();
                        TxtCodCliente.Enabled = false;
                        BtnAlterar.Enabled    = true;
                        BtnDeletar.Enabled    = true;
                        CboCadPor.Enabled     = false;
                    }
                    else
                    {
                        LimpaDados();
                        TxtCodCliente.Enabled = false;
                        BtnAlterar.Enabled    = false;
                        BtnDeletar.Enabled    = false;
                        BtnCadastrar.Enabled  = true;
                        MessageBox.Show("Cadastro de Cliente não Encontrado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    conn.Close();
                }
            }
        }
 private void HabilitarCampos()
 {
     TxtNome.Enabled     = true;
     TxtCPF.Enabled      = true;
     TxtEndereco.Enabled = true;
     CbCargo.Enabled     = true;
     TxtTelefone.Enabled = true;
     TxtNome.Focus();
 }
Beispiel #16
0
 private void HabilitarCampos()
 {
     TxtNome.Enabled      = true;
     TxtDescricao.Enabled = true;
     TxtValor.Enabled     = true;
     CbFornecedor.Enabled = true;
     TxtEstoque.Enabled   = true;
     BtnImg.Enabled       = true;
     TxtNome.Focus();
 }
Beispiel #17
0
 private void BtnAlterar_Click(object sender, EventArgs e)
 {
     BtnIncluir.Enabled = true;
     BtnAlterar.Enabled = false;
     BtnExcluir.Enabled = false;
     HabilitaControles(true);
     TxtCodigo.Enabled = false;
     TxtNome.Focus();
     incluir = false;
 }
 private bool ValidaGravar()
 {
     try
     {
         if (string.IsNullOrEmpty(TxtNome.Text))
         {
             MessageBox.Show("Favor preencher o campo de Nome!", "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             TxtNome.Focus();
             return(false);
         }
         if (string.IsNullOrEmpty(txtCpf.Text))
         {
             MessageBox.Show("Favor preencher o campo de CPF!", "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtCpf.Focus();
             return(false);
         }
         if (ValidadorCpf.ValidaCpf(txtCpf.Text) == false)
         {
             MessageBox.Show("CPF Inválido : " + txtCpf.Text, "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtCpf.Focus();
             return(false);
         }
         if (string.IsNullOrEmpty(txtEmail.Text))
         {
             MessageBox.Show("Favor preencher o campo de E-mail!", "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtEmail.Focus();
             return(false);
         }
         if (CmbPerfil.SelectedIndex == -1)
         {
             MessageBox.Show("Favor selecionar um perfil!", "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             CmbPerfil.Focus();
             return(false);
         }
         if (txtSenha.Text != txtConfirma.Text)
         {
             MessageBox.Show("As senhas não são iguais!", "Campo faltando",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtSenha.Focus();
             return(false);
         }
         return(true);
     }
     catch (Exception e)
     {
         MessageBox.Show("Erro - ValidaGravar " + e.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
Beispiel #19
0
 private void BtnNovoL_Click(object sender, EventArgs e)
 {
     TxtNome.Enabled    = true;
     TxtAutor.Enabled   = true;
     TxtEditora.Enabled = true;
     ResetaForm();
     novoRegistro = true;
     MostraBotoes(true);
     livro = new Livro();
     TxtNome.Focus();
 }
 private void limparObjetos()
 {
     TxtCodigo.Clear();
     TxtNome.Clear();
     TxtRg.Clear();
     MtbCelular.Clear();
     MtbCpf.Clear();
     MtbDtNasc.Clear();
     MtbFone.Clear();
     CbCargo.Text = string.Empty;
     GC.Collect();
     TxtNome.Focus();
 }
Beispiel #21
0
 private void BtnNovo_Click(object sender, EventArgs e)
 {
     novo = true;
     BtnPrimeiro.Enabled  = false;
     BtnAnterior.Enabled  = false;
     BtnProximo.Enabled   = false;
     BtnUltimo.Enabled    = false;
     BtnGravar.Enabled    = true;
     TxtCodigo.Text       = (ultimoregistro + 1).ToString();
     TxtNome.Text         = "";
     TxtEndereco.Text     = "";
     MskTelefone.Text     = "";
     DtpDataCadastro.Text = "";
     TxtNome.Focus();
 }
Beispiel #22
0
 private void TxtCodigo_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (!char.IsDigit(e.KeyChar))
     {
         e.Handled = true;
     }
     if (e.KeyChar == (char)Keys.Back)
     {
         e.Handled = false;
     }
     if (e.KeyChar == 13)
     {
         TxtNome.Focus();
     }
 }
 private void BtnExcluir_Click(object sender, EventArgs e)
 {
     if (TxtNome.Text != string.Empty)
     {
         conexaoBanco.executaSql("DELETE FROM FUNCIONARIO WHERE CODIGO = " + TxtCodigo.Text);
         MessageBox.Show("Dados excluídos com sucesso!", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         atualizaDtGrid();
         limparObjetos();
     }
     else
     {
         MessageBox.Show("Escolha um registro antes de fazer uma exclusão.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNome.Focus();
     }
 }
Beispiel #24
0
        private void TxtIdUsuario_KeyUp_1(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (TxtIdUsuario.Text == "")
                {
                    TxtNome.Focus();
                    TxtIdUsuario.Enabled = false;
                    BtnDeletar.Enabled   = false;
                    BtnAlterar.Enabled   = false;
                    BtnCadastrar.Enabled = true;
                    MessageBox.Show("Nenhum Código Digitado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string     cadSql = "SELECT * from Usuario where Id_Usuario='" + TxtIdUsuario.Text + "'";
                    SqlCommand comand = new SqlCommand(cadSql, conn);
                    conn.Open();
                    SqlDataReader ler = comand.ExecuteReader();
                    if (ler.Read() == true)
                    {
                        TxtNome.Text         = ler["Nome"].ToString();
                        TxtEmail.Text        = ler["Email"].ToString();
                        TxtUsuario.Text      = ler["Usuario"].ToString();
                        TxtSenha.Text        = ler["Senha"].ToString();
                        CboTipoUsuario.Text  = ler["Tipo"].ToString();
                        CboCadPor.Text       = ler["Id_User"].ToString();
                        DataCad.Text         = ler["DataCad"].ToString();
                        TxtIdUsuario.Enabled = false;
                        BtnAlterar.Enabled   = true;
                        BtnDeletar.Enabled   = true;
                        BtnCadastrar.Enabled = false;
                        CboCadPor.Enabled    = false;
                    }
                    else
                    {
                        LimpaDados();
                        TxtIdUsuario.Enabled = false;
                        BtnAlterar.Enabled   = false;
                        BtnDeletar.Enabled   = false;
                        CboCadPor.Enabled    = true;
                        MessageBox.Show("Cadastro de Usuário não Encontrado!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    conn.Close();
                }
            }
        }
 private void BtnIncluir_Click(object sender, EventArgs e)
 {
     if (TxtNome.Text != string.Empty)
     {
         setCampos();
         conexaoBanco.executaSql("INSERT INTO FUNCIONARIO(" + campos() + ") VALUES(" + valoresInsert() + ")");
         MessageBox.Show("Dados inseridos com sucesso", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         atualizaDtGrid();
         limparObjetos();
     }
     else
     {
         MessageBox.Show("Campo nome não pode estar vazio.", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNome.Focus();
     }
 }
Beispiel #26
0
 private void BtnExcluir_Click(object sender, EventArgs e)
 {
     if (TxtCodigo.Text != "")
     {
         conexaoBanco.executaSql("DELETE FROM FUNCAO WHERE Codigo = " + TxtCodigo.Text + "");
         MessageBox.Show("Exclusão feita com sucesso!", "Informção", MessageBoxButtons.OK, MessageBoxIcon.Information);
         geralVerificacoes.redimensionaDtGrid(DtGridFuncao);
         atualizarGrid();
         limparObjetos();
         TxtNome.Focus();
     }
     else
     {
         MessageBox.Show("Pesquise uma função antes de fazer uma exclusão.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNome.Focus();
     }
 }
Beispiel #27
0
 private void BtnAlterar_Click(object sender, EventArgs e)
 {
     if (TxtCodigo.Text != "")
     {
         conexaoBanco.executaSql("UPDATE FUNCAO SET NOME = '" + TxtNome.Text + "', " +
                                 "CBO = " + TxtCbo.Text + ", " + "SALARIO = " + TxtSalario.Text +
                                 " WHERE CODIGO = " + TxtCodigo.Text);
         MessageBox.Show("Alteração feita com sucesso!", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         atualizarGrid();
         limparObjetos();
         TxtNome.Focus();
     }
     else
     {
         MessageBox.Show("Pesquise uma função antes de fazer uma alteração.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNome.Focus();
     }
 }
        private void Inicializar()
        {
            try
            {
                if (AlunoVm == null)
                {
                    AlunoVm = new AlunoVm();
                }

                TxtNome.Focus();

                DataContext = AlunoVm;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Falha para inicializar a tela de cadastro. {ex.Message}", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #29
0
 private void BtnAlterar_Click(object sender, EventArgs e)
 {
     if (TxtIdUsuario.Text == "")
     {
         MessageBox.Show("Digite ID Válido!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TxtIdUsuario.Clear();
         TxtIdUsuario.Focus();
     }
     else if (TxtSenha.Text != TxtRepeteSenha.Text)
     {
         MessageBox.Show("Senhas Não Conferem! Digite Novamente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TxtSenha.Text       = "";
         TxtRepeteSenha.Text = "";
         TxtSenha.Focus();
     }
     else
     {
         try
         {
             conn.Open();
             SqlCommand comando = new SqlCommand(@"UPDATE Usuario SET Nome='" + TxtNome.Text + "',Email='" + TxtEmail.Text + "',Usuario='" + TxtUsuario.Text + "',Senha='" + TxtSenha.Text + "',Tipo='" + CboTipoUsuario.Text + "' where (Id_Usuario='" + TxtIdUsuario.Text + "')", conn)
             {
                 CommandType = System.Data.CommandType.Text
             };
             comando.ExecuteNonQuery();
             LimpaDados();
             TxtIdUsuario.Clear();
             MessageBox.Show("Usuário Atualizado Com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             MessageBox.Show("Erro ao Atualizar Usuário!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     conn.Close();
     LimpaDados();
     TxtIdUsuario.Enabled = false;
     BtnCadastrar.Enabled = true;
     BtnAlterar.Enabled   = false;
     BtnDeletar.Enabled   = false;
     TxtNome.Focus();
 }
Beispiel #30
0
 private void BtnIncluir_Click(object sender, EventArgs e)
 {
     if (TxtNome.Text != string.Empty)
     {
         setCampos();
         conexaoBanco.executaSql("INSERT INTO FUNCAO(" + camposInsert() + ") VALUES(" + valoresInsert() + ")");
         MessageBox.Show("Dados inseridos com sucesso!", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         atualizarGrid();
         DtGridFuncao.Refresh();
         limparObjetos();
         TxtNome.Focus();
     }
     else
     {
         MessageBox.Show("O campo Nome está em branco.\n " +
                         "Por favor informe um nome antes de inserir um novo registro.",
                         "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNome.Focus();
     }
 }