private void ajouterButton(object sender, RoutedEventArgs e) { myDataObject.nomCommuneProperty = nomTextBox.Text; myDataObject.departementCommune = (DepartementViewModel)listeDepartementsCombo.SelectedItem; CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject.nomCommuneProperty, myDataObject.departementCommuneProperty); le.Add(nouveau); CommuneORM.insertCommune(nouveau); listeCommunes.Items.Refresh(); }
private void ajouterCommune_Click(object sender, EventArgs e) { myDataObject.nomCommuneProperty = Nom.Text; if ((DepartementViewModel)listeDepartementsCombo.SelectedItem != null) { myDataObject.departementCommune = (DepartementViewModel)listeDepartementsCombo.SelectedItem; } else { myDataObject.departementCommune = new DepartementViewModel(1, "MauvaisNumeroDepartement", 0); } CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject.nomCommuneProperty, myDataObject.departementCommune); lu.Add(nouveau); CommuneORM.insertCommune(nouveau); listeDepartementsCombo.ItemsSource = lp; listeCommunes.Items.Refresh(); listeDepartementsCombo.Items.Refresh(); listeCommunes.ItemsSource = lu; }
///////////////////////////////////// Commune ///////////////////////////////////// ///////////////////////////////////// Commune ///////////////////////////////////// private void ValideCommune_Click(object sender, RoutedEventArgs e) { myDataObject2 = new CommuneViewModel(); myDataObject2.nomCommuneProperty = NomCommune.Text; myDataObject2.CodePostaleProperty = CodePostale.Text; myDataObject2.DepartementCommune = (DepartementViewModel)listeDepartementsCombo.SelectedItem; CommuneViewModel nouveau = new CommuneViewModel(CommuneDAL.getMaxIdCommune() + 1, myDataObject2.nomCommuneProperty, myDataObject2.CodePostaleProperty, myDataObject2.DepartementCommune); lp2.Add(nouveau); CommuneORM.insertCommune(nouveau); listeDepartementsCombo.ItemsSource = lp3; listeCommunes.Items.Refresh(); listeDepartementsCombo.Items.Refresh(); listeCommunes.ItemsSource = lp2; compteur = lp2.Count(); ((TextBox)NomCommune).Text = string.Empty; ((TextBox)CodePostale).Text = string.Empty; MessageBox.Show("Commune ajoutée avec succes ! "); }