Exemplo n.º 1
0
 private void executeQuery()
 {
     try {
         MB.Util.Model.QueryParameterInfo[] queryParamters = null;
         if (tabCtlFilterMain.SelectedTabPage.Equals(tPageAdvanceFilter))
         {
             queryParamters = GetAdvanceQueryParameters();//modify by aifang 2012-07-30 queryParamters = _AdvanceFilter.GetQueryParameters();
         }
         else
         {
             queryParamters = _FilterConditionCtl.GetQueryParameters();  // _SimpleFilterEdit.GetQueryParameters();
         }
         if (queryParamters == null || queryParamters.Length == 0)
         {
             if (!_FilterConditionCtl.AllowEmptyFilter)
             {
                 MB.WinBase.MessageBoxEx.Show("请至少输入一个数据过滤的条件!");
                 return;
             }
             else
             {
                 MB.Util.Model.QueryParameterInfo allFilter = new MB.Util.Model.QueryParameterInfo("0", "0", MB.Util.DataFilterConditions.Special);
                 queryParamters = new MB.Util.Model.QueryParameterInfo[] { allFilter };
             }
         }
         _ViewGridForm.ClientRuleObject.CurrentQueryBehavior.PageSize             = MyConvert.Instance.ToInt(nubMaxShotCount.Value);
         _ViewGridForm.ClientRuleObject.CurrentQueryBehavior.IsTotalPageDisplayed = this.cbShowTotalPage.Checked;
         OnAfterGetObjectData(new QueryFilterInputEventArgs(queryParamters));
         this.Close();
     }
     catch (Exception ex) {
         MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据输入的条件获取查询的参数。
        /// </summary>
        /// <returns></returns>
        public MB.Util.Model.QueryParameterInfo[] GetQueryParameters()
        {
            List <MB.Util.Model.QueryParameterInfo> parameters = new List <MB.Util.Model.QueryParameterInfo>();
            bool validated = true;

            foreach (MB.WinBase.Binding.ColumnBindingInfo bindingInfo in _EditColumnCtlBinding.Values)
            {
                if (!_DataElementCfgs.ContainsKey(bindingInfo.ColumnName))
                {
                    throw new MB.Util.APPException(string.Format("DataFilterElements配置中不包含列 {0}", bindingInfo.ColumnName), MB.Util.APPMessageType.SysErrInfo);
                }

                DataFilterElementCfgInfo          filterCfgInfo = _DataElementCfgs[bindingInfo.ColumnName];
                MB.WinBase.Common.EditControlType controlType   = (EditControlType)Enum.Parse(typeof(EditControlType), filterCfgInfo.EditControlType);
                Control ctl = bindingInfo.BindingControl;
                //先情况错误的消息描述。
                _ErrorProvider.SetError(ctl, string.Empty);
                switch (controlType)
                {
                case EditControlType.TextBox:
                case EditControlType.Combox_DropDown:
                case EditControlType.Combox_DropDownList:
                case EditControlType.ClickButtonInput:
                    if (!string.IsNullOrEmpty(ctl.Text.Trim()))
                    {
                        MB.Util.Model.QueryParameterInfo parInfo = new MB.Util.Model.QueryParameterInfo(bindingInfo.ColumnName, ctl.Text, filterCfgInfo.FilterCondition, filterCfgInfo.LimitColumn);

                        if (controlType == EditControlType.TextBox ||
                            controlType == EditControlType.ClickButtonInput)
                        {
                            parInfo.MultiValue = filterCfgInfo.AllowMultiValue;

                            // 生成子查询条件支持多值模糊查询.XiaoMin
                            createChildQueryParameterForMultiValue(parInfo);
                        }
                        //end
                        parameters.Add(parInfo);
                    }
                    else
                    {
                        if (!filterCfgInfo.Nullable)
                        {
                            _ErrorProvider.SetError(ctl, MSG_NOT_ALLOW_NULL_ABLE);
                            validated = false;
                        }
                    }
                    break;

                case EditControlType.CheckBox:
                    CheckBox cBox = ctl as CheckBox;
                    MB.Util.Model.QueryParameterInfo bparInfo = new MB.Util.Model.QueryParameterInfo(bindingInfo.ColumnName, cBox.Checked, filterCfgInfo.FilterCondition, filterCfgInfo.LimitColumn);
                    bparInfo.DataType = "System.Boolean";
                    parameters.Add(bparInfo);

                    break;

                case EditControlType.ComboCheckedListBox:
                    MB.WinBase.Ctls.ucComboCheckedListBox comboListBox = ctl as MB.WinBase.Ctls.ucComboCheckedListBox;
                    string str = string.Join(",", comboListBox.GetAllCheckedItemsKey());
                    if (!string.IsNullOrEmpty(str))
                    {
                        MB.Util.Model.QueryParameterInfo parInfo = new MB.Util.Model.QueryParameterInfo(bindingInfo.ColumnName, str, filterCfgInfo.FilterCondition, filterCfgInfo.LimitColumn);
                        parInfo.MultiValue = true;     //如果设置为该控件,那么就必须允许输入多个值。
                        parameters.Add(parInfo);
                    }
                    else
                    {
                        if (!filterCfgInfo.Nullable)
                        {
                            _ErrorProvider.SetError(ctl, MSG_NOT_ALLOW_NULL_ABLE);
                            validated = false;
                        }
                    }
                    break;

                case EditControlType.LookUpEdit:
                    ComboBox box = ctl as ComboBox;
                    if (box.SelectedIndex >= 0 && !string.IsNullOrEmpty(box.Text.Trim()))
                    {
                        parameters.Add(new MB.Util.Model.QueryParameterInfo(bindingInfo.ColumnName, box.SelectedValue, filterCfgInfo.FilterCondition, filterCfgInfo.LimitColumn));
                    }
                    else
                    {
                        if (!filterCfgInfo.Nullable)
                        {
                            _ErrorProvider.SetError(ctl, MSG_NOT_ALLOW_NULL_ABLE);
                            validated = false;
                        }
                    }
                    break;

                case EditControlType.DateFilterCtl:
                    MB.WinBase.Ctls.ucEditDateFilter dateFilter = ctl as MB.WinBase.Ctls.ucEditDateFilter;
                    if (dateFilter.DateFilterType != MB.WinBase.Ctls.ucEditDateFilter.DateFilterEditType.None)
                    {
                        MB.Util.Model.DateFilterStruct   dateFilterValue = dateFilter.CurrentSettingValue;
                        MB.Util.Model.QueryParameterInfo dateInfo        = new MB.Util.Model.QueryParameterInfo(bindingInfo.ColumnName,
                                                                                                                dateFilterValue.BeginDate, MB.Util.DataFilterConditions.Between, filterCfgInfo.LimitColumn);
                        dateInfo.DataType = "DateTime";
                        dateInfo.Value2   = dateFilterValue.EndDate;

                        //服务端不在过滤时间的问题
                        if (dateInfo.Value != null)
                        {
                            dateInfo.Value = DateTime.Parse(((DateTime)dateInfo.Value).ToString(filterCfgInfo.Formate));
                        }
                        if (dateInfo.Value2 != null)
                        {
                            dateInfo.Value2 = DateTime.Parse(((DateTime)dateInfo.Value2).ToString(filterCfgInfo.Formate));
                        }

                        parameters.Add(dateInfo);
                    }
                    else
                    {
                        if (!filterCfgInfo.Nullable)
                        {
                            _ErrorProvider.SetError(ctl, MSG_NOT_ALLOW_NULL_ABLE);
                            validated = false;
                        }
                    }
                    break;

                case EditControlType.PopupRegionEdit:
                    MB.WinBase.Ctls.ucPopupRegionEdit regionEdit = ctl as MB.WinBase.Ctls.ucPopupRegionEdit;
                    if (_ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit != null && _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit.ContainsKey(filterCfgInfo.Name))
                    {
                        regionEdit.ColumnEditCfgInfo = _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit[filterCfgInfo.Name];

                        var curRegion = regionEdit.CurRegionEdit;
                        foreach (var data in regionEdit.ColumnEditCfgInfo.EditCtlDataMappings)
                        {
                            object obj = MB.Util.MyReflection.Instance.InvokePropertyForGet(curRegion, data.SourceColumnName);
                            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                            {
                                MB.Util.Model.QueryParameterInfo param = new QueryParameterInfo(data.ColumnName, obj, MB.Util.DataFilterConditions.Equal);
                                parameters.Add(param);
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            if (!validated)
            {
                throw new MB.Util.APPException("查询条件输入有误,请检查!", MB.Util.APPMessageType.DisplayToUser);
            }
            return(parameters.ToArray());
        }
        private void queryFilterData()
        {
            try
            {
                ucFilterCondition filterCtl = _StepShowControlPane[PaneViewType.FilterPane] as ucFilterCondition;
                MB.Util.Model.QueryParameterInfo[] filters = filterCtl.GetQueryParameters();

                List <QueryParameterInfo> tempFilters = new List <QueryParameterInfo>(filters);

                //判断如果是自定义的条件,在查询的时候,需要再加上这个条件
                if (_FilterParametersIfNoFiterPanel != null && _FilterParametersIfNoFiterPanel.Count > 0)
                {
                    tempFilters.AddRange(_FilterParametersIfNoFiterPanel);
                    filters = tempFilters.ToArray();
                }


                if (filters == null || filters.Length == 0)
                {
                    if (!filterCtl.AllowEmptyFilter)
                    {
                        MB.WinBase.MessageBoxEx.Show("请至少输入一个数据过滤的条件!");
                        return;
                    }
                    else
                    {
                        MB.Util.Model.QueryParameterInfo allFilter = new MB.Util.Model.QueryParameterInfo("0", "0", MB.Util.DataFilterConditions.Special);
                        filters = new MB.Util.Model.QueryParameterInfo[] { allFilter };
                    }
                }
                //modify by aifang 2012-04-17 支持树型控件数据助手选择
                //ucDataCheckListView listView = _StepShowControlPane[PaneViewType.DataSelect] as ucDataCheckListView;
                IDataAssistantListControl listView = _StepShowControlPane[PaneViewType.DataSelect] as IDataAssistantListControl;
                //modify by aifang 2012-04-17 支持树型控件数据助手选择

                listView.MultiSelect       = _MultiSelect;
                listView.ColumnEditCfgInfo = _ClumnEditCfgInfo;
                lnkChecked.Visible         = _MultiSelect;

                using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this))
                {
                    int mainType = 0;
                    if (_ClientRule.MainDataTypeInDoc != null)
                    {
                        mainType = (int)_ClientRule.MainDataTypeInDoc;
                    }

                    //获得动态列的MessageKey
                    string messageHeaderKey = string.Empty;
                    if (_ClientRule.ClientLayoutAttribute.LoadType == ClientDataLoadType.ReLoad)
                    {
                        messageHeaderKey = _ClientRule.ClientLayoutAttribute.MessageHeaderKey;
                    }

                    //添加动态列消息头
                    MB.XWinLib.XtraGrid.XtraGridDynamicHelper.Instance.AppendQueryBehaviorColumns(_ClientRule);

                    using (QueryBehaviorScope scope = new QueryBehaviorScope(_ClientRule.CurrentQueryBehavior, messageHeaderKey))
                    {
                        var lstDatas = this.GetFilterObjects(mainType, new List <MB.Util.Model.QueryParameterInfo>(filters));
                        if (lstDatas != null && lstDatas.Count > 0)
                        {
                            listView.SetDataSource(_ClientRule, lstDatas);
                            _StepShowControlPane[PaneViewType.DataSelect].BringToFront();
                            validateButton(PaneViewType.DataSelect);
                            validatedPageControl((lstDatas as IList).Count);
                        }
                        else
                        {
                            MB.WinBase.MessageBoxEx.Show("根据该条件查找不到数据,请重试!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
            }
        }