/// <summary> /// Evenement valider / modifier /// </summary> private void valider(object sender, EventArgs e) { ElementConstitutif ec = new ElementConstitutif(this.nomBox.Text, ue); Boolean elementConstitutifIncorrect = string.IsNullOrWhiteSpace(nomBox.Text); if (elementConstitutifIncorrect) { // Initializes the variables to pass to the MessageBox.Show method. string message = "Erreur lors de la saisie des données \n"; message += " le nom de l'élément constitutif est vide !"; DiplomeView.afficherPopup(message); } else { if (input) { ElementConstitutifDAO.create(ec); } else { ec.id = elementModifie.id; ElementConstitutifDAO.update(ec); } this.Close(); } }
public static ElementConstitutif update(ElementConstitutif obj) { MySqlConnection _connection = ConnectionMySql.getInstance(); MySqlCommand _cmd = new MySqlCommand(); _cmd.Connection = _connection; String sql = ""; try { sql = "UPDATE element_constitutif set libelle = @libelle, ue_id = @ue_id WHERE id = @id"; _cmd.CommandText = sql; _cmd.Parameters.AddWithValue("@id", obj.id); _cmd.Parameters.AddWithValue("@libelle", obj.libelle); _cmd.Parameters.AddWithValue("@ue_id", obj.uniteEnseignement.id); _cmd.ExecuteNonQuery(); obj.id = _cmd.LastInsertedId; } catch (Exception e) { Console.WriteLine("Exception : " + e); } _cmd.Dispose(); return(obj); }
public static void delete(ElementConstitutif obj) { MySqlConnection _connection = ConnectionMySql.getInstance(); MySqlCommand _cmd = new MySqlCommand(); _cmd.Connection = _connection; String sql = ""; try { sql = "DELETE FROM element_constitutif WHERE id = @id"; _cmd.CommandText = sql; _cmd.Parameters.AddWithValue("@id", obj.id); _cmd.ExecuteNonQuery(); obj.id = _cmd.LastInsertedId; } catch (Exception e) { Console.WriteLine("Exception : " + e); } _cmd.Dispose(); }
public static ElementConstitutif create(ElementConstitutif obj) { MySqlConnection _connection = ConnectionMySql.getInstance(); MySqlCommand _cmd = new MySqlCommand(); _cmd.Connection = _connection; String sql = ""; try { sql = "INSERT INTO element_constitutif (id, libelle, ue_id) VALUES (@id,@libelle,@UniteEnseignement) "; _cmd.CommandText = sql; _cmd.Parameters.AddWithValue("@id", obj.id); _cmd.Parameters.AddWithValue("@libelle", obj.libelle); _cmd.Parameters.AddWithValue("@UniteEnseignement", obj.uniteEnseignement.id); _cmd.ExecuteNonQuery(); obj.id = _cmd.LastInsertedId; } catch (Exception e) { Console.WriteLine("Exception : " + e); } _cmd.Dispose(); return(obj); }
public static List <ElementConstitutif> findByUniteEnseignement(long id) { MySqlConnection _connection = ConnectionMySql.getInstance(); MySqlCommand _cmd = new MySqlCommand(); _cmd.Connection = _connection; String sql = ""; MySqlDataReader reader = null; List <ElementConstitutif> resultats = new List <ElementConstitutif>(); try { sql = "SELECT element_constitutif.id as elemConstID, element_constitutif.libelle as elemConstLibelle, " + "unite_enseignement.id as uniteEnsID, unite_enseignement.libelle as uniteEnsLibelle, " + "periode.id AS periodeID, periode.libelle AS periodeLibelle, " + "annee.id AS anneeId, annee.libelle AS anneeLibelle, " + "diplome.id AS diplomeID, diplome.libelle AS diplomeLibelle " + "FROM element_constitutif " + "JOIN unite_enseignement on element_constitutif.ue_id = unite_enseignement.id " + "JOIN periode ON unite_enseignement.periode_id = periode.id " + "JOIN annee ON periode.annee_id = annee.id " + "JOIN diplome ON annee.diplome_id = diplome.id " + "WHERE unite_enseignement.id = @id"; _cmd.CommandText = sql; _cmd.Parameters.AddWithValue("@id", id); reader = _cmd.ExecuteReader(); while (reader.Read()) { Diplome tempDiplome = DiplomeDAO.populateDiplome(reader); Annee tempAnnee = AnneeDAO.populateAnnee(reader); tempAnnee.diplome = tempDiplome; Periode tempPeriode = PeriodeDAO.populatePeriode(reader); tempPeriode.annee = tempAnnee; UniteEnseignement tempUnite = UniteEnseignementDAO.populateUniteEnseignement(reader); tempUnite.periode = tempPeriode; ElementConstitutif tempElementConstitutif = populateElementConstitutif(reader); tempElementConstitutif.uniteEnseignement = tempUnite; resultats.Add(tempElementConstitutif); } reader.Close(); } catch (Exception e) { Console.WriteLine("Exception : " + e); } _cmd.Dispose(); return(resultats); }
public void TestFindByUniteEnseignementElementConstitutif() { // test du fin by libelle ElementConstitutif elem = creerElementConstitutif("TEST_ELEM"); List <ElementConstitutif> resultatFind = ElementConstitutifDAO.findByUniteEnseignement(elem.uniteEnseignement.id); Assert.IsTrue(resultatFind.Count > 0); }
public void TestCreationElementConstitutif() { // test la création d'une UniteEnseignement et la recherche grace à son libelle ElementConstitutif resultat = creerElementConstitutif("TEST_ElementConstitutif"); Assert.AreNotEqual("", resultat.libelle); Assert.AreEqual("TEST_ElementConstitutif", resultat.libelle); Assert.IsTrue(resultat.id > 0); }
/// <summary> /// Évènement changement de sélection /// </summary> private void ecGridView_SelectionChanged(object sender, EventArgs e) { ElementConstitutif elem = getCurrentEc(); if (elem != null) { ecDetailGridViewLoad(); } }
public InputModifCoursForm(String name, ElementConstitutif element) { input = true; this.Text = name; this.elementConstitutif = element; InitializeComponent(); load(); groupeLabel.Text = "Nombre de groupe :*"; }
public InputModifECForm(String name, UniteEnseignement ue, ElementConstitutif e) { input = false; elementModifie = e; this.Text = name; this.ue = ue; InitializeComponent(); this.nomBox.Text = e.libelle; }
/** * Methodes pour aider aux tests * **/ public static ElementConstitutif creerElementConstitutif(String libelle) { ElementConstitutif elementConstitutif = new ElementConstitutif(); elementConstitutif.libelle = libelle; elementConstitutif.uniteEnseignement = UniteEnseignementTest.creerUniteEnseignement(libelle); ElementConstitutif resultat = ElementConstitutifDAO.create(elementConstitutif); return(resultat); }
public InputModifCoursForm(String name, Cours cours, ElementConstitutif element) : this(name, element) { input = false; coursModifie = cours; // EC - Volume - Type de cours - Groupe s'il y en a un // Mais pas le prof -> optionnel this.groupeBox.Text = cours.numeroGroupe; this.volumeBox.Text = cours.volumeHoraire.ToString(); load(); groupeLabel.Text = "Nom du groupe :*"; }
public void TestFind() { // test du find simple ElementConstitutif resultat = creerElementConstitutif("TEST_ElementConstitutif"); ElementConstitutif resultatFind = ElementConstitutifDAO.find(resultat.id); Assert.AreEqual("TEST_ElementConstitutif", resultatFind.libelle); Assert.AreNotEqual(0, resultatFind.id); Assert.AreNotEqual(0, resultatFind.uniteEnseignement.id); Assert.AreNotEqual(0, resultatFind.uniteEnseignement.periode.id); Assert.AreNotEqual(0, resultatFind.uniteEnseignement.periode.annee.id); Assert.AreNotEqual(0, resultatFind.uniteEnseignement.periode.annee.diplome.id); }
public static ElementConstitutif populateElementConstitutif(MySqlDataReader reader) { ElementConstitutif resultat = new ElementConstitutif(); if (reader.IsDBNull(reader.GetOrdinal("elemConstID")) || reader.IsDBNull(reader.GetOrdinal("elemConstLibelle"))) { return(null); } resultat.id = Convert.ToInt64(reader["elemConstID"]); resultat.libelle = (String)reader["elemConstLibelle"]; return(resultat); }
/// <summary> /// EC sélectionné /// </summary> /// <returns>personnel</returns> private ElementConstitutif getCurrentEC() { if (ecGridView.SelectedCells.Count > 0) { int selectedRowIndex = ecGridView.SelectedCells[0].RowIndex; ElementConstitutif ec = ((ObjectView <ElementConstitutif>)ecGridView.Rows[selectedRowIndex].DataBoundItem).Object; return(ec); } else { return(null); } }
/// <summary> /// Suppression d'une Ec /// </summary> private void supprimerEc(object sender, EventArgs e) { ElementConstitutif ec = getCurrentEC(); if (ec != null) { ElementConstitutifDAO.delete(ec); ecGridViewLoad(); } else { afficherPopup("Aucun élément constitutif sélectionné \n"); } }
/// <summary> /// Modification d'une Ec /// </summary> private void modifierEc(object sender, EventArgs e) { UniteEnseignement ue = getCurrentUE(); ElementConstitutif ec = getCurrentEC(); if (ue != null && ec != null) { var formPopup = new InputModifECForm("Nouvel Ec", ue, ec); formPopup.ShowDialog(this); ecGridViewLoad(); } else { afficherPopup("Aucun élément constitutif sélectionné \n"); } }
/// <summary> /// Modification d'un Cours /// </summary> private void modifierCours(object sender, EventArgs e) { Cours cours = getCurrentCours(); ElementConstitutif ec = getCurrentEc(); if (cours != null && ec != null) { var formPopup = new InputModifCoursForm("Modifier cours", cours, ec); formPopup.ShowDialog(this); ueGridViewLoad(); } else { afficherPopup("Aucun cours ou d'élément constitutif sélectionné \n"); } }
/// <summary> /// Ajouter un Cours /// </summary> private void ajouterCours(object sender, EventArgs e) { UniteEnseignement ue = getCurrentUE(); ElementConstitutif ec = getCurrentEc(); if (ue != null && ec != null) { var formPopup = new InputModifCoursForm("Nouveau cours", ec); formPopup.ShowDialog(this); ueGridViewLoad(); } else { afficherPopup("Aucun élément constitutif ou d'unité d'enseignement sélectionné \n"); } }
/// <summary> /// Charge les données de la grille ec /// </summary> private void ecDetailGridViewLoad() { ElementConstitutif ec = getCurrentEC(); List <Cours> allCours = CoursDAO.findAllCours(); List <Cours> cours = new List <Cours>(); foreach (Cours c in allCours) { if (ec != null && ec.id == c.elementConstitutif.id) { cours.Add(c); } } BindingListView <Cours> bindingSourceCours = new BindingListView <Cours>(cours); ecDetailsGridView.DataSource = bindingSourceCours; }
private void updateTauxAffectationEC() { // On fait la somme par année des cours et des cours qui sont affectés var tabUe = new ArrayList(); var tabAnneeSumCours = new List <int>(); var tabAnneeSumCoursAffecte = new List <int>(); foreach (Cours c in cours) { ElementConstitutif ue = c.elementConstitutif; int index = -1; for (int i = 0; i < tabUe.Count; i++) { ElementConstitutif tmp = (ElementConstitutif)(tabUe[i]); if (tmp.id == ue.id) { index = i; } } if (index < 0) { tabUe.Add(ue); index = tabUe.Count - 1; tabAnneeSumCours.Add(0); tabAnneeSumCoursAffecte.Add(0); } tabAnneeSumCours[index] += c.volumeHoraire; if (c.intervenant != null) { tabAnneeSumCoursAffecte[index] += c.volumeHoraire; } } //On ajoute pour chaque année le pourcentage for (int i = 0; i < tabUe.Count; i++) { float percentage = tabAnneeSumCoursAffecte[i] * 100 / tabAnneeSumCours[i]; ElementConstitutif ec = ((ElementConstitutif)tabUe[i]); string libelle = ec.uniteEnseignement.periode.annee + " " + ec.uniteEnseignement + " " + ec.libelle; column.Series["Series1"].Points.AddXY(libelle, percentage); } }
public static List <Cours> findByPersonnel(long id) { MySqlConnection _connection = ConnectionMySql.getInstance(); MySqlCommand _cmd = new MySqlCommand(); _cmd.Connection = _connection; String sql = ""; MySqlDataReader reader = null; List <Cours> resultats = new List <Cours>(); try { sql = "SELECT cours.id as coursID, cours.volume as coursVolume, cours.groupe as coursGroupe, cours.ec_id, " + "type_cours.id AS typeCoursID, type_cours.libelle AS typeCoursLibelle, " + "personnel.id AS personnelId, personnel.nom AS personnelNom, personnel.prenom AS personnelPrenom, " + "categorie_personnel.id AS categID, categorie_personnel.libelle AS categLibelle, categorie_personnel.volume_horaire as categVolume, " + "element_constitutif.id as elemConstID, element_constitutif.libelle as elemConstLibelle, " + "unite_enseignement.id as uniteEnsID, unite_enseignement.libelle as uniteEnsLibelle, " + "periode.id AS periodeID, periode.libelle AS periodeLibelle, " + "annee.id AS anneeId, annee.libelle AS anneeLibelle, " + "diplome.id AS diplomeID, diplome.libelle AS diplomeLibelle " + "FROM cours " + "LEFT JOIN type_cours on cours.type_id = type_cours.id " + "LEFT JOIN element_constitutif on cours.ec_id = element_constitutif.id " + "LEFT JOIN personnel on cours.personnel_id = personnel.id " + "LEFT JOIN categorie_personnel ON personnel.categorie_id = categorie_personnel.id " + "LEFT JOIN unite_enseignement on element_constitutif.ue_id = unite_enseignement.id " + "LEFT JOIN periode ON unite_enseignement.periode_id = periode.id " + "LEFT JOIN annee ON periode.annee_id = annee.id " + "LEFT JOIN diplome ON annee.diplome_id = diplome.id " + "WHERE personnel.id = @id"; _cmd.CommandText = sql; _cmd.Parameters.AddWithValue("@id", id); reader = _cmd.ExecuteReader(); while (reader.Read()) { Cours resultat = populateCours(reader); Diplome tempDiplome = DiplomeDAO.populateDiplome(reader); Annee tempAnnee = AnneeDAO.populateAnnee(reader); if (tempDiplome != null) { tempAnnee.diplome = tempDiplome; } Periode tempPeriode = PeriodeDAO.populatePeriode(reader); if (tempPeriode != null) { tempPeriode.annee = tempAnnee; } UniteEnseignement tempUnite = UniteEnseignementDAO.populateUniteEnseignement(reader); if (tempUnite != null) { tempUnite.periode = tempPeriode; } ElementConstitutif tempElemConstitutif = ElementConstitutifDAO.populateElementConstitutif(reader); if (tempElemConstitutif != null) { tempElemConstitutif.uniteEnseignement = tempUnite; } // champ du cours resultat = populateCours(reader); // ajout element constitutif resultat.elementConstitutif = tempElemConstitutif; // ajout type de cours TypeCours tempTypeCours = TypeCoursDAO.populateTypeCours(reader); resultat.typeCours = tempTypeCours; // ajout intervenant et sa categorie CategoriePersonnel tempCategPersonnel = CategoriePersonnelDAO.populateCategoriePersonnel(reader); Personnel tempPersonnel = PersonnelDAO.populatePersonnel(reader); if (tempPersonnel != null) { tempPersonnel.categoriePersonnel = tempCategPersonnel; } resultat.intervenant = tempPersonnel; resultats.Add(resultat); } reader.Close(); } catch (Exception e) { Debug.WriteLine("Exception : " + e); } _cmd.Dispose(); return(resultats); }
public static void supprimerElementConstitutif(ElementConstitutif elementConstitutif) { UniteEnseignementTest.supprimerUniteEnseignement(elementConstitutif.uniteEnseignement); ElementConstitutifDAO.delete(elementConstitutif); }