Example #1
0
        private void buttonValidAssoPortefeuille_Click(object sender, EventArgs e)
        {
            if (dataGridViewCommerciaux.SelectedRows.Count == 1)
            {
                Utilisateur lutilisateur = (Utilisateur)dataGridViewCommerciaux.CurrentRow.DataBoundItem;

                if (lutilisateur.porteFeuille == null)
                {
                    PorteFeuille lePortefeuille = (PorteFeuille)dataGridViewPortefeuilles.CurrentRow.DataBoundItem;

                    MessageBox.Show("Vous allez associer le comercial: " + lutilisateur + " au portefeuille " + lePortefeuille);

                    ISession session = sessionFactory.OpenSession();
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        lutilisateur.porteFeuille  = null;
                        lePortefeuille.utilisateur = lutilisateur;
                        session.Update(lutilisateur);
                        session.Update(lePortefeuille);
                        transaction.Commit();
                    }
                    MessageBox.Show("Nouveau commercial associé au portefeuille");
                }
                else if (lutilisateur.porteFeuille != null)
                {
                    MessageBox.Show("Le commercial possède déjà un portefeuille: " + lutilisateur.porteFeuille);
                }
            }
            else
            {
                MessageBox.Show("Merci de séléctionner un nouveau commercial à associer");
            }
        }
Example #2
0
        private void buttonVal_Click(object sender, EventArgs e)
        {
            buttonVal.DialogResult = DialogResult.OK;
            using (ISession session = sessionFactory.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    if (radioButtonAjout.Checked == true)
                    {
                        PorteFeuille portefeuille = new PorteFeuille();
                        portefeuille.libellePortefeuille = textBoxPF.Text;
                        if (checkBoxselect.Checked == true)
                        {
                            portefeuille.utilisateur = (Utilisateur)comboBoxCom.SelectedItem;
                        }
                        else
                        {
                            portefeuille.utilisateur = null;
                        }
                        session.SaveOrUpdate(portefeuille);
                        transaction.Commit();
                    }
                    if (radioButtonModif.Checked == true)
                    {
                        portefeuille.libellePortefeuille = textBoxPF.Text;
                        portefeuille.utilisateur         = (Utilisateur)comboBoxCom.SelectedItem;
                        session.SaveOrUpdate(portefeuille);
                        transaction.Commit();
                    }
                }

                session.Dispose();
            }
        }
Example #3
0
 private void dataGridViewPFIP_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewPFII.Visible == true)
     {
         //On charge le portefeuille selectionné dans 'lePortefeuilleSelected'
         PorteFeuille lePortefeuilleSelected = (PorteFeuille)dataGridViewPFIP.CurrentRow.DataBoundItem;
         ISession     session = sessionFactory.OpenSession();
         dataGridViewPFII.DataSource = session.CreateQuery(@"select e from Individu e where e.interlocuteur.porteFeuille.idPorteFeuille =:idPorteFeuille
         ").SetInt32("idPorteFeuille", lePortefeuilleSelected.idPorteFeuille).List <Individu>();
     }
     else if (dataGridViewPFIIS.Visible == true)
     {
         //On charge le portefeuille selectionné dans 'lePortefeuilleSelected'
         PorteFeuille lePortefeuilleSelected = (PorteFeuille)dataGridViewPFIP.CurrentRow.DataBoundItem;
         ISession     session = sessionFactory.OpenSession();
         dataGridViewPFIIS.DataSource = session.CreateQuery(@"select e from InterlocuteurStructure e where e.interlocuteur.porteFeuille.idPorteFeuille =:idPorteFeuille
         ").SetInt32("idPorteFeuille", lePortefeuilleSelected.idPorteFeuille).List <InterlocuteurStructure>();
     }
 }
Example #4
0
        private void dataGridViewCommerciaux_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //la couleur de dataGridViewCommerciaux devient bleu, la coleur de dataGridViewPortefeuilles sera verte
            dataGridViewCommerciaux.DefaultCellStyle.SelectionBackColor   = Color.Blue;
            dataGridViewPortefeuilles.DefaultCellStyle.SelectionBackColor = Color.GreenYellow;

            //On charge le commercial selectionné dans 'leCommercialSelected'
            Utilisateur leCommercialSelected = (Utilisateur)dataGridViewCommerciaux.CurrentRow.DataBoundItem;

            //On parcours le dataGridViewPortefeuilles à la recherche du même 'leCommercialSelected.numUtilisateur' que celui présent dans portefeuille
            foreach (DataGridViewRow row in dataGridViewPortefeuilles.Rows)
            {
                PorteFeuille lePortefeuille = (PorteFeuille)row.DataBoundItem;
                //Si on trouve on selectionne le champ correspondant
                if (leCommercialSelected.numUtilisateur == lePortefeuille.utilisateur.numUtilisateur)
                {
                    row.Selected = true;
                }
                else if (row.Selected == true)
                {
                    row.Selected = false;                            //sinon on le désélectionne
                }
            }
        }