//加载对象数据 private void loadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_AsynQueryRule == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultViewForm>时 需要配置对应的ClientRule 类!"); } if (!tabCtlMain.SelectedTab.Equals(tPageDynamicGroup)) { //在非动态聚组查询的条件下 //特殊说明 2009-02-20 在这里需要增加 RefreshLookupDataSource 以便在加载数据ID 时能得到对应的描述信息。 using (MB.Util.MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (AsynLoadDataHelper asynCall = new AsynLoadDataHelper(_AsynQueryRule, this.IsTotalPageDisplayed, _IsQueryAll)) { asynCall.WorkerCompleted += new EventHandler <RunWorkerCompletedEventArgs>(asynCall_WorkerCompleted); asynCall.RunLoad(this, queryParams); } } _ExcuteTime = timeTrack.GetExecutedTimes(); } } else { var dynamicGroupSetting = _DynamicGroupSettings; if (dynamicGroupSetting == null) { throw new APPException("动态聚组查询,聚组条件不能为空"); } DataSet ds = _AsynQueryRule.GetDynamicGroupQueryData(dynamicGroupSetting, queryParams); ucDynamicGroupResultInQuery.BindDynamicResultQueryResult(ds, _AsynQueryRule.ClientLayoutAttribute.UIXmlConfigFile); } }
/// <summary> /// 扩展功能菜单中通用业务操作时相应的事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void _BusinessOperateTrace_CommandItemClick(object sender, MB.WinClientDefault.Common.EditDocStateTraceEventArgs e) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { int re = 0; try { re = _ClientRuleObject.BusinessFlowSubmit(_BindingSource.Current, e.DocOperateType, e.Remark); } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); } if (re > 0) { try { ////刷新当前编辑的对象。 AcceptDataChanged(true); // OnToolsButtonValidate(); MB.WinBase.MessageBoxEx.Show("操作成功"); } catch (Exception x) { MB.WinBase.MessageBoxEx.Show("对象数据库保存已经成功,但本地化更新时出错,请关闭窗口后重新刷新!"); MB.Util.TraceEx.Write("对象数据库保存已经成功,但本地化更新时出错." + x.Message); } } } }
private void tabCtlMain_SelectedIndexChanged(object sender, EventArgs e) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { try { this._IsDynamicGroupIsActive = false; if (tabCtlMain.SelectedTab.Equals(tPageMultiView)) { if (_CurrentQueryData == null) { MB.WinBase.MessageBoxEx.Show("请先查询数据,得到数据后才能进行数据多维分析!"); tabCtlMain.SelectedIndex = 0; return; } //以后需要判断是否已经加载,同时还要判断数据是否已经发生变化来决定是否需要转换和重新加载 Dictionary <string, ColumnPropertyInfo> bindingPropertys = XtraGridDynamicHelper.Instance.GetDynamicColumns(_AsynQueryRule); DataSet dsData = MB.WinBase.ShareLib.Instance.ConvertDataSetToQaDataSet(_CurrentQueryData.Tables[0].DefaultView, bindingPropertys, _AsynQueryRule.UIRuleXmlConfigInfo.ColumnsCfgEdit); if (pivGrdCtlMain.DataSource == null) { MB.XWinLib.PivotGrid.ColPivotList pivColList = MB.XWinLib.Share.XmlCfgHelper.Instance.GetPivotGridCfgData(_AsynQueryRule.ClientLayoutAttribute.UIXmlConfigFile); MB.XWinLib.PivotGrid.PivotGridHelper.Instance.LoadPivotGridData(pivGrdCtlMain, dsData.Tables[0].DefaultView, _AsynQueryRule, pivColList); } else { pivGrdCtlMain.DataSource = dsData.Tables[0].DefaultView; } } else if (tabCtlMain.SelectedTab.Equals(tPageQAChart)) { if (_ChartViewControl == null) { _ChartViewControl = MB.WinClientDefault.Common.ChartAnalyzeHelper.Instance.CreateDefaultChartControl(); Control charCtl = _ChartViewControl as Control; charCtl.Dock = DockStyle.Fill; tPageQAChart.Controls.Add(charCtl); } _ChartViewControl.CreateDataBinding(_AsynQueryRule, _CurrentQueryData); _ChartViewControl.RefreshLayout(); } else if (tabCtlMain.SelectedTab.Equals(tPageDynamicGroup)) { this._IsDynamicGroupIsActive = true; } MB.WinBase.AppMessenger.DefaultMessenger.Publish(DynamicGroupUIHelper.DYNAMIC_GROUP_ACTIVE_MSG_ID); } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); } } }
public new int Refresh() { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { try { if (_CurrentQueryParameters != null && _CurrentQueryParameters.Length > 0) { loadObjectData(_CurrentQueryParameters); } } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); return(-1); } return(1); } }
private void exportAllMenuItem_Click(object sender, EventArgs e) { _AsynQueryRule.CurrentQueryBehavior.PageIndex = 0; _AsynQueryRule.CurrentQueryBehavior.PageSize = Int32.MaxValue; using (MB.Util.MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (AsynLoadDataHelper asynCall = new AsynLoadDataHelper(_AsynQueryRule, this.IsTotalPageDisplayed, _IsQueryAll)) { asynCall.WorkerCompleted += new EventHandler <RunWorkerCompletedEventArgs>(asynCall_WorkerCompleted_ExportAll); asynCall.RunLoad(this, _QueryParamsFromQueryFilterForm); } } double excuteTime = timeTrack.GetExecutedTimes(); MB.Util.TraceEx.Write("导出全部使用的时间是 (毫秒): {0}", excuteTime.ToString()); } }
//加载对象数据 private void loadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_AsynQueryRule == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultAsynCustomQueryView>时 需要配置对应的ClientRule 类!"); } //特殊说明 2009-02-20 在这里需要增加 RefreshLookupDataSource 以便在加载数据ID 时能得到对应的描述信息。 using (MB.Util.MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (AsynLoadDataHelper asynCall = new AsynLoadDataHelper(_AsynQueryRule, this.IsTotalPageDisplayed, _IsQueryAll)) { asynCall.WorkerCompleted += new EventHandler <RunWorkerCompletedEventArgs>(asynCall_WorkerCompleted); asynCall.RunLoad(this, queryParams); } } _ExcuteTime = timeTrack.GetExecutedTimes(); } }
public int DataExport() { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { try { if (_CustomViewControl != null) { _CustomViewControl.Export(); } else { return(0); } } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); return(-1); } return(1); } }
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); } }
private void bntItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { try { if (e.Item.Equals(bntMoveFirstItem)) { moveFocusPosition(GridDataRowMoveType.First); reloadEditBindingSource(); } else if (e.Item.Equals(bntMovePreviousItem)) { moveFocusPosition(GridDataRowMoveType.Prev); reloadEditBindingSource(); } else if (e.Item.Equals(bntMoveNextItem)) { moveFocusPosition(GridDataRowMoveType.Next); reloadEditBindingSource(); } else if (e.Item.Equals(bntMoveLastItem)) { moveFocusPosition(GridDataRowMoveType.Last); reloadEditBindingSource(); } else if (e.Item.Equals(bntAddNewItem)) { AddNew(); } else if (e.Item.Equals(bntSaveItem)) { Save(); } else if (e.Item.Equals(bntDeleteItem)) { Delete(); reloadEditBindingSource(); } else if (e.Item.Equals(bntSubmitItem)) { if (_EditBindingSource.Current == null) { return; } MB.Util.Model.EntityState entityState = MB.WinBase.UIDataEditHelper.Instance.GetEntityState(_EditBindingSource.Current); if (entityState == MB.Util.Model.EntityState.Modified) { throw MB.Util.APPExceptionHandlerHelper.CreateDisplayToUser("单据数据已经发生改变,请先保存"); } Submit(); } else if (e.Item.Equals(bntCancelSubmitItem)) { CancelSubmit(); } else if (e.Item.Equals(butExtendItem)) { if (_ExtendToolStripButtonMenu != null) { Point p = default(Point); foreach (DevExpress.XtraBars.BarItemLink item in barTools.ItemLinks) { if (item.Item.Equals(butExtendItem)) { p.X = item.Bounds.X; } } _ExtendToolStripButtonMenu.Show(this, new Point(p.X, butExtendItem.Height + 6));//6为偏移量 return; } } else if (e.Item.Equals(tsButQuit)) { this.Close(); return; } else { } OnToolsButtonValidate(); } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); } } }