internal static void LoadGridInfos(MyGrid grdSetup, IGrid masterGrid)
        {
            if (masterGrid == null)
                return;

            if (grdSetup.Columns.Count == 0)
            {
                grdSetup.Columns.Add(new Xceed.Grid.Column("����", typeof(string)));
                grdSetup.Columns.Add(new Xceed.Grid.Column("�Ƿ���ʾ", typeof(bool)));
                grdSetup.ReadOnly = false;
                grdSetup.Columns["�Ƿ���ʾ"].ReadOnly = false;
                grdSetup.Columns["����"].ReadOnly = true;
            }

            grdSetup.DataRows.Clear();

            if (masterGrid != null)
            {
                Dictionary<string, GridColumnInfo> visibleColumns = new Dictionary<string, GridColumnInfo>();
                IList<GridColumnInfo> gridColumnInfos = ADInfoBll.Instance.GetGridColumnInfos(masterGrid.GridName);
                bool hasInfo = gridColumnInfos.Count > 0;

                foreach (GridColumnInfo info in gridColumnInfos)
                {
                    if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }
                    visibleColumns[info.GridColumnName] = info;
                }

                SortedList<int, Xceed.Grid.Column> columns = new SortedList<int, Xceed.Grid.Column>();
                foreach (Xceed.Grid.Column column in masterGrid.Columns)
                {
                    if (hasInfo && !visibleColumns.ContainsKey(column.FieldName))
                    {
                        continue;
                    }

                    columns.Add(column.VisibleIndex, column);
                }

                foreach (KeyValuePair<int, Xceed.Grid.Column> kvp in columns)
                {
                    Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew();
                    row.Cells["�Ƿ���ʾ"].Value = kvp.Value.Visible;
                    row.Cells["����"].Value = kvp.Value.Title;
                    row.EndEdit();

                    if (visibleColumns.ContainsKey(kvp.Value.FieldName))
                    {
                        row.ReadOnly = Authority.AuthorizeByRule(visibleColumns[kvp.Value.FieldName].NotNull);
                    }
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public ArchiveOperationForm(MyGrid masterGrid)
            : base(masterGrid)
        {
            InitializeComponent();

            base.MergeMenu(this.menuStrip1);
            base.MergeToolStrip(this.toolStrip1);

            this.tsbAddNew.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconNew.png").Reference;
            this.tsbEdit.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconEdit.png").Reference;
            this.tsbDelete.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconErase.png").Reference;
            this.tsmAddNew.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconNew.png").Reference;
            this.tsmEdit.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconEdit.png").Reference;
            this.tsmDelete.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconErase.png").Reference;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="grids"></param>
        /// <param name="gridFilterName"></param>
        public void SetFilters(MyGrid[] grids, string gridFilterName)
        {
            m_grids = grids;

            IList<GridFilterInfo> filters = m_bll.GetGridFilterInfos(gridFilterName);
            foreach (GridFilterInfo filter in filters)
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Name = filter.Name + "toolStripMenuItem";
                item.Size = new System.Drawing.Size(172, 22);
                item.Text = filter.Name;
                item.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
                item.Tag = filter;

                this.DropDownItems.Add(item);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridControl"></param>
        public BoundGridHelper(IBoundGrid gridControl)
        {
            InitializeComponent();

            m_grid = gridControl;

            m_masterGrid = m_grid as MyGrid;
            if (m_masterGrid == null)
            {
                tsmFind.Visible = false;
                //tsmExportExcel.Visible = false;
                tsmPrintPreview.Visible = false;
                tsmGenerateReport.Visible = false;
                toolStripSeparator1.Visible = false;
                //tsmGroup.Visible = false;

                tsmLoadLayout.Visible = false;
                tsmSaveLayout.Visible = false;
                tsmPresetLayout.Visible = false;
            }

            this.tsmResetColumns.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconReset.png").Reference;
            this.tsmInvibleColumn.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconInvisible.png").Reference;
            this.tsmAutoAdjustWidth.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconAdjust.png").Reference;
            this.tsmPresetLayout.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconPreset.png").Reference;
            this.tsmLoadLayout.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconOpen.png").Reference;
            this.tsmSaveLayout.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSave.png").Reference;
            this.tsmFilter.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFilter.png").Reference;
            this.tsmGroup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconGroup.png").Reference;
            this.tsmResetColumns.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconReset.png").Reference;
            this.tsmFind.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFind.png").Reference;
            this.tsmExportExcel.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconExportExcel.png").Reference;
            this.tsmPrintPreview.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconPrint.png").Reference;
            this.tsmGenerateReport.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconReport.png").Reference;
            this.tsmSetup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSetup.png").Reference;

            this.tsmRefresh.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconRefresh.png").Reference;
            //this.tsmRefresh.Visible = false;

            GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(m_grid.GridName);
            if (Authority.AuthorizeByRule(gridInfo.AllowInnerMenu) || Authority.IsDeveloper())
            {
                m_grid.GridHelper.MergeContenxtMenuStripForCell(this.contextMenuStrip1);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="template"></param>
 protected MyGrid(MyGrid template)
     : base(template)
 {
 }
 internal static void SwapRow(MyGrid grid, Xceed.Grid.CellRow row1, Xceed.Grid.CellRow row2)
 {
     foreach (Xceed.Grid.Column c in grid.Columns)
     {
         object t = row1.Cells[c.Index].Value;
         row1.Cells[c.Index].Value = row2.Cells[c.Index].Value;
         row2.Cells[c.Index].Value = t;
     }
 }
        internal static void SaveSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster)
        {
            if (dmMaster == null)
                return;

            foreach (Xceed.Grid.DataRow row in grdSetup.DataRows)
            {
                ISearchManager fmc = dmMaster.SearchManager;
                if (fmc != null)
                {
                    foreach (ISearchControl sc in fmc.SearchControls)
                    {
                        if (row.Cells["����"].Value.ToString() == sc.Caption)
                        {
                            sc.Available = Convert.ToBoolean(row.Cells["�Ƿ���ʾ"].Value);
                            sc.Index = row.Index;
                            break;
                        }
                    }
                }
            }
        }
        internal static void SaveGridInfos(MyGrid grdSetup, IGrid masterGrid)
        {
            if (masterGrid == null)
                return;

            foreach (Xceed.Grid.DataRow row in grdSetup.DataRows)
            {
                foreach (Xceed.Grid.Column column in masterGrid.Columns)
                {
                    if (row.Cells["����"].Value.ToString() == column.Title)
                    {
                        column.Visible = Convert.ToBoolean(row.Cells["�Ƿ���ʾ"].Value);
                        column.VisibleIndex = row.Index;
                        break;
                    }
                }
            }
        }
        internal static void ResetSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster)
        {
            if (dmMaster == null)
                return;

            if (dmMaster.SearchManager != null)
            {
                int n = 0;
                foreach (ISearchControl sc in dmMaster.SearchManager.SearchControls)
                {
                    GridColumnInfo info = sc.Tag as GridColumnInfo;

                    if (info == null || (!string.IsNullOrEmpty(info.SearchControlType)
                        && Authority.AuthorizeByRule(info.SearchControlVisible)))
                    {
                        sc.Available = true;
                    }
                    else
                    {
                        sc.Available = false;
                    }

                    sc.Index = n;
                    n++;
                }

                //LoadSearchControlInfos(grdSetup, dmMaster);
            }
        }
        internal static void ResetGridInfos(MyGrid grdSetup, IGrid masterGrid)
        {
            if (masterGrid == null)
                return;

            masterGrid.LoadGridDefaultLayout();
            masterGrid.AutoAdjustColumnWidth();

            //LoadGridInfos(grdSetup, masterGrid);
        }
 internal static void MoveRow(MyGrid grid, bool up)
 {
     Xceed.Grid.DataRow row = grid.CurrentRow as Xceed.Grid.DataRow;
     if (row != null)
     {
         int n = row.Index;
         if (up)
         {
             if (n - 1 >= 0)
             {
                 SwapRow(grid, grid.DataRows[n - 1], row);
                 grid.CurrentRow = grid.DataRows[n - 1];
             }
         }
         else
         {
             if (n  + 1 < grid.DataRows.Count)
             {
                 SwapRow(grid, grid.DataRows[n + 1], row);
                 grid.CurrentRow = grid.DataRows[n + 1];
             }
         }
     }
 }
        internal static void LoadSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster)
        {
            if (dmMaster == null)
                return;

            if (grdSetup.Columns.Count == 0)
            {
                grdSetup.Columns.Add(new Xceed.Grid.Column("����", typeof(string)));
                grdSetup.Columns.Add(new Xceed.Grid.Column("�Ƿ���ʾ", typeof(bool)));
                grdSetup.ReadOnly = false;
                grdSetup.Columns["�Ƿ���ʾ"].ReadOnly = false;
                grdSetup.Columns["����"].ReadOnly = true;
            }

            grdSetup.DataRows.Clear();

            ISearchManager sm = dmMaster.SearchManager;
            if (sm != null)
            {
                SortedList<int, ISearchControl> scc1 = new SortedList<int, ISearchControl>();
                SortedList<int, ISearchControl> scc2 = new SortedList<int, ISearchControl>();

                foreach (ISearchControl sc in sm.SearchControls)
                {
                    GridColumnInfo info = sc.Tag as GridColumnInfo;
                    if (info == null || (!string.IsNullOrEmpty(info.SearchControlType) &&
                         Authority.AuthorizeByRule(info.SearchControlVisible)))
                    {
                        if (sc.Available)
                        {
                            scc1.Add(sc.Index, sc);
                        }
                        else
                        {
                            scc2.Add(sc.Index, sc);
                        }
                    }
                }

                foreach (KeyValuePair<int, ISearchControl> kvp in scc1)
                {
                    Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew();
                    row.Cells["�Ƿ���ʾ"].Value = kvp.Value.Available;
                    row.Cells["����"].Value = kvp.Value.Caption;
                    row.EndEdit();
                }
                foreach (KeyValuePair<int, ISearchControl> kvp in scc2)
                {
                    Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew();
                    row.Cells["�Ƿ���ʾ"].Value = kvp.Value.Available;
                    row.Cells["����"].Value = kvp.Value.Caption;
                    row.EndEdit();
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public ArchiveSeeForm(MyGrid masterGrid)
        {
            InitializeComponent();

            base.MergeMenu(this.menuStrip1);
            base.MergeToolStrip(this.toolStrip1);
            base.MergeToolStrip(this.pageNavigator1);

            m_masterGrid = masterGrid;
            if (m_masterGrid != null)
            {
                m_masterGrid.Dock = DockStyle.Fill;
                m_masterGrid.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow());
                this.splitContainer1.Panel1.Controls.Add(m_masterGrid);
            }

            this.tsbView.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconDetail.png").Reference;
            this.tsbRefresh.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconRefresh.png").Reference;
            this.tsbSearch.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSearch.png").Reference;
            this.tsbFilter.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFilter.png").Reference;
            this.tsbGroup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconGroup.png").Reference;
            this.tsbFind.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFind.png").Reference;
            this.tsbRelatedInfo.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconExternalLink.png").Reference;

            this.tsbAttachment.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconAttach.png").Reference;
            this.tsbExportExcel.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconExportExcel.png").Reference;
            this.tsbPrintPreview.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconPrint.png").Reference;
            this.tsbGenerateReport.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconNewReport.png").Reference;
            this.tsbSetup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSetup.png").Reference;

            this.tsmView.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconDetail.png").Reference;
            this.tsmRefresh.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconRefresh.png").Reference;
            this.tsmSearch.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSearch.png").Reference;
            this.tsmFilter.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFilter.png").Reference;
            this.tsmGroup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconGroup.png").Reference;
            this.tsmFind.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFind.png").Reference;
            this.tsmRelatedInfo.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconExternalLink.png").Reference;

            this.tsmExportExcel.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconExportExcel.png").Reference;
            this.tsmPrintPreview.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconPrint.png").Reference;
            this.tsmGenerateReport.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconNewReport.png").Reference;
            this.tsmSetup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSetup.png").Reference;

            this.bindingNavigatorMoveLastItem.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconLast.png").Reference;
            this.bindingNavigatorMoveNextItem.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconNext.png").Reference;
            this.bindingNavigatorMovePreviousItem.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconPrevious.png").Reference;
            this.bindingNavigatorMoveFirstItem.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFirst.png").Reference;

            if (Feng.Utils.ReflectionHelper.GetObjectValue(typeof(TabbedMdiForm), ServiceProvider.GetService<IApplication>(), "m_twReletedInfos") != null)
            {
                this.tsbRelatedInfo.Visible = this.tsmRelatedInfo.Visible = false;
            }
            else
            {
                this.tsbRelatedInfo.Click += new EventHandler((sender, e) =>
                    {
                        GridRelatedControl taskPane = this.GetGridRelatedPanel() as GridRelatedControl;
                        if (taskPane != null)
                        {
                            PositionPersistForm searchForm = new PositionPersistForm();
                            searchForm.Name = taskPane.Name;
                            searchForm.Text = tsbRelatedInfo.Text;

                            searchForm.Controls.Add(taskPane);
                            taskPane.Dock = DockStyle.Fill;
                            searchForm.ShowDialog();

                            searchForm.Controls.Remove(taskPane);
                            searchForm.Dispose();
                        }
                    });
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            if (disposing)
            {
                GridRelatedControl taskPane = this.GetCustomProperty(MyChildForm.GridRelatedPanelName, false) as GridRelatedControl;
                if (taskPane != null)
                {
                    taskPane.Dispose();
                }

                if (this.m_masterGrid != null)
                {
                    this.m_masterGrid.Dispose();
                    this.m_masterGrid = null;
                }

                if (this.ArchiveDetailForm != null)
                {
                    this.ArchiveDetailForm.Dispose();
                }

                base.RevertMergeMenu(this.menuStrip1);
                base.RevertMergeToolStrip(this.pageNavigator1);
                base.RevertMergeToolStrip(this.toolStrip1);
            }

            base.Dispose(disposing);
        }