public void btnAjoutAvenant_Click(object sender, EventArgs e) { ctrlNouvAvenant nouvelAvenant = new ctrlNouvAvenant(this.leContrat); if (nouvelAvenant.Resultat == true) { AvenantDAOEFStatic.InstancieAvenants(this.leContrat); } this.leForm.grdAvenant.DataSource = leContrat.ListerAvenants(); }
public ctrlNouvAvenant(MContrat leContrat) { leForm = new frmAvenant(); leForm.btnAnnuler.Click += this.btnAnnuler_Click; leForm.btnValider.Click += this.btnValider_Click; if (leForm.ShowDialog() == DialogResult.OK) { lAvenant = new MAvenant(leForm.dtpDateEtablissement.Value.Date); AvenantDAOEFStatic.InsereAvenant(lAvenant, leContrat); this.Resultat = true; } }
/// <summary> /// Constructeur, remplit les champs avec les informations du MContrat reçu en paramètre et initialise selon le type de contrat /// </summary> /// <param name="unContrat">instance du contrat à afficher</param> public frmContrat(MContrat unContrat) { if (unContrat is MCdd) { InitializeComponent(); this.ModeCdd(); this.masqueGridview(); this.txtNumContrat.Text = Convert.ToString(unContrat.NumContrat); this.txtQualif.Text = unContrat.Qualification; this.txtMotif.Text = (unContrat as MCdd).Motif; this.dtpDateDebut.Value = unContrat.DateDebutContrat; this.dtpDateFinPrev.Value = (unContrat as MCdd).DateFinPrevue; this.txtSalaire.Text = Convert.ToString((unContrat as MCdd).SalaireBrut); if ((unContrat as MCdd).DateFinContrat == null) { this.chkFinNonConnue.Checked = true; this.dtpDateFin.Enabled = false; } else { this.chkFinNonConnue.Checked = false; this.dtpDateFin.Value = (DateTime)unContrat.DateFinContrat; } AvenantDAOEFStatic.InstancieAvenants(unContrat); this.grdAvenant.DataSource = unContrat.ListerAvenants(); this.grdAvenant.Refresh(); } else if (unContrat is MCdi) { InitializeComponent(); this.ModeCdi(); this.rbtCdi.Checked = true; this.masqueGridview(); this.txtNumContrat.Text = Convert.ToString(unContrat.NumContrat); this.txtQualif.Text = unContrat.Qualification; this.dtpDateDebut.Value = unContrat.DateDebutContrat; this.txtSalaire.Text = Convert.ToString((unContrat as MCdi).SalaireBrut); if ((unContrat as MCdi).DateFinContrat == null) { this.chkFinNonConnue.Checked = true; this.dtpDateFin.Enabled = false; } else { this.chkFinNonConnue.Checked = false; this.dtpDateFin.Value = (DateTime)unContrat.DateFinContrat; } AvenantDAOEFStatic.InstancieAvenants(unContrat); this.grdAvenant.DataSource = unContrat.ListerAvenants(); this.grdAvenant.Refresh(); } else if (unContrat is MStage) { InitializeComponent(); this.ModeStage(); this.rbtStage.Checked = true; this.masqueGridview(); this.txtNumContrat.Text = Convert.ToString(unContrat.NumContrat); this.txtQualif.Text = unContrat.Qualification; this.txtIndemnite.Text = Convert.ToString((unContrat as MStage).Indemnite); this.txtMotif.Text = (unContrat as MStage).Motif; this.txtMission.Text = (unContrat as MStage).Mission; this.dtpDateDebut.Value = unContrat.DateDebutContrat; this.dtpDateFinPrev.Value = (unContrat as MStage).DateFinPrevue; if ((unContrat as MStage).DateFinContrat == null) { this.chkFinNonConnue.Checked = true; this.dtpDateFin.Enabled = false; } else { this.chkFinNonConnue.Checked = false; this.dtpDateFin.Value = (DateTime)unContrat.DateFinContrat; } this.txtEcole.Text = (unContrat as MStage).Ecole; AvenantDAOEFStatic.InstancieAvenants(unContrat); this.grdAvenant.Refresh(); this.grdAvenant.DataSource = unContrat.ListerAvenants(); } else { InitializeComponent(); this.ModeInterim(); this.rbtInterim.Checked = true; this.masqueGridview(); this.txtNumContrat.Text = Convert.ToString(unContrat.NumContrat); this.txtQualif.Text = unContrat.Qualification; this.txtMotif.Text = (unContrat as MInterim).Motif; this.dtpDateDebut.Value = unContrat.DateDebutContrat; this.dtpDateFinPrev.Value = (unContrat as MInterim).DateFinPrevue; if ((unContrat as MInterim).DateFinContrat == null) { this.chkFinNonConnue.Checked = true; this.dtpDateFin.Enabled = false; } else { this.chkFinNonConnue.Checked = false; this.dtpDateFin.Value = (DateTime)unContrat.DateFinContrat; } this.txtAgence.Text = (unContrat as MInterim).AgenceInterim; AvenantDAOEFStatic.InstancieAvenants(unContrat); this.grdAvenant.Refresh(); this.grdAvenant.DataSource = unContrat.ListerAvenants(); } }