public FormMain() { Services service1 = new Services(1, "Production"); Services service2 = new Services(2, "Comptabilité"); Services service3 = new Services(3, "Direction"); entreprise.AjouterPersonne(new Employe(1, "DUPONT", "Charles", Personnel.Gender.male, new DateTime(1998, 04, 12), 1500, service1, 14)); entreprise.AjouterPersonne(new Employe(2, "KERBAN", "Henry", Personnel.Gender.female, new DateTime(1981, 09, 24), 1500, service1, 7)); entreprise.AjouterPersonne(new Employe(3, "CHAMPOT", "Paul", Personnel.Gender.male, new DateTime(1981, 03, 17), 1500, service1, 6)); entreprise.AjouterPersonne(new Cadre(4, "JOULIE", "Alexandre", Personnel.Gender.female, new DateTime(1987, 11, 21), 2100, service2, 100)); entreprise.AjouterPersonne(new Cadre(5, "MITAUT", "Marcel", Personnel.Gender.female, new DateTime(1972, 10, 06), 6000, service3, 2000)); InitializeComponent(); }
public FormMain() { // Au début on entre les valeurs en dur Service production = new Service(1, "Production"); entreprise.AjouterService(production); Service compta = new Service(2, "Comptabilité"); entreprise.AjouterService(compta); Service direction = new Service(3, "Direction"); entreprise.AjouterService(direction); entreprise.AjouterPersonne(new Employe(1, "DUPONT", "Charles", new DateTime(1998, 04, 12), 1500, production, 30)); entreprise.AjouterPersonne(new Employe(2, "KERBAN", "Henry", new DateTime(1981, 09, 24), 1500, production, 30)); entreprise.AjouterPersonne(new Employe(3, "CHAMPOT", "Paul", new DateTime(1981, 09, 17), 1500, production, 30)); entreprise.AjouterPersonne(new Cadre(4, "JOULIE", "Alexandre", new DateTime(1987, 11, 21), 2100, compta, 100, Cadre.TypeStatut.Financier)); entreprise.AjouterPersonne(new Cadre(5, "MITAUT", "Marcel", new DateTime(1972, 03, 04), 6000, direction, 2000, Cadre.TypeStatut.Administratif)); InitializeComponent(); }
private void btnOK_Click(object sender, EventArgs e) { // Nous validons les changements dans l'objet Entreprise if (personne != null) { // Mise à jour du service personne.Service = (cbService.SelectedItem as Service); entreprise.ModifierPersonne(personne); // La valeur renvoyé est donc OK this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.Cancel; } switch (this.mode) { case FormPersonneMode.Ajout: try { Personne.TypePersonneEnum statut = (Personne.TypePersonneEnum)Enum.Parse(typeof(Personne.TypePersonneEnum), cbType.SelectedItem.ToString());; switch (statut) { case Personne.TypePersonneEnum.Employe: personne = new Employe(0, txtNom.Text, txtPrenom.Text, dtPickerDateDenaissance.Value, Convert.ToDouble(txtSalaireBrut.Text), cbService.SelectedItem as Service, 0); break; case Personne.TypePersonneEnum.Cadre: personne = new Cadre(0, txtNom.Text, txtPrenom.Text, dtPickerDateDenaissance.Value, Convert.ToDouble(txtSalaireBrut.Text), cbService.SelectedItem as Service, 0); break; } personne.SalaireBrut = Convert.ToDouble(txtSalaireBrut.Text); // On ajoute la personne à l’objet entreprise personne = entreprise.AjouterPersonne(personne); // La valeur renvoyée est donc OK this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Erreur : " + ex.Message); this.DialogResult = DialogResult.Cancel; } break; case FormPersonneMode.Modification: if (personne != null) { // Mise à jour du service personne.Service = (cbService.SelectedItem as Service); // On modifie la personne dans l’objet entreprise entreprise.ModifierPersonne(personne); // La valeur renvoyé est donc OK this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.Cancel; } break; } }