public void ListTypeBenneEngin() { var l = TypeBenneEngin.getAll(); foreach (var item in l) { LoadCombo lCombo = new LoadCombo(); lCombo.Id = item.Id; lCombo.Libelle = item.Libelle; ListCmbTypeBenneEngins.Add(lCombo); } cmbTypeBenne.ItemsSource = ListCmbTypeBenneEngins; }
private void BtnValider_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txtMatricule.Text) || string.IsNullOrWhiteSpace(txtMarque.Text) || string.IsNullOrWhiteSpace(txtCapacite.Text) || string.IsNullOrWhiteSpace(txtAnneeAchat.Text)) { MessageBox.Show("Veuillez remplir tous les champs !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error); } else { BenneEngin T = new BenneEngin(); T.Matricule = txtMatricule.Text; T.Marque = txtMarque.Text; T.AnneeAchat = int.Parse(txtAnneeAchat.Text); T.Capacite = int.Parse(txtCapacite.Text); var c = cmbTypeBenne.SelectedItem as LoadCombo; T.IdTypeBenne = c.Id; if (Id > 0) { T.Id = Id; T.Update(); MessageBox.Show("Modification effectuée !"); LoadTabBenneEngin(); GriserChamps(); Id = 0; } else { T.Insert(); var b = TypeBenneEngin.getUnTypeBenneEngin(c.Id); T.TypeBenneEngin = b; ListBenneEngin.Add(T); TabBenneEngin.Items.Refresh(); MessageBox.Show("Enregistrement effectué !"); GriserChamps(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Insert() { var input = string.Empty; var dialog = new InputDialog("Type benne engin", "Saisissez le type de benne engin", input); if (dialog.ShowDialog() == true) { if (!string.IsNullOrEmpty(dialog.Input)) { var typ = new TypeBenneEngin { Libelle = dialog.Input }; typ.Insert(); ListeTypeDepense.Add(typ); TabTypeDepense.Items.Refresh(); } } }
private void LoadTabTypeDepense() { ListeTypeDepense = TypeBenneEngin.getAll(); TabTypeDepense.ItemsSource = ListeTypeDepense; }