//Validation des données private void BtnValider_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txtMatricule.Text) || string.IsNullOrWhiteSpace(txtMarque.Text) || string.IsNullOrWhiteSpace(txtModele.Text) || string.IsNullOrWhiteSpace(txtNbrePlace.Text) || string.IsNullOrWhiteSpace(txtAnneeAchat.Text) || string.IsNullOrWhiteSpace(txtNoChassis.Text)) { Outils.BoxMessage("C"); } else { TeteEngin T = new TeteEngin(); T.Matricule = txtMatricule.Text; T.NbrePlaces = int.Parse(txtNbrePlace.Text); T.Marque = txtMarque.Text; T.AnneeAchat = int.Parse(txtAnneeAchat.Text); T.Modele = txtModele.Text; T.NoChassis = txtNoChassis.Text; if (Id > 0) { T.Id = Id; T.Update(); Outils.BoxMessage("M"); LoadTabTeteEngin(); GriserChamps(); Id = 0; } else { if (Outils.VerifNoChassis(txtNoChassis.Text)) { MessageBox.Show("Le No de chassis: " + txtNoChassis.Text + " existe déjà !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error); txtNoChassis.Focus(); return; } //T.Matricule = Outils.GenMatricule(); T.Insert(); ListTeteEngin.Add(T); TabTeteEngin.Items.Refresh(); Outils.BoxMessage("A"); GriserChamps(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }