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
| private void button2_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlCommand sql = new SqlCommand("insert into journal values('" + textBox1.Text + "','" + textBox2.Text + "','" + comboBox2.SelectedItem.ToString() + "','" + comboBox1.SelectedItem.ToString() + "','" + checkBox1.Checked.ToString()+"','"+checkBox2.Checked.ToString()+"');", connection);
int o = sql.ExecuteNonQuery();
MessageBox.Show(o + " Le Fichier journal a ?t? ajout? avec succ?s");
connection.Close();
textBox1.Text = "";
textBox2.Text = "";
if(textBox1.Text ==" ")
{
MessageBox.Show("La saisie du code Journal est obligatoire!!");
}
affich();
}
private void affich()
{
try
{
pat = connectionString;
req = "SELECT * FROM journal";
con = new SqlConnection(pat);
con.Open();
dr = new SqlDataAdapter(req, con);
dr.Fill(ds, "journal");
Form4 Form4 = new Form4();//ceci va creer une nouvelle instance je ne veux pas avoir une nouvelleFen?te
Form4.journalDataGridView.DataSource = ds.Tables["journal"];
Form4.Show();
}
catch (Exception e) { MessageBox.Show("Base de donn?es non trouv?e", e.Message); }
} |
Partager