protected override void LoadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_ClientRuleObject == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultViewForm>时 需要配置对应的ClientRule 类!"); } if (_ClientRuleObject.ClientLayoutAttribute == null) { throw new MB.Util.APPException(string.Format("对于客户段逻辑类 {0} ,需要配置 RuleClientLayoutAttribute.", _ClientRuleObject.GetType().FullName)); } ITreeListViewHoster treeListHoster = _TreeListHoster; try { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { if (_ClientRuleObject.ClientLayoutAttribute.CommunicationDataType == CommunicationDataType.DataSet) { throw new MB.Util.APPException("树型浏览主界面暂时不支持DataSet 的绑定", MB.Util.APPMessageType.SysErrInfo); } else { IList lstDatas = null; try { lstDatas = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "DefaultTreeListViewForm.GetObjects 出错!"); } if (_BindingSource == null || _RecreateTreeAfterSorting) { IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas); _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.ListChanged += new ListChangedEventHandler(_BindingSource_ListChanged); _BindingSource.DataSource = bl; treeListHoster.CreateTreeListViewDataBinding(trvLstMain, _BindingSource); if (trvLstMain.Nodes.Count > 0) { trvLstMain.Nodes[0].Expanded = true; trvLstMain.FocusedNode = trvLstMain.Nodes[0]; } _RecreateTreeAfterSorting = false; } else { treeListHoster.RefreshTreeListData(trvLstMain, lstDatas); } } panTitle.Visible = false; } } catch (MB.Util.APPException aex) { throw aex; } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "在浏览窗口DefaultTreeListViewForm_Load 时出错!"); } }
public void showChart(DevExpress.XtraGrid.GridControl xtraGrid, string itemName, ref ChartTemplateInfo template) { try { object datasource = xtraGrid.DataSource; DataSet ds = null; if (_ContainerForm.ClientRuleObject.ClientLayoutAttribute.CommunicationDataType == WinBase.Common.CommunicationDataType.DataSet) { ds = datasource as DataSet; } else { MB.WinBase.Binding.BindingSourceEx bindingSource = datasource as MB.WinBase.Binding.BindingSourceEx; Type T = bindingSource.Current.GetType(); ds = MB.Util.MyConvert.Instance.ConvertEntityToDataSet(T, bindingSource.List, null); } MB.WinDxChart.FrmEditChart frmChart = new WinDxChart.FrmEditChart(itemName, _ContainerForm.ClientRuleObject, template, ds); frmChart.ShowDialog(); template = frmChart.CurTemplate; } catch (Exception ex) { MB.Util.TraceEx.Write(ex.Message); } }
private void LoadDataObject() { ITreeListViewHoster treeListHoster = _TreeListHoster; IList lstDatas = null; try { int id = (int)_SortingNode.GetValue(_TreeListHoster.TreeViewCfg.KeyFieldName); MB.Util.Model.QueryParameterInfo[] queryParams = new Util.Model.QueryParameterInfo[1]; queryParams[0] = new Util.Model.QueryParameterInfo(_TreeListHoster.TreeViewCfg.ParentFieldName, id, Util.DataFilterConditions.Equal); lstDatas = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "DefaultTreeListViewForm.GetObjects 出错!"); } if (_BindingSource == null) { IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas); _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.DataSource = bl; treeListHoster.CreateTreeListViewDataBinding(trvLstMain, _BindingSource); if (trvLstMain.Nodes.Count > 0) { trvLstMain.Nodes[0].Expanded = true; trvLstMain.FocusedNode = trvLstMain.Nodes[0]; } } else { treeListHoster.RefreshTreeListData(trvLstMain, lstDatas); } }
/// <summary> /// 设置控件数据源。 /// </summary> /// <param name="clientRule"></param> /// <param name="dataSource"></param> public void SetDataSource(IClientRuleQueryBase clientRule, object dataSource) { IList lstDatas = dataSource as IList; if (lstDatas == null) { throw new MB.Util.APPException("目前树型浏览列表只支持IList 数据类型", MB.Util.APPMessageType.SysErrInfo); } _TreeListHoster = clientRule as ITreeListViewHoster; if (_TreeListHoster == null) { throw new MB.Util.APPException("获取树型列表数据的业务对象必须继承 ITreeListViewHoster 接口。", MB.Util.APPMessageType.SysErrInfo); } MB.WinBase.Binding.BindingSourceEx bindingSource = new MB.WinBase.Binding.BindingSourceEx(); bindingSource.DataSource = dataSource; _TreeListHoster.CreateTreeListViewDataBinding(trvLstMain, bindingSource); trvLstMain.DataSource = lstDatas; //add by aifang 2012-04-17 数据绑定无效,重新对控件数据源赋值 trvLstMain.RefreshDataSource(); if (trvLstMain.Nodes.Count > 0) { trvLstMain.Nodes[0].Expanded = true; trvLstMain.FocusedNode = trvLstMain.Nodes[0]; } }
/// <summary> /// 显示数据导入对话框。 /// </summary> /// <param name="parent"></param> /// <param name="clientRule"></param> /// <param name="bindingSource"></param> public void ShowDataImportDialog(MB.WinBase.IFace.IViewGridForm viewGridForm, MB.WinBase.Binding.BindingSourceEx bindingSource) { _ViewGridForm = viewGridForm; _ClientRule = viewGridForm.ClientRuleObject as MB.WinBase.IFace.IClientRule; _BindingSource = bindingSource; IDocDataImportProvider importProvider = _ClientRule as IDocDataImportProvider; if (importProvider == null) { MB.Util.TraceEx.Write(string.Format("业务类 {0} 还没有实现相应的数据导入接口 {1}", _ClientRule.GetType().FullName, "IDocDataImportProvider"), MB.Util.APPMessageType.SysErrInfo); throw new MB.Util.APPException("当前模块尚未提供数据导入的功能", APPMessageType.DisplayToUser); } var importInfo = DefaultDataImportDialog.ShowDataImport(_ViewGridForm as Form, _ClientRule, _ClientRule.ClientLayoutAttribute.UIXmlConfigFile, true); if (importInfo == null) { return; } IList hasImportEntity; bool b = importProvider.DataImport(_ViewGridForm, importInfo, out hasImportEntity); if (!b) { return; } DialogResult re = MB.WinBase.MessageBoxEx.Question("数据导入成功,是否需要从数据库中重新刷新数据?"); if (re == DialogResult.Yes) { _ViewGridForm.Refresh(); } else { if (hasImportEntity == null && hasImportEntity.Count == 0) { return; } foreach (object entity in hasImportEntity) { _BindingSource.Add(entity); } } }
/// <summary> /// 报表模板设计。 /// </summary> /// <param name="reportDataHelper"></param> /// <param name="moduleID"></param> /// <param name="templeteID"></param> public FrmEditPrintTemplete(MB.WinPrintReport.IFace.IReportData reportDataHelper, System.Guid templeteID) { InitializeComponent(); _ModuleID = reportDataHelper.ModuleID; _ReportDataHelper = reportDataHelper; _ReportTempleteHelper = new ReportTemplete(reportDataHelper); _PrintTemplete = reportDataHelper.GetPrintTemplete(templeteID); if (_PrintTemplete == null) { _PrintTemplete = createNewPrintTemplete(); _PrintTemplete.GID = templeteID; _PrintTemplete.DataSource = (reportDataHelper.DataSource as DataSet).Tables[0].TableName; } _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.DataSource = _PrintTemplete; }
protected override void LoadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_ClientRuleObject == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultViewForm>时 需要配置对应的ClientRule 类!"); } if (_ClientRuleObject.ClientLayoutAttribute == null) { throw new MB.Util.APPException(string.Format("对于客户段逻辑类 {0} ,需要配置 RuleClientLayoutAttribute.", _ClientRuleObject.GetType().FullName)); } try { //添加右键菜单扩展 add by aifang 2012-07-19 begin if (_ClientRuleObject.ReSetContextMenu != null && _ClientRuleObject.ReSetContextMenu.MenuItems.Count > 0) { grdCtlMain.ContextMenu = _ClientRuleObject.ReSetContextMenu; } //end gridViewMain.RowHeight = MB.WinBase.LayoutXmlConfigHelper.Instance.GetMainGridViewRowHeight(_ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile); using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (MB.Util.MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { if (!tabCtlMain.SelectedTab.Equals(tPageDynamicGroup)) { #region 非动态聚组下的查询 //特殊说明 2009-02-20 在这里需要增加 RefreshLookupDataSource 以便在加载数据ID 时能得到对应的描述信息。 int rowCount = 0; int dbRecordCount = 0; string messageHeaderKey = string.Empty; //添加动态列消息头 XtraGridDynamicHelper.Instance.AppendQueryBehaviorColumns(_ClientRuleObject); Dictionary <string, ColumnPropertyInfo> bindingPropertys = XtraGridDynamicHelper.Instance.GetDynamicColumns(_ClientRuleObject); //加载额外的列,通过继承当前窗口有并重写方法LoadExtraColumns的方式去加载 Dictionary <string, ColumnPropertyInfo> extraColumns = LoadExtraColumns(); if (extraColumns != null && extraColumns.Count > 0) { foreach (KeyValuePair <string, ColumnPropertyInfo> extraCol in extraColumns) { if (!bindingPropertys.ContainsKey(extraCol.Key)) { bindingPropertys.Add(extraCol.Key, extraCol.Value); } } } if (_ClientRuleObject.ClientLayoutAttribute.LoadType == ClientDataLoadType.ReLoad) { messageHeaderKey = _ClientRuleObject.ClientLayoutAttribute.MessageHeaderKey; } if (_ClientRuleObject.ClientLayoutAttribute.CommunicationDataType == CommunicationDataType.DataSet) { DataSet dsData = null; try { using (QueryBehaviorScope scope = new QueryBehaviorScope(_ClientRuleObject.CurrentQueryBehavior, messageHeaderKey)) { //指定是否需要显示页数 QueryBehaviorScope.CurQueryBehavior.IsTotalPageDisplayed = this.IsTotalPageDisplayed; dsData = _ClientRuleObject.GetObjectAsDataSet((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); string queryRefreshTotalPage = getTotalPageAndCurrentpage(dsData.Tables[0].Rows.Count, out dbRecordCount); AppMessenger.DefaultMessenger.Publish(QUERY_REFRESH_TOTAL_PAGE_ID, queryRefreshTotalPage); #region 得到自定义网格页脚汇总列的信息 if (dsData.Tables[0].Rows.Count > 0) { _CustomFootSummaryCols = getCustomSummaryColValues(queryParams); } #endregion } } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, " GetObjectAsDataSet 出错!"); } rowCount = dsData.Tables[0].Rows.Count; MB.XWinLib.XtraGrid.XtraGridHelper.Instance.BindingToXtraGrid(grdCtlMain, dsData, bindingPropertys, _ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit, _ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile, true); } else { IList lstDatas = null; try { MB.WinBase.InvokeMethodWithWaitCursor.InvokeWithWait(() => { using (QueryBehaviorScope scope = new QueryBehaviorScope(_ClientRuleObject.CurrentQueryBehavior, messageHeaderKey)) { //指定是否需要显示页数 QueryBehaviorScope.CurQueryBehavior.IsTotalPageDisplayed = this.IsTotalPageDisplayed; lstDatas = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); string queryRefreshTotalPage = getTotalPageAndCurrentpage(lstDatas.Count, out dbRecordCount); AppMessenger.DefaultMessenger.Publish(QUERY_REFRESH_TOTAL_PAGE_ID, queryRefreshTotalPage); #region 得到自定义网格页脚汇总列的信息 if (lstDatas.Count > 0) { _CustomFootSummaryCols = getCustomSummaryColValues(queryParams); } #endregion } }); } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, " GetObjects 出错!"); } rowCount = lstDatas.Count; if (_BindingSource == null || _IsReloadData) { IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas); _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.DataSource = bl; MB.XWinLib.XtraGrid.XtraGridHelper.Instance.BindingToXtraGrid(grdCtlMain, _BindingSource, bindingPropertys, _ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit, _ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile, true); //每次重新加载完以后,清空动态列的条件,比避免重复加载 this._IsReloadData = false; } else { MB.XWinLib.XtraGrid.XtraGridHelper.Instance.RefreshDataGrid(grdCtlMain, lstDatas); } } _ClientRuleObject.BindingSource = _BindingSource; var msg = string.Format("查询花费:{0} 毫秒,返回 {1} 记录,查询时间:{2}", timeTrack.GetExecutedTimes(), rowCount, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); AppMessenger.DefaultMessenger.Publish(QUERY_REFRESH_MSG_ID, msg); validatedPageControl(rowCount, dbRecordCount); #endregion } else { var dynamicGroupSetting = _DynamicGroupSettings; if (dynamicGroupSetting == null) { throw new APPException("动态聚组查询,聚组条件不能为空"); } DataSet ds = _ClientRuleObject.GetDynamicGroupQueryData(dynamicGroupSetting, queryParams); ucDynamicGroupResultInQuery.BindDynamicResultQueryResult(ds, _ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile); } } } } catch (MB.Util.APPException aex) { throw aex; } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "在浏览窗口Form_Load 时出错!"); } if ((_ClientRuleObject.ClientLayoutAttribute.DataViewStyle & DataViewStyle.Multi) == 0) { tabCtlMain.TabPages.Remove(tPageMultiView); } }
/// <summary> /// 提供树型列表控件的绑定。 /// </summary> /// <param name="treeListCtl"></param> /// <param name="bindingSource"></param> public virtual void CreateTreeListViewDataBinding(MB.XWinLib.XtraTreeList.TreeListEx treeListCtl, MB.WinBase.Binding.BindingSourceEx bindingSource) { _TreeListCtl = treeListCtl; _TreeListDataBinding.CreateDataBinding(treeListCtl, bindingSource, this.UIRuleXmlConfigInfo.GetDefaultColumns(), this.UIRuleXmlConfigInfo.ColumnsCfgEdit, TreeViewCfg, false); }
/// <summary> /// 显示数据导入处理窗口。 /// </summary> /// <returns></returns> public virtual bool ShowDataImport(IViewGridForm viewGridForm, MB.WinBase.Binding.BindingSourceEx bindingSource) { return(false); }
protected override void LoadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_ClientRuleObject == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultViewForm>时 需要配置对应的ClientRule 类!"); } if (_ClientRuleObject.ClientLayoutAttribute == null) { throw new MB.Util.APPException(string.Format("对于客户段逻辑类 {0} ,需要配置 RuleClientLayoutAttribute.", _ClientRuleObject.GetType().FullName)); } try { //添加右键菜单扩展 if (_ClientRuleObject.ReSetContextMenu != null) { grdCtlMain.ContextMenu = _ClientRuleObject.ReSetContextMenu; //else { // grdCtlMain.ContextMenu.MenuItems.Add(new MenuItem("-")); // foreach (MenuItem item in _ClientRuleObject.ReSetContextMenu.MenuItems) { // grdCtlMain.ContextMenu.MenuItems.Add(item); // } //} } string messageHeaderKey = string.Empty; if (_ClientRuleObject.ClientLayoutAttribute.LoadType == ClientDataLoadType.ReLoad) { messageHeaderKey = _ClientRuleObject.ClientLayoutAttribute.MessageHeaderKey; } gridViewMain.RowHeight = MB.WinBase.LayoutXmlConfigHelper.Instance.GetMainGridViewRowHeight(_ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile); using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { //特殊说明 2009-02-20 在这里需要增加 RefreshLookupDataSource 以便在加载数据ID 时能得到对应的描述信息。 if (_ClientRuleObject.ClientLayoutAttribute.CommunicationDataType == CommunicationDataType.DataSet) { throw new MB.Util.APPException("当前不支持基于DataSet 的网格编辑", MB.Util.APPMessageType.SysErrInfo); } else { IList lstDatas = null; try { using (QueryBehaviorScope scope = new QueryBehaviorScope(_ClientRuleObject.CurrentQueryBehavior, messageHeaderKey)) { lstDatas = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); } } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, " 在加载编辑网格窗口获取数据时执行业务类的 GetObjects 出错"); } //IGridViewEditRule gridViewEditRule = _ClientRuleObject as IGridViewEditRule; //if (gridViewEditRule == null) // throw new MB.Util.APPException("所有基于Mid 子窗口网格编辑的业务类必须实现IGridViewEditRule 接口", MB.Util.APPMessageType.SysErrInfo); if (_BindingSource == null) { IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas); _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.ListChanged += new ListChangedEventHandler(_BindingSource_ListChanged); _BindingSource.AddingNew += new AddingNewEventHandler(_BindingSource_AddingNew); _BindingSource.DataSource = bl; MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo = MB.WinBase.LayoutXmlConfigHelper.Instance.GetGridColumnLayoutInfo(_ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile, string.Empty); var detailBindingParams = new MB.XWinLib.GridDataBindingParam(grdCtlMain, _BindingSource, false); MB.XWinLib.XtraGrid.XtraGridEditHelper.Instance.CreateEditXtraGrid(detailBindingParams, _ClientRuleObject.UIRuleXmlConfigInfo.GetDefaultColumns(), _ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit, gridViewLayoutInfo); } else { MB.XWinLib.XtraGrid.XtraGridHelper.Instance.RefreshDataGrid(grdCtlMain, lstDatas); } #region 刷新status strip int rowCount = (lstDatas == null ? 0 : lstDatas.Count); var msg = string.Format("查询花费:{0} 毫秒,返回 {1} 记录,查询时间:{2}", timeTrack.GetExecutedTimes(), rowCount, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string totalPageandCurrentPage = GetTotalPageAndCurrentpage(rowCount); //刷新查询消息 labTitleMsg.Text = msg; //刷新上一页/下一页 lnkNextPage.Enabled = rowCount >= _ClientRuleObject.CurrentQueryBehavior.PageSize; lnkPreviousPage.Enabled = _ClientRuleObject.CurrentQueryBehavior.PageIndex > 0; //刷新总页数 labTotalPageNumber.Visible = IsTotalPageDisplayed; labCurrentPageNumber.Visible = IsTotalPageDisplayed; if (this.IsTotalPageDisplayed) { string[] totalPage_currentPage = totalPageandCurrentPage.Split(','); labTotalPageNumber.Text = string.Format("共{0}页", totalPage_currentPage[0]); labCurrentPageNumber.Text = string.Format("第{0}页", totalPage_currentPage[1]); } #endregion _ClientRuleObject.BindingSource = _BindingSource; } panTitle.Visible = false; } } //在GRIDVIEW创建完成以后 //根据UI RULE来判断GRID的编辑状态,是否允许新增,修改,删除 DevExpress.XtraGrid.Views.Grid.GridView mainView = grdCtlMain.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (_ClientRuleObject != null) { var rejectCfg = MB.WinBase.Atts.AttributeConfigHelper.Instance.GetModuleRejectCommands(_ClientRuleObject.GetType()); if (rejectCfg != null) { if ((rejectCfg.RejectCommands & UICommandType.AddNew) != 0) { mainView.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False; mainView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None; } else { mainView.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True; mainView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; } if ((rejectCfg.RejectCommands & UICommandType.Edit) != 0) { mainView.OptionsBehavior.ReadOnly = true; mainView.OptionsBehavior.Editable = false; } else { mainView.OptionsBehavior.ReadOnly = false; mainView.OptionsBehavior.Editable = true; } if ((rejectCfg.RejectCommands & UICommandType.Delete) != 0) { mainView.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False; } else { mainView.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.True; } } } } catch (MB.Util.APPException aex) { throw aex; } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "加载网格浏览编辑窗口Form_Load 时出错"); } }