private void AjoutCommune_Click_1(object sender, EventArgs e) { try { if (codePosatelDepartementTextBox.Text.Length > 5) { throw new CodePostalCommuneInvalideException("Code Postal trop long"); } if (codePosatelDepartementTextBox.Text.Length < 5) { throw new CodePostalCommuneInvalideException("Code Postal trop court"); } if (codePosatelDepartementTextBox.Text.Length == 0) { throw new CodePostalCommuneInvalideException("Code Postal requit"); } myDataObject4 = new CommuneViewModel(); myDataObject4.nomCommuneProperty = nomCommuneTextBox.Text; myDataObject4.codePostalProperty = codePosatelDepartementTextBox.Text; DepartementViewModel departement = (DepartementViewModel)listeDepartement.SelectedItem; CommuneViewModel nouveau = new CommuneViewModel(0, myDataObject4.nomCommuneProperty, myDataObject4.codePostalProperty, departement); lp4.Add(nouveau); CommuneORM.insertCommune(nouveau); lp4 = CommuneORM.listeCommune(); nomCommuneTextBox.Text = string.Empty; codePosatelDepartementTextBox.Text = string.Empty; listeDepartement.Items.Refresh(); } catch (CodePostalCommuneInvalideException exptcodepostal) { MessageBox.Show(exptcodepostal.Message); } }
private void supprimerButton_Click(object sender, EventArgs e) { CommuneViewModel toRemove = (CommuneViewModel)listeCommunes.SelectedItem; lu.Remove(toRemove); listeCommunes.Items.Refresh(); CommuneORM.supprimerCommune(selectedCommuneId); }
public static PlageViewModel getPlage(int idPlage) { PlageDAO pDAO = PlageDAO.getPlage(idPlage); int idCommune = pDAO.idCommunePlageDAO; CommuneViewModel m = CommuneORM.getCommune(idCommune); PlageViewModel p = new PlageViewModel(pDAO.idPlageDAO, pDAO.nomPlageDAO, m, pDAO.nbEspecesDifferentesPlageDAO, pDAO.surfacePlageDAO); return(p); }
public static CommuneViewModel getCommune(int idCommune) { CommuneDAO cDAO = CommuneDAO.getCommunes(idCommune); int idDepartement = cDAO.idDepartementDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); CommuneViewModel e = new CommuneViewModel(cDAO.idCommuneDAO, cDAO.nomCommuneDAO, m); return(e); }
public AfficherCommunes() { InitializeComponent(); lu = CommuneORM.listeCommunes(); listeCommunes.ItemsSource = lu; myDataObject = new CommuneViewModel(); lp = DepartementORM.listeDepartements(); listeDepartementsCombo.ItemsSource = lp; }
public static CommuneViewModel getCommune(int idCommune) { CommuneDAO pDAO = CommuneDAO.getCommune(idCommune); int idDepartement = pDAO.DepartementCommuneDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); CommuneViewModel p = new CommuneViewModel(pDAO.idCommuneDAO, pDAO.nomCommuneDAO, pDAO.CodePostaleDAO, m); return(p); }
public static PlageViewModel getPlage(int idPlage) { PlageDAO pDAO = PlageDAO.getPlage(idPlage); int id = pDAO.idCommunePlageDAO; CommuneViewModel m = CommuneORM.getCommune(id); PlageViewModel p = new PlageViewModel(pDAO.idPlageDAO, pDAO.nomPlageDAO, m); return(p); }
public static PlageViewModel getPlage(int idPlage) { PlageDAO pDAO = PlageDAO.getPlages(idPlage); int idCommune = pDAO.idCommuneDAO; CommuneViewModel m = CommuneORM.getCommune(idCommune); // Plus propre que d'aller chercher la commune dans la DAO. PlageViewModel u = new PlageViewModel(pDAO.idPlageDAO, pDAO.nomPlageDAO, m, pDAO.nbEspecesDifferentesDAO, pDAO.surfaceDAO); return(u); }
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 supprimerButton_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { CommuneViewModel toRemove = (CommuneViewModel)listeCommunes.SelectedItem; lp2.Remove(toRemove); listeDepartementsCombo.ItemsSource = lp3; listeCommunes.Items.Refresh(); listeDepartementsCombo.Items.Refresh(); CommuneORM.supprimerCommune(selectedCommunesId); MessageBox.Show("Commune supprimée avec succes ! "); }
public static ObservableCollection <CommuneViewModel> listeCommuneDepartement(DepartementViewModel departement) { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommuneDepartement(departement.idDepartementProperty); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDep = element.idDepartementCommuneDAO; CommuneViewModel p = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, element.codePostalDAO, departement); l.Add(p); } return(l); }
public static ObservableCollection <PlageViewModel> listePlage() { ObservableCollection <PlageDAO> lDAO = PlageDAO.listePlage(); ObservableCollection <PlageViewModel> l = new ObservableCollection <PlageViewModel>(); foreach (PlageDAO element in lDAO) { int id = element.idCommunePlageDAO; CommuneViewModel m = CommuneORM.getCommune(id); PlageViewModel p = new PlageViewModel(element.idPlageDAO, element.nomPlageDAO, m); l.Add(p); } return(l); }
public static ObservableCollection <CommuneViewModel> ListeCommunes() { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommunes(); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDepartement = element.DepartementCommuneDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); CommuneViewModel p = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, element.CodePostaleDAO, m); l.Add(p); } return(l); }
public static ObservableCollection <PlageViewModel> listePlageParCommune(CommuneViewModel commune) { ObservableCollection <PlageDAO> lDAO = PlageDAO.listePlageParCommune(commune.idCommuneProperty); ObservableCollection <PlageViewModel> l = new ObservableCollection <PlageViewModel>(); foreach (PlageDAO element in lDAO) { int id = element.idCommunePlageDAO; PlageViewModel p = new PlageViewModel(element.idPlageDAO, element.nomPlageDAO, commune); l.Add(p); } return(l); }
public static ObservableCollection <PlageViewModel> listePlages() { ObservableCollection <PlageDAO> lDAO = PlageDAO.listePlages(); ObservableCollection <PlageViewModel> l = new ObservableCollection <PlageViewModel>(); foreach (PlageDAO element in lDAO) { int idCommune = element.idCommuneDAO; CommuneViewModel m = CommuneORM.getCommune(idCommune); // Plus propre que d'aller chercher la commune dans la DAO. PlageViewModel u = new PlageViewModel(element.idPlageDAO, element.nomPlageDAO, m, element.nbEspecesDifferentesDAO, element.surfaceDAO); l.Add(u); } return(l); }
public static PlageViewModel getPlage(int idPlage) { PlageDAO pDAO = PlageDAO.getPlage(idPlage); int idPrelevement = pDAO.prelevement_idprelevementDAO; int idVille = pDAO.Ville_idVilleDAO; int iDepartement = pDAO.Departement_idDepartementDAO; PrelevementViewModel pr = PrelevementORM.getPrelevement(idPrelevement); CommuneViewModel c = CommuneORM.getCommune(idVille); DepartementViewModel d = DepartementORM.getDepartement(iDepartement); PlageViewModel p = new PlageViewModel(pDAO.idPlageDAO, pDAO.nomDAO, c, pr, d); return(p); }
public static ObservableCollection <CommuneViewModel> listeCommunes() { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommunes(); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDepartement = element.idDepartementDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); // Plus propre que d'aller chercher le departement dans la DAO. CommuneViewModel e = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, m); l.Add(e); } return(l); }
public async Task <IHttpActionResult> Save([FromBody] CommuneViewModel commune) { using (var context = new RedContext()) { var newCommune = context.Communes.Add(new Commune { CommuneId = commune.CommuneId, Name = commune.Name, CountryId = commune.CountryId, DepartmentId = commune.DepartmentId, CityId = commune.CityId }); await context.SaveChangesAsync(); return(Ok(new CommuneViewModel(newCommune))); } }
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; }
public async Task <IHttpActionResult> Update([FromBody] CommuneViewModel commune) { using (var context = new RedContext()) { var ExistCommune = await context.Communes.FirstOrDefaultAsync(b => b.CommuneId == commune.CommuneId); if (ExistCommune == null) { return(NotFound()); } ExistCommune.Name = commune.Name; ExistCommune.CountryId = commune.CountryId; ExistCommune.DepartmentId = commune.DepartmentId; ExistCommune.CityId = commune.CityId; await context.SaveChangesAsync(); return(Ok(new CommuneViewModel(ExistCommune))); } }
public static ObservableCollection <PlageViewModel> listePlages() { ObservableCollection <PlageDAO> lDAO = PlageDAO.listePlages(); ObservableCollection <PlageViewModel> l = new ObservableCollection <PlageViewModel>(); foreach (PlageDAO element in lDAO) { int idPrelevement = element.prelevement_idprelevementDAO; int idVille = element.Ville_idVilleDAO; int iDepartement = element.Departement_idDepartementDAO; PrelevementDAO m = PrelevementDAO.getPrelevement(idPrelevement); CommuneDAO c = CommuneDAO.getCommune(idVille); DepartementDAO d = DepartementDAO.getDepartement(iDepartement); PrelevementViewModel prelevement = new PrelevementViewModel(m.idprelevementDAO, m.PositionGPSDAO, m.TypeDAO); CommuneViewModel commune = new CommuneViewModel(c.idVilleDAO, c.nomSpecialisteDAO, c.nomVilleDAO); DepartementViewModel departement = new DepartementViewModel(d.idDepartementDAO, d.nomDAO); PlageViewModel p = new PlageViewModel(element.idPlageDAO, element.nomDAO, commune, prelevement, departement); l.Add(p); } return(l); }
///////////////////////////////////// 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 ! "); }
public static void insertCommune(CommuneViewModel p) { CommuneDAO.insertCommune(new CommuneDAO(p.idCommuneProperty, p.nomCommuneProperty, p.departementCommune.idDepartementProperty)); }
public static void insertCommune(CommuneViewModel d) { CommuneDAO.insertCommune(new CommuneDAO(d.idCommuneProperty, d.nomCommuneProperty, d.codePostalProperty, d.departementProperty.idDepartementProperty)); }
public static void updateCommune(CommuneViewModel p) { CommuneDAO.updateCommune(new CommuneDAO(p.idCommuneProperty, p.nomCommuneProperty, p.CodePostaleProperty, p.DepartementCommuneProperty.idDepartementProperty)); }