/// <summary> /// /// </summary> /// <param name="parentColumn"></param> /// <returns></returns> protected override Cell CreateCell(Column parentColumn) { SearchCell cell = new SearchCell(parentColumn); cell.CellEditorManager = new SearchEditor(); bool enable = true; GridColumnInfo info = parentColumn.Tag as GridColumnInfo; if (info != null) { enable = info.GridColumnType == GridColumnType.Normal; if (enable) { string searchPropertyName = SearchCell.GetSearchPropertyName(info); IBoundGrid grid = this.GridControl as IBoundGrid; if (grid != null && grid.DisplayManager != null) { var p = grid.DisplayManager.EntityInfo.GetPropertMetadata(searchPropertyName); if (p == null) { enable = false; } } } } cell.ReadOnly = !enable; return(cell); }
private void ColumnManageCell_MouseDown(object sender, MouseEventArgs e) { Cell cell = (Cell)sender; GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(m_grid.GridName); if (!Authority.AuthorizeByRule(gridInfo.AllowInnerMenu) && !Authority.IsDeveloper()) { return; } if (e.Button == MouseButtons.Right) { // DetailGrid只是从DetailGridTemplate复制,Constructor里的grid只是模版 DetailGrid detailGrid = ((Xceed.Grid.ColumnManagerCell)sender).ParentGrid; if (detailGrid is DataBoundDetailGrid) { m_grid = detailGrid as DataBoundDetailGrid; } m_contextMenuManagerColumnCell = cell; contextMenuStrip2.Show(cell.PointToScreen(new System.Drawing.Point(e.X, e.Y))); } else { m_contextMenuManagerColumnCell = null; } }
internal static void SetGridRowCellProperties(this IBoundGrid grid) { foreach (Xceed.Grid.DataRow row in grid.DataRows) { SetGridRowCellPermissions(grid, row); SetGridRowCellColors(grid, row); } }
/// <summary> /// 创建Group /// </summary> internal static void CreateGroups(this IBoundGrid grid) { IList <GridGroupInfo> groupInfos = ADInfoBll.Instance.GetGridGroupInfos(grid.GridName); foreach (GridGroupInfo info in groupInfos) { Group group = grid.AddGroup(info.GroupBy, info.TitleFormat); group.Collapsed = info.Collapsed; } }
/// <summary> /// 获取查找行的可见性 /// </summary> /// <param name="grid"></param> /// <returns></returns> public static bool GetSearchRowVisible(this IBoundGrid grid) { if (grid.BoundGridHelper.SearchRow != null) { return(grid.BoundGridHelper.SearchRow.Visible); } else { return(false); } }
private void btnResetGrid_Click(object sender, EventArgs e) { IBoundGrid grid = m_masterGrid as IBoundGrid; if (grid != null) { grid.LoadDefaultLayoutBoundGrid(); grid.AutoAdjustColumnWidth(); LoadGridInfos(); } }
public 电子作业单(车辆作业 clzy) { System.Diagnostics.Debug.Assert(clzy != null, "电子作业单车辆作业不能为空"); InitializeComponent(); m_clzy = clzy; m_cm = AssociateDataControlsInControlManager(new Control[] { pnl作业号, pnl作业路线, pnl车牌号, pnl驾驶员, pnl任务性质, pnl开始时间, pnl疏港期限, pnl进港还箱期限, pnl备注,pnl车载Id号}, "实时监控_车辆作业_电子作业单"); m_作业流程 = base.AssociateBoundGrid(pnl作业流程, "实时监控_车辆作业_电子作业单_作业流程"); }
/// <summary> /// 重新读入数据 /// </summary> /// <param name="grid"></param> /// <param name="reload">是否读入上一查询条件的数据。如false,则重新载入查询条件并读入数据</param> public static void ReloadData(this IBoundGrid grid, bool reload) { int pos = grid.DisplayManager.Position; grid.DisplayManager.BeginBatchOperation(); if (reload) { grid.DisplayManager.SearchManager.ReloadData(); } else { grid.DisplayManager.SearchManager.LoadDataAccordSearchControls(); } bool ret = grid.DisplayManager.SearchManager.WaitLoadData(); grid.DisplayManager.EndBatchOperation(); if (!ret) { return; } if (pos != -1 && pos < grid.DataRows.Count) { if (grid.DisplayManager.Position != pos) { grid.DisplayManager.Position = pos; } else { grid.DisplayManager.OnPositionChanged(System.EventArgs.Empty); } MyGrid.SyncSelectedRowToCurrentRow(grid.GridControl); //if (grid.Visible && grid.DataRows[pos].Visible) //{ // grid.DataRows[pos].BringIntoView(); // //grid.GridControl.SelectedRows.Clear(); // //grid.GridControl.SelectedRows.Add(grid.DataRows[pos]); // //MyGrid.SetCurrentRow(grid as Xceed.Grid.GridControl, grid.DataRows[pos]); //} } //else //{ // MessageForm.ShowWarning("无数据可刷新,请先搜索。"); //} }
internal static void SetGridRowVisible(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo info = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; bool visible = Permission.AuthorizeByRule(info.Visible, entity); row.Visible = visible; if (!row.Visible) { grid.DataRows.Remove(row); return; } }
internal static void SetGridRowCellPermissions(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo info = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; if (grid.ReadOnly) { return; } // Only set when readOnly(如果ReadOnly=false,则不设置,继承Parent's ReadOnly) bool readOnly = Feng.Permission.AuthorizeByRule(info.ReadOnly, entity); if (readOnly) { row.ReadOnly = readOnly; } if (row.ReadOnly) { return; } foreach (GridCellInfo cellInfo in ADInfoBll.Instance.GetGridCellInfos(grid.GridName)) { Xceed.Grid.Cell cell = row.Cells[cellInfo.GridColumName]; if (cell == null) { continue; } if (cell.ParentGrid.ReadOnly) { continue; } if (cell.ParentColumn.ReadOnly) { continue; } if (cell.ParentRow.ReadOnly) { continue; } readOnly = Permission.AuthorizeByRule(cellInfo.ReadOnly, entity); if (readOnly) { cell.ReadOnly = readOnly; } } }
private void CreateControls() { IBoundGrid grdDetail = CreateDetailGrid(); if (grdDetail != null) { MyGrid gridControl = grdDetail as MyGrid; gridControl.Dock = DockStyle.Fill; gridControl.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow()); this.splitContainer1.Panel2.Controls.Add(gridControl); } this.AddDetailGrid(grdDetail); }
private void SaveGridInfos() { foreach (Xceed.Grid.DataRow row in grdGridColumns.DataRows) { IBoundGrid masterGrid = m_masterGrid as IBoundGrid; foreach (Xceed.Grid.Column column in masterGrid.Columns) { if (row.Cells["名称"].Value.ToString() == column.Title) { column.Visible = Convert.ToBoolean(row.Cells["是否显示"].Value); break; } } } }
public 单个作业监控详情(车辆作业 clzy) { System.Diagnostics.Debug.Assert(clzy != null, "单个作业监控详情车辆作业不能为空"); InitializeComponent(); m_clzy = clzy; m_dm = new DisplayManager<车辆作业>(null); AssociateDataControls(new Control[] { pnl作业号, pnl车主, pnl车牌号, pnl驾驶员, pnl驾驶员联系方式, pnl车主联系方式 }, m_dm, "实时监控_车辆作业_单个作业监控详情"); m_任务集合1 = base.AssociateBoundGrid(pnl任务集合1, "实时监控_车辆作业_单个作业监控详情_任务"); m_任务集合2 = base.AssociateBoundGrid(pnl任务集合2, "实时监控_车辆作业_单个作业监控详情_任务2"); }
/// <summary> /// 增加详细信息Grid /// </summary> /// <param name="detailGrid"></param> protected void AddDetailGrid(IBoundGrid detailGrid) { m_detailGrids.Add(detailGrid); IArchiveGrid archiveGrid = detailGrid as IArchiveGrid; if (archiveGrid != null) { archiveGrid.IsInDetailMode = true; if (base.ControlManager != null) { base.ControlManager.StateControls.Add(archiveGrid); base.ControlManager.CheckControls.Add(archiveGrid); } } }
/// <summary> /// /// </summary> /// <returns></returns> protected virtual IBoundGrid[] CreateDetailGrids(int detailGridCount) { IBoundGrid[] ret = new IBoundGrid[detailGridCount]; for (int i = 0; i < ret.Length; ++i) { if (base.ControlManager != null) { ret[i] = new ArchiveUnboundWithDetailGridLoadOnDemand(); } else { ret[i] = new DataUnboundWithDetailGridLoadOnDemand(); } } return(ret); }
/// <summary> /// /// </summary> /// <returns></returns> protected virtual IBoundGrid[] CreateDetailGrids(int detailGridCount) { IBoundGrid[] ret = new IBoundGrid[detailGridCount]; for (int i = 0; i < ret.Length; ++i) { if (base.ControlManager != null) { ret[i] = new ArchiveUnboundWithDetailGridLoadOnDemand(); } else { ret[i] = new DataUnboundWithDetailGridLoadOnDemand(); } } return ret; }
/// <summary> /// 设置显示控制器 /// </summary> /// <param name="grid"></param> /// <param name="dm"></param> /// <param name="gridName"></param> public static void SetDisplayManager(this IBoundGrid grid, IDisplayManager dm, string gridName) { if (dm == null) { throw new ArgumentNullException("dm"); } grid.DisplayManager = dm; grid.GridName = gridName; grid.SetState(StateType.View); grid.DisplayManager.BindingControls.Add(grid); grid.CreateGrid(); ManagerFactory.CreateSearchManagerEagerFetchs(dm.SearchManager, gridName); grid.AfterLoadData(); }
internal static void OnCurrentRowChanged(IBoundGrid grid) { if (!(grid.CurrentRow is Xceed.Grid.DataRow)) { return; } if (grid.DisplayManager.InBatchOperation) { return; } DataUnboundDetailGrid detailGrid = null; bool setNewCurrentRow = false; try { grid.DisplayManager.BeginBatchOperation(); if (grid.CurrentRow != null) { detailGrid = grid.CurrentRow.ParentGrid as DataUnboundDetailGrid; } if (detailGrid == null) { setNewCurrentRow = DataUnboundGrid.TryChangeCurrentRow(grid.DisplayManager, grid); } else { setNewCurrentRow = DataUnboundGrid.TryChangeCurrentRow(detailGrid.DisplayManager, detailGrid); } } finally { grid.DisplayManager.EndBatchOperation(); if (detailGrid == null) { // 已经触发过了 //// CurrentRow改变了 //if (setNewCurrentRow) //{ // grid.DisplayManager.OnPositionChanged(System.EventArgs.Empty); //} } } }
/// <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); } }
internal static void AddDateItemToUnBoundGrid(this IBoundGrid grid, object dataItem) { GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(grid.GridName); if (!Authority.AuthorizeByRule(gridInfo.Visible)) { return; } GridRowInfo gridRowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); if (!Permission.AuthorizeByRule(gridRowInfo.Visible, dataItem)) { return; } Xceed.Grid.DataRow row = grid.DataRows.AddNew(); grid.SetDataRowsIListData(dataItem, row); row.EndEdit(); }
/// <summary> /// /// </summary> public void ApplyFilters() { if (!this.Enabled) { return; } m_searchExps.Clear(); int cellsCount = this.Cells.Count; for (int j = 0; j < cellsCount; j++) { if (!this.Cells[j].Visible) { continue; } if (this.Cells[j].ReadOnly) { continue; } SearchCell searchCell = (SearchCell)this.Cells[j]; ISearchExpression filter = searchCell.GetSearchExpression(); //object cellValue = dataRow.Cells[j].Value; if (filter != null) { m_searchExps.Add(filter); } } //if (m_searchExps.Count > 0) { IBoundGrid grid = this.GridControl as IBoundGrid; if (grid != null) { ISearchExpression exp = SearchExpression.ConvertListToOne(m_searchExps); grid.DisplayManager.SearchManager.LoadData(exp, null); } } }
internal static void SetUnBoundGridDataBinding(this IBoundGrid grid) { try { grid.BeginInit(); grid.DataRows.Clear(); GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(grid.GridName); if (!Authority.AuthorizeByRule(gridInfo.Visible)) { return; } if (!string.IsNullOrEmpty(gridInfo.ReadOnly)) { grid.ReadOnly = Authority.AuthorizeByRule(gridInfo.ReadOnly); } GridRowInfo gridRowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); foreach (object entity in grid.DisplayManager.Items) { if (!Permission.AuthorizeByRule(gridRowInfo.Visible, entity)) { continue; } Xceed.Grid.DataRow row = grid.DataRows.AddNew(); grid.SetDataRowsIListData(entity, row); row.EndEdit(); } } catch (Exception ex) { ExceptionProcess.ProcessWithNotify(ex); } finally { grid.EndInit(); } grid.AfterLoadData(); }
// 必定是DisplayManager接管,不可编辑 internal static void GenerateDetailGrids(IBoundGrid masterGrid, WindowTabInfo masterTabInfo) { if (masterTabInfo.ChildTabs.Count == 0) { return; } if (!(masterGrid is IBoundGridWithDetailGridLoadOnDemand)) { throw new ArgumentException("Grid With DetailGrid must be IBoundGridWithDetailGridLoadOnDemand"); } IDisplayManager masterDm = masterGrid.DisplayManager; foreach (WindowTabInfo subTabInfo in masterTabInfo.ChildTabs) { if (subTabInfo.IsInGrid) { ISearchManager subSm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(subTabInfo, masterDm); IDisplayManager subDm; if (!string.IsNullOrEmpty(subTabInfo.DisplayManagerClassName)) { subDm = ServiceProvider.GetService <IManagerFactory>().GenerateDisplayManager(subTabInfo, subSm); } else { subDm = (ServiceProvider.GetService <IManagerFactory>().GenerateControlManager(subTabInfo, subSm)).DisplayManager; } subDm.Name = subTabInfo.Name; // IBoundGridWithDetailGridLoadOnDemand DataUnboundDetailGrid detailGrid = new DataUnboundDetailGrid(); detailGrid.SetDisplayManager(subDm, subTabInfo.GridName); ((IBoundGridWithDetailGridLoadOnDemand)masterGrid).AddDetailGrid(detailGrid); GenerateDetailGrids(detailGrid, subTabInfo); } } }
/// <summary> /// Constructor /// </summary> public ArchiveCheckForm(bool isArchive) { InitializeComponent(); 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 (isArchive) { // wrong. There is no ControlManager //m_grid = new ArchiveUnboundWithDetailGridLoadOnDemand(); } else { m_masterGrid = new DataUnboundWithDetailGridLoadOnDemand(); } m_masterGrid.FixedHeaderRows.Add(new Xceed.Grid.ColumnManagerRow()); this.splitContainer1.Panel1.Controls.Add(this.m_masterGrid as Control); (this.m_masterGrid as Control).Dock = DockStyle.Fill; (this.m_masterGrid as Control).BringToFront(); (this.m_masterGrid as MyGrid).SingleClickEdit = true; 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.tsbFind.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFind.png").Reference; this.tsbFilter.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFilter.png").Reference; this.tsbSetup.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconSetup.png").Reference; this.tsbOk.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconOk.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.tsmFind.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFind.png").Reference; this.tsmFilter.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconFilter.png").Reference; base.MergeMenu(this.menuStrip1); base.MergeToolStrip(this.toolStrip1); base.MergeToolStrip(this.pageNavigator1); }
private void LoadGridInfos() { grdGridColumns.DataRows.Clear(); IBoundGrid masterGrid = m_masterGrid as IBoundGrid; if (masterGrid != null) { Dictionary <string, GridColumnInfo> visibleColumns = new Dictionary <string, GridColumnInfo>(); bool hasInfo = GridSettingInfoCollection.Instance[masterGrid.GridName].GridColumnInfos.Count > 0; foreach (GridColumnInfo info in GridSettingInfoCollection.Instance[masterGrid.GridName].GridColumnInfos) { if (!Authority.AuthorizeByRule(info.ColumnVisible)) { continue; } visibleColumns[info.GridColumnName] = info; } foreach (Xceed.Grid.Column column in masterGrid.Columns) { if (hasInfo && !visibleColumns.ContainsKey(column.FieldName)) { continue; } Xceed.Grid.DataRow row = grdGridColumns.DataRows.AddNew(); row.Cells["是否显示"].Value = column.Visible; row.Cells["名称"].Value = column.Title; row.EndEdit(); if (visibleColumns.ContainsKey(column.FieldName)) { row.ReadOnly = Authority.AuthorizeByRule(visibleColumns[column.FieldName].NotNull); } } } }
public static void SetCellButton(IBoundGrid grid, string columnName, System.Windows.Forms.Button btn) { Xceed.Grid.CellRow row = null; foreach (Xceed.Grid.Row i in grid.FixedFooterRows) { row = i as Xceed.Grid.CellRow; if (row != null && row.Cells[columnName] != null) { break; } } if (row != null) { btn.Parent.Controls.Remove(btn); btn.Visible = true; grid.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>((sender, e) => { Xceed.Grid.CellRow row2 = null; foreach (Xceed.Grid.Row i in grid.FixedFooterRows) { row2 = i as Xceed.Grid.CellRow; if (row2 != null && row2.Cells[columnName] != null) { break; } } if (row2 != null) { row2.Cells[columnName].CellViewerManager = new Xceed.Grid.Viewers.CellViewerManager(btn, string.Empty); row2.Cells[columnName].CellEditorManager = new Xceed.Grid.Editors.CellEditorManager(btn, string.Empty, true, true); } }); row.Cells[columnName].CellViewerManager = new Xceed.Grid.Viewers.CellViewerManager(btn, string.Empty); row.Cells[columnName].CellEditorManager = new Xceed.Grid.Editors.CellEditorManager(btn, string.Empty, true, true); } }
public static void SetCellButton(IBoundGrid grid, string columnName, System.Windows.Forms.Button btn) { Xceed.Grid.CellRow row = null; foreach (Xceed.Grid.Row i in grid.FixedFooterRows) { row = i as Xceed.Grid.CellRow; if (row != null && row.Cells[columnName] != null) { break; } } if (row != null) { btn.Parent.Controls.Remove(btn); btn.Visible = true; grid.DisplayManager.SearchManager.DataLoaded +=new EventHandler<DataLoadedEventArgs>( (sender, e) => { Xceed.Grid.CellRow row2 = null; foreach (Xceed.Grid.Row i in grid.FixedFooterRows) { row2 = i as Xceed.Grid.CellRow; if (row2 != null && row2.Cells[columnName] != null) { break; } } if (row2 != null) { row2.Cells[columnName].CellViewerManager = new Xceed.Grid.Viewers.CellViewerManager(btn, string.Empty); row2.Cells[columnName].CellEditorManager = new Xceed.Grid.Editors.CellEditorManager(btn, string.Empty, true, true); } }); row.Cells[columnName].CellViewerManager = new Xceed.Grid.Viewers.CellViewerManager(btn, string.Empty); row.Cells[columnName].CellEditorManager = new Xceed.Grid.Editors.CellEditorManager(btn, string.Empty, true, true); } }
/// <summary> /// 创建Group /// </summary> internal static void CreateEvents(this IBoundGrid grid) { foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName)) { switch (info.GridColumnType) { case GridColumnType.NoColumn: break; default: if (info.DoubleClick != null) { GridColumnInfo info2 = info; grid.DataRowTemplate.Cells[info.GridColumnName].DoubleClick += new EventHandler(delegate(object sender, EventArgs e) { EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info2.DoubleClick), sender, e); }); } break; //default: // throw new InvalidOperationException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name); } } }
private void 车队调度主界面_Load(object sender, EventArgs e) { m_新任务集合Grid = base.AssociateBoundGrid(pnl新任务集合, "车队级调度_主界面_新任务集合"); m_作业未结束Grid = base.AssociateBoundGrid(pnl未结束的作业, "车队级调度_主界面_未结束"); }
/// <summary> /// /// </summary> /// <param name="grid"></param> public MyGridSetupForm(IBoundGrid grid) { InitializeComponent(); m_masterGrid = grid; }
/// <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) { if (this.m_masterGrid != null) { this.m_masterGrid.Dispose(); this.m_masterGrid = null; } base.RevertMergeMenu(this.menuStrip1); base.RevertMergeToolStrip(this.pageNavigator1); base.RevertMergeToolStrip(this.toolStrip1); } base.Dispose(disposing); }
public static bool 票费用保存(ArchiveOperationForm masterForm) { IBoundGrid grid = (masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0]; if (grid.DataRows.Count == 0) { return(true); } using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用信息>()) { try { rep.BeginTransaction(); IList <费用信息> list = (rep as Feng.NH.INHibernateRepository).List <费用信息>(NHibernate.Criterion.DetachedCriteria.For <费用信息>() .Add(NHibernate.Criterion.Expression.Eq("票Id", (Guid)grid.DataRows[0].Cells["费用实体"].Value))); Dictionary <string, 费用信息> fyxxs = new Dictionary <string, 费用信息>(); foreach (费用信息 i in list) { fyxxs[i.费用项编号] = i; } // 收 foreach (Xceed.Grid.DataRow row in grid.DataRows) { bool?b = Feng.Utils.ConvertHelper.ToBoolean(row.Cells["Submitted"].Value); if (!b.HasValue) { continue; } string fyx = (string)(row.Cells["费用项"].Value); if (!fyxxs.ContainsKey(fyx)) { 费用信息 fyxx = new 费用信息(); fyxx.票Id = (Guid)row.Cells["费用实体"].Value; fyxx.费用项编号 = (string)(row.Cells["费用项"].Value); fyxx.业务类型编号 = (int)(row.Cells["业务类型"].Value); fyxx.Submitted = b.Value; (new HdBaseDao <费用信息>()).Save(rep, fyxx); fyxxs[fyxx.费用项编号] = fyxx; // MessageForm.ShowInfo("此费用项下还未有费用,不需要打完全标志!"); } else { 费用信息 fyxx = fyxxs[fyx]; if (fyxx.Submitted != b.Value) { fyxx.Submitted = b.Value; (new HdBaseDao <费用信息>()).Update(rep, fyxx); } } } // 付 foreach (Xceed.Grid.DataRow row in grid.DataRows) { bool?b = Feng.Utils.ConvertHelper.ToBoolean(row.Cells["完全标志付"].Value); if (!b.HasValue) { continue; } string fyx = (string)(row.Cells["费用项"].Value); if (!fyxxs.ContainsKey(fyx)) { 费用信息 fyxx = new 费用信息(); fyxx.票Id = (Guid)row.Cells["费用实体"].Value; fyxx.费用项编号 = (string)(row.Cells["费用项"].Value); fyxx.业务类型编号 = (int)(row.Cells["业务类型"].Value); fyxx.完全标志付 = b.Value; (new HdBaseDao <费用信息>()).Save(rep, fyxx); fyxxs[fyxx.费用项编号] = fyxx; // MessageForm.ShowInfo("此费用项下还未有费用,不需要打完全标志!"); } else { 费用信息 fyxx = fyxxs[fyx]; if (fyxx.完全标志付 != b.Value) { fyxx.完全标志付 = b.Value; (new HdBaseDao <费用信息>()).Update(rep, fyxx); } } } rep.CommitTransaction(); masterForm.ControlManager.OnCurrentItemChanged(); grid.ReloadData(); masterForm.ControlManager.State = Feng.StateType.View; if (masterForm.ControlManager.ControlCheckExceptionProcess != null) { masterForm.ControlManager.ControlCheckExceptionProcess.ClearAllError(); } masterForm.ControlManager.EndEdit(false); return(true); } catch (Exception ex) { rep.RollbackTransaction(); ServiceProvider.GetService <IExceptionProcess>().ProcessWithNotify(ex); } return(false); } }
internal static void OnCurrentRowChanged(IBoundGrid grid) { if (!(grid.CurrentRow is Xceed.Grid.DataRow)) return; if (grid.DisplayManager.InBatchOperation) { return; } DataUnboundDetailGrid detailGrid = null; bool setNewCurrentRow = false; try { grid.DisplayManager.BeginBatchOperation(); if (grid.CurrentRow != null) { detailGrid = grid.CurrentRow.ParentGrid as DataUnboundDetailGrid; } if (detailGrid == null) { setNewCurrentRow = DataUnboundGrid.TryChangeCurrentRow(grid.DisplayManager, grid); } else { setNewCurrentRow = DataUnboundGrid.TryChangeCurrentRow(detailGrid.DisplayManager, detailGrid); } } finally { grid.DisplayManager.EndBatchOperation(); if (detailGrid == null) { // �Ѿ��������� //// CurrentRow�ı��� //if (setNewCurrentRow) //{ // grid.DisplayManager.OnPositionChanged(System.EventArgs.Empty); //} } } }
// 必定是DisplayManager接管,不可编辑 internal static void GenerateDetailGrids(IBoundGrid masterGrid, WindowTabInfo masterTabInfo) { if (masterTabInfo.ChildTabs.Count == 0) return; if (!(masterGrid is IBoundGridWithDetailGridLoadOnDemand)) { throw new ArgumentException("Grid With DetailGrid must be IBoundGridWithDetailGridLoadOnDemand"); } IDisplayManager masterDm = masterGrid.DisplayManager; foreach (WindowTabInfo subTabInfo in masterTabInfo.ChildTabs) { if (subTabInfo.IsInGrid) { ISearchManager subSm = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(subTabInfo, masterDm); IDisplayManager subDm; if (!string.IsNullOrEmpty(subTabInfo.DisplayManagerClassName)) { subDm = ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(subTabInfo, subSm); } else { subDm = (ServiceProvider.GetService<IManagerFactory>().GenerateControlManager(subTabInfo, subSm)).DisplayManager; } subDm.Name = subTabInfo.Name; // IBoundGridWithDetailGridLoadOnDemand DataUnboundDetailGrid detailGrid = new DataUnboundDetailGrid(); detailGrid.SetDisplayManager(subDm, subTabInfo.GridName); ((IBoundGridWithDetailGridLoadOnDemand)masterGrid).AddDetailGrid(detailGrid); GenerateDetailGrids(detailGrid, subTabInfo); } } }
internal static void CreateUnBoundGrid(this IBoundGrid 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.NoColumn: break; case GridColumnType.CheckColumn: { CheckColumn column = grid.AddCheckColumn(info.GridColumnName); SetColumnProperties(column, info, grid); } break; case GridColumnType.Normal: { Xceed.Grid.Column column; if (grid.Columns[info.GridColumnName] != null) { //throw new ArgumentException("there have already exist column " + info.GridColumnName); continue; } else { column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info)); } SetColumnProperties(column, info, grid); GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager); bool readOnly = Authority.AuthorizeByRule(info.ReadOnly); if (readOnly) { column.ReadOnly = readOnly; } else { GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager); } grid.Columns.Add(column); } break; case GridColumnType.WarningColumn: { Columns.WarningColumn column = new Columns.WarningColumn(info.GridColumnName, info.PropertyName); grid.Columns.Add(column); } break; case GridColumnType.StatColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info)); SetColumnProperties(column, info, grid); GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager); column.ReadOnly = true; grid.Columns.Add(column); } break; case GridColumnType.ExpressionColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info)); SetColumnProperties(column, info, grid); GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager); bool readOnly = Authority.AuthorizeByRule(info.ReadOnly); if (readOnly) { column.ReadOnly = readOnly; } else { GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager); } grid.Columns.Add(column); } break; case GridColumnType.ImageColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(System.Drawing.Image)); SetColumnProperties(column, info, grid); column.ReadOnly = true; column.MaxWidth = 72; grid.Columns.Add(column); } break; case GridColumnType.SplitColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(string)); SetColumnProperties(column, info, grid); column.ReadOnly = true; column.BackColor = System.Drawing.Color.LightGray; column.Title = " "; column.MaxWidth = 5; column.Width = 5; grid.Columns.Add(column); } break; case GridColumnType.UnboundColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info)); SetColumnProperties(column, info, grid); GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager); bool readOnly = Authority.AuthorizeByRule(info.ReadOnly); if (readOnly) { column.ReadOnly = readOnly; } else { GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager); } grid.Columns.Add(column); } break; case GridColumnType.IndexColumn: { Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(int)); SetColumnProperties(column, info, grid); column.ReadOnly = true; grid.Columns.Add(column); } break; default: throw new NotSupportedException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name); } } } catch (Exception ex) { ExceptionProcess.ProcessWithNotify(ex); } finally { grid.EndInit(); } grid.CreateSumRow(); grid.CreateGroups(); grid.CreateEvents(); grid.BoundGridHelper.CreateColumnManageRowEvent(); grid.SetColumnManagerRowHorizontalAlignment(); grid.CreateMultiColumnHeaderColumnManagerRow(); }
/// <summary> /// 设置查找行的可见性 /// </summary> /// <param name="grid"></param> /// <param name="visible"></param> public static void SetSearchRowVisible(this IBoundGrid grid, bool visible) { grid.BoundGridHelper.SearchRowVisible = visible; }
internal static void SetGridRowCellColors(this IBoundGrid grid, Xceed.Grid.DataRow row) { GridRowInfo rowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); object entity = row.Tag; if (!string.IsNullOrEmpty(rowInfo.BackColor)) { string s = (string)EntityScript.CalculateExpression(rowInfo.BackColor, entity); if (!string.IsNullOrEmpty(s)) { row.BackColor = System.Drawing.Color.FromName(s); } else { row.ResetBackColor(); } } if (!string.IsNullOrEmpty(rowInfo.ForeColor)) { string s = (string)EntityScript.CalculateExpression(rowInfo.ForeColor, entity); if (!string.IsNullOrEmpty(s)) { row.ForeColor = System.Drawing.Color.FromName(s); } else { row.ResetForeColor(); } } foreach (GridCellInfo cellInfo in ADInfoBll.Instance.GetGridCellInfos(grid.GridName)) { Xceed.Grid.Cell cell = row.Cells[cellInfo.GridColumName]; if (cell == null) { continue; } if (!string.IsNullOrEmpty(cellInfo.BackColor)) { string s = (string)EntityScript.CalculateExpression(cellInfo.BackColor, entity); if (!string.IsNullOrEmpty(s)) { cell.BackColor = System.Drawing.Color.FromName(s); } else { cell.ResetBackColor(); } } if (!string.IsNullOrEmpty(rowInfo.ForeColor)) { string s = (string)EntityScript.CalculateExpression(cellInfo.ForeColor, entity); if (!string.IsNullOrEmpty(s)) { cell.ForeColor = System.Drawing.Color.FromName(s); } else { cell.ResetForeColor(); } } } }