private void load() { this.typeCoursBox.Items.Clear(); // selecteur liste type cours List <TypeCours> typeCours = TypeCoursDAO.findAll(); foreach (TypeCours t in typeCours) // filtre { this.typeCoursBox.Items.Add(t); } // si modif on remet le bon type cours if (coursModifie != null && coursModifie.typeCours != null) { this.typeCoursBox.SelectedIndex = typeCoursBox.FindStringExact(coursModifie.typeCours.libelle); } this.intervenantBox.Items.Clear(); // selecteur liste personnel List <Personnel> personnels = PersonnelDAO.findAll(); foreach (Personnel p in personnels) { this.intervenantBox.Items.Add(p); } if (coursModifie != null && coursModifie.intervenant != null) { this.intervenantBox.SelectedIndex = intervenantBox.FindStringExact(coursModifie.intervenant.ToString()); } }
//Delete private void button1_Click_1(object sender, EventArgs e) { TypeCours type = (TypeCours)listBox1.Items[listBox1.SelectedIndex]; List <Cours> cours = CoursDAO.findAllCours(); bool doDelete = true; foreach (Cours c in cours) { if (c.typeCours.id == type.id) { MessageBox.Show("Au moins un cours est de ce type, veuillez le modifier avant la suppression", "Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); doDelete = false; break; } } if (doDelete) { TypeCoursDAO.delete(type); upadateList(); } }
public void TestFind() { // test du find simple TypeCours resultatFind = TypeCoursDAO.find(1); Assert.AreEqual("CM", resultatFind.libelle); Assert.AreNotEqual(0, resultatFind.id); }
private void upadateList() { this.listBox1.Items.Clear(); typesListe = TypeCoursDAO.findAll(); foreach (TypeCours type in typesListe) { this.listBox1.Items.Add(type); } }
/** * Methodes pour aider aux tests * **/ public static TypeCours creerTypeCours(String libelle) { TypeCours res = new TypeCours(); res.libelle = libelle; TypeCours c = TypeCoursDAO.create(res); return(c); }
public void TestFindByLibelleTypeCours() { // test du fin by libelle List <TypeCours> resultatFind = TypeCoursDAO.findByLibelle("TEST_type_cours"); foreach (TypeCours res in resultatFind) { Assert.AreEqual("TEST_type_cours", res.libelle); Assert.IsTrue(res.id > 0); } }
public void TestFindAll() { // test du fin by libelle List <TypeCours> resultatFind = TypeCoursDAO.findAll(); foreach (TypeCours res in resultatFind) { Assert.IsNotNull(res.id); Assert.IsNotNull(res.libelle); } }
public void TestDeleteTypeCours() { // test du delete List <TypeCours> resultatFind = TypeCoursDAO.findByLibelle("TEST_%"); foreach (TypeCours res in resultatFind) { supprimeTypeCours(res); } List <TypeCours> resultatFind2 = TypeCoursDAO.findByLibelle("TEST_%"); Assert.AreEqual(resultatFind2.Count, 0); }
private void loadType() { List <TypeCours> typeCours = TypeCoursDAO.findAll(); foreach (TypeCours tc in typeCours) { this.typeBox.Items.Add(tc); if (tc.id == modifCours.typeCours.id) { this.typeBox.SelectedItem = tc; } } }
public void TestUpdateTypeCours() { // test du delete List <TypeCours> resultatFind = TypeCoursDAO.findByLibelle("TEST_type_cours"); foreach (TypeCours res in resultatFind) { res.libelle = "TEST_type_cours_2"; TypeCoursDAO.update(res); } List <TypeCours> resultatFind2 = TypeCoursDAO.findByLibelle("TEST_type_cours_2"); Assert.IsTrue(resultatFind2.Count > 0); }
private void categorieCB_SelectedIndexChanged(object sender, EventArgs e) { this.groupBox1.Enabled = true; categorie = (CategoriePersonnel)categorieCB.SelectedItem; List <TypeCours> tcs = TypeCoursDAO.findAll(); List <Ratio> listeRatio = RatioDAO.findAll(); this.typeCoursComboBox.Items.Clear(); this.volumeTextBox.Text = categorie.volumeHoraire.ToString(); foreach (Ratio ratio in listeRatio) { if (ratio.categoriePersonnel.id == categorie.id) { this.typeCoursComboBox.Items.Add(ratio.typeCours); } } }
//Ajout private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBox1.Text)) { DiplomeView.afficherPopup("Le nom est vide"); } else { TypeCours type = new TypeCours(textBox1.Text); TypeCoursDAO.create(type); upadateList(); List <CategoriePersonnel> catList = CategoriePersonnelDAO.findAll(); foreach (CategoriePersonnel cat in catList) { Ratio r = new Ratio(type, cat); r.ratio = 1; RatioDAO.create(r); } } }
/// <summary> /// Evenement valider / modifier /// </summary> private void validerAction(object sender, EventArgs e) { CategoriePersonnel categorie = new CategoriePersonnel(); int volumeHoraire = 0; Boolean categorieIncorrect = String.IsNullOrWhiteSpace(categorietextBox.Text); Boolean volumeHoraireIncorrect = !Int32.TryParse(volumeTextBox.Text, out volumeHoraire); if (categorieIncorrect || volumeHoraireIncorrect) { // Initializes the variables to pass to the MessageBox.Show method. string message = "Erreur lors de la saisie des données \n"; message += volumeHoraireIncorrect ? " le volume horaire est incorrect" : ""; message += categorieIncorrect ? " le nom de la categorie est incorrect" : ""; DiplomeView.afficherPopup(message); } else { categorie.libelle = categorietextBox.Text; categorie.volumeHoraire = volumeHoraire; categorie = CategoriePersonnelDAO.create(categorie); if (categorie != null) { foreach (TypeCours typeCours in TypeCoursDAO.findAll()) { Ratio temp = new Ratio(); temp.ratio = 1; temp.typeCours = typeCours; temp.categoriePersonnel = categorie; RatioDAO.create(temp); } this.Close(); } } }
public static void supprimeTypeCours(TypeCours typeCours) { TypeCoursDAO.delete(typeCours); }