void ConfigGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.FieldName == "FieldName" || e.Column.FieldName == "IsUseAlias")
            {
                ABCGridColumn.ColumnConfig config = this.ConfigGridView.GetRow(this.ConfigGridView.FocusedRowHandle) as ABCGridColumn.ColumnConfig;
                if (config != null)
                {
                    if (config.IsUseAlias)
                    {
                        String strCaption = String.Empty;
                        if (config.FieldName.Contains(":"))
                        {
                            DataCachingProvider.AccrossStructInfo structInfo = DataCachingProvider.GetAccrossStructInfo(config.TableName, config.FieldName);
                            if (structInfo != null)
                            {
                                strCaption = DataConfigProvider.GetFieldCaption(structInfo.TableName, structInfo.FieldName);
                            }
                        }
                        else
                        {
                            strCaption = DataConfigProvider.GetFieldCaption(config.TableName, config.FieldName);
                        }

                        if (string.IsNullOrWhiteSpace(strCaption) == false)
                        {
                            config.Caption = strCaption;
                        }
                    }
                }
            }

            RefreshDisplayGrid();
        }
Esempio n. 2
0
        public static String GetLabelCaption(String strTableName, String strDataMember)
        {
            if (string.IsNullOrWhiteSpace(strDataMember) || String.IsNullOrWhiteSpace(strTableName))
            {
                return(String.Empty);
            }

            if (strDataMember.Contains(":") == false)
            {
                return(DataConfigProvider.GetFieldCaption(strTableName, strDataMember));
            }

            String strCurrentTableName = strTableName;

            String[] strArray = strDataMember.Split(':');
            foreach (String strCurrentField in strArray)
            {
                if (DataStructureProvider.IsForeignKey(strCurrentTableName, strCurrentField))
                {
                    strCurrentTableName = DataStructureProvider.GetTableNameOfForeignKey(strCurrentTableName, strCurrentField);
                }
                else
                {
                    return(DataConfigProvider.GetFieldCaption(strCurrentTableName, strCurrentField));
                }
            }

            return(String.Empty);
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        public void CreatePoints(object obj)
        {
            this.Points.Clear();
            if (obj == null)
            {
                return;
            }

            String[] strArrays = this.ValueMembers.Split(';');
            int      i         = 0;

            foreach (String strItem in strArrays)
            {
                PropertyInfo proInfo = obj.GetType().GetProperty(strItem);
                if (proInfo == null)
                {
                    return;
                }

                object objValue = proInfo.GetValue(obj, null);

                i++;
                String strCaption = String.Empty;
                if (obj is BusinessObject)
                {
                    strCaption = DataConfigProvider.GetFieldCaption((obj as BusinessObject).AATableName, strItem);
                }

                SeriesPoint point = new SeriesPoint(strCaption, new object[] { objValue }, i);
                this.Points.Add(point);
            }
        }
Esempio n. 5
0
        private void InitField(ABCCommonTreeListNode parentNode, String strTableName, String strFieldName)
        {
            ABCScreen.ABCBindingConfig bindInfo = ((FieldNodeInfo)parentNode.InnerData).Config;
            String strDiplay = DataConfigProvider.GetFieldCaption(strTableName, strFieldName);

            if (strDiplay == strFieldName)
            {
                return;
            }

            FieldNodeInfo fieldInfo = new FieldNodeInfo();

            fieldInfo.Display = strDiplay;
            fieldInfo.Type    = FiledNodeType.Field;
            fieldInfo.Config  = bindInfo;
            if (String.IsNullOrWhiteSpace(((FieldNodeInfo)parentNode.InnerData).FieldName) == false)
            {
                fieldInfo.FieldName = ((FieldNodeInfo)parentNode.InnerData).FieldName + ":";
            }

            fieldInfo.FieldName += strFieldName;
            fieldInfo.TableName  = strTableName;

            ABCCommonTreeListNode node = new ABCCommonTreeListNode(parentNode, fieldInfo);

            InitControls(node);

            if (DataStructureProvider.IsForeignKey(strTableName, strFieldName))
            {
                fieldInfo.Type = FiledNodeType.Foreign;
            }
        }
Esempio n. 6
0
        public void PopulateControls(ABCView view, String BusName, String strTableName)
        {
            ViewOwner  = view;
            DataSource = BusName;
            TableName  = strTableName;
            int iCount = 0;

            foreach (DataConfigProvider.FieldConfig fieldConfig in DataConfigProvider.TableConfigList[strTableName].FieldConfigList.Values)
            {
                //if ( fieldConfig.IsDefault )
                //{
                String strDiplay = DataConfigProvider.GetFieldCaption(strTableName, fieldConfig.FieldName);
                if (strDiplay == fieldConfig.FieldName)
                {
                    continue;
                }

                ABCBindingBaseEdit ctrl;

                if (view.Mode == ViewMode.Design)
                {
                    ctrl = (ABCBindingBaseEdit)view.Surface.DesignerHost.CreateComponent(typeof(ABCBindingBaseEdit));
                }
                else
                {
                    ctrl = (ABCBindingBaseEdit)ABCDynamicInvoker.CreateInstanceObject(typeof(ABCBindingBaseEdit));
                }

                ABCBindingInfo bindInfo = new ABCBindingInfo();
                bindInfo.BusName   = BusName;
                bindInfo.TableName = TableName;
                bindInfo.FieldName = fieldConfig.FieldName;
                List <Type> lstType = ABCControls.ABCPresentHelper.GetControlTypes(TableName, fieldConfig.FieldName);
                if (lstType.Count <= 0)
                {
                    continue;
                }
                foreach (Type type in lstType)
                {
                    if (type != typeof(ABCSearchControl))
                    {
                        bindInfo.ControlType = lstType[0];
                        break;
                    }
                }
                ctrl.Initialize(view, bindInfo);
                ctrl.Parent = this;
                iCount++;
                //}
            }
            if (iCount % 2 != 0)
            {
                iCount++;
            }
            iCount    = iCount / 2;
            this.Size = new Size(229 * 2 + 4 * 3, 20 * iCount + (iCount + 1) * 5);
        }
Esempio n. 7
0
        public static void InitDefaultColumns(String strTableName, ABCGridView view)
        {
            DataConfigProvider.TableConfig config = DataConfigProvider.TableConfigList[strTableName];

            SortedDictionary <String, ABCGridColumn> sortedListCols = new SortedDictionary <String, ABCGridColumn>();

            foreach (String strField in config.FieldConfigList.Keys)
            {
                if (config.FieldConfigList[strField].InUse && config.FieldConfigList[strField].IsDefault)
                {
                    ABCGridColumn gridCol = new ABCGridColumn();
                    gridCol.Name         = strField;
                    gridCol.TableName    = strTableName;
                    gridCol.FieldName    = strField;
                    gridCol.Caption      = DataConfigProvider.GetFieldCaption(strTableName, strField);
                    gridCol.Visible      = true;
                    gridCol.VisibleIndex = config.FieldConfigList[strField].SortOrder;

                    InitDefaultRepository(gridCol);

                    gridCol.InitFormat();

                    if (sortedListCols.ContainsKey(config.FieldConfigList[strField].SortOrder.ToString()) == false)
                    {
                        sortedListCols.Add(config.FieldConfigList[strField].SortOrder.ToString(), gridCol);
                    }
                    else
                    {
                        sortedListCols.Add(config.FieldConfigList[strField].SortOrder.ToString() + strField, gridCol);
                    }
                }
            }
            foreach (ABCGridColumn gridCol in sortedListCols.Values)
            {
                view.Columns.Add(gridCol);
            }

            foreach (ABCGridColumn gridCol in sortedListCols.Values)
            {
                if (config.FieldConfigList.ContainsKey(gridCol.FieldName) && config.FieldConfigList[gridCol.FieldName].IsGrouping)
                {
                    if (gridCol.FieldName != null && gridCol.FieldName.Contains(":"))
                    {
                        gridCol.GroupInterval = ColumnGroupInterval.DisplayText;
                    }
                    gridCol.Group();
                }
            }
        }
Esempio n. 8
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)
            {
            }
        }
Esempio n. 9
0
        public void InitColumnsFromTable( )
        {
            foreach (String strField in DataStructureProvider.DataTablesList[TableName].ColumnsList.Keys)
            {
                if (!DataConfigProvider.TableConfigList[TableName].FieldConfigList.ContainsKey(strField))
                {
                    continue;
                }

                DataConfigProvider.FieldConfig config = DataConfigProvider.TableConfigList[TableName].FieldConfigList[strField];
                String strCaption = DataConfigProvider.GetFieldCaption(TableName, strField);

                if (config.TypeName == "DateTime" || config.TypeName == "Nullable<DateTime>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(DateTime), new RepositoryItemDateEdit(), FilterColumnClauseClass.DateTime));
                }
                if (config.TypeName == "int" || config.TypeName == "Nullable<int>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(int), new RepositoryItemSpinEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "Guid" || config.TypeName == "Nullable<Guid>")
                {
                    if (DataStructureProvider.IsForeignKey(TableName, strField))
                    {
                        String strPKTableName             = DataStructureProvider.GetTableNameOfForeignKey(TableName, strField);
                        RepositoryItemLookUpEditBase repo = ABCControls.UICaching.GetDefaultRepository(strPKTableName, false);
                        repo.DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);

                        this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(Guid), repo, FilterColumnClauseClass.Lookup));
                    }
                }
                if (config.TypeName == "String")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(String), new RepositoryItemTextEdit(), FilterColumnClauseClass.String));
                }
                if (config.TypeName == "double")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(double), new RepositoryItemTextEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "bool" || config.TypeName == "Nullable<bool>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(bool), new RepositoryItemCheckEdit(), FilterColumnClauseClass.Generic));
                }
            }
        }
Esempio n. 10
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;
                }
            }
        }
Esempio n. 11
0
        private void InitRepositoryLookupEdit( )
        {
            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
            {
                this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);
                ABCControls.UICaching.InitDefaultRepositoryLookupEdit(this.LookupTableName, this.Properties);

                if (String.IsNullOrWhiteSpace(this.DisplayMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.DisplayMember))
                {
                    this.Properties.DisplayMember = this.DisplayMember;
                }

                if (String.IsNullOrWhiteSpace(this.ValueMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.ValueMember))
                {
                    this.Properties.ValueMember = this.ValueMember;
                }


                #region DataSource
                if (String.IsNullOrWhiteSpace(DefaultFilterString))
                {
                    this.Properties.DataSource = DataCachingProvider.TryToGetDataView(this.LookupTableName, false);
                }
                else
                {
                    DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                    newView.RowFilter          = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));
                    this.Properties.DataSource = newView;
                }
                #endregion

                if (this.Enabled)
                {
                    this.Enabled = ABCScreen.ABCScreenHelper.Instance.CheckTablePermission(this.LookupTableName, TablePermission.AllowView);
                }
            }
            else if (DataStructureProvider.IsTableColumn(this.TableName, strFieldName) &&
                     String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum) == false)
            {
                String strEnum = DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum;
                if (EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    this.Properties.ValueMember = "ItemName";
                    if (ABCApp.ABCDataGlobal.Language == "VN")
                    {
                        this.Properties.DisplayMember = "CaptionVN";
                    }
                    else
                    {
                        this.Properties.DisplayMember = "CaptionEN";
                    }

                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = this.Properties.DisplayMember;
                    col.Caption   = DataConfigProvider.GetFieldCaption(this.TableName, strFieldName);
                    col.Visible   = true;
                    this.Properties.Columns.Add(col);

                    this.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                }
            }
            this.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit;
            this.Properties.BestFit();
        }