private void buttonAfficherJob_Click(object sender, EventArgs e) { if (dataGridViewListingJob.SelectedRows.Count == 1) { int value; Int32.TryParse(dataGridViewListingJob.SelectedCells[0].Value.ToString(), out value); Connectds.jobRow jobSelectionne; jobSelectionne = EntrepriseManager.GetJob(value); Job jobDetail = new Job(jobSelectionne); jobDetail.MdiParent = HomePage.ActiveForm; jobDetail.Show(); this.Close(); } }
private void PopulateAndBind(int jobID) { ds = EntrepriseManager.GetDS(); comboBoxEntreprise.DataSource = ds; comboBoxEntreprise.ValueMember = "entreprise.entreprise_id"; comboBoxEntreprise.DisplayMember = "entreprise.nom_entreprise"; if (id != -1) { jobRow = EntrepriseManager.GetJob(id); comboBoxEntreprise.SelectedValue = jobRow.entreprise_id; comboBoxEntreprise.Enabled = false; if (!jobRow.Isetudiant_idNull()) { etudiantRow = EtudiantManager.GetEtudiant(jobRow.etudiant_id); textBoxEtudiantJob.Text = etudiantRow.etudiant_id + " - " + etudiantRow.nom_etudiant + " " + etudiantRow.prenom_etudiant; } textBoxJobID.Text = jobID.ToString(); buttonValiderJob.Text = "Modifier"; } else { if (entrepriseID != -1) { comboBoxEntreprise.SelectedValue = entrepriseID; } Connectds.jobDataTable jobDT = new Connectds.jobDataTable(); jobRow = (Connectds.jobRow)jobDT.NewjobRow(); //Tentative de contourner les contraintes de FK not null du DataSet: //jobRow.Setetudiant_idNull(); jobRow.etudiant_id = 1; comboBoxEntreprise.DropDownStyle = ComboBoxStyle.DropDownList; jobRow.titre_job = string.Empty; jobRow.descriptif_job = string.Empty; jobRow.profil_job = string.Empty; jobRow.date_debut_job = DateTime.Now; jobRow.date_fin_job = DateTime.Now; jobRow.horaire_job = string.Empty; jobRow.remuneration_job = 0; jobRow.permis_voiture_job = false; jobRow.remarque_job = string.Empty; jobRow.date_publication_job = DateTime.Now; jobRow.statut_job = false; labelJob.Visible = false; textBoxJobID.Visible = false; } textBoxIntituleJob.DataBindings.Add("Text", jobRow, "titre_job"); textBoxDescriptif.DataBindings.Add("Text", jobRow, "descriptif_job"); textBoxProfilJob.DataBindings.Add("Text", jobRow, "profil_job"); datePickerDebutJob.DataBindings.Add("Value", jobRow, "date_debut_job"); datePickerFinJob.DataBindings.Add("Value", jobRow, "date_fin_job"); textBoxHoraireJob.DataBindings.Add("Text", jobRow, "horaire_job"); numericUpDownSalaireJob.DataBindings.Add("Value", jobRow, "remuneration_job"); textBoxRmqJob.DataBindings.Add("Text", jobRow, "remarque_job"); datePickerPublicationJob.DataBindings.Add("Value", jobRow, "date_publication_job"); // création du binding pour le radiobutton "Oui" (permis) var permisJobBinding = new Binding("Checked", jobRow, "permis_voiture_job"); // Format = lecture à partir du datasource, retourne "true" s'il lit la valeur true permisJobBinding.Format += (s, args) => args.Value = ((bool)args.Value) == true; // Parse = écriture dans le datasource, retourne la valeur true s'il lit true, sinon il retourne false permisJobBinding.Parse += (s, args) => args.Value = (bool)args.Value ? true : false; // Binding: radioButtonPermisOuiJob.DataBindings.Add(permisJobBinding); // création du binding pour le radiobutton "Non" (permis) var permisJobNonBinding = new Binding("Checked", jobRow, "permis_voiture_job"); // Format = lecture à partir du datasource, retourne "true" s'il lit la valeur false permisJobNonBinding.Format += (s, args) => args.Value = ((bool)args.Value) == false; // Parse = écriture dans le datasource, retourne la valeur false s'il lit true, sinon il retourne true permisJobNonBinding.Parse += (s, args) => args.Value = (bool)args.Value ? false : true; // Binding: radioButtonPermisNonJob.DataBindings.Add(permisJobNonBinding); }