コード例 #1
0
 //BOTÃO INSERIR ---------------------------------------------------------------------------------------------------------------------------------------------
 private void btnConcluir_Click(object sender, EventArgs e)
 {
     if (btnConcluir.Text == "Atualizar")
     {
         cDAO.AtualizarCliente(codigo, txtNome.Text, Convert.ToInt64(txtTelefone.Text));
         eDAO.AtualizarEndereco(txtRua.Text, Convert.ToInt32(NudNumero.Value), Convert.ToInt64(txtCEP.Text), cbmUF.Text, txtCidade.Text, codigo);
         atualizaGridCLi();
         txtNome.Focus();
         btnConcluir.Text = "Inserir";
         limpaTextBox(this);
     }
     if (btnConcluir.Text == "Inserir")
     {
         limpaTextBox(this);
         txtNome.Focus();
         btnConcluir.Text = "Concluir";
     }
     else
     {
         if (btnConcluir.Text == "Concluir")
         {
             if (txtNome.Text == string.Empty ||
                 txtTelefone.Text == string.Empty ||
                 txtCEP.Text == string.Empty ||
                 txtRua.Text == string.Empty ||
                 cbmUF.Text == string.Empty ||
                 txtCidade.Text == string.Empty ||
                 NudNumero.Value == 0)
             {
                 MessageBox.Show("Preencha todos os campos");
                 return;
             }
             //METODOS DE INSERÇÃO
             eDAO.cadastrarEndereco(Convert.ToInt64(txtCEP.Text), txtRua.Text, Convert.ToInt32(NudNumero.Value), cbmUF.Text, txtCidade.Text);
             cDAO.cadastrarCliente(txtNome.Text, Convert.ToInt64(txtTelefone.Text));
             cDAO.EncadeandoChaves();
             //----------------------------------------------------------------------------------------------------------------------------
             btnConcluir.Text = "Inserir";
             edit             = false;
             limpaTextBox(this);
             atualizaGridCLi();
             MessageBox.Show("Operação realizada com sucesso!");
         }
     }
 }