private void Popup_NewClient_Load(object sender, EventArgs e)
        {
            ISession session = sessionFactory.OpenSession();

            using (session)
            {
                TypeStructure lesTypeStructure = new TypeStructure();
                comboBoxTS.DataSource             = lesTypeStructure.GetLesTypesStructure();
                groupBoxAS.Visible                = false;
                comboBoxChoixStructure.DataSource = session.CreateQuery(@"select e from Structure e order by e.denominationSociale asc").List <Structure>();
                session.Dispose();
            }
        }
Example #2
0
        private void Popup_ModifierClient_Load(object sender, EventArgs e)
        {
            ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();
            ISession        session        = sessionFactory.OpenSession();

            using (ITransaction transaction = session.BeginTransaction())
            {
                TypeStructure lesTypeStructure = new TypeStructure();
                comboBoxTS.DataSource             = lesTypeStructure.GetLesTypesStructure();
                comboBoxChoixStructure.DataSource = session.CreateQuery(@"select e from Structure e order by e.denominationSociale asc").List <Structure>();

                if (interlocuteur != null)
                {
                    if (interlocuteur.nomInterlocuteur != null)
                    {
                        textBoxNom.Text = interlocuteur.nomInterlocuteur;
                    }

                    if (interlocuteur.prenomInterlocuteur != null)
                    {
                        textBoxPrenom.Text = interlocuteur.prenomInterlocuteur;
                    }

                    if (interlocuteur.telInterlocuteur != null)
                    {
                        textBoxTel.Text = interlocuteur.telInterlocuteur;
                    }

                    if (interlocuteur.telInterlocuteur != null)
                    {
                        textBoxTel.Text = interlocuteur.telInterlocuteur;
                    }

                    if (interlocuteur.mailInterlocuteur != null)
                    {
                        textBoxMail.Text = interlocuteur.mailInterlocuteur;
                    }

                    // Si l'interlocuteur est un particulier
                    if (isIndividu)
                    {
                        Individu individu = session.CreateQuery("select e from Individu e where e.interlocuteur.idInterlocuteur=:num").SetParameter("num", interlocuteur.idInterlocuteur).UniqueResult <Individu>();

                        if (individu.adresseIndividu != null)
                        {
                            textBoxAdresse.Text = individu.adresseIndividu;
                        }

                        if (individu.cpIndividu != null)
                        {
                            textBoxCp.Text = individu.cpIndividu;
                        }

                        if (individu.villeIndividu != null)
                        {
                            textBoxVille.Text = individu.villeIndividu;
                        }

                        if (individu.distanceSiege != null)
                        {
                            textBoxDistance.Text = individu.distanceSiege.ToString();
                        }

                        if (individu.infosSupplementaire != null)
                        {
                            textBoxIC.Text = individu.infosSupplementaire;
                        }
                    }

                    // Si l'interlocuteur est un interlocuteur_structure
                    if (!isIndividu)
                    {
                        groupBoxParticulier.Visible        = false;
                        groupBoxStructureExistante.Visible = true;

                        InterlocuteurStructure interlocuteurStructure = session.CreateQuery("select e from InterlocuteurStructure e where e.interlocuteur.idInterlocuteur=:num").SetParameter("num", interlocuteur.idInterlocuteur).UniqueResult <InterlocuteurStructure>();

                        if (interlocuteurStructure.structure != null)
                        {
                            foreach (Structure s in comboBoxChoixStructure.Items)
                            {
                                if (s.numStructure == interlocuteurStructure.structure.numStructure)
                                {
                                    comboBoxChoixStructure.SelectedItem = s;
                                }
                            }
                        }
                    }
                }
                session.Dispose();
            }
        }