예제 #1
0
        public CChampTimosWebApp(DataSet ds, I2iWebControl wndControl, IElementAVariables elementEdite, int nIdGroupe, string strIdCarac, bool bIsEditable)
        {
            DataTable dt = ds.Tables[c_nomTable];

            if (dt == null)
            {
                return;
            }
            m_elementAVariables = elementEdite;

            DataRow row = dt.NewRow();

            string strNomChamp   = wndControl.WebLabel;
            string strLibelleWeb = wndControl.WebLabel;
            int    nIdChampFictif;

            if (!s_dicWebControl.TryGetValue(strLibelleWeb, out nIdChampFictif))
            {
                nIdChampFictif = s_nIdChampFictif++;
                s_dicWebControl.Add(strLibelleWeb, nIdChampFictif);
            }
            int    nIdChampCustom   = -1;
            int    nOrdreWeb        = wndControl.WebNumOrder;
            int    nTypeDonneeChamp = 2; // par défaut type string
            bool   bIsChoixParmis   = false;
            bool   bIsMultiline     = false;
            string strCustomClass   = "";

            if (wndControl is C2iWndChampCustom)
            {
                C2iWndChampCustom wndChamp = (C2iWndChampCustom)wndControl;
                bIsMultiline = wndChamp.MultiLine;
                CChampCustom champ = wndChamp.ChampCustom;
                if (champ != null)
                {
                    m_champ          = champ;
                    nIdChampCustom   = champ.Id;
                    strNomChamp      = champ.Nom;
                    nTypeDonneeChamp = (int)champ.TypeDonneeChamp.TypeDonnee;
                    bIsChoixParmis   = champ.IsChoixParmis();
                }
            }
            else if (wndControl is C2iWndFormule)
            {
                C2iWndFormule wndFormule = (C2iWndFormule)wndControl;
                C2iExpression formule    = wndFormule.Formule;
                if (formule != null)
                {
                    m_formule   = formule;
                    bIsEditable = false;
                }
            }
            else if (wndControl is C2iWndPanel || wndControl is C2iWndSlidingPanel)
            {
                bIsEditable    = false;
                strCustomClass = "sous-titre-champ";
            }

            row[c_champId]                = bIsEditable ? nIdChampCustom : nIdChampFictif;
            row[c_champIdTimos]           = nIdChampCustom;
            row[c_champNom]               = strNomChamp;
            row[c_champLibelleConvivial]  = strLibelleWeb == "" ? strNomChamp : strLibelleWeb;
            row[c_champOrdreAffichage]    = nOrdreWeb;
            row[c_champTypeDonne]         = nTypeDonneeChamp;
            row[c_champIsChoixParmis]     = bIsChoixParmis && bIsEditable;
            row[c_champIsMultiline]       = bIsMultiline;
            row[c_champIsEditable]        = bIsEditable;
            row[c_champCustomClass]       = strCustomClass;
            row[c_champIdGroupeChamps]    = nIdGroupe;
            row[c_champIdCaracteristique] = strIdCarac;
            row[c_champUseAutoComplete]   = false;

            m_row = row;
            dt.Rows.Add(row);
        }
예제 #2
0
        public CTodoValeurChamp(DataSet ds, IObjetDonneeAChamps obj, CChampTimosWebApp champWeb, int nIdGroupeAssocie, bool bIsEditable)
        {
            DataTable dt = ds.Tables[c_nomTable];

            if (dt == null)
            {
                return;
            }

            DataRow row = dt.NewRow();

            int    nIdChampWeb    = champWeb.Id;
            int    nIdChampTimos  = champWeb.IdTimos;
            string strLibelleWeb  = champWeb.WebLabel;
            int    nOrdreWeb      = champWeb.WebNumOrder;
            string strValeur      = "";
            string strElementType = "";
            int    nElementId     = -1;

            CChampCustom champ         = champWeb.Champ;
            bool         bAutoComplete = champWeb.UseAutoComplete;

            if (champ != null)
            {
                if (obj != null)
                {
                    strElementType = obj.GetType().ToString();
                    nElementId     = ((IObjetDonneeAIdNumerique)obj).Id;

                    m_valeur = CUtilElementAChamps.GetValeurChamp(obj, nIdChampTimos);
                    if (m_valeur != null)
                    {
                        if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tObjetDonneeAIdNumeriqueAuto)
                        {
                            IObjetDonneeAIdNumerique objetValeur = m_valeur as IObjetDonneeAIdNumerique;
                            if (objetValeur != null)
                            {
                                try
                                {
                                    if (bIsEditable && !bAutoComplete)
                                    {
                                        strValeur = objetValeur.Id.ToString();
                                    }
                                    else
                                    {
                                        strValeur = objetValeur.DescriptionElement;
                                    }
                                }
                                catch
                                {
                                    strValeur = "";
                                }
                            }
                        }
                        else if (champ.IsChoixParmis())
                        {
                            try
                            {
                                if (bIsEditable)
                                {
                                    strValeur = m_valeur.ToString();
                                }
                                else
                                {
                                    strValeur = champ.DisplayFromValue(m_valeur);
                                }
                            }
                            catch
                            {
                                strValeur = "";
                            }
                        }
                        else
                        {
                            try
                            {
                                strValeur = m_valeur.ToString();
                            }
                            catch
                            {
                                strValeur = "";
                            }
                        }
                    }
                }
            }
            else
            {
                C2iExpression formule = champWeb.Formule;
                if (formule != null)
                {
                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(obj);
                    CResultAErreur resFormule         = formule.Eval(ctx);
                    if (resFormule && resFormule.Data != null)
                    {
                        strValeur = resFormule.Data.ToString();
                    }
                }
            }


            row[c_champId]              = nIdChampWeb;
            row[c_champLibelle]         = strLibelleWeb;
            row[c_champOrdreAffichage]  = nOrdreWeb;
            row[c_champValeur]          = strValeur;
            row[c_champElementType]     = strElementType;
            row[c_champElementId]       = nElementId;
            row[c_champIdGroupeChamps]  = nIdGroupeAssocie;
            row[c_champUseAutoComplete] = champWeb.UseAutoComplete;

            m_row = row;
            dt.Rows.Add(row);
        }