1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| private void ajt_btn_Click(object sender, EventArgs e)
{
int i;
commande.UpdateCommand = new SqlCommand("Update users SET PRENOM = @PRENOM , NOM = @NOM , num = @num WHERE ID = @ID", conn);
commande.UpdateCommand.Parameters.Add("@PRENOM", SqlDbType.VarChar).Value = textBox1.Text;
commande.UpdateCommand.Parameters.Add("@NOM", SqlDbType.VarChar).Value = textBox2.Text;
commande.UpdateCommand.Parameters.Add("@num", SqlDbType.VarChar).Value = textBox3.Text;
commande.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int).Value = ds.Tables[0].Rows[BS.Position][0];
conn.Open();
i = commande.UpdateCommand.ExecuteNonQuery();
conn.Close();
if (i >= 1)
MessageBox.Show(" Votre enregistrement(s) a été bien Mis à Jour");
}
private void pictureBox2_Click(object sender, EventArgs e)
{
this.Close();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
commande.SelectCommand = new SqlCommand("select * from users", conn);
ds.Clear();
commande.Fill(ds);
dataGrid.DataSource = ds.Tables[0];
BS.DataSource = ds.Tables[0];
textBox1.DataBindings.Add(new Binding("text", BS, "PRENOM"));
textBox2.DataBindings.Add(new Binding("text", BS, "NOM"));
textBox3.DataBindings.Add(new Binding("text", BS, "num"));
enregistrement();
} |
Partager