//加载对象数据
        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);
            }
        }
        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());
            }
        }
예제 #3
0
        //加载对象数据
        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();
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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 时出错");
            }
        }