Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnGrava_Click(object sender, EventArgs e)
- {
- string valordtcj = string.Empty;
- if (txtNome.Text == string.Empty &&
- mtbDataNascto.Text == string.Empty)
- {
- MessageBox.Show("Campos Nome e Data Nascto ObrigatΓ³rios", "Mensagem");
- return;
- }
- if (String.IsNullOrEmpty(valordtcj))
- valordtcj = "NULL,";
- else
- valordtcj = "str_to_date(\'" + mtbDataNasctoEsposa.Text + "\', '%d/%m/%Y'), ";
- string sqlUpdate = "update tbcadastro set " +
- "cliente ='" + txtNome.Text.Trim() + "'," +
- "nascto = str_to_date(\'" + mtbDataNascto.Text + "\', '%d/%m/%Y'), " +
- "conjugue = '" + txtNomeEsposa.Text + "'," +
- "nasctoconjugue = '" + valordtcj + "'," +
- "fone = \'" + txtFone.Text + "\' " +
- " where codigocliente = \'" + dtgCadastro.CurrentRow.Cells[0].Value.ToString() + "\'";
- MySqlCommand cmdAlterar = new MySqlCommand(sqlUpdate, dbConexao);
- cmdAlterar.ExecuteNonQuery();
- MessageBox.Show("Registro Alterado com Sucesso!!!", "Mensagem");
- limpar();
- atualizaGrid();
- btnExcluir.Enabled = false;
- btnAlterar.Enabled = false;
- btnNovo.Enabled = true;
- btnCancelar.Enabled = false;
- btnGrava.Enabled = false;
- travaJanelas();
- txtNome.Focus();
- }
Advertisement
Add Comment
Please, Sign In to add comment