예제 #1
0
 private void BtnValider_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(txtLibelle.Text) ||
             cmbTeteEngin.SelectedIndex == -1 ||
             cmbBenneEngin.SelectedIndex == -1
             )
         {
             MessageBox.Show("Veuillez remplir tous les champs !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else
         {
             Vehicule T = new Vehicule();
             T.Libelle = txtLibelle.Text;
             var te = cmbTeteEngin.SelectedItem as LoadCombo;
             T.IdTeteEngins = te.Id;
             var be = cmbBenneEngin.SelectedItem as LoadCombo;
             T.IdBenneEngins = be.Id;
             if (Id > 0)
             {
                 T.Id = Id;
                 var k = BenneEngin.getUnBenneEngin(be.Id);
                 T.BenneEngin = k;
                 var m = TeteEngin.getTeteEngin(te.Id);
                 T.TeteEngin = m;
                 T.Update();
                 MessageBox.Show("Modification effectuée !");
                 LoadTabVehicule();
                 emptyCombo();
                 GriserChamps();
                 Id = 0;
             }
             else
             {
                 T.Insert();
                 var k = BenneEngin.getUnBenneEngin(be.Id);
                 T.BenneEngin = k;
                 var m = TeteEngin.getTeteEngin(te.Id);
                 T.TeteEngin = m;
                 ListVehicule.Add(T);
                 TabVehicule.Items.Refresh();
                 MessageBox.Show("Enregistrement effectué !");
                 emptyCombo();
                 GriserChamps();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private string concatValue(int id, int cas = 1)
        {
            string strValue = "";

            if (cas == 1)
            {
                strValue = BenneEngin.getUnBenneEngin(id).Matricule + ' ' + BenneEngin.getUnBenneEngin(id).Marque;
            }
            else
            {
                strValue = TeteEngin.getTeteEngin(id).Matricule + ' ' + TeteEngin.getTeteEngin(id).Modele;
            }
            return(strValue);
        }
예제 #3
0
 private void BtnSupprimer_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TabTeteEngin.SelectedIndex != -1)
         {
             TeteEngin Tab = (TeteEngin)TabTeteEngin.SelectedItem;
             var       T   = TeteEngin.getTeteEngin(Tab.Id);
             T.Supprime = true;
             T.Delete();
             LoadTabTeteEngin();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }