public InvokeDataAssistantHosterEventArgs(IClientRuleQueryBase clientRule, ColumnEditCfgInfo clumnEditCfgInfo, object currentEditObject, List <QueryParameterInfo> filterParameters) { _ClientRule = clientRule; _FilterParameters = filterParameters; _ClumnEditCfgInfo = clumnEditCfgInfo; _CurrentEditObject = currentEditObject; }
/// <summary> /// 创建数据获取帮助窗口。 /// </summary> /// <param name="cfgInfo"></param> /// <param name="parentForm"></param> /// <param name="clientQueryRule"></param> /// <returns></returns> public MB.WinBase.IFace.IDataAssistant CreateDataAssistantObject(object srcControl, ColumnEditCfgInfo cfgInfo, System.Windows.Forms.Control parentHoster, ref MB.WinBase.IFace.IClientRuleQueryBase clientQueryRule) { MB.WinBase.Common.ColumnEditCfgInfo columnEditCfgInfo = cfgInfo; if (columnEditCfgInfo == null) { throw new MB.Util.APPException("需要进行查询的对象ColumnEditCfg 没有进行进行相应的配置。", MB.Util.APPMessageType.DisplayToUser); } if (cfgInfo.CreateDataAssistant != null) { return(cfgInfo.CreateDataAssistant(srcControl)); } //判断是否存在自定义弹出窗口的配置,如果存在就进行处理 else if (columnEditCfgInfo.ClickButtonShowForm != null && !string.IsNullOrEmpty(columnEditCfgInfo.ClickButtonShowForm.Type)) { //edit by aifang 2012-4-19 MB.WinBase.IFace.IInvokeDataAssistantHoster hoster = parentHoster as MB.WinBase.IFace.IInvokeDataAssistantHoster; if (hoster != null) { MB.WinBase.IFace.InvokeDataAssistantHosterEventArgs arg = new MB.WinBase.IFace.InvokeDataAssistantHosterEventArgs(columnEditCfgInfo); arg.ClientRule = clientQueryRule; hoster.BeforeShowDataAssistant(srcControl, arg); if (arg.Cancel) { return(null); } clientQueryRule = arg.ClientRule; columnEditCfgInfo = arg.ClumnEditCfgInfo; } //end string[] pars = null; if (!string.IsNullOrEmpty(columnEditCfgInfo.ClickButtonShowForm.TypeConstructParams)) { pars = columnEditCfgInfo.ClickButtonShowForm.TypeConstructParams.Split(','); } string[] frmSetting = columnEditCfgInfo.ClickButtonShowForm.Type.Split(','); object frm = MB.Util.DllFactory.Instance.LoadObject(frmSetting[0], pars, frmSetting[1]); if ((frm as Form) == null) { throw new MB.Util.APPException(" ColumnEditCfgInfo 的 ClickButtonShowForm 配置不是有效的一个窗口类", MB.Util.APPMessageType.SysErrInfo); } if ((frm as MB.WinBase.IFace.IDataAssistant) == null) { throw new MB.Util.APPException(" ClickButtonInput 弹出的自定义窗口必须实现 MB.WinBase.IFace.IDataAssistant 接口", MB.Util.APPMessageType.SysErrInfo); } return(frm as MB.WinBase.IFace.IDataAssistant); } else { if (columnEditCfgInfo.InvokeDataSourceDesc == null) { throw new MB.Util.APPException(" ColumnEditCfg 配置项的InvokeDataSourceDesc 没有进行进行相应的配置。", MB.Util.APPMessageType.SysErrInfo); } string[] descs = columnEditCfgInfo.InvokeDataSourceDesc.Type.Split(','); string[] conPars = null; if (!string.IsNullOrEmpty(cfgInfo.InvokeDataSourceDesc.TypeConstructParams)) { conPars = cfgInfo.InvokeDataSourceDesc.TypeConstructParams.Split(','); } if (clientQueryRule == null) { clientQueryRule = MB.Util.DllFactory.Instance.LoadObject(descs[0], conPars, descs[1]) as MB.WinBase.IFace.IClientRuleQueryBase; } MB.Util.TraceEx.Assert(clientQueryRule != null, "调用UI层业务控制类配置有误!"); //edit by chendc 2010-09-03 MB.WinBase.IFace.IInvokeDataAssistantHoster hoster = parentHoster as MB.WinBase.IFace.IInvokeDataAssistantHoster; if (hoster != null) { MB.WinBase.IFace.InvokeDataAssistantHosterEventArgs arg = new MB.WinBase.IFace.InvokeDataAssistantHosterEventArgs(columnEditCfgInfo); arg.ClientRule = clientQueryRule; hoster.BeforeShowDataAssistant(srcControl, arg); if (arg.Cancel) { return(null); } clientQueryRule = arg.ClientRule; } string defaultQueryFilterForm = "MB.WinClientDefault.QueryFilter.FrmGetObjectDataAssistant,MB.WinClientDefault.Dll"; string[] formSetting = defaultQueryFilterForm.Split(','); MB.WinBase.IFace.IGetObjectDataAssistant dataAssistant = MB.Util.DllFactory.Instance.LoadObject(formSetting[0], formSetting[1]) as MB.WinBase.IFace.IGetObjectDataAssistant; MB.Util.TraceEx.Assert(dataAssistant != null, "帮助查找窗口必须实现接口MB.WinBase.IFace.IGetObjectDataAssistant!"); resetDataAssistant(clientQueryRule, columnEditCfgInfo, null, hoster, dataAssistant); return(dataAssistant); } }
public InvokeDataAssistantHosterEventArgs(MB.WinBase.Common.ColumnEditCfgInfo clumnEditCfgInfo) { _ClumnEditCfgInfo = clumnEditCfgInfo; }
//根据指定的ColumnPropertyInfo 判断输入的值是否符合要求。 private bool validated(MB.WinBase.Common.ColumnPropertyInfo colPropertyInfo, MB.WinBase.Common.ColumnEditCfgInfo colEditProInfo, object inputValue, ref string errMsg) { bool b; StringBuilder msgStr = new StringBuilder(); //得到要检验的这个列 //如果是字符窜类型需要检验长度 //如果值为空不需要检验数据类型 if (colPropertyInfo.IsNull == true && (inputValue == null || inputValue.ToString().Length == 0)) { return(true); } if (colPropertyInfo.IsNull != true && (inputValue == null || inputValue.ToString().Length == 0)) { string nameDesc = (colPropertyInfo.Description != null && colPropertyInfo.Description.Length > 0) ? colPropertyInfo.Description : colPropertyInfo.Name; msgStr.Append(nameDesc + ":不能为空"); //如果检验不通过输出错误的信息 errMsg = CLL.Message(MSG_NOTNULL, new string[] { nameDesc }); return(false); } Type sType = MB.Util.General.CreateSystemType(colPropertyInfo.DataType, false); if (sType == null) { throw new MB.Util.APPException(string.Format("XML 文件中列{0} 的类型配置信息有误,请检查XML 文件配置", colPropertyInfo.Description)); } b = MB.Util.DataValidated.Instance.ValidatedDataType(sType, inputValue); if (b == true) { if (string.Compare(sType.Name, "String", true) == 0) { b = validatedString(colPropertyInfo, inputValue, ref errMsg); } else if (Array.IndexOf(NUMBER_DATA_TYPE, sType.Name.ToUpper()) >= 0) { b = validatedNumber(colPropertyInfo, inputValue, ref errMsg); } else if (Array.IndexOf(DATETIME_DATA_TYPE, sType.Name.ToUpper()) >= 0) { b = validatedDateTime(colPropertyInfo, inputValue, ref errMsg); } else { //其它类型先不做处理 后期根据实际需要再加上 } } else { errMsg = CLL.Message(MSG_MUST_INPUT, new string[] { colPropertyInfo.Description, MB.Util.DataValidated.Instance.GetTypeValidatedErrMsg(sType) }); return(false); } if (colEditProInfo != null && colEditProInfo.IsValidateInputFromDataSource) { b = validateColValueInLookUpSource(colPropertyInfo, colEditProInfo, inputValue, ref errMsg); } return(b); }
public void ShowProperty(MB.WinBase.Common.ColumnEditCfgInfo columnEditCfgInfo, string columnName, object value) { try { if (columnEditCfgInfo.InvokeDataSourceDesc == null) { throw new MB.Util.APPException(" ColumnEditCfg 配置项的InvokeDataSourceDesc 没有进行进行相应的配置。", MB.Util.APPMessageType.SysErrInfo); } string type = columnEditCfgInfo.InvokeDataSourceDesc.Type; string method = columnEditCfgInfo.InvokeDataSourceDesc.Method; if (columnEditCfgInfo.InvokeDataPropertyDesc != null) { type = columnEditCfgInfo.InvokeDataPropertyDesc.Type; method = columnEditCfgInfo.InvokeDataPropertyDesc.Method; } string[] descs = type.Split(','); string[] conPars = null; if (!string.IsNullOrEmpty(columnEditCfgInfo.InvokeDataSourceDesc.TypeConstructParams)) { conPars = columnEditCfgInfo.InvokeDataSourceDesc.TypeConstructParams.Split(','); } var clientQueryRule = MB.Util.DllFactory.Instance.LoadObject(descs[0], conPars, descs[1]); ModuleInvokeConfigAttribute[] atts = AttributeConfigHelper.Instance.GetModuleInvokeConfig(clientQueryRule.GetType()); var configAtt = atts.Where(o => o.OptType == UICommandType.AddNew).FirstOrDefault(); if (configAtt == null) { throw new MB.Util.APPException("ModuleInvokeConfigAttribute属性未配置 UICommandType.AddNew 类型值", Util.APPMessageType.DisplayToUser); } string fullName = configAtt.UIViewType.FullName; //获取数据 List <MB.Util.Model.QueryParameterInfo> filterParams = new List <QueryParameterInfo>(); filterParams.Add(new QueryParameterInfo(columnName, value, Util.DataFilterConditions.Equal)); ArrayList pars = new ArrayList(); string[] methods = method.Split(','); if (methods.Length > 1) { for (int i = 1; i < methods.Length; i++) { pars.Add(methods[i]); } } pars.Add(filterParams.ToArray()); object data = MB.Util.MyReflection.Instance.InvokeMethod(clientQueryRule, methods[0], pars.ToArray()); if (data == null) { throw new MB.Util.APPException("获取数据为空!", Util.APPMessageType.DisplayToUser); } IList list = data as IList; BindingSourceEx bindingSource = new BindingSourceEx(); bindingSource.DataSource = list[0]; object[] objPars = new object[3]; objPars[0] = clientQueryRule; objPars[1] = ObjectEditType.OpenReadOnly; objPars[2] = bindingSource; var objFrm = MB.Util.DllFactory.Instance.LoadObject(fullName, objPars, descs[1]); Form frm = (Form)objFrm; frm.ShowDialog(); } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); } }
//设置combobox 的items 值。 private void setRComboxItems(DevExpress.XtraEditors.Repository.RepositoryItemComboBox cobItem, MB.WinBase.Common.ColumnEditCfgInfo editInfo) { if (editInfo.DataSource == null) { return; } string txtName = editInfo.TextFieldName; cobItem.Items.Clear(); IList lstDatas = editInfo.DataSource as IList; if (lstDatas != null) { foreach (object entity in lstDatas) { object txtValue = MB.Util.MyReflection.Instance.InvokePropertyForGet(entity, txtName); cobItem.Items.Add(txtValue); } } else { DataTable dtData = MB.Util.MyConvert.Instance.ToDataTable(editInfo.DataSource, string.Empty); foreach (DataRow dr in dtData.Rows) { cobItem.Items.Add(dr[txtName]); } } }
/// <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); }
/// <summary> /// 通过设置的Edit 列信息得到一个编辑列的控件。 /// </summary> /// <param name="editInfo"></param> /// <returns></returns> public DevExpress.XtraEditors.Repository.RepositoryItem CreateEditItemByEditInfo(MB.WinBase.Common.ColumnEditCfgInfo editInfo, string colDataType) { return(CreateEditItemByEditInfo(editInfo, true, colDataType)); }
/// <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) { return(CreateEditItemByEditInfo(editInfo, allowEdit, COL_UNKNOW_DATE_TYPE_FOR_CREATING)); }
/// <summary> /// /// </summary> /// <param name="columnEditCfgInfo"></param> public XtraRepositoryItemRegionEdit(MB.WinBase.Common.ColumnEditCfgInfo columnEditCfgInfo) { _ColumnEditCfgInfo = columnEditCfgInfo; }