Пример #1
0
        private void Liste_Departemts_Crees_In_GridView()
        {
            MySqlConnection conn = new MySqlConnection(Authentification.MyString);

            conn.Open();

            string           req    = "SELECT DISTINCT id_departement, departement FROM departement";
            MySqlDataAdapter da     = new MySqlDataAdapter(req, conn);
            DataTable        dtable = new DataTable();

            da.Fill(dtable);
            GDV_Creation.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            //GDV_Creation.RowStyle.HorizontalAlign = HorizontalAlign.Center;
            if (dtable.Rows.Count > 0)
            {
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();
            }
            else
            {
                dtable.Rows.Add(dtable.NewRow());
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();

                GDV_Creation.Rows[0].Cells.Clear();
                GDV_Creation.Rows[0].Cells.Add(new TableCell());
                GDV_Creation.Rows[0].Cells[0].ColumnSpan      = dtable.Columns.Count;
                GDV_Creation.Rows[0].Cells[0].Text            = "Aucun departemnt n’a été créée à cette date";
                GDV_Creation.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }
            conn.Close();
        }
        private void Facultes_Crees_In_GridView()
        {
            MySqlConnection conn = new MySqlConnection(Authentification.MyString);

            conn.Open();

            string req = "SELECT faculte.id_faculte, faculte.faculte, faculte.type sigle, faculte_type.type" +
                         " FROM faculte INNER JOIN faculte_type ON faculte.id_type = faculte_type.id_type";
            MySqlDataAdapter da     = new MySqlDataAdapter(req, conn);
            DataTable        dtable = new DataTable();

            da.Fill(dtable);
            GDV_Creation.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            GDV_Creation.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            GDV_Creation.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            //GDV_Creation.RowStyle.HorizontalAlign = HorizontalAlign.Center;
            if (dtable.Rows.Count > 0)
            {
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();
            }
            else
            {
                dtable.Rows.Add(dtable.NewRow());
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();

                GDV_Creation.Rows[0].Cells.Clear();
                GDV_Creation.Rows[0].Cells.Add(new TableCell());
                GDV_Creation.Rows[0].Cells[0].ColumnSpan      = dtable.Columns.Count;
                GDV_Creation.Rows[0].Cells[0].Text            = "Aucune faculté n’a été créée à cette date";
                GDV_Creation.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }
            conn.Close();
        }
        private void Unite_Par_Semestre(int id_annee, int id_faculte, int id_departement, int id_classe, int id_semestre)
        {
            try
            {
                conn = new MySqlConnection(Authentification.MyString);
                conn.Open();
                string sql = "SELECT id_unite, unite,code_unite FROM unite" +
                             " WHERE id_annee=@id_annee AND id_faculte=@id_faculte AND id_departement=@id_departement AND id_classe=@id_classe AND id_semestre=@id_semestre" +
                             " ORDER BY unite";
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@id_semestre", id_semestre);
                cmd.Parameters.AddWithValue("@id_classe", id_classe);
                cmd.Parameters.AddWithValue("@id_departement", id_departement);
                cmd.Parameters.AddWithValue("@id_faculte", id_faculte);
                cmd.Parameters.AddWithValue("@id_annee", id_annee);

                MySqlDataAdapter da     = new MySqlDataAdapter(cmd);
                DataTable        dtable = new DataTable();
                da.Fill(dtable);

                GDV_Creation.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                GDV_Creation.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center;

                if (dtable.Rows.Count > 0)
                {
                    GDV_Creation.DataSource = dtable;
                    GDV_Creation.DataBind();
                }
                else
                {
                    dtable.Rows.Add(dtable.NewRow());
                    GDV_Creation.DataSource = dtable;
                    GDV_Creation.DataBind();
                    GDV_Creation.Rows[0].Cells.Clear();
                    GDV_Creation.Rows[0].Cells.Add(new TableCell());
                    GDV_Creation.Rows[0].Cells[0].ColumnSpan      = dtable.Columns.Count;
                    GDV_Creation.Rows[0].Cells[0].Text            = "Aucune UE créée dans ce semestre";
                    GDV_Creation.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('Echec!')</script>");
                return;
            }
        }
        private void Load_Created_Years()
        {
            MySqlConnection conn = new MySqlConnection(Authentification.MyString);

            conn.Open();

            string           req    = "SELECT id_annee,annee,debut,fin,etat_annee FROM annee ";
            MySqlDataAdapter da     = new MySqlDataAdapter(req, conn);
            DataTable        dtable = new DataTable();

            da.Fill(dtable);

            GDV_Creation.RowStyle.HorizontalAlign = HorizontalAlign.Center;
            if (dtable.Rows.Count > 0)
            {
                exist_years             = "Yes";
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();

                DataRow lastRow = (DataRow)dtable.Rows[dtable.Rows.Count - 1];
                end_previous_year = lastRow["fin"].ToString().Trim();

                GDV_Creation.FooterRow.Cells[1].Text = end_previous_year;
                GDV_Creation.FooterRow.Cells[2].Text = (Convert.ToInt32(end_previous_year) + 1).ToString();

                start_current_year = GDV_Creation.FooterRow.Cells[1].Text;
                end_current_year   = GDV_Creation.FooterRow.Cells[2].Text;
            }
            else
            {
                exist_years = "No";
                dtable.Rows.Add(dtable.NewRow());
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();

                GDV_Creation.Rows[0].Cells.Clear();
                GDV_Creation.Rows[0].Cells.Add(new TableCell());
                GDV_Creation.Rows[0].Cells[0].ColumnSpan      = dtable.Columns.Count - 1;
                GDV_Creation.Rows[0].Cells[0].Text            = "Aucune année académique n’a été créée à cette date";
                GDV_Creation.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }
            conn.Close();
        }
        private void Unite_Par_Classe()
        {
            conn = new MySqlConnection(Authentification.MyString);
            conn.Open();
            string sql = "select unite.id_unite, unite,code_unite,SUM(credits) as credit  from unite inner join cours "
                         + " where  unite.id_classe=@idc and unite.id_departement=@id_departement and unite.id_faculte=@id_faculte and unite.id_annee=@id_annee "
                         + " and cours.id_unite=unite.id_unite  and unite.id_faculte=cours.id_faculte GROUP BY (unite.id_unite);";
            MySqlCommand cmd = new MySqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@idc", id_classe);
            cmd.Parameters.AddWithValue("@id_departement", id_departement);
            cmd.Parameters.AddWithValue("@id_faculte", id_faculte);
            cmd.Parameters.AddWithValue("@id_annee", id_annee);

            MySqlDataAdapter da     = new MySqlDataAdapter(cmd);
            DataTable        dtable = new DataTable();

            da.Fill(dtable);

            GDV_Creation.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            GDV_Creation.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            GDV_Creation.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Center;

            if (dtable.Rows.Count > 0)
            {
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();
            }
            else
            {
                dtable.Rows.Add(dtable.NewRow());
                GDV_Creation.DataSource = dtable;
                GDV_Creation.DataBind();
                GDV_Creation.Rows[0].Cells.Clear();
                GDV_Creation.Rows[0].Cells.Add(new TableCell());
                GDV_Creation.Rows[0].Cells[0].ColumnSpan      = dtable.Columns.Count;
                GDV_Creation.Rows[0].Cells[0].Text            = "Aucune UE déjà créée";
                GDV_Creation.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }

            conn.Close();
        }