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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
private void parcourControl(Control c,int IdPere)
{
//AJOUT DANS LA BASE
if (c.GetType().ToString() != "System.Windows.Forms.VScrollBar" && c.GetType().ToString() != "System.Windows.Forms.HScrollBar")
{
string sql = "AjoutObjet '" + c.Name + "','" + c.GetType().ToString() + "','" + IdPere.ToString() + "' ";
SqlConnection ConsultConnection = new SqlConnection(oSurveillant.strConnexionSecurite);
SqlCommand Command = new SqlCommand(sql, ConsultConnection);
Command.Connection.Open();
int IdFils = (int)Command.ExecuteScalar();
Command.Connection.Close();
if (c.Controls.Count != 0)
{
foreach (Control c1 in c.Controls)
{
parcourControl(c1,IdFils);
}
}
}
}
private void Bt_Upload_Click(object sender, EventArgs e)
{
string sql = "ViderObjets ";
SqlConnection ConsultConnection = new SqlConnection(oSurveillant.strConnexionSecurite);
SqlCommand Command = new SqlCommand(sql, ConsultConnection);
Command.Connection.Open();
Command.ExecuteNonQuery();
Command.Connection.Close();
//On met le père de l'apply à l'id 0
string sql2 = "AjoutObjet 'Consultation' ,'Application','0' ";
SqlConnection ConsultConnection2 = new SqlConnection(oSurveillant.strConnexionSecurite);
SqlCommand Command2 = new SqlCommand(sql2, ConsultConnection2);
Command2.Connection.Open();
Id_Application = (int)Command2.ExecuteScalar();
Command2.Connection.Close();
Assembly asm = Assembly.GetExecutingAssembly();
// Parcours de tous les types de l'assembly
foreach (Type t in asm.GetTypes())
{
// Il s'agit d'une form
if (t.BaseType == typeof(Form))
{
string sql3 = "AjoutObjet '" + t.Name.ToString() + "','" + t.BaseType.ToString() + "','" + Id_Application.ToString() + "'";
SqlConnection ConsultConnection3 = new SqlConnection(oSurveillant.strConnexionSecurite);
SqlCommand Command3 = new SqlCommand(sql3, ConsultConnection3);
Command3.Connection.Open();
IdFormEnCours = (int)Command3.ExecuteScalar();
Command3.Connection.Close();
if(t.Name.ToString() == "F_ConsultRef")
{
Form f = (Form)Activator.CreateInstance(t, oSurveillant, false);
foreach (Control c in f.Controls)
{
parcourControl(c, IdFormEnCours);
}
}
else{
Form f = (Form)Activator.CreateInstance(t, oSurveillant);
foreach (Control c in f.Controls)
{
parcourControl(c, IdFormEnCours);
}
}
}
}
} |
Partager