Ejemplo n.º 1
0
        /// <summary>
        /// 根据配置,从数据源中得到所有ClickButton的列,并把这些列的text值与列名做成字典,方便后面转换
        /// </summary>
        /// <param name="dsData">从excel中获得的数据源</param>
        /// <returns>字典,键是ClickButtonInput的名字,值是所有text的集合</returns>
        private Dictionary <string, List <object> > generateClickButtonWithTextDic(DataSet dsData)
        {
            //对ClickButtonInput的导入数据进行赋值,因为在excel中,导入的是这个字段的Text Value
            IEnumerable <ColumnEditCfgInfo> clickInputButtonCols = _EditColumns.Values.Where(editCol => {
                MB.WinBase.Common.EditControlType controlType =
                    (MB.WinBase.Common.EditControlType)Enum.Parse(typeof(MB.WinBase.Common.EditControlType), editCol.EditControlType);
                return(controlType == EditControlType.ClickButtonInput);
            });

            Dictionary <string, List <object> > clickInputButtonColsWithTexts = new Dictionary <string, List <object> >();

            foreach (DataRow dr in dsData.Tables[0].Rows)
            {
                foreach (var clickButtonInputCol in clickInputButtonCols)
                {
                    if (!dsData.Tables[0].Columns.Contains(clickButtonInputCol.Name))
                    {
                        continue;
                    }

                    if (clickInputButtonColsWithTexts.ContainsKey(clickButtonInputCol.Name))
                    {
                        if (dr[clickButtonInputCol.Name] != null &&
                            dr[clickButtonInputCol.Name] != System.DBNull.Value &&
                            !clickInputButtonColsWithTexts[clickButtonInputCol.Name].Contains(dr[clickButtonInputCol.Name]))
                        {
                            clickInputButtonColsWithTexts[clickButtonInputCol.Name].Add(dr[clickButtonInputCol.Name]);
                        }
                    }
                    else
                    {
                        List <object> textValues = new List <object>();
                        textValues.Add(dr[clickButtonInputCol.Name]);
                        clickInputButtonColsWithTexts.Add(clickButtonInputCol.Name, textValues);
                    }
                }
            }
            return(clickInputButtonColsWithTexts);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 通过设置的Edit 列信息得到一个编辑列的控件。
        /// </summary>
        /// <param name="editInfo"></param>
        /// <param name="allowEdit"></param>
        /// <returns></returns>
        public DevExpress.XtraEditors.Repository.RepositoryItem CreateEditItemByEditInfo(MB.WinBase.Common.ColumnEditCfgInfo editInfo, bool allowEdit, string colDataType)
        {
            DevExpress.XtraEditors.Repository.RepositoryItem item = null;
            MB.WinBase.Common.EditControlType controlType         = (MB.WinBase.Common.EditControlType)Enum.Parse(typeof(MB.WinBase.Common.EditControlType), editInfo.EditControlType);

            switch (controlType)
            {
            case MB.WinBase.Common.EditControlType.Combox_DropDownList:
            case MB.WinBase.Common.EditControlType.Combox_DropDown:
                DevExpress.XtraEditors.Repository.RepositoryItemComboBox cobItem = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
                //cobItem.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton());
                cobItem.AutoComplete = true;
                setRComboxItems(cobItem, editInfo);
                item = cobItem;
                break;

            case MB.WinBase.Common.EditControlType.ComboCheckedListBox:    //如果设置为
            case MB.WinBase.Common.EditControlType.LookUpEdit:
                DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit lookUp = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();

                XtraRepositoryItemLookUpEditHelper.Instance.CreateLookUpEditItems(lookUp, editInfo, colDataType);
                //暂时把所有的LookUp 的格式 转换为PopupCOntainer 的格式,正确的处理方法应该是区别对待。
                // DevExpress.XtraEditors.Repository.RepositoryItemPopupContainerEdit lookUp = new XtraRepositoryItemPopupContainerEdit(editInfo, allowEdit);
                // lookUp.Name = editInfo.Name;
                item = lookUp;
                break;

            case MB.WinBase.Common.EditControlType.ImageIcoEdit:
                var imageEdit = new DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit();
                item = imageEdit;
                break;

            case MB.WinBase.Common.EditControlType.ColorEdit:
                var colorEdit = new DevExpress.XtraEditors.Repository.RepositoryItemColorEdit();
                colorEdit.ColorText           = DevExpress.XtraEditors.Controls.ColorText.Integer;
                colorEdit.StoreColorAsInteger = true;
                item = colorEdit;
                break;

            //
            //case "ImageCombox": //可以当做存储键/值列并且是只能选择的Combox 控件来使用。
            //    DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox imgCob = new DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox();
            //    imgCob.AllowFocused = false;
            //    imgCob.AutoHeight = false;
            //    setImageCobItems(imgCob, editInfo);
            //    item = imgCob;
            //    break;
            //case "PopupContainer":
            //    DevExpress.XtraEditors.Repository.RepositoryItemPopupContainerEdit popuCon = new XtraRepositoryItemPopupContainerEdit(editInfo, allowEdit);
            //    item = popuCon;
            //    break;
            //case "Ellipsis":
            //    //DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit butEdit = new DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit();
            //    //butEdit.ButtonClick +=new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(butEdit_ButtonClick);
            //    //butEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            //    //																		   new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)});
            //    //					RepositoryItemMyButtonEdit butEdit = new RepositoryItemMyButtonEdit();
            //    //
            //    //					item = butEdit;
            //    break;
            case MB.WinBase.Common.EditControlType.ClickButtonInput:
                XtraRepositoryItemClickButtonEdit butEdit = new XtraRepositoryItemClickButtonEdit(editInfo);
                // (butEdit.Buttons[0] as MyButtonEdit).ColumnEditCfgInfo = editInfo;
                item = butEdit;

                break;

            case MB.WinBase.Common.EditControlType.PopupRegionEdit:
                XtraRepositoryItemRegionEdit regionEdit = new XtraRepositoryItemRegionEdit(editInfo);
                item = regionEdit;
                break;

            default:
                throw new MB.Util.APPException("该EditCols 类型" + editInfo.EditControlType + "还没有进行处理。请确定配置的信息是否正确?");
                //break;
            }
            return(item);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        private List <QueryParameterInfo> buildQueryParams(MB.Util.Model.QueryParameterInfo[] queryParamters)
        {
            List <MB.Util.Model.QueryParameterInfo> filterList = new List <QueryParameterInfo>();

            foreach (var queryParam in queryParamters)
            {
                if (string.IsNullOrEmpty(queryParam.PropertyName))
                {
                    if (queryParam.Childs != null && queryParam.Childs.Count > 0)
                    {
                        filterList.AddRange(buildQueryParams(queryParam.Childs.ToArray()));
                        continue;
                    }
                }
                if (_ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit == null || !_ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit.ContainsKey(queryParam.PropertyName))
                {
                    continue;
                }

                var cfgEditInfo = _ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit[queryParam.PropertyName];
                MB.WinBase.Common.EditControlType controlType = (EditControlType)Enum.Parse(typeof(EditControlType), cfgEditInfo.EditControlType);
                if (controlType == EditControlType.PopupRegionEdit)
                {
                    var filter = queryParamters.Where(o => o.PropertyName.Equals(cfgEditInfo.Name)).FirstOrDefault();
                    if (filter != null)
                    {
                        string   val  = filter.Value.ToString();
                        string[] vals = val.Split(' ');

                        if (vals.Length > 0)
                        {
                            var mappingInfo = cfgEditInfo.EditCtlDataMappings.Find(o => o.SourceColumnName.Equals("Country"));
                            if (mappingInfo != null)
                            {
                                filterList.Add(new MB.Util.Model.QueryParameterInfo(mappingInfo.ColumnName, vals[0], filter.Condition));
                            }
                        }
                        if (vals.Length > 1)
                        {
                            var mappingInfo = cfgEditInfo.EditCtlDataMappings.Find(o => o.SourceColumnName.Equals("Province"));
                            if (mappingInfo != null)
                            {
                                filterList.Add(new MB.Util.Model.QueryParameterInfo(mappingInfo.ColumnName, vals[1], filter.Condition));
                            }
                        }
                        if (vals.Length > 2)
                        {
                            var mappingInfo = cfgEditInfo.EditCtlDataMappings.Find(o => o.SourceColumnName.Equals("City"));
                            if (mappingInfo != null)
                            {
                                filterList.Add(new MB.Util.Model.QueryParameterInfo(mappingInfo.ColumnName, vals[2], filter.Condition));
                            }
                        }
                        if (vals.Length > 3)
                        {
                            var mappingInfo = cfgEditInfo.EditCtlDataMappings.Find(o => o.SourceColumnName.Equals("District"));
                            if (mappingInfo != null)
                            {
                                filterList.Add(new MB.Util.Model.QueryParameterInfo(mappingInfo.ColumnName, vals[3], filter.Condition));
                            }
                        }

                        filterList.Remove(filter);
                    }
                }
            }
            return(filterList);
        }
Ejemplo n.º 5
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());
        }