private void buttonSelectionRechercheEtudiant_Click(object sender, EventArgs e) { // Petit "bricolage" qui permet d'outrepasser les protections du DataSet concernant la FK etudiant_id. Utilisation de l'ID n°1 de la table étudiant // comme valeur "null" if (jobRow.etudiant_id == 1) { Connectds.jobDataTable dt = new Connectds.jobDataTable(); dt = EntrepriseManager.GetJobDT(); jobRow = dt.Last <Connectds.jobRow>(); } int value; if (dataGridViewRechercheEtudiant.SelectedRows.Count == 1) { Int32.TryParse(dataGridViewRechercheEtudiant.SelectedCells[0].Value.ToString(), out value); jobRow.etudiant_id = value; jobRow.statut_job = true; EntrepriseManager.SaveJob(jobRow); this.Close(); Job jobDetail = new Job(jobRow); jobDetail.MdiParent = HomePage.ActiveForm; jobDetail.Show(); } else { MessageBox.Show("Veuillez sélectionner un étudiant", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Valider() { if (jobRow.date_debut_job <= jobRow.date_fin_job) { if (textBoxEtudiantJob.Text != string.Empty) { jobRow.statut_job = true; //attribué jobRow.etudiant_id = etudiantRow.etudiant_id; } else { jobRow.statut_job = false; } if (id == -1) { int idEntreprise; Int32.TryParse(comboBoxEntreprise.SelectedValue.ToString(), out idEntreprise); entrepriseRow = EntrepriseManager.GetEntreprise(idEntreprise); if (entrepriseRow.statut_entreprise) //si l'entreprise est active, on peut ajouter un nouveau job { jobRow.entreprise_id = idEntreprise; EntrepriseManager.AddJob(jobRow); } else { MessageBox.Show("Le statut de l'entreprise n°" + entrepriseRow.entreprise_id + " est inactif. Vous ne pouvez pas lui créer de nouveaux jobs", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { EntrepriseManager.SaveJob(jobRow); } } else { MessageBox.Show("La date de début doit se situer avant la date de fin", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }