Beispiel #1
0
 private void btnAlterFunc_Click(object sender, EventArgs e)
 {
     try
     {
         Cad_Func_DTO obj = new Cad_Func_DTO();
         obj.Nome     = txtNome.Text.ToUpper();
         obj.Endereco = txtEndereco.Text.ToUpper();
         obj.Numero   = txtNumero.Text.ToUpper();
         obj.Cpf      = txtCpf.Text;
         obj.Rg       = txtRg.Text;
         obj.Cidade   = txtCidade.Text.ToUpper();
         obj.Bairro   = txtBairro.Text.ToUpper();
         obj.Conta    = txtConta.Text.ToUpper();
         obj.Agencia  = txtAgencia.Text.ToUpper();
         obj.Banco    = txtBanco.Text.ToUpper();
         obj.Telefone = txtTel.Text;
         string nome = txtNomeBuscFunc.Text.ToUpper();
         string msg  = Cad_Func_BLL.AlterFunc(obj, nome);
         MessageBox.Show(msg, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         limparFunc();
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 public static string alterFunc(Cad_Func_DTO obj, string nome)
 {
     try
     {
         string     sql = "update tb_funcionario set nome = @nome, endereco = @endereco,rg = @rg,cpf= @cpf, cidade = @cidade,numero= @numero,telefone = @telefone ,bairro = @bairro,conta = @conta,agencia = @agencia ,banco = @banco where nome = @nome1";
         SqlCommand cmd = new SqlCommand(sql, Conexao.Login());
         cmd.Parameters.AddWithValue("@nome", obj.Nome);
         cmd.Parameters.AddWithValue("@endereco", obj.Endereco);
         cmd.Parameters.AddWithValue("@rg", obj.Rg);
         cmd.Parameters.AddWithValue("@cpf", obj.Cpf);
         cmd.Parameters.AddWithValue("@cidade", obj.Cidade);
         cmd.Parameters.AddWithValue("@numero", obj.Numero);
         cmd.Parameters.AddWithValue("@bairro", obj.Bairro);
         cmd.Parameters.AddWithValue("@telefone", obj.Telefone);
         cmd.Parameters.AddWithValue("@agencia", obj.Agencia);
         cmd.Parameters.AddWithValue("@banco", obj.Banco);
         cmd.Parameters.AddWithValue("@conta", obj.Conta);
         cmd.Parameters.AddWithValue("@nome1", nome);
         cmd.ExecuteNonQuery();
         return("Dados do funcionario alterados com sucesso");
     }
     catch
     {
         throw new Exception("Erro ao alterar dados do funcionario");
     }
     finally
     {
         if (Conexao.Login().State != ConnectionState.Closed)
         {
             Conexao.Login().Close();
         }
     }
 }
Beispiel #3
0
 public static void buscFunc(Cad_Func_DTO obj, string nome)
 {
     try
     {
         string     sql = "SELECT * FROM tb_funcionario where nome = @nome";
         SqlCommand cmd = new SqlCommand(sql, Conexao.Login());
         cmd.Parameters.AddWithValue("@nome", nome);
         SqlDataReader data = cmd.ExecuteReader();
         while (data.Read())
         {
             if (data.HasRows)
             {
                 obj.Nome     = data["nome"].ToString();
                 obj.Endereco = data["endereco"].ToString();
                 obj.Rg       = data["rg"].ToString();
                 obj.Cpf      = data["cpf"].ToString();
                 obj.Numero   = data["numero"].ToString();
                 obj.Telefone = data["telefone"].ToString();
                 obj.Cidade   = data["cidade"].ToString();
                 obj.Bairro   = data["bairro"].ToString();
                 obj.Banco    = data["banco"].ToString();
                 obj.Agencia  = data["agencia"].ToString();
                 obj.Conta    = data["conta"].ToString();
             }
         }
     }
     catch
     {
         throw new Exception("Erro ao buscar nome!! nome nao encontrado");
     }
 }
Beispiel #4
0
 public static string CadastrarFunc(Cad_Func_DTO obj)
 {
     try
     {
         string     sql = "INSERT INTO tb_funcionario(nome,endereco,rg,cpf,cidade,numero,telefone,bairro,conta,agencia,banco) values(@nome,@endereco,@rg,@cpf,@cidade,@numero,@telefone,@bairro,@conta,@agencia,@banco)";
         SqlCommand cmd = new SqlCommand(sql, Conexao.Login());
         cmd.Parameters.AddWithValue("@nome", obj.Nome);
         cmd.Parameters.AddWithValue("@endereco", obj.Endereco);
         cmd.Parameters.AddWithValue("@rg", obj.Rg);
         cmd.Parameters.AddWithValue("@cpf", obj.Cpf);
         cmd.Parameters.AddWithValue("@cidade", obj.Cidade);
         cmd.Parameters.AddWithValue("@bairro", obj.Bairro);
         cmd.Parameters.AddWithValue("@numero", obj.Numero);
         cmd.Parameters.AddWithValue("@telefone", obj.Telefone);
         cmd.Parameters.AddWithValue("@agencia", obj.Agencia);
         cmd.Parameters.AddWithValue("@banco", obj.Banco);
         cmd.Parameters.AddWithValue("@conta", obj.Conta);
         cmd.ExecuteNonQuery();
         return("Cadastro efetuado com sucesso");
     }
     catch
     {
         throw new Exception("Houve um erro ao cadastrar o cliente no banco");
     }
     finally
     {
         if (Conexao.Login().State != ConnectionState.Closed)
         {
             Conexao.Login().Close();
         }
     }
 }
Beispiel #5
0
 public static void bucFunc(Cad_Func_DTO obj, string nome)
 {
     if (string.IsNullOrWhiteSpace(nome))
     {
         throw new Exception("Digite o nome do funcionario que deseja buscar");
     }
     Cad_Func_DAL.buscFunc(obj, nome);
 }
Beispiel #6
0
        public static string ValidarCad(Cad_Func_DTO obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Nome))
            {
                throw new Exception("Campo nome vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Endereco))
            {
                throw new Exception("Campo endereço vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Cpf))
            {
                throw new Exception("Campo CPF vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Rg))
            {
                throw new Exception("Campo RG vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Bairro))
            {
                throw new Exception("Campo bairro vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Cidade))
            {
                throw new Exception("Campo cidade vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Numero))
            {
                throw new Exception("Campo número vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Telefone))
            {
                throw new Exception("Campo telefone vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Agencia))
            {
                throw new Exception("Campo agência vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Banco))
            {
                throw new Exception("Campo banco vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Conta))
            {
                throw new Exception("Campo conta vazio!!!");
            }

            bool result = Cad_Func_DAL.VerifFunc(obj.Cpf);

            if (result == true)
            {
                throw new Exception("CPF ja cadastrado");
            }
            string msg = Cad_Func_DAL.CadastrarFunc(obj);

            return(msg);
        }
Beispiel #7
0
        public static string AlterFunc(Cad_Func_DTO obj, string nome)
        {
            if (string.IsNullOrWhiteSpace(obj.Nome))
            {
                throw new Exception("Campo nome vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Endereco))
            {
                throw new Exception("Campo endereço vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Cpf))
            {
                throw new Exception("Campo CPF vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Rg))
            {
                throw new Exception("Campo RG vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Bairro))
            {
                throw new Exception("Campo bairro vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Cidade))
            {
                throw new Exception("Campo cidade vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Numero))
            {
                throw new Exception("Campo número vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Telefone))
            {
                throw new Exception("Campo telefone vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Agencia))
            {
                throw new Exception("Campo agência vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Banco))
            {
                throw new Exception("Campo banco vazio!!!");
            }
            if (string.IsNullOrWhiteSpace(obj.Conta))
            {
                throw new Exception("Campo conta vazio!!!");
            }
            string msg = Cad_Func_DAL.alterFunc(obj, nome);

            return(msg);
        }
Beispiel #8
0
 private void panel5_MouseClick(object sender, MouseEventArgs e)
 {
     try
     {
         Cad_Func_DTO obj = new Cad_Func_DTO();
         string       msg = txtNomeBuscFunc.Text.ToUpper();
         Cad_Func_BLL.bucFunc(obj, msg);
         txtNome.Text     = obj.Nome;
         txtEndereco.Text = obj.Endereco;
         txtNumero.Text   = obj.Numero;
         txtCpf.Text      = obj.Cpf;
         txtRg.Text       = obj.Rg;
         txtCidade.Text   = obj.Cidade;
         txtBairro.Text   = obj.Bairro;
         txtConta.Text    = obj.Conta;
         txtAgencia.Text  = obj.Agencia;
         txtBanco.Text    = obj.Banco;
         txtTel.Text      = obj.Telefone;
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }