//Fonction pour remplir le ListView private ListViewItem GetListViewPilote(PiloteDTO Pilote) { ListViewItem item = new ListViewItem(Pilote.IdPilote.ToString()); item.SubItems.Add(Pilote.Nom); item.SubItems.Add(Pilote.Grade); return(item); }
//Fonction pour créer une nouvelle facture public double NouvelleFacture(AvionDTO avion, PiloteDTO instruteur, PiloteDTO pilote, DateTime HeureDemarrage, DateTime HeureArret, DateTime HeureAtterissage, DateTime HeureDecolage, double TarifAvion) { double HeuredeVol, HeureSol; HeuredeVol = calculertempsVol(HeureDecolage, HeureAtterissage); HeureSol = calculertempssol(HeureDemarrage, HeureDecolage, HeureAtterissage, HeureArret); Mappeur.MappeurFacture mappeur = new Mappeur.MappeurFacture(); facture = mappeur.Map(avion, instruteur, pilote, HeuredeVol, HeureSol, HeureDemarrage, HeureArret, HeureAtterissage, HeureDecolage, tarifHrVol, tarifHrSol, facture); RepositoryFacture.NouvelleFacture(facture); return(calculertotalFacture(facture, TarifAvion)); }
public FrmModifierPilote(GestionPilote gestionPilote, PiloteDTO pilote) { gestionPilotes = gestionPilote; InitializeComponent(); txtId.Text = pilote.IdPilote.ToString(); txtNom.Text = pilote.Nom; if (pilote.Grade == "Pilote") { cmbGrade.SelectedIndex = 0; } else if (pilote.Grade == "Instructeur") { cmbGrade.SelectedIndex = 1; } }
//Fonction pour mapper a partir des informations de la facture public FactureDto Map(AvionDTO avion, PiloteDTO instruteur, PiloteDTO pilote, double HeuredeVol, double HeureSol, DateTime HeureDemarrage, DateTime HeureArret, DateTime HeureAtterissage, DateTime HeureDecolage, double tarifHrVol, double tarifHrSol, FactureDto cible) { cible.HrVol = HeuredeVol; cible.HrSol = HeureSol; cible.TarifHrVol = tarifHrVol; cible.TarifHrSol = tarifHrSol; cible.avion = avion.IdAvion; cible.Instructeur = instruteur.IdPilote; cible.Pilote = pilote.IdPilote; cible.HrDemarrage = HeureDemarrage; cible.HrDecollage = HeureDecolage; cible.HrArret = HeureArret; cible.HrAtterissage = HeureAtterissage; return(cible); }
//Fonction pour aller chercher un Pilote avec le nom public PiloteDTO GetPilote(string NomPilote) { using (SqlConnection connexion = new SqlConnection(ChaineConnexion)) { SqlCommand commande = new SqlCommand("select * from Tbl_Pilote inner join Tbl_Grade on Tbl_Pilote.IdGrade = Tbl_Grade.IdGrade where Nom=@NomPilote", connexion); commande.Parameters.AddWithValue("@NomPilote", NomPilote); connexion.Open(); using (SqlDataReader reader = commande.ExecuteReader()) if (reader.Read()) { var dto = new PiloteDTO(); mapper.Map(reader, dto); return(dto); } else { return(null); } } }
//fonctions pour aller chercher et retourner la liste des pilotes public List <PiloteDTO> GetListePilote() { var listePilote = new List <PiloteDTO>(); using (SqlConnection connexion = new SqlConnection(ChaineConnexion)) { SqlCommand commande = new SqlCommand("select IdPilote,Nom,Titre from Tbl_Pilote inner join Tbl_Grade on Tbl_Pilote.IdGrade = Tbl_Grade.IdGrade", connexion); connexion.Open(); using (SqlDataReader reader = commande.ExecuteReader()) { while (reader.Read()) { var dto = new PiloteDTO(); mapper.Map(reader, dto); listePilote.Add(dto); } } return(listePilote); } }
//Fonction pour créé un pilote public void NouveauPilote(PiloteDTO Pilote) { int grade = 0; using (SqlConnection connexion = new SqlConnection(ChaineConnexion)) { SqlCommand commande = new SqlCommand("select IdGrade from Tbl_Grade where Titre = @Grade", connexion); commande.Parameters.AddWithValue("@Grade", Pilote.Grade); connexion.Open(); using (SqlDataReader reader = commande.ExecuteReader()) if (reader.Read()) { grade = (int)reader["IdGrade"]; } SqlCommand commande2 = new SqlCommand("INSERT INTO Tbl_Pilote (Nom,IdGrade ) VALUES (@Nom," + grade + "); SELECT SCOPE_IDENTITY()", connexion); commande2.Parameters.AddWithValue("@Nom", Pilote.Nom); object valeur = commande2.ExecuteScalar(); Pilote.IdPilote = int.Parse(valeur.ToString()); } }
//Fonction pour modifier un pilote public void ModifierPilote(PiloteDTO Pilote) { int grade = 0; using (SqlConnection connexion = new SqlConnection(ChaineConnexion)) { SqlCommand commande = new SqlCommand("update Tbl_Pilote set Nom = @Nom, IdGrade = @Grade where IdPilote = @IdPilote", connexion); if (Pilote.Grade == "Pilote") { grade = 1; } else if (Pilote.Grade == "Instructeur") { grade = 2; } commande.Parameters.AddWithValue("@IdPilote", Pilote.IdPilote); commande.Parameters.AddWithValue("@Nom", Pilote.Nom); commande.Parameters.AddWithValue("@Grade", grade); connexion.Open(); commande.ExecuteNonQuery(); } }
private void btnModifier_Click(object sender, EventArgs e) { if (int.TryParse(txtModifier.Text, out int Id)) { foreach (var Pilote in ListePilotes) { if (Pilote.IdPilote == Id) { piloteDTO = Pilote; break; } } Form ModifierPilote = new FrmModifierPilote(gestionPilotes, piloteDTO); ModifierPilote.ShowDialog(); lstViewPilote.Items.Clear(); RemplirListe(); txtModifier.Clear(); } else { MessageBox.Show("Veuillez entrez un Id valide svp"); } }
//Fonction pour mapper a partir d'informations complètes public void Map(int Id, string nom, string IdGrade, PiloteDTO cible) { cible.IdPilote = Id; cible.Nom = nom; cible.Grade = IdGrade; }
//Fonction pour mapper a partir d'un sqlDataReader public void Map(SqlDataReader source, PiloteDTO cible) { cible.IdPilote = (int)source["IdPilote"]; cible.Grade = (string)source["Titre"]; cible.Nom = (string)source["Nom"]; }