private void CFormEditVariableFiltreCalculee_Load(object sender, System.EventArgs e)
        {
            // Lance la traduction du formulaire
            sc2i.win32.common.CWin32Traducteur.Translate(this);

            m_cmbOperation.ValueMember   = "Valeur";
            m_cmbOperation.DisplayMember = "Libelle";
            m_cmbOperation.DataSource    = CUtilSurEnum.GetCouplesFromEnum(typeof(OperationsAgregation));
            m_cmbOperation.SelectedValue = (int)m_champ.OperationAgregation;

            //Types finaux
            m_cmbTypeFinal.Items.Clear();
            List <CInfoClasseDynamique> lstTypes = new List <CInfoClasseDynamique>();

            lstTypes.Add(new CInfoClasseDynamique(typeof(DBNull), I.T("Default|20007")));
            lstTypes.Add(new CInfoClasseDynamique(typeof(int), C2iTypeDonnee.GetLibelleType(TypeDonnee.tEntier)));
            lstTypes.Add(new CInfoClasseDynamique(typeof(string), C2iTypeDonnee.GetLibelleType(TypeDonnee.tString)));
            lstTypes.Add(new CInfoClasseDynamique(typeof(bool), C2iTypeDonnee.GetLibelleType(TypeDonnee.tBool)));
            lstTypes.Add(new CInfoClasseDynamique(typeof(DateTime), C2iTypeDonnee.GetLibelleType(TypeDonnee.tDate)));
            lstTypes.Add(new CInfoClasseDynamique(typeof(double), C2iTypeDonnee.GetLibelleType(TypeDonnee.tDouble)));
            m_cmbTypeFinal.DataSource    = lstTypes;
            m_cmbTypeFinal.ValueMember   = "Classe";
            m_cmbTypeFinal.DisplayMember = "Nom";

            Type tp = m_champ.TypeDonneeFinalForce;

            if (tp == null)
            {
                tp = typeof(DBNull);
            }
            try
            {
                m_cmbTypeFinal.SelectedValue = tp;
            }
            catch
            { }

            m_chkGrouper.Checked = m_champ.GroupBy;
            //m_lblSource.Text = m_champ.Source;
            m_txtNomChamp.Text    = m_champ.NomChamp;
            m_txtFonctionSql.Text = m_champ.FonctionSql;

            int nIndex = 0;

            foreach (CSourceDeChampDeRequete source in m_champ.Sources)
            {
                CPanelSourceDeRequete panel = new CPanelSourceDeRequete();
                panel.Dock = DockStyle.Top;
                m_panelSources.Controls.Add(panel);
                panel.BringToFront();
                panel.Init(source, nIndex++, m_typeSource, m_defRacineDeChamps);
            }
        }
        private void m_lnkAjouterSource_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CSourceDeChampDeRequete source = new CSourceDeChampDeRequete("");
            CPanelSourceDeRequete   panel  = new CPanelSourceDeRequete();

            panel.Dock = DockStyle.Top;
            m_panelSources.Controls.Add(panel);
            panel.BringToFront();

            // Initialise le nouveau control avec l'index incrémenté de 1
            int nIndexControls = m_panelSources.Controls.Count;

            panel.Init(
                source,
                nIndexControls > 0 ? nIndexControls - 1  : 0,
                m_typeSource,
                m_defRacineDeChamps);
            panel.Focus();
        }
        private void m_btnOk_Click(object sender, System.EventArgs e)
        {
            if (m_cmbOperation.SelectedValue == null)
            {
                CFormAlerte.Afficher(I.T("Select an operation|30009"), EFormAlerteType.Exclamation);
                return;
            }
            m_champ.GroupBy             = m_chkGrouper.Checked;
            m_champ.OperationAgregation = (OperationsAgregation)m_cmbOperation.SelectedValue;
            if (m_txtNomChamp.Text.Trim() == "")
            {
                CFormAlerte.Afficher(I.T("Enter a field name|30008"), EFormAlerteType.Exclamation);
                return;
            }
            ArrayList lst = new ArrayList(m_panelSources.Controls);

            lst.Sort(new CPanelSourceComparer());
            ArrayList lstSources = new ArrayList();

            foreach (Control ctrl in lst)
            {
                if (ctrl is CPanelSourceDeRequete)
                {
                    CPanelSourceDeRequete panel = (CPanelSourceDeRequete)ctrl;
                    if (panel.Source != null)
                    {
                        lstSources.Add(panel.Source);
                    }
                }
            }
            m_champ.Sources     = (CSourceDeChampDeRequete[])lstSources.ToArray(typeof(CSourceDeChampDeRequete));
            m_champ.FonctionSql = m_txtFonctionSql.Text.Trim();
            m_champ.NomChamp    = m_txtNomChamp.Text.Replace(" ", "_").Trim();
            Type tp = m_cmbTypeFinal.SelectedValue as Type;

            if (tp == typeof(DBNull))
            {
                tp = null;
            }
            m_champ.TypeDonneeFinalForce = tp;
            DialogResult = DialogResult.OK;
            Close();
        }