Пример #1
0
        public static void InitDefaultRepositoryLookupEdit(String strTableName, ABCRepositoryLookUpEdit repo)
        {
            DataConfigProvider.TableConfig config = DataConfigProvider.TableConfigList[strTableName];

            #region Columns
            foreach (String strField in config.FieldConfigList.Keys)
            {
                if (config.FieldConfigList[strField].InUse && config.FieldConfigList[strField].IsDefault)
                {
                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = strField;
                    col.Caption   = DataConfigProvider.GetFieldCaption(strTableName, strField);
                    col.Visible   = true;
                    repo.Columns.Add(col);
                }
            }
            #endregion

            repo.ValueMember = DataStructureProvider.DataTablesList[strTableName].PrimaryColumn;

            repo.DisplayMember = DataStructureProvider.GetDisplayColumn(strTableName);
            if (String.IsNullOrWhiteSpace(repo.DisplayMember) && repo.Columns.Count > 0)
            {
                repo.DisplayMember = repo.Columns[0].FieldName;
            }

            repo.BestFit();
        }
Пример #2
0
        public static void InitDefaultRepository(ABCGridColumn gridCol)
        {
            try
            {
                #region RepositoryLookupEdit
                if (DataStructureProvider.IsForeignKey(gridCol.TableName, gridCol.FieldName))
                {
                    String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(gridCol.TableName, gridCol.FieldName);
                    gridCol.ColumnEdit = GetDefaultRepositoryLookUpEdit(strPKTableName, false);
                    (gridCol.ColumnEdit as ABCRepositoryLookUpEdit).DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);
                }
                #endregion

                #region Enum
                else if (DataStructureProvider.IsTableColumn(gridCol.TableName, gridCol.FieldName) &&
                         String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum) == false)
                {
                    String strEnum = DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum;
                    if (EnumProvider.EnumList.ContainsKey(strEnum))
                    {
                        ABCRepositoryLookUpEdit repo = new ABCRepositoryLookUpEdit();

                        repo.Properties.ValueMember = "ItemName";
                        if (ABCApp.ABCDataGlobal.Language == "VN")
                        {
                            repo.Properties.DisplayMember = "CaptionVN";
                        }
                        else
                        {
                            repo.Properties.DisplayMember = "CaptionEN";
                        }

                        DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                        col.FieldName = repo.Properties.DisplayMember;
                        col.Caption   = DataConfigProvider.GetFieldCaption(gridCol.TableName, gridCol.FieldName);
                        col.Visible   = true;
                        repo.Properties.Columns.Add(col);
                        repo.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                        gridCol.ColumnEdit         = repo;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Пример #3
0
 public override void Assign(RepositoryItem item)
 {
     BeginUpdate();
     try
     {
         base.Assign(item);
         ABCRepositoryLookUpEdit source = item as ABCRepositoryLookUpEdit;
         if (source == null)
         {
             return;
         }
         _OwnerGridView = source.OwnerGridView;
     }
     finally
     {
         EndUpdate();
     }
 }
Пример #4
0
        public static ABCRepositoryLookUpEdit GetDefaultRepositoryLookUpEdit(String strTableName, bool isCreateNew)
        {
            ABCRepositoryLookUpEdit repo;

            if (isCreateNew)
            {
                repo = new ABCRepositoryLookUpEdit();
                InitDefaultRepositoryLookupEdit(strTableName, repo);
                return(repo);
            }

            if (ReposityLookupEdits.TryGetValue(strTableName, out repo))
            {
                return(repo);
            }

            repo = new ABCRepositoryLookUpEdit();
            InitDefaultRepositoryLookupEdit(strTableName, repo);
            ReposityLookupEdits.Add(strTableName, repo);

            return(repo);
        }
Пример #5
0
        public static void AssignEnums(GridColumn gridCol, String strTableName, String strFieldName, String strFilterString)
        {
            if (DataStructureProvider.IsTableColumn(strTableName, strFieldName) &&
                String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[strTableName].FieldConfigList[strFieldName].AssignedEnum) == false)
            {
                String strEnum = DataConfigProvider.TableConfigList[strTableName].FieldConfigList[strFieldName].AssignedEnum;
                if (EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    ABCRepositoryLookUpEdit repo = new ABCRepositoryLookUpEdit();

                    repo.Properties.ValueMember = "ItemName";
                    if (ABCApp.ABCDataGlobal.Language == "VN")
                    {
                        repo.Properties.DisplayMember = "CaptionVN";
                    }
                    else
                    {
                        repo.Properties.DisplayMember = "CaptionEN";
                    }

                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = repo.Properties.DisplayMember;
                    col.Caption   = DataConfigProvider.GetFieldCaption(strTableName, strFieldName);
                    col.Visible   = true;
                    repo.Properties.Columns.Add(col);
                    if (!String.IsNullOrWhiteSpace(strFilterString))
                    {
                        List <String> lstTemps = strFilterString.Split(';').ToList();
                        repo.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.Where(e => lstTemps.Contains(e.ItemName)).ToArray();
                    }
                    else
                    {
                        repo.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                    }
                    gridCol.ColumnEdit = repo;
                }
            }
        }
Пример #6
0
 static ABCLookUpEdit( )
 {
     ABCRepositoryLookUpEdit.RegisterCustomEdit();
 }
Пример #7
0
 public ABCLookUpListDataAdapter(ABCRepositoryLookUpEdit item)
     : base(item)
 {
 }