コード例 #1
0
        private void btnCadastroFunc_Click(object sender, EventArgs e)
        {
            try
            {
                CADASTRO_DTO obj = new CADASTRO_DTO();
                obj.nome     = txtNomeFun.Text;
                obj.CPF      = mTxtCPF.Text;
                obj.RG       = txtRgFunc.Text;
                obj.banco    = cbbBancoFunc.Text;
                obj.agencia  = txtAgenciaFunc.Text;
                obj.conta    = txtContaFunc.Text;
                obj.endereco = txtEndereco.Text;
                obj.cidade   = txtCidade.Text;
                obj.bairro   = txtBairro.Text;
                obj.estado   = CbEstado.Text;
                obj.numero   = txtNumero.Text;
                obj.telefone = mTxtTelefone.Text;
                string retorno;//a string de retorno servirá para trazer o retorno que irá vir da classe bll ou dal
                retorno = CADASTRO_BLL.Val_Cad_Func(obj);

                if (retorno == "Sucesso!")
                {
                    MessageBox.Show(retorno, "Funcionário cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    txtNomeFun.Clear();
                    txtRgFunc.Clear();
                    cbbBancoFunc.Text = "";
                    txtAgenciaFunc.Clear();
                    txtContaFunc.Clear();
                    txtEndereco.Clear();
                    txtCidade.Clear();
                    txtBairro.Clear();
                    CbEstado.Text = "";
                    txtNumero.Clear();
                    mTxtTelefone.Clear();
                    mTxtCPF.Clear();
                }
                else
                {
                    MessageBox.Show(retorno, "Funcionário não foi cadastrado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            /*catch (Exception ex)//MOSTRA A EXCEÇÃO NO BANCO, PORÉM COM SOFTWARE PRONTO NÃO É BOM MOSTRAR PARA O USUÁRIO!!
             * {
             *
             *  MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }*/
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
 private void btnAlterarFunc_Click(object sender, EventArgs e)
 {
     try
     {
         CADASTRO_DTO obj = new CADASTRO_DTO();
         obj.nome     = txtNomeFun.Text;
         obj.CPF      = mTxtCPF.Text;
         obj.RG       = txtRgFunc.Text;
         obj.banco    = cbbBancoFunc.Text;
         obj.agencia  = txtAgenciaFunc.Text;
         obj.conta    = txtContaFunc.Text;
         obj.endereco = txtEndereco.Text;
         obj.cidade   = txtCidade.Text;
         obj.bairro   = txtBairro.Text;
         obj.estado   = CbEstado.Text;
         obj.numero   = txtNumero.Text;
         obj.telefone = mTxtTelefone.Text;
         string retorno;//a string de retorno servirá para trazer o retorno que irá vir da classe bll ou dal
         retorno = CADASTRO_BLL.Alterar(obj);
         if (retorno == "Sucesso!")
         {
             MessageBox.Show(retorno, "Cadastro Alterado", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             txtNomeFun.Clear();
             txtRgFunc.Clear();
             cbbBancoFunc.Text = "";
             txtAgenciaFunc.Clear();
             txtContaFunc.Clear();
             txtEndereco.Clear();
             txtCidade.Clear();
             txtBairro.Clear();
             CbEstado.Text = "";
             txtNumero.Clear();
             mTxtTelefone.Clear();
             mTxtCPF.Clear();
         }
         else
         {
             MessageBox.Show(retorno, "Cadastro não foi alterado", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }