Esempio n. 1
0
        //动态创建Label
        private Label createLabel(DataFilterElementCfgInfo filterCfgInfo)
        {
            Dictionary <string, ColumnPropertyInfo> columns = _ClientRule.UIRuleXmlConfigInfo.GetDefaultColumns();
            Label lab = new Label();

            lab.Text      = columns[filterCfgInfo.Name].Description + ":";
            lab.Size      = new System.Drawing.Size(Convert.ToInt32(panFilterPan.ColumnStyles[0].Width), Convert.ToInt32(panFilterPan.RowStyles[0].Height - MARGE_WIDTH));
            lab.TextAlign = ContentAlignment.MiddleLeft;

            if (!filterCfgInfo.Nullable)
            {
                lab.ForeColor = Color.Red;
            }
            return(lab);
        }
Esempio n. 2
0
        //创建编辑控件。
        private Control createEditCtl(DataFilterElementCfgInfo filterCfgInfo)
        {
            MB.WinBase.IFace.IDataFilterElementHoster hoster = _ClientRule as MB.WinBase.IFace.IDataFilterElementHoster;

            Dictionary <string, ColumnPropertyInfo> columns = _ClientRule.UIRuleXmlConfigInfo.GetDefaultColumns();

            MB.WinBase.Common.EditControlType controlType = MB.WinBase.Common.EditControlType.None;
            try {
                string editCtlType = filterCfgInfo.EditControlType;
                //如果在查询带没有配置那么根据名称在 编辑带查找
                if (string.IsNullOrEmpty(editCtlType))
                {
                    if (_ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit != null && _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit.ContainsKey(filterCfgInfo.Name))
                    {
                        editCtlType = _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit[filterCfgInfo.Name].EditControlType;
                    }
                    //如果在编辑带还没有找到就根据数据类型创建
                    if (string.IsNullOrEmpty(editCtlType))
                    {
                        editCtlType = getEditControlTypeByDayaType(columns[filterCfgInfo.Name].DataType).ToString();
                    }
                }
                controlType = (EditControlType)Enum.Parse(typeof(EditControlType), editCtlType);
                filterCfgInfo.EditControlType = controlType.ToString();
            }
            catch {
                throw new MB.Util.APPException(string.Format("控件类型{0} 配置有误,请检查!", filterCfgInfo.EditControlType), MB.Util.APPMessageType.SysErrInfo);
            }
            MB.WinBase.Atts.EditControlTypeAttribute ctlAtt = MB.WinBase.Atts.AttributeConfigHelper.Instance.GetEditControlTypeAtt(controlType);
            Control newCtl = ctlAtt.FormCtlType.Assembly.CreateInstance(ctlAtt.FormCtlType.FullName, true) as Control;

            switch (controlType)
            {
            case EditControlType.Combox_DropDown:
                (newCtl as ComboBox).DropDownStyle = ComboBoxStyle.DropDown;
                MB.WinBase.Binding.BindingSourceHelper.Instance.FillCombox(newCtl, filterCfgInfo.Name, _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit, false);
                break;

            case EditControlType.Combox_DropDownList:
                (newCtl as ComboBox).DropDownStyle = ComboBoxStyle.DropDownList;
                MB.WinBase.Binding.BindingSourceHelper.Instance.FillCombox(newCtl, filterCfgInfo.Name, _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit, true);
                break;

            case EditControlType.LookUpEdit:
                (newCtl as ComboBox).DropDownStyle = ComboBoxStyle.DropDownList;
                MB.WinBase.Binding.BindingSourceHelper.Instance.FillComboxLookUp(newCtl, filterCfgInfo.Name, _ClientRule.UIRuleXmlConfigInfo.GetDefaultColumns(), _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit, true);
                break;

            case EditControlType.CheckBox:
                (newCtl as CheckBox).Text = columns[filterCfgInfo.Name].Description;
                break;

            case EditControlType.ComboCheckedListBox:
                MB.WinBase.Binding.BindingSourceHelper.Instance.FillComboCheckListBox(newCtl, filterCfgInfo.Name, _ClientRule.UIRuleXmlConfigInfo.GetDefaultColumns(), _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit);
                break;

            case EditControlType.ClickButtonInput:
                MB.WinBase.Ctls.ucClickButtonInput clickButton = newCtl as MB.WinBase.Ctls.ucClickButtonInput;

                if (_ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit != null && _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit.ContainsKey(filterCfgInfo.Name))
                {
                    clickButton.ColumnEditCfgInfo = _ClientRule.UIRuleXmlConfigInfo.ColumnsCfgEdit[filterCfgInfo.Name];
                    clickButton.FilterElementInfo = filterCfgInfo;
                    clickButton.ClientRule        = this._ClientRule;
                }
                break;

            //add by aifang 2012-03-28 begin 根据xml配置设置日期显示的格式
            case EditControlType.DateFilterCtl:
                MB.WinBase.Ctls.ucEditDateFilter dateFilter = newCtl as MB.WinBase.Ctls.ucEditDateFilter;
                dateFilter.DateFilterType = WinBase.Ctls.ucEditDateFilter.DateFilterEditType.Today;      //所有查询字段默认为当天 edit by aifang
                if (string.IsNullOrEmpty(filterCfgInfo.Formate))
                {
                    filterCfgInfo.Formate = "yyyy-MM-dd";
                }
                dateFilter.Formate = filterCfgInfo.Formate;
                break;
            //add by aifang 2012-03-28 end

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

            default:
                //
                break;
            }
            if (hoster != null)
            {
                hoster.AfterCreateFilterCtl(newCtl, filterCfgInfo);
            }

            return(newCtl);
        }
Esempio n. 3
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());
        }