protected void GDV_Etat_Avancement_PageIndexChanging(object sender, GridViewPageEventArgs e) { clear_meassage(); GDV_Etat_Avancement.PageIndex = e.NewPageIndex; GDV_Etat_Avancement.DataBind(); Load_Etats(); }
public void Load_Etats() { try { MySqlConnection conn = new MySqlConnection(Authentification.MyString); conn.Open(); string req = "SELECT DISTINCT attribution_cours.id_cours, cours.cours, cours.credits,cours.code_cours, attribution_cours.etat" + " FROM (unite INNER JOIN cours ON unite.id_unite = cours.id_unite) INNER JOIN attribution_cours ON cours.id_cours = attribution_cours.id_cours" + " WHERE unite.id_classe=@idcl AND unite.id_departement=@id_departement AND unite.id_faculte=@id_faculte AND unite.id_annee=@id_annee"; MySqlCommand cmc = new MySqlCommand(req, conn); cmc.Parameters.AddWithValue("@idcl", id_classe); cmc.Parameters.AddWithValue("@id_departement", id_departement); cmc.Parameters.AddWithValue("@id_faculte", id_faculte); cmc.Parameters.AddWithValue("@id_annee", id_annee); MySqlDataAdapter da = new MySqlDataAdapter(cmc); DataTable dtable = new DataTable(); da.Fill(dtable); GDV_Etat_Avancement.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Etat_Avancement.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Etat_Avancement.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Etat_Avancement.Columns[4].ItemStyle.HorizontalAlign = HorizontalAlign.Center; if (dtable.Rows.Count > 0) { GDV_Etat_Avancement.DataSource = dtable; GDV_Etat_Avancement.DataBind(); } else { dtable.Rows.Add(dtable.NewRow()); GDV_Etat_Avancement.DataSource = dtable; GDV_Etat_Avancement.DataBind(); GDV_Etat_Avancement.Rows[0].Cells.Clear(); GDV_Etat_Avancement.Rows[0].Cells.Add(new TableCell()); GDV_Etat_Avancement.Rows[0].Cells[0].ColumnSpan = dtable.Columns.Count; GDV_Etat_Avancement.Rows[0].Cells[0].Text = "Aucune année académique n’a été créée à cette date"; GDV_Etat_Avancement.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } conn.Close(); } catch (Exception ex) { } }
private void Classes_par_Departement(int id_annee, int id_faculte, int id_departement, int operation) { id_annee_combo = id_annee; id_faculte_combo = id_faculte; id_departement_combo = id_departement; int id_operation = operation; MySqlConnection conn = new MySqlConnection(Authentification.MyString); conn.Open(); string req = "SELECT classe_par_departement.id_classe, classe.classe,classe_par_departement.etat_avancement " + " FROM classe_par_departement INNER JOIN classe ON classe_par_departement.id_classe = classe.id_classe" + " WHERE classe_par_departement.id_annee=@id_annee AND classe_par_departement.id_faculte=@id_faculte AND classe_par_departement.id_departement=@id_departement"; MySqlCommand cmd = new MySqlCommand(req, conn); cmd.Parameters.AddWithValue("@id_annee", id_annee); cmd.Parameters.AddWithValue("@id_faculte", id_faculte); cmd.Parameters.AddWithValue("@id_departement", id_departement); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dtable = new DataTable(); da.Fill(dtable); switch (id_operation) { case 1: GDV_Gestion.Columns[0].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Gestion.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Gestion.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center; if (dtable.Rows.Count > 0) { GDV_Gestion.DataSource = dtable; GDV_Gestion.DataBind(); } else { dtable.Rows.Add(dtable.NewRow()); GDV_Gestion.DataSource = dtable; GDV_Gestion.DataBind(); GDV_Gestion.Rows[0].Cells.Clear(); GDV_Gestion.Rows[0].Cells.Add(new TableCell()); GDV_Gestion.Rows[0].Cells[0].ColumnSpan = dtable.Columns.Count; GDV_Gestion.Rows[0].Cells[0].Text = "Aucune classe dans ce départemnt"; GDV_Gestion.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } break; case 2: GDV_Etat_Avancement.Columns[0].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Etat_Avancement.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center; GDV_Etat_Avancement.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center; if (dtable.Rows.Count > 0) { GDV_Etat_Avancement.DataSource = dtable; GDV_Etat_Avancement.DataBind(); } else { dtable.Rows.Add(dtable.NewRow()); GDV_Etat_Avancement.DataSource = dtable; GDV_Etat_Avancement.DataBind(); GDV_Etat_Avancement.Rows[0].Cells.Clear(); GDV_Etat_Avancement.Rows[0].Cells.Add(new TableCell()); GDV_Etat_Avancement.Rows[0].Cells[0].ColumnSpan = dtable.Columns.Count; GDV_Etat_Avancement.Rows[0].Cells[0].Text = "Aucune classe dans ce départemnt"; GDV_Etat_Avancement.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } break; } conn.Close(); }