Exemplo n.º 1
0
        private void PopulateAndBind()
        {
            ds = EntrepriseManager.GetDS();
            labelEntrepriseListingJob.Visible    = false;
            comboBoxEntrepriseListingJob.Visible = false;
            buttonSelectEntrepriseJob.Text       = "Sélectionner Entreprise";

            dataGridViewListingJob.DataSource               = ds;
            dataGridViewListingJob.DataMember               = "job";
            dataGridViewListingJob.Columns[2].Visible       = false;
            dataGridViewListingJob.Columns[3].Visible       = false;
            dataGridViewListingJob.Columns[6].Visible       = false;
            dataGridViewListingJob.Columns[7].Visible       = false;
            dataGridViewListingJob.Columns[9].Visible       = false;
            dataGridViewListingJob.Columns[11].Visible      = false;
            dataGridViewListingJob.Columns[12].Visible      = false;
            dataGridViewListingJob.Columns[0].HeaderText    = "ID Job";
            dataGridViewListingJob.Columns[1].HeaderText    = "Intitulé";
            dataGridViewListingJob.Columns[15].HeaderText   = "Entreprise";
            dataGridViewListingJob.Columns[15].DisplayIndex = 2;
            dataGridViewListingJob.Columns[4].HeaderText    = "Début";
            dataGridViewListingJob.Columns[5].HeaderText    = "Fin";
            dataGridViewListingJob.Columns[8].HeaderText    = "Permis voiture";
            dataGridViewListingJob.Columns[13].HeaderText   = "ID Etudiant";
            dataGridViewListingJob.Columns[13].DisplayIndex = 11;
            dataGridViewListingJob.Columns[14].HeaderText   = "Etudiant";
            dataGridViewListingJob.Columns[14].DisplayIndex = 12;
            dataGridViewListingJob.Columns[10].HeaderText   = "Attribué";
            dataGridViewListingJob.Columns[10].SortMode     = DataGridViewColumnSortMode.Automatic; // permet de trier les jobs attribués ou non (pas de tri par défaut pour les colonnes de type bit)
        }
Exemplo n.º 2
0
        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);
        }