Israel

Israel

  • 700
  • 1.3k
  • 217.6k

MessageBoxConfirmation: "Yes" or "No"

Apr 21 2016 6:47 AM
Hi!
 
I wrote these codes but I need to know where to put or insert some code that will help me to have a messBox saying confirmation: "Are you sure to save: Yes or Not" .
 
conn.Open();
OleDbCommand comm = new OleDbCommand();
comm.Connection = conn;
connstr = "SELECT COUNT(*) FROM cadastdoc WHERE [noficio] = @noficio";
comm.CommandText = connstr;
comm.Parameters.Clear();
comm.Parameters.AddWithValue("@noficio", txtNOficioCadastDoc.Text);
int numRecords = (int)comm.ExecuteScalar();
if (numRecords == 0)
{
connstr = "INSERT INTO cadastdoc([nregisto],[procedencia],[assunto],[noficio],[data],[hora],[area_destino],[anexo])VALUES(@nregisto,@procedencia,@assunto,@noficio,@data,@hora,@area_destino,@anexo)";
comm.CommandText = connstr;
comm.Parameters.Clear();
comm.Parameters.AddWithValue("@nregisto", lblNregisto.Text);
comm.Parameters.AddWithValue("@procedencia", txtProcedenciaCadastDoc.Text);
comm.Parameters.AddWithValue("@assunto", txtAssuntoCadastDoc.Text);
comm.Parameters.AddWithValue("@noficio", txtNOficioCadastDoc.Text);
comm.Parameters.AddWithValue("@data", dtCadastDoc.Text);
comm.Parameters.AddWithValue("@hora", txtHoraCadastDoc.Text);
comm.Parameters.AddWithValue("@area_destino", cbxAreaDestinoCadastDoc.Text);
comm.Parameters.AddWithValue("@anexo", "1");
comm.ExecuteNonQuery();
MessageBox.Show("Saved ..");
///////////////////////////////////////refresh datagrid
//conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select [nregisto],[procedencia],[assunto],[noficio],[data],[hora],[area_destino] from cadastdoc";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
//conn.Close();
dvgCadastramentoDoc.DataSource = dt;
dvgCadastramentoDoc.CurrentCell = dvgCadastramentoDoc.Rows[dvgCadastramentoDoc.Rows.Count - 2].Cells[0];
}
else
{
MessageBox.Show("Already exist", txtNOficioCadastDoc.Text);
}
conn.Close();

Answers (1)