public static DepartementViewModel getDepartement(int idDepartement) { DepartementDAO pDAO = DepartementDAO.getDepartement(idDepartement); DepartementViewModel p = new DepartementViewModel(pDAO.idDepartementDAO, pDAO.nomDepartementDAO, pDAO.numeroDepartementDAO); return(p); }
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); } }
public static ObservableCollection <DepartementViewModel> listeDepartement() { ObservableCollection <DepartementDAO> lDAO = DepartementDAO.listeDepartement(); ObservableCollection <DepartementViewModel> l = new ObservableCollection <DepartementViewModel>(); foreach (DepartementDAO element in lDAO) { DepartementViewModel p = new DepartementViewModel(element.idDepartementDAO, element.nomDepartementDAO, element.numeroDepartementDAO); l.Add(p); } return(l); }
private void nomPrenomButton_Click_1(object sender, EventArgs e) { myDataObject = new DepartementViewModel(); myDataObject.numeroDepartementProperty = numeroDepartementTextBox.Text; myDataObject.nomDepartementProperty = nomDepartementTextBox.Text; DepartementViewModel nouveau = new DepartementViewModel(0, myDataObject.nomDepartementProperty, myDataObject.numeroDepartementProperty); lp.Add(nouveau); DepartementORM.insertDepartement(nouveau); lp = DepartementORM.listeDepartement(); numeroDepartementTextBox.Text = string.Empty; nomDepartementTextBox.Text = string.Empty; }
public static void insertDepartement(DepartementViewModel d) { DepartementDAO.insertDepartement(new DepartementDAO(d.idDepartementProperty, d.nomDepartementProperty, d.numeroDepartementProperty)); }