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
|
public void AjoutDansTableNote(TextBox matiere , DropDownList dep, DropDownList section, SqlConnection connect)
{
////////////
connect.Open();
string data = "SELECT id_matiere FROM[Matiere] WHERE nom_matiere='"+matiere.Text+"'";
SqlCommand command1 = new SqlCommand(data, connect);
SqlDataReader read1 = command1.ExecuteReader();
read1.Read();
int id_matiere = (int) read1["id_matiere"];
connect.Close();
//////////
SqlCommand cmd = connect.CreateCommand();
cmd.CommandText = "SELECT * FROM[Etudiant] WHERE id_dep='" + dep.SelectedValue + "' AND id_section='" + section.SelectedValue + "'";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
//connect.Dispose();
connect.Close();
////////////////
connect.Open();
foreach (DataRow read in ds.Tables[0].Rows)
{
string requete = "INSERT INTO[Note](id_etd,id_matiere,id_section,id_dep)";
requete += "VALUES('" + read["id_etd"] + "','" + id_matiere + "','" + read["id_section"] + "','" + read["id_dep"] + "')";
SqlCommand Mycommand = new SqlCommand(requete, connect);
Mycommand.ExecuteNonQuery();
}
connect.Close();
} |