//-------------------------------------------------------------------
        public object[] GetValues(CChartSetup chart)
        {
            List <object>         lstValeurs = new List <object>();
            CParametreSourceChart p          = chart.ParametresDonnees.GetSourceFV(SourceId);

            if (p != null)
            {
                CEasyQuery query = p.GetSource(chart) as CEasyQuery;
                if (query != null)
                {
                    //trouve la table
                    DataTable table = query.GetTable(TableName);
                    if (table != null)
                    {
                        DataColumn col = table.Columns[ColumnName];
                        if (col != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                object val = row[col];
                                if (val == DBNull.Value)
                                {
                                    lstValeurs.Add(null);
                                }
                                else
                                {
                                    lstValeurs.Add(val);
                                }
                            }
                        }
                        else if (Formule != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                CDynamicDataTableRow          dr  = new CDynamicDataTableRow(row);
                                CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(dr);
                                CResultAErreur result             = Formule.Eval(ctx);
                                if (result)
                                {
                                    lstValeurs.Add(result.Data);
                                }
                                else
                                {
                                    lstValeurs.Add(null);
                                }
                            }
                        }
                    }
                }
            }
            return(lstValeurs.ToArray());
        }
Exemple #2
0
 //-----------------------------------------------------------------
 private void FillChamps()
 {
     m_comboChamp.BeginUpdate();
     m_comboChamp.Items.Clear();
     if (m_comboTable.Text.Length > 0)
     {
         CParametreSourceChart p = m_chartSetup.ParametresDonnees.GetSourceFV(m_fournisseur.SourceId);
         if (p != null)
         {
             CEasyQuery query = p.GetSource(m_chartSetup) as CEasyQuery;
             if (query != null)
             {
                 foreach (C2iObjetGraphique obj in query.Childs)
                 {
                     IObjetDeEasyQuery oe = obj as IObjetDeEasyQuery;
                     if (oe != null)
                     {
                         if (oe.NomFinal == m_comboTable.Text)
                         {
                             DataTable table = query.GetTable(oe.NomFinal);
                             if (table != null)
                             {
                                 foreach (DataColumn col in table.Columns)
                                 {
                                     m_comboChamp.Items.Add(col.ColumnName);
                                 }
                             }
                             CDynamicDataTableDef    tableDef = new CDynamicDataTableDef(table);
                             CDynamicDataTableRowDef rowDef   = new CDynamicDataTableRowDef(tableDef);
                             m_txtFormule.Init(new CFournisseurGeneriqueProprietesDynamiques(),
                                               new CObjetPourSousProprietes(rowDef));
                         }
                     }
                 }
             }
         }
     }
     m_comboChamp.EndUpdate();
     m_comboChamp.SelectedItem = m_fournisseur.ColumnName;
 }
Exemple #3
0
        //-----------------------------------------------------------------
        public CResultAErreur MajChamps()
        {
            CResultAErreur result = CResultAErreur.True;

            if (m_comboTable.Text.Length == 0)
            {
                result.EmpileErreur(I.T("Select a table|20020"));
                return(result);
            }
            if (m_rbtnFormule.Checked && m_txtFormule.Formule == null)
            {
                result.EmpileErreur(I.T("Select a field or a formula|20034"));
                return(result);
            }

            //Vérifie que la sélection est valide
            CParametreSourceChart p = m_chartSetup.ParametresDonnees.GetSourceFV(m_fournisseur.SourceId);
            CEasyQuery            q = p != null?p.GetSource(m_chartSetup) as CEasyQuery : null;

            if (q == null)
            {
                result.EmpileErreur(I.T("Invalid source|20021"));
                return(result);
            }
            //Trouve la table
            IObjetDeEasyQuery oqSel = null;

            foreach (C2iObjetGraphique objet in q.Childs)
            {
                IObjetDeEasyQuery o = objet as IObjetDeEasyQuery;
                if (o != null && o.NomFinal == m_comboTable.Text)
                {
                    oqSel = o;
                    break;
                }
            }
            if (oqSel == null)
            {
                result.EmpileErreur(I.T("Invalid table name (@1)|20022", m_comboTable.Text));
                return(result);
            }
            DataColumn colSel = null;
            DataTable  table  = q.GetTable(oqSel.NomFinal);

            if (m_rbtnField.Checked)
            {
                foreach (DataColumn col in table.Columns)
                {
                    if (col.ColumnName == m_comboChamp.Text)
                    {
                        colSel = col;
                        break;
                    }
                }
                if (colSel == null)
                {
                    result.EmpileErreur(I.T("Invalid column name @1|20023", m_comboChamp.Text));
                    return(result);
                }
            }
            if (m_rbtnFormule.Checked)
            {
                if (!m_txtFormule.ResultAnalyse && colSel == null)
                {
                    result.EmpileErreur(m_txtFormule.ResultAnalyse.Erreur);
                }
                else
                {
                    m_fournisseur.Formule    = m_txtFormule.Formule;
                    m_fournisseur.ColumnName = "";
                }
            }

            if (colSel != null)
            {
                m_fournisseur.ColumnName = colSel.ColumnName;
                m_fournisseur.Formule    = null;
            }
            m_fournisseur.TableName = oqSel.NomFinal;
            return(result);
        }