示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="profile"></param>
        /// <param name="minLevel"></param>
        /// <returns></returns>
        public static bool LoadLayout(this IGrid grid, AMS.Profile.IProfile profile, int minLevel)
        {
            // 在未初始化前,不读入
            if (grid.Columns.Count == 0)
            {
                return(false);
            }

            bool ret = true;

            try
            {
                grid.BeginInit();

                if (0 >= minLevel)
                {
                    Form form = grid.FindForm();
                    ret = grid.LoadLayout("MyGrid." + (form != null ? form.Name : "") + "." + grid.GridName + ".Layout", profile);
                }

                LoadLayoutDetailGrid(grid, 1, grid.DataRows, profile, minLevel);
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithResume(ex);
            }
            finally
            {
                grid.EndInit();
            }

            return(ret);
        }
        private void CreateGridColumns(IGrid grid)
        {
            try
            {
                grid.BeginInit();

                grid.Columns.Clear();

                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                {
                    // 有些列是要设置值但不可见的,例如Id
                    //if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    //    continue;

                    switch (info.GridColumnType)
                    {
                    case GridColumnType.Normal:
                    {
                        Xceed.Grid.Column column;
                        if (grid.Columns[info.GridColumnName] != null)
                        {
                            throw new ArgumentException("there have already exist column " + info.GridColumnName);
                        }
                        else
                        {
                            column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                        }

                        UnBoundGridExtention.SetColumnProperties(column, info, grid);

                        GridFactory.CreateCellViewerManager(column, info, this.ControlManager.DisplayManager);

                        bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                        if (!readOnly)
                        {
                            GridFactory.CreateCellEditorManager(column, info, this.ControlManager.DisplayManager);
                        }

                        grid.Columns.Add(column);
                    }
                    break;

                    default:
                        break;
                        //default:
                        //    throw new InvalidOperationException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
            finally
            {
                grid.EndInit();
            }
        }
        private void CreateGridColumns(IGrid grid)
        {
            try
            {
                grid.BeginInit();

                grid.Columns.Clear();

                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                {
                    // 有些列是要设置值但不可见的,例如Id
                    //if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    //    continue;

                    switch (info.GridColumnType)
                    {
                        case GridColumnType.Normal:
                            {
                                Xceed.Grid.Column column;
                                if (grid.Columns[info.GridColumnName] != null)
                                {
                                    throw new ArgumentException("there have already exist column " + info.GridColumnName);
                                }
                                else
                                {
                                    column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                                }

                                UnBoundGridExtention.SetColumnProperties(column, info, grid);

                                GridFactory.CreateCellViewerManager(column, info, this.ControlManager.DisplayManager);

                                bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                                if (!readOnly)
                                {
                                    GridFactory.CreateCellEditorManager(column, info, this.ControlManager.DisplayManager);
                                }

                                grid.Columns.Add(column);
                            }
                            break;
                        default:
                            break;
                        //default:
                        //    throw new InvalidOperationException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
            finally
            {
                grid.EndInit();
            }
        }