Guest User

Untitled

a guest
Sep 15th, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1.  private void btnGrava_Click(object sender, EventArgs e)
  2.         {
  3.             string valordtcj = string.Empty;
  4.            
  5.             if (txtNome.Text == string.Empty &&
  6.                 mtbDataNascto.Text == string.Empty)
  7.             {
  8.                 MessageBox.Show("Campos Nome e Data Nascto ObrigatΓ³rios", "Mensagem");
  9.                 return;
  10.             }
  11.  
  12.            
  13.            
  14.             if (String.IsNullOrEmpty(valordtcj))
  15.                 valordtcj = "NULL,";
  16.  
  17.             else
  18.                 valordtcj = "str_to_date(\'" + mtbDataNasctoEsposa.Text + "\', '%d/%m/%Y'), ";
  19.  
  20.             string sqlUpdate = "update tbcadastro set " +
  21.                     "cliente ='" + txtNome.Text.Trim() + "'," +
  22.             "nascto = str_to_date(\'" + mtbDataNascto.Text + "\', '%d/%m/%Y'), " +
  23.                     "conjugue = '" + txtNomeEsposa.Text + "'," +
  24.                     "nasctoconjugue = '" + valordtcj + "'," +
  25.                     "fone = \'" + txtFone.Text + "\' " +
  26.                     " where codigocliente = \'" + dtgCadastro.CurrentRow.Cells[0].Value.ToString() + "\'";
  27.  
  28.  
  29.  
  30.             MySqlCommand cmdAlterar = new MySqlCommand(sqlUpdate, dbConexao);
  31.             cmdAlterar.ExecuteNonQuery();
  32.             MessageBox.Show("Registro Alterado com Sucesso!!!", "Mensagem");
  33.             limpar();
  34.  
  35.             atualizaGrid();
  36.  
  37.             btnExcluir.Enabled = false;
  38.             btnAlterar.Enabled = false;
  39.             btnNovo.Enabled = true;
  40.             btnCancelar.Enabled = false;
  41.             btnGrava.Enabled = false;
  42.             travaJanelas();
  43.             txtNome.Focus();
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment