Example #1
0
        public bool Initialiser(object valeur)
        {
            Controls.Clear();
            try
            {
                m_valeur = (CControlListeOperationsSurCAVO.CValeurCAVOO)valeur;
            }
            catch
            {
                return(false);
            }

            CAuditVersionObjetOperation cavoo = m_valeur.CAVOO;
            Type   tpEntite = cavoo.TypeEntite;
            string strType  = cavoo.IDifferencesBlobType == null || cavoo.IDifferencesBlobType == "" ? cavoo.TypeValeurString : cavoo.IDifferencesBlobType;
            Type   tpValeur = CActivatorSurChaine.GetType(strType);

            Control ctrl = null;

            //ENTITE LIEE ?
            if (tpValeur == typeof(int))
            {
                if (cavoo.Champ.GetType() == typeof(CChampCustomPourVersion))
                {
                    //SAVOIR SI LE CHAMP CUSTOM POINTE VERS UNE ENTITE...
                    //((CChampPourVersionInDb)cavoo.Champ).
                }
                else
                {
                    PropertyInfo[] props = tpEntite.GetProperties();
                    foreach (PropertyInfo p in props)
                    {
                        object[] atts = p.GetCustomAttributes(typeof(RelationAttribute), false);
                        if (atts.Length == 1)
                        {
                            RelationAttribute att = (RelationAttribute)atts[0];
                            if (att.ChampsParent.Length == 1 &&
                                att.ChampsFils.Length == 1 &&
                                att.ChampsParent[0] == cavoo.Champ.FieldKey)
                            {
                                string strDescrip = "";

                                if (m_valeur.Valeur != null)
                                {
                                    CFiltreData         filtre   = new CFiltreData(att.ChampsFils[0] + " =@1", (int)m_valeur.Valeur);
                                    CListeObjetsDonnees lstObj   = new CListeObjetsDonnees(cavoo.ContexteDonnee, p.PropertyType, filtre);
                                    bool bElementAccessible      = lstObj.Count == 1;
                                    CObjetDonneeAIdNumerique obj = null;

                                    if (bElementAccessible)
                                    {
                                        obj        = (CObjetDonneeAIdNumerique)lstObj[0];
                                        strDescrip = obj.DescriptionElement;
                                    }
                                    else
                                    {
                                        strDescrip = I.T("Indefinite element from type @1 |30278", DynamicClassAttribute.GetNomConvivial(p.PropertyType));
                                    }
                                    CControlListeOperationsSurCAVO.CValeurCAVOOEntite valeurEntite = new CControlListeOperationsSurCAVO.CValeurCAVOOEntite(strDescrip, (int)m_valeur.Valeur, p.PropertyType, obj);
                                    CControlOpertionCAVOOEntite ctrlEntite = new CControlOpertionCAVOOEntite();
                                    ctrlEntite.Initialiser(valeurEntite);
                                    ctrl = ctrlEntite;
                                    break;
                                }
                                return(true);
                            }
                        }
                    }
                }
            }
            if (ctrl == null)
            {
                //if (tpValeur == typeof(DateTime))
                //{
                //}
                //else if (tpValeur == typeof(int))
                //{
                //}
                //else if (tpValeur == typeof(bool))
                //{
                //}
                if (typeof(IDifferencesBlob).IsAssignableFrom(tpValeur))
                {
                    if (tpValeur == typeof(timos.data.CDifferencesTables))
                    {
                        CControlOpertionCAVOOBlobTableParametrable ctrlTable = new CControlOpertionCAVOOBlobTableParametrable();
                        ctrlTable.Init(m_valeur);
                        ctrl = ctrlTable;
                    }
                    else
                    {
                    }
                }
                //else if (tpValeur == typeof(byte[]))
                //{
                //}
                else
                {
                    try
                    {
                        Label lbl = new Label();
                        if (m_valeur.Valeur != null)
                        {
                            lbl.Text = m_valeur.Valeur.ToString();
                        }
                        ctrl = lbl;
                    }
                    catch
                    {
                    }
                }
            }
            if (ctrl != null)
            {
                Controls.Add(ctrl);
                ctrl.Dock = DockStyle.Fill;
            }
            return(true);
        }
        public void Init(CControlListeOperationsSurCAVO.CValeurCAVOO valeurCAVOO)
        {
            m_origine         = valeurCAVOO.Origine;
            m_strLigneCible   = valeurCAVOO.CAVOO.ValChampCibleString;
            m_strLigneOrigine = valeurCAVOO.CAVOO.ValChampSourceString;
            byte[] byteOfTb = null;

            if (valeurCAVOO.CAVOO.ValChampCibleBlob.Donnees != null &&
                valeurCAVOO.CAVOO.ValChampCibleBlob.Donnees.Length > 0)
            {
                byteOfTb = valeurCAVOO.CAVOO.ValChampCibleBlob.Donnees;
            }
            else
            {
                byteOfTb = valeurCAVOO.CAVOO.ValChampSourceBlob.Donnees;
            }

            m_dt = CUtilADataTable.UnserializeDataTable(byteOfTb);

            string strLigneConcernee = m_origine == EOrigineVersion.Cible ? m_strLigneCible: m_strLigneOrigine;
            bool   bNull             = strLigneConcernee == "@NULL";

            if (bNull)
            {
                m_dgv.DataSource       = null;
                m_dgv.ContextMenuStrip = null;
                return;
            }
            string[] datas = null;
            if (!bNull)
            {
                datas = strLigneConcernee.Split('|');
            }

            DataRow dr = m_dt.NewRow();

            int nCpt = 0;

            foreach (DataColumn dc in m_dt.Columns)
            {
                if (nCpt >= datas.Length)
                {
                    break;
                }
                if (dc.ColumnName == "ID")
                {
                    dr[dc] = 0;
                    continue;
                }
                if (!bNull)
                {
                    if (datas[nCpt] == "@NULL")
                    {
                        dr[dc] = DBNull.Value;
                    }
                    else
                    {
                        if (dc.DataType == typeof(DateTime))
                        {
                            dr[dc] = (DateTime)CUtilTexte.FromUniversalString((string)datas[nCpt], typeof(DateTime));
                        }
                        else if (dc.DataType == typeof(int))
                        {
                            dr[dc] = (int)CUtilTexte.FromUniversalString((string)datas[nCpt], typeof(int));
                        }
                        else if (dc.DataType == typeof(bool))
                        {
                            dr[dc] = (bool)CUtilTexte.FromUniversalString((string)datas[nCpt], typeof(bool));
                        }
                        else if (dc.DataType == typeof(double))
                        {
                            dr[dc] = (double)CUtilTexte.FromUniversalString((string)datas[nCpt], typeof(double));
                        }
                        else
                        {
                            dr[dc] = datas[nCpt];
                        }
                    }
                }
                else
                {
                    dc.AllowDBNull = true;
                    dr[dc]         = DBNull.Value;
                }
                nCpt++;
            }
            m_dt.Rows.Add(dr);
            m_dgv.DataSource         = m_dt;
            m_dgv.Columns[0].Visible = false;


            m_dgv.CellFormatting += new DataGridViewCellFormattingEventHandler(m_dgv_CellFormatting);

            m_dgv.ColumnWidthChanged  += new DataGridViewColumnEventHandler(m_dgv_ColumnWidthChanged);
            m_dgv.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.Fill;
            m_dgv.AllowUserToAddRows   = false;
            m_dgv.ColumnHeadersVisible = false;
            m_dgv.RowHeadersVisible    = true;
            m_dgv.RowHeadersWidth      = 10;
            m_dgv.ReadOnly             = true;

            ActualiserTextMenu();
            //m_dgv.ColumnHeadersVisible = false;

            //if (diffTable.CreationTable)
            //{
            //}
            //else if (diffTable.ChangementStructureTable)
            //{
            //}
            //else if (diffTable.ChangementClePrimaire)
            //{
            //}
            //else
            //{
            //    //Récupération de la ligne concernée

            //}
        }