public void AjouterEpreuveTitre(int positionTitre, EpreuveTitre epreuveTitre) { if (DAL.TitresDAL.AjouterEpreuveTitre(epreuveTitre) >= 0) { if(epreuveTitre.ListeJury != null && epreuveTitre.ListeJury.Count > 0) DAL.TitresDAL.AjouterJuryEpreuveTitre(epreuveTitre); this.listTitres.ElementAt(positionTitre).ListeEpreuves.Add(epreuveTitre); histoTitre = this.listTitres.ElementAt(positionTitre); } }
public void AjouterTitre(Titre titre) { if(!string.IsNullOrEmpty(titre.CodeTitre) && !string.IsNullOrEmpty(titre.LibelleCourt)) { titre.DateCreation = DateTime.Now; titre.DateModif = titre.DateCreation; if(DAL.TitresDAL.AjouterTitre(titre) > 0) { listTitres.Add(titre); InitDictionnaires(); } } else { System.Windows.MessageBox.Show("Le code et le libellé court du titre doivent être obligatoirement renseignés!", "Ajout titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop); } }
public static int ModifierTitre(Titre titre) { try { string req = "update Titre set LibelleCourt = @libC, LibelleLong = @libL, DateCreation = @dateC, TitreENI = @titENI, Archiver = @archiv, niveau = @nivo, codeRome = @codeR, codeNSF = @codeN where CodeTitre=@codeT"; SqlConnection conn = ConnexionSQL.CreationConnexion(); SqlCommand commande = conn.CreateCommand(); commande.CommandText = req; commande.Parameters.AddWithValue("@codeT", titre.CodeTitre); commande.Parameters.AddWithValue("@libC", titre.LibelleCourt); commande.Parameters.AddWithValue("@libL", titre.LibelleLong ?? string.Empty); commande.Parameters.AddWithValue("@dateC", titre.DateCreation); commande.Parameters.AddWithValue("@titENI", titre.TitreENI); commande.Parameters.AddWithValue("@archiv", titre.Archiver); commande.Parameters.AddWithValue("@nivo", titre.Niveau ?? string.Empty); commande.Parameters.AddWithValue("@codeR", titre.CodeRome ?? string.Empty); commande.Parameters.AddWithValue("@codeN", titre.CodeNSF ?? string.Empty); int retour = commande.ExecuteNonQuery(); conn.Close(); return retour; } catch(Exception e) { System.Windows.MessageBox.Show("La modification de ce titre est impossible : " + e.Message, "Modification Titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop); return -1; } }
public static int AjouterTitre(Titre titre) { try { string req = "insert into Titre (CodeTitre,LibelleCourt,LibelleLong,DateCreation,TitreENI,Archiver,niveau,codeRome,codeNSF) " + "select @codeT, @libC, @libL, @dateC, @titENI, @archiv, @nivo, @codeR, @codeN " + "where not exists (select 0 from Titre where CodeTitre=@codeT)"; SqlConnection conn = ConnexionSQL.CreationConnexion(); SqlCommand commande = conn.CreateCommand(); commande.CommandText = req; commande.Parameters.AddWithValue("@codeT", titre.CodeTitre); commande.Parameters.AddWithValue("@libC", titre.LibelleCourt); commande.Parameters.AddWithValue("@libL", titre.LibelleLong ?? string.Empty); commande.Parameters.AddWithValue("@dateC", titre.DateCreation); commande.Parameters.AddWithValue("@titENI", titre.TitreENI); commande.Parameters.AddWithValue("@archiv", titre.Archiver); commande.Parameters.AddWithValue("@nivo", titre.Niveau ?? string.Empty); commande.Parameters.AddWithValue("@codeR", titre.CodeRome ?? string.Empty); commande.Parameters.AddWithValue("@codeN", titre.CodeNSF ?? string.Empty); int retour = commande.ExecuteNonQuery(); conn.Close(); return retour; } catch(Exception e) { System.Windows.MessageBox.Show("L'ajout de ce titre est impossible : " + e.Message, "Ajout Titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop); return -1; } }
private void btAnnulTitre_Click(object sender, RoutedEventArgs e) { if(this.cbChoixTitre.SelectedIndex != -1) titre = Controleur.HistoTitre; else { cbChoixTitre.SelectedIndex = 0; titre = Controleur.GetTitre((string)cbChoixTitre.SelectedValue); } this.cbChoixTitre.IsEnabled = true; this.txtCodeTitre.IsEnabled = false; this.groupBoxTitre.DataContext = titre; }
//Initialisation des données du titre (partie haute) private void InitData() { this.groupBoxTitre.DataContext = null; this.cbChoixTitre.ItemsSource = null; this.cbChoixTitre.ItemsSource = Controleur.GetListeCodeTitre(); this.cbNiveau.ItemsSource = null; this.cbNiveau.ItemsSource = Controleur.GetListeNiveaux(); this.cbSalle.ItemsSource = null; this.cbSalle.ItemsSource = Controleur.GetSalles(); this.cbChoixTitre.SelectedIndex = 0; titre = Controleur.GetTitre((string)cbChoixTitre.SelectedValue); this.groupBoxTitre.DataContext = titre; ResetDetailPassage(); }
private void cbChoixTitre_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.cbChoixTitre.SelectedIndex != -1) { titre = Controleur.GetTitre((string)cbChoixTitre.SelectedValue); if (titre.ListeEpreuves != null && titre.ListeEpreuves.Count > 0) { this.dgDatesPassage.ItemsSource = titre.ListeEpreuves; } else this.dgDatesPassage.ItemsSource = null; this.btSupprTitre.IsEnabled = true; } else { titre = new Titre(); this.dgDatesPassage.ItemsSource = null; btSupprTitre.IsEnabled = false; } this.groupBoxTitre.DataContext = titre; }
private void btSupprPassage_Click(object sender, RoutedEventArgs e) { if (cbChoixTitre.SelectedIndex != -1) { MessageBoxResult mr = MessageBox.Show("Êtes-vous sûr(e) de vouloir supprimer cette épreuve?", "Suppression Epreuve Titre", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (mr == MessageBoxResult.Yes) { SupprimerEpreuveTitre(); this.dgDatesPassage.ItemsSource = null; this.dgDatesPassage.Items.Clear(); titre = Controleur.HistoTitre; this.dgDatesPassage.ItemsSource = titre.ListeEpreuves; ResetDetailPassage(); } } }
//Validation de l'ajout ou d'une modification d'une épreuve private void btModifPassage_Click(object sender, RoutedEventArgs e) { try { if(titre != null && titre.CodeTitre != null && cbSalle.SelectedIndex != -1 && dpPassage.SelectedDate.HasValue) { btSupprPassage.IsEnabled = true; btAjoutPassage.IsEnabled = true; dgDatesPassage.IsEnabled = true; this.epreuveTitre.DateEpreuve = dpPassage.SelectedDate.Value; this.epreuveTitre.Salle = (string)cbSalle.SelectedValue; if(IsUniqueEpreuve() || (!IsUniqueEpreuve() && (histoEpreuveTitre!=null && histoEpreuveTitre.ListeJury != epreuveTitre.ListeJury))) { if(dgJury.HasItems) this.epreuveTitre.ListeJury = (List<Jury>)dgJury.ItemsSource; //Si on est en modification, on supprime toutes les références de l'ancienne EpreuveTitre if(histoEpreuveTitre != null) { //Suppression de l'ancienne épreuve -> histoEpreuveTitre SupprimerEpreuveTitre(); } //Ensuite, dans tous les cas, on ajoute toutes les références de la nouvelle EpreuveTitre Controleur.AjouterEpreuveTitre(this.cbChoixTitre.SelectedIndex, this.epreuveTitre); this.dgDatesPassage.ItemsSource = null; this.dgDatesPassage.Items.Clear(); titre = Controleur.HistoTitre; this.dgDatesPassage.ItemsSource = titre.ListeEpreuves; this.dgDatesPassage.SelectedValue = this.epreuveTitre; } else throw new Exception(); } } catch(Exception) { MessageBox.Show("Cette épreuve existe déjà!", "Gestion Epreuve Titre", MessageBoxButton.OK, MessageBoxImage.Error); this.btAnnulPassage_Click(sender, e); } }
public Titre GetTitre(string codeTitre) { Titre t = listTitres.Where(x => x.CodeTitre.Equals(codeTitre)).First(); //Il faut créer un nouvel objet titre pour que l'historique fonctionne bien. //Sinon, avec le binding, la liste du contrôleur est automatiquement modifiée. histoTitre = new Titre(t.CodeTitre,t.LibelleCourt,t.LibelleLong,t.Niveau, t.CodeRome,t.CodeNSF,t.DateCreation,t.DateModif,t.TitreENI,t.Archiver,t.ListeEpreuves); return t; }
public void SupprimerEpreuveTitre(int positionTitre, EpreuveTitre HistoEpreuveTitre, EpreuveTitre EpreuveTitre) { if(EpreuveTitre != null) { DAL.TitresDAL.SupprimerJuryEpreuveTitre(HistoEpreuveTitre); DAL.TitresDAL.SupprimerEpreuveTitre(HistoEpreuveTitre); bool i = this.listTitres.ElementAt(positionTitre).ListeEpreuves.Remove(HistoEpreuveTitre); histoTitre = this.listTitres.ElementAt(positionTitre); } }
public void ModifierTitre(Titre titre) { if(!string.IsNullOrEmpty(titre.LibelleCourt)) { titre.DateModif = DateTime.Now; if(DAL.TitresDAL.ModifierTitre(titre) > 0) { histoTitre = new Titre(titre.CodeTitre, titre.LibelleCourt, titre.LibelleLong, titre.Niveau, titre.CodeRome, titre.CodeNSF, titre.DateCreation, titre.DateModif, titre.TitreENI, titre.Archiver, titre.ListeEpreuves); System.Windows.MessageBox.Show("Le titre a bien été modifié!", "Modification titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } } else { System.Windows.MessageBox.Show("Le libellé court du titre doit être obligatoirement renseigné!", "Modification titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop); } }