示例#1
0
        protected override DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs DoFormatEditValue(object val)
        {
            object objValue = val;

            if (objValue != null && objValue != DBNull.Value)
            {
                if (this.OwnerEdit != null)
                {
                    ABCTextEdit textEdit = (this.OwnerEdit as ABCTextEdit);

                    String strDataMember = textEdit.DataMember;
                    if (DataStructureProvider.IsForeignKey(textEdit.TableName, textEdit.DataMember))
                    {
                        strDataMember = textEdit.DataMember + ":" + DataStructureProvider.GetDisplayColumn(textEdit.TableName);
                    }

                    if (textEdit.BindingManager.Position >= 0 && textEdit.BindingManager.Current != null && textEdit.BindingManager.Current is ABCBusinessEntities.BusinessObject)
                    {
                        if (strDataMember.Contains(":") && objValue is Guid && ABCHelper.DataConverter.ConvertToGuid(objValue) != Guid.Empty)
                        {
                            ABCBusinessEntities.BusinessObject objBinds = textEdit.BindingManager.Current as ABCBusinessEntities.BusinessObject;
                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(objBinds, ABCHelper.DataConverter.ConvertToGuid(objValue), strDataMember);
                        }
                    }
                }
            }
            return(base.DoFormatEditValue(objValue));
        }
示例#2
0
        public override string GetDisplayText(object editValue)
        {
            if (editValue != null && editValue != DBNull.Value)
            {
                try
                {
                    if (this.OwnerEdit != null)
                    {
                        ABCTextEdit textEdit = (this.OwnerEdit as ABCTextEdit);
                        if (String.IsNullOrWhiteSpace(textEdit.DataMember) == false && String.IsNullOrWhiteSpace(textEdit.TableName) == false)
                        {
                            String strDataMember = textEdit.DataMember;
                            if (DataStructureProvider.IsForeignKey(textEdit.TableName, textEdit.DataMember))
                            {
                                strDataMember = textEdit.DataMember + ":" + DataStructureProvider.GetDisplayColumn(textEdit.TableName);
                            }

                            if (String.IsNullOrWhiteSpace(strDataMember) == false)
                            {
                                if (!String.IsNullOrWhiteSpace(textEdit.DataSource))
                                {
                                    if (textEdit.BindingManager.Position >= 0 && textEdit.BindingManager.Current != null && textEdit.BindingManager.Current is ABCBusinessEntities.BusinessObject)
                                    {
                                        object objValue = editValue;
                                        if (strDataMember.Contains(":") && editValue is Guid && ABCHelper.DataConverter.ConvertToGuid(editValue) != Guid.Empty)
                                        {
                                            ABCBusinessEntities.BusinessObject objBinds = textEdit.BindingManager.Current as ABCBusinessEntities.BusinessObject;
                                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(objBinds, ABCHelper.DataConverter.ConvertToGuid(editValue), strDataMember);
                                        }
                                        return(DataFormatProvider.DoFormat(objValue, textEdit.TableName, strDataMember));
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                { }
            }

            return(base.GetDisplayText(editValue));
        }