private void Nouveau_maintenance_click(object sender, RoutedEventArgs e) { DateTime date; if (DateTime.TryParse(Date.Text, out date)) { DAL_Maintenance.AjouterMaintenance(DAL_Avion.FindByMatricule(Avion.Text).Id, date, DAL_Aeroport.FindByName(Aeroport.Text).Id, Details.Text, employe); AfficherMaintenance(); } }
private void Edit(object sender, DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { DataGridColumn column = e.Column; if (column != null) { string column_nom = (string)column.Header; TextBox el = e.EditingElement as TextBox; ComboBox co = e.EditingElement as ComboBox; Maintenance maintenance = DAL_Maintenance.GetMaintenance(IdMaintenance); switch (column_nom) { case "Avion": maintenance.Avion = co.Text; break; case "Date": DateTime date; if (!DateTime.TryParse(el.Text, out date)) { date = maintenance.Date; } maintenance.Date = date; break; case "Aéroport": maintenance.Aeroport = co.Text; break; case "Détails": maintenance.Details = el.Text; break; default: break; } DAL_Maintenance.ModifierMaintenance(maintenance.Id, DAL_Avion.FindByMatricule(maintenance.Avion).Id, maintenance.Date, DAL_Aeroport.FindByName(maintenance.Aeroport).Id, maintenance.Details, employe); } } }
public void AfficherMaintenance() { ListeMaintenances = new ObservableCollection <Maintenance>(); ListeMaintenances = DAL_Maintenance.SelectMaintenancesByEmploye(employe); this.grid.ItemsSource = ListeMaintenances; }
private void Supp_maintenance_click(object sender, RoutedEventArgs e) { DAL_Maintenance.SupprimerMaintenance(IdMaintenance); AfficherMaintenance(); }