diff --git a/插件库/Lskj.Control/GridControlEx.cs b/插件库/Lskj.Control/GridControlEx.cs index 1be67a1..186ffaf 100644 --- a/插件库/Lskj.Control/GridControlEx.cs +++ b/插件库/Lskj.Control/GridControlEx.cs @@ -354,6 +354,10 @@ namespace Lskj.Control ///选中的行在数据源中的索引 /// private List SelectedDataSource = new List(); + /// + /// 禁显列不加载数据源 + /// + public bool DisableFieldSources; public GridControlEx() { @@ -660,6 +664,11 @@ namespace Lskj.Control /// The dr row. protected void InitEditColumns(GridColumn column, GridColumnModel model) { + if (this.DisableFieldSources && model.isVislble) + { + return; + } + if (!string.IsNullOrEmpty(model.SqlSource)) { Task sourceTask = new Task(() => @@ -793,6 +802,10 @@ namespace Lskj.Control case ControlType.LabSelectReturnText: InitSelectReturnId(column, model); break; + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: + InitSelectReturnIdNew(column, model); + break; case ControlType.LabSelectReturnRows: InitSelectReturnRows(column, model); break; @@ -927,6 +940,7 @@ namespace Lskj.Control for (int i = 0; i < table.Rows.Count; i++) { GridColumnModel model = new GridColumnModel(table.Rows[i], false); + GridColumn gridColumn = new GridColumn(); gridColumn.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; @@ -1055,9 +1069,18 @@ namespace Lskj.Control { foreach (GridColumnModel item in mControlList) { + if (this.DisableFieldSources && item.isVislble) continue; if (!string.IsNullOrWhiteSpace(item.SqlSource)) { - DataTable dataTable = BaseImpl.GetDataTableResult(item.SqlSource); + DataTable dataTable = new DataTable(); + if (mControlSourceDic.ContainsKey(item)) + { + dataTable = mControlSourceDic[item].Result; + } + else + { + dataTable = BaseImpl.GetDataTableResult(item.SqlSource); + } Application.DoEvents(); if (!item.Visible) continue; switch (item.FieldType) @@ -1278,7 +1301,6 @@ namespace Lskj.Control foreach (DataRow item in table.Rows) { GridColumnModel model = new GridColumnModel(item); - GridColumn gridColumn = new GridColumn(); gridColumn.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; gridColumn.FieldName = model.FieldName; @@ -3995,6 +4017,7 @@ namespace Lskj.Control } } + /// /// 说明:创建 模块返回ID /// 创建人:曹屹峰 @@ -4039,6 +4062,50 @@ namespace Lskj.Control this.mControlList.Add(model); } + /// + /// 说明:创建 模块返回ID 新版 + /// 创建人:曹屹峰 + /// 创建日期:2021-08-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitSelectReturnIdNew(GridColumn gridColumn, GridColumnModel model) + { + FrmModelLookUp2 modelLookUp = new FrmModelLookUp2(model.addModuleld, model.IsRadio); + modelLookUp.ConfigureColumnMode = model.ConfigureColumnMode; + modelLookUp.ValueField = model.ValueMember; + modelLookUp.TextField = model.TextMember; + modelLookUp.SourceSQL = model.SqlSource; + modelLookUp.IsType = model.FieldType; + modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; + modelLookUp.Tag = model; + + RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit(); + btnEdit.NullText = ""; + btnEdit.PopupBorderStyle = PopupBorderStyles.Flat; + btnEdit.AllowNullInput = DefaultBoolean.False; + btnEdit.DisplayMember = model.TextMember; + btnEdit.SeparatorChar = ','; + btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; + //DataTable dataTable = MainImpl.GetDataTableResult(modelLookUp.SingleChoiceMode ? modelLookUp.SysModel.MenuSql : model.SqlSource); + ////ModuleEnclosure.Add(model.FieldName, dataTable); + //btnEdit.DataSource = dataTable; + btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用. + btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) }); + + btnEdit.Tag = model; + btnEdit.Buttons[1].Tag = modelLookUp; + btnEdit.ButtonClick += new ButtonPressedEventHandler(OnModuleChoiceNew); + btnEdit.KeyDown += BtnEdit_KeyDown; + gridControl.RepositoryItems.Add(btnEdit); + gridColumn.OptionsColumn.ReadOnly = true; + gridColumn.ColumnEdit = btnEdit; + + + this.mControlList.Add(model); + } @@ -4068,14 +4135,6 @@ namespace Lskj.Control RepositoryItemButtonEdit btnEdit = new RepositoryItemButtonEdit(); btnEdit.NullText = ""; btnEdit.AllowNullInput = DefaultBoolean.False; - //RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit(); - //btnEdit.NullText = ""; - //btnEdit.PopupBorderStyle = PopupBorderStyles.Flat; - //btnEdit.AllowNullInput = DefaultBoolean.False; - //btnEdit.DisplayMember = model.TextMember; - //btnEdit.SeparatorChar = ','; - //btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnId ? model.ValueMember : model.TextMember; - //btnEdit.DataSource = MainImpl.GetDataTableResult(model.SqlSource); btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用. btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) }); @@ -4841,7 +4900,7 @@ namespace Lskj.Control if (model.FieldType == 116) { RepositoryItemCheckedComboBoxEdit rccbe = col.ColumnEdit as RepositoryItemCheckedComboBoxEdit; - FrmModelLookUp modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp; + FrmModelLookUp2 modelLookUp = rccbe.Buttons[1].Tag as FrmModelLookUp2; if (modelLookUp.SingleChoiceMode) { value = GetValueByCaption(model, col.ColumnEdit, cellValue, out IsTextEqualValue); @@ -5959,6 +6018,7 @@ namespace Lskj.Control } + /// /// 说明:表格打开模块返回id /// 创建人:曹屹峰 @@ -5975,6 +6035,60 @@ namespace Lskj.Control CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender; FrmModelLookUp modelLookUp = e.Button.Tag as FrmModelLookUp; + GridColumnModel model = modelLookUp.Tag as GridColumnModel; + modelLookUp.EditText = btnEdit.Text; + modelLookUp.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName; + if (model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueParam) + { + modelLookUp.EditValue = btnEdit.EditValue + ""; + modelLookUp.EditText = string.Empty; + } + else + { + modelLookUp.EditText = btnEdit.Text; + modelLookUp.EditValue = string.Empty; + } + //多选关联单据头 + modelLookUp.SourceSQL = model.SqlSource.Replace("#", ""); + //单据头关联取值 + if (this.ParentControl != null) + { + modelLookUp.SourceSQL = this.ParentControl.ReplaceControlValue(modelLookUp.SourceSQL); + } + + modelLookUp.SourceSQL = ReplaceHelper.ReplaceRowParam(this.gridView.GetFocusedDataRow(), modelLookUp.SourceSQL); + //modelLookUp.DataSource = BaseImpl.GetDataTableResult(modelLookUp.SourceSQL); + modelLookUp.InitControls(modelLookUp.UnionModuleCodel); + DialogResult result = modelLookUp.ShowDialog(); + if (result == DialogResult.OK) + { + btnEdit.EditValue = modelLookUp.EditValue; + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode); + MessageUtil.Show(Message, ex.Message); + } + } + + /// + /// 说明:表格打开模块返回id 新版 + /// 创建人:曹屹峰 + /// 创建日期:2021-08-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void OnModuleChoiceNew(object sender, ButtonPressedEventArgs e) + { + try + { + CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender; + FrmModelLookUp2 modelLookUp = e.Button.Tag as FrmModelLookUp2; + GridColumnModel model = modelLookUp.Tag as GridColumnModel; modelLookUp.EditText = btnEdit.Text; modelLookUp.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName; diff --git a/插件库/Lskj.Control/LabelAutoTreeEdit.cs b/插件库/Lskj.Control/LabelAutoTreeEdit.cs index 4eb5f81..4f26f30 100644 --- a/插件库/Lskj.Control/LabelAutoTreeEdit.cs +++ b/插件库/Lskj.Control/LabelAutoTreeEdit.cs @@ -263,35 +263,4 @@ namespace Lskj.Control if (this.isMultiClick) { this.TextEdit.Popup.AddVisible = true; - this.TextEdit.Popup.OnAddMouseClick += new EventHandler(Popup_OnAddMouseClick); - } - } - /// - /// 说明:添加操作后 - /// 创建人:龚宇超 - /// 创建日期:2018-04-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - protected void Popup_OnAddMouseClick(object sender, EventArgs e) - { - try - { - this.TextEdit.SetValue(); - this.TextEdit.HidePopup(); - } - catch (Exception ex) - { - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - } - - - - } -} \ No newline at end of file + this.TextEdit.Popup.OnAddMouseClick += new Even \ No newline at end of file diff --git a/插件库/Lskj.Control/LabelComboxEdit.cs b/插件库/Lskj.Control/LabelComboxEdit.cs index 0f0aea8..3718342 100644 --- a/插件库/Lskj.Control/LabelComboxEdit.cs +++ b/插件库/Lskj.Control/LabelComboxEdit.cs @@ -57,6 +57,7 @@ namespace Lskj.Control InitializeComponent(); } + /// /// 说明:设置控件显示文本 /// 创建人:龚宇超 @@ -255,45 +256,4 @@ namespace Lskj.Control /// 修改人: /// 修改日期: /// 修改备注: - /// 版本:1.0 - /// - /// 数据源 - public void SetDataSource(DataTable dataSource) - { - try - { - foreach (DataRow item in dataSource.Rows) - { - ComboBoxModel model = new ComboBoxModel - { - ValueMember = ValueField, - DisplayMember = TextField, - RowItem = item - }; - this._sources.Add(model); - this.txtEdit.Properties.Items.Add(model); - } - } - catch (Exception) - { - - } - } - - - } - class ComboBoxModel - { - public string ValueMember; - public string DisplayMember; - public DataRow RowItem; - - public override string ToString() - { - return this.RowItem[DisplayMember] + ""; - } - - - - } -} \ No newline at end of file + /// 版本: \ No newline at end of file diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs b/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs index 1192a6a..de09895 100644 --- a/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs @@ -7,15 +7,22 @@ * 修改备注: * 版本:1.0.0.0 ******************************/ -using DevExpress.XtraEditors; -using Lskj.Business.Impl; -using Lskj.Control.Model; -using Lskj.Control.MultiModelLookUp; using System; -using System.Data; +using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Data; using System.Linq; +using System.Text; using System.Windows.Forms; +using DevExpress.XtraEditors.Controls; +using DevExpress.XtraEditors; +using Lskj.Data; +using Lskj.Control.Model; +using Lskj.Control.MultiGridLookUp; +using Lskj.Business.Impl; +using Lskj.Util; +using Lskj.Control.MultiModelLookUp; namespace Lskj.Control { @@ -70,18 +77,6 @@ namespace Lskj.Control /// /// The Union ModuleCodel. public string UnionModuleCodel; - /// - /// 条件 - /// - public string SplicingConditions; - /// - ///模块选择返回框,是否单选模式 - /// - public bool IsRadio { get; set; } - /// - ///模块选择返回框,配置列加载模式(默认根据sql动态加载列) - /// - public bool ConfigureColumnMode { get; set; } public LabelMultiAutoTextEdit2() { @@ -281,14 +276,12 @@ namespace Lskj.Control /// 数据源 public void SetDataSource(DataTable dataSource) { - _lookUpForm = new FrmModelLookUp(UnionModuleCodel, IsRadio); - _lookUpForm.ConfigureColumnMode = ConfigureColumnMode; + _lookUpForm = new FrmModelLookUp(UnionModuleCodel); _lookUpForm.ValueField = ValueField; _lookUpForm.ValueMember = ValueMember; _lookUpForm.TextField = TextField; - - //_lookUpForm.SourceSQL = SourceSQL; - //_lookUpForm.DataSource = dataSource; + _lookUpForm.SourceSQL = SourceSQL; + _lookUpForm.DataSource = dataSource; } /// /// 说明:清空选中的值 @@ -318,6 +311,16 @@ namespace Lskj.Control { try { + //_lookUpForm = new FrmModelLookUp(); + //_lookUpForm.ValueField = ValueField; + //_lookUpForm.ValueMember = ValueMember; + //_lookUpForm.TextField = TextField; + //_lookUpForm.SourceSQL = Model.SourceSql; + //_lookUpForm.UnionModuleCodel = UnionModuleCodel; + //_lookUpForm.EditValue = this.EditValue; + //_lookUpForm.IsType = Model.FieldType; + //_lookUpForm.EditText = this.TextEdit.Text; + //_lookUpForm.DataSource = BaseImpl.GetDataTableResult(_lookUpForm.SourceSQL); if (_lookUpForm != null) { if (_lookUpForm != null) @@ -327,14 +330,7 @@ namespace Lskj.Control _lookUpForm.EditText = this.TextEdit.Text; } - string sqlValue = _lookUpForm.SysModel.MenuSql + Model.SplicingConditions; + string sqlValue = string.Empty; if (this.ControlObj != null) { - sqlValue = this.ControlObj.ReplaceControlValue(sqlValue); - sqlValue = sqlValue.Replace("#", ""); - - //_lookUpForm.DataSource = MainImpl.GetDataTableResult(sqlValue); - } - _lookUpForm.NewSourceSQL = sqlValue; - _lookUpForm.AddModuleResult = Model.AddModuleResult; - _lookUpForm \ No newline at end of file + sqlValue = this.Cont \ No newline at end of file diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit4.Designer.cs b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.Designer.cs new file mode 100644 index 0000000..94cb57b --- /dev/null +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.Designer.cs @@ -0,0 +1,102 @@ +namespace Lskj.Control +{ + partial class LabelMultiAutoTextEdit4 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LabelMultiAutoTextEdit4)); + this.lblText = new System.Windows.Forms.Label(); + this.plRight = new System.Windows.Forms.Panel(); + this.btnMore = new DevExpress.XtraEditors.SimpleButton(); + this.plLeft = new System.Windows.Forms.Panel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.txtEdit = new DevExpress.XtraEditors.MemoEdit(); + this.plRight.SuspendLayout(); + this.plLeft.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtEdit.Properties)).BeginInit(); + this.SuspendLayout(); + // + // lblText + // + this.lblText.AutoSize = true; + this.lblText.Location = new System.Drawing.Point(5, 4); + this.lblText.Name = "lblText"; + this.lblText.Size = new System.Drawing.Size(29, 12); + this.lblText.TabIndex = 0; + this.lblText.Text = "名称"; + // + // plRight + // + this.plRight.Controls.Add(this.btnMore); + this.plRight.Dock = System.Windows.Forms.DockStyle.Right; + this.plRight.Location = new System.Drawing.Point(136, 0); + this.plRight.Name = "plRight"; + this.plRight.Size = new System.Drawing.Size(26, 21); + this.plRight.TabIndex = 5; + // + // btnMore + // + this.btnMore.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnMore.Appearance.Options.UseFont = true; + this.btnMore.Dock = System.Windows.Forms.DockStyle.Fill; + this.btnMore.Image = ((System.Drawing.Image)(resources.GetObject("btnMore.Image"))); + this.btnMore.Location = new System.Drawing.Point(0, 0); + this.btnMore.Name = "btnMore"; + this.btnMore.Size = new System.Drawing.Size(26, 21); + this.btnMore.TabIndex = 2; + this.btnMore.Click += new System.EventHandler(this.btnMore_Click); + // + // plLeft + // + this.plLeft.Controls.Add(this.lblText); + this.plLeft.Dock = System.Windows.Forms.DockStyle.Left; + this.plLeft.Location = new System.Drawing.Point(0, 0); + this.plLeft.Name = "plLeft"; + this.plLeft.Size = new System.Drawing.Size(40, 21); + this.plLeft.TabIndex = 4; + // + // panel1 + // + this.panel1.Controls.Add(this.txtEdit); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(40, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(96, 21); + this.panel1.TabIndex = 6; + // + // txtEdit + // + this.txtEdit.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtEdit.Location = new System.Drawing.Point(0, 0); + this.txtEdit.Name = "txtEdit"; + this.txtEdit.Size = new System.Drawing.Size(96, 21); + this.txtEdit.TabIndex = 0; + // + // LabelMultiAutoTextEdit + // + this.AutoScaleMode = System.Windows.Forms \ No newline at end of file diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit4.cs b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.cs new file mode 100644 index 0000000..b974f71 --- /dev/null +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.cs @@ -0,0 +1,347 @@ +/****************************** +* 说明:自定义多选搜索框 +* 创建人:龚宇超 +* 创建日期:2017-08-08 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using DevExpress.XtraEditors; +using Lskj.Business.Impl; +using Lskj.Control.Model; +using Lskj.Control.MultiModelLookUp; +using System; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; + +namespace Lskj.Control +{ + /// + /// 自定义多选搜索框 + /// + public partial class LabelMultiAutoTextEdit4 : BaseUserControl + { + /// + /// The _look up form + /// + private FrmModelLookUp2 _lookUpForm = null; + /// + /// 绑定ValueMember + /// + public string ValueMember = string.Empty; + /// + /// 隐藏值字段 + /// + public string ValueField = string.Empty; + /// + /// 显示值字段 + /// + public string TextField = string.Empty; + /// + /// 备注字段 + /// + public string RemarkField = string.Empty; + /// + /// 数据源SQL + /// + public string SourceSQL = string.Empty; + /// + /// 隐藏值 + /// + //public string EditValue = string.Empty; + /// + /// The contro object + /// + public MyControl ControlObj; + /// + /// 文本 + /// + /// The label. + public Label Label { get { return lblText; } } + /// + /// 自动搜索框控件 + /// + public TextEdit TextEdit { get { return txtEdit; } } + /// + /// 配置的关联ModuleCodel值 + /// + /// The Union ModuleCodel. + public string UnionModuleCodel; + /// + /// 条件 + /// + public string SplicingConditions; + /// + ///模块选择返回框,是否单选模式 + /// + public bool IsRadio { get; set; } + /// + ///模块选择返回框,配置列加载模式(默认根据sql动态加载列) + /// + public bool ConfigureColumnMode { get; set; } + + private string editValue; + + public LabelMultiAutoTextEdit4() + { + InitializeComponent(); + } + + /// + /// 说明:设置控件显示文本 + /// 创建人:龚宇超 + /// 创建日期:2017-08-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 显示Lebel文本 + public override string LabelText + { + get + { + return this.lblText.Text; + } + set + { + this.lblText.Text = value; + if (FontSize > 0) + { + this.plLeft.Dock = DockStyle.Left; + this.plLeft.AutoSize = false; + this.lblText.AutoSize = false; + this.lblText.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblText.Location = new System.Drawing.Point(0, 0); + this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.txtEdit.Properties.AutoHeight = false; + this.plLeft.Width = value.Length * GetCharWidth(); + + GetCharWidthMultilingual(this.lblText, this.lblText.Text, this.plLeft); + } + else + { + this.plLeft.Width = this.lblText.Width + PaddingLeft; + } + } + } + /// + /// 字体大小 + /// + /// The size of the control. + public override float FontSize + { + get + { + return base.FontSize; + } + set + { + base.FontSize = value; + if (value > 0) + { + this.lblText.Font = new Font(this.lblText.Font.FontFamily, value); + this.TextEdit.Font = new Font(this.TextEdit.Font.FontFamily, value); + } + } + } + + /// + /// 说明:设置控件值 + /// 创建人:龚宇超 + /// 创建日期:2017-08-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + public override string EditText + { + get + { + return this.txtEdit.Text; + } + set + { + this.EditValue = value; + } + } + + + + /// + /// 说明:设置控件值 + /// 创建人:龚宇超 + /// 创建日期:2017-08-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + public string EditValue + { + get + { + return this.TextEdit.Text; + } + set + { + this.TextEdit.Text = value.TrimEnd(','); + this.editValue = value.TrimEnd(','); + } + } + /// + /// 说明:设置控件提示文本 + /// 创建人:龚宇超 + /// 创建日期:2017-08-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 返回控件值 + public override string NullText + { + get + { + return this.txtEdit.Properties.NullValuePrompt; + } + set + { + if (!string.IsNullOrEmpty(value)) + { + this.TextEdit.Properties.NullValuePromptShowForEmptyValue = true; + this.TextEdit.Properties.NullValuePrompt = value; + } + base.NullText = value; + } + } + /// + /// 只读文本颜色 + /// + /// The color of the read only label. + public override bool ReadOnly + { + get + { + return base.ReadOnly; + } + set + { + base.ReadOnly = value; + this.txtEdit.Properties.ReadOnly = value; + this.lblText.ForeColor = value ? base.ReadOnlyLabelForceColor : Required ? base.RequiredLabelForceColor : base.DefaultLabelForceColor; + } + } + /// + /// 必填文本颜色 + /// + /// The color of the required label. + public override bool Required + { + get + { + return base.Required; + } + set + { + base.Required = value; + if (value) + { + this.lblText.ForeColor = base.RequiredLabelForceColor; + } + } + } + /// + /// 说明:需要单独验证是否修改 + /// 创建人:龚宇超 + /// 创建日期:2017-11-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if this instance is update; otherwise, false. + public override bool IsUpdate() + { + if (Model.FieldType == ControlType.LabMultiSelectValue || + Model.FieldType == ControlType.LabMultiSelectValueParam) + { + return !this.Model.Text.Equals(this.EditValue, StringComparison.OrdinalIgnoreCase); + } + else + { + return base.IsUpdate(); + } + } + /// + /// 说明:设置数据源 + /// 创建人:龚宇超 + /// 创建日期:2017-08-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 数据源 + public void InitialFrame() + { + _lookUpForm = new FrmModelLookUp2(UnionModuleCodel, IsRadio); + _lookUpForm.ConfigureColumnMode = ConfigureColumnMode; + _lookUpForm.ValueField = ValueField; + _lookUpForm.ValueMember = ValueMember; + _lookUpForm.TextField = TextField; + //_lookUpForm.SourceSQL = SourceSQL; + //_lookUpForm.DataSource = dataSource; + } + /// + /// 说明:清空选中的值 + /// 创建人:龚宇超 + /// 创建日期:2018-08-24 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + public void ClearSelectForm() + { + // _lookUpForm.ClearSelect(); + } + /// + /// 说明:打开界面 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnMore_Click(object sender, EventArgs e) + { + try + { + if (_lookUpForm != null) + { + if (_lookUpForm != null) + { + _lookUpForm.EditValue = this.EditValue; + _lookUpForm.IsType = Model.FieldType; + _lookUpForm.EditText = this.TextEdit.Text; + } + + string sqlValue = _lookUpForm.SysModel.MenuSql + Model.SplicingConditions; + if (this.ControlObj != null) + { + sqlValue = this.ControlObj.ReplaceControlValue(sqlValue); + sqlValue = sqlValue.Replace("#", ""); + + //_lookUpForm.DataSource = MainImpl.GetDataTableResult(sqlValue); + } + _lookUpForm.NewSourceSQL = sqlValue; + _lookUpForm.AddModuleResult = Model.AddModuleResult; + _lookUpForm.In \ No newline at end of file diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit4.resx b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.resx new file mode 100644 index 0000000..90f604c --- /dev/null +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit4.resx @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 + JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAC8UlEQVQ4T6WSaUhUURTHb0lj4yy+kRIk + xbRQTL9kfdCSIkIIgoiCwBRbRKTU8ENpgZUoalSaqagpmksomeaamqbiOC65oTi5pjaa+zozzTjjm5l/ + 11HKoE/14ffuue/d87uc8w4B8F+QaUlAycg7F/ZLtgUGC46wsga/ku40EelIEZG2RIY0JzCkKc6cNDw1 + J7Wx5qQqSkgqIoS/BSOFLuyG8hsMOjWrVQyjL8+JJYTs3oHJX9h8vyWQZlkAhnUYNF2AKhua2UdoeclA + HM+g4Zk56mKFqI4WojJSiLLHAlRFW7LNqYfKNyVGQW8GFehXgR/pgCIahtVw6BeCoZsLhl5RAd1SDtiZ + OGxMhEEz5IeVlnPIv8unmYRjFHSnigB2CvrFMOhmb4OV+UA7ehHaAU9oek9A3ekKVaszlGIHKOrtIf9o + i9wQo4BrFLQnMTCoe2nSFaxLz+NNiB3SfDkU0x3rNte22d6/um4KInnBQLdcA1XHSQyVXUJ9mjftiZaW + paSNnaPhIPSqJujW8sEuPoF2KhDr414YKHWlPdknI43PGWgnMyGvc0RF9HHMj9ZDv5ZOa48BO3+fJvjT + hAtQDblB0UfL6LGBvNMaJeF8NMYz/qQqUgC1NArj70+hOv40vbgCG1M3oZX5QjN2GaphTyj7j0HeZY/V + NkssSywxXGSB4gc8RdYtLiGF93hQtAehIdkdkz2p0Ex4QT3oAZXUHcreo1jrcMCKxAqLjSIs1IkwV82g + KoqPoodmCTl3zAjJCuBiptYH5TEOdAYSoOw6APlna6y2WmGpaT8WPgkwV8PHTCUP30t4GM7loTDUTOdo + vdsmL4QKMvz4rDjtDPo/BGKpzQ0zNTxM08NTpTzIinmYeGuGsQIuvuZyMZLJRXUEF5lBe8X0NwpfB9IS + ikPt6lJuCJDobYrEq5tw/iDpV7z1LdmHYzjrbOJBBXsSvTl02ZptIcWKYk2xpdhTDlMcKI4Upx0cpNCr + yS7jIG0+/h2Qn42FYhSZQkV1AAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/插件库/Lskj.Control/Lskj.Control.csproj b/插件库/Lskj.Control/Lskj.Control.csproj index d327741..ad938d8 100644 --- a/插件库/Lskj.Control/Lskj.Control.csproj +++ b/插件库/Lskj.Control/Lskj.Control.csproj @@ -787,17 +787,23 @@ LabelIntExtendEdit.cs + + UserControl + + + LabelMultiAutoTextEdit2.cs + UserControl LabelMultiAutoTextEdit3.cs - + UserControl - - LabelMultiAutoTextEdit2.cs + + LabelMultiAutoTextEdit4.cs UserControl @@ -878,17 +884,23 @@ FrmLookUp.cs + + Form + + + FrmModelLookUp.cs + Form FrmRowsModelLookUp.cs - + Form - - FrmModelLookUp.cs + + FrmModelLookUp2.cs Form @@ -1459,11 +1471,14 @@ LabelIntExtendEdit.cs + + LabelMultiAutoTextEdit2.cs + LabelMultiAutoTextEdit3.cs - - LabelMultiAutoTextEdit2.cs + + LabelMultiAutoTextEdit4.cs LabelRadioButtonGroupEdit.cs @@ -1489,11 +1504,14 @@ FrmLookUp.cs + + FrmModelLookUp.cs + FrmRowsModelLookUp.cs - - FrmModelLookUp.cs + + FrmModelLookUp2.cs FrmRowsModelLookUpNew.cs diff --git a/插件库/Lskj.Control/Model/AutoSizeChange.cs b/插件库/Lskj.Control/Model/AutoSizeChange.cs index 05b65a0..154a89f 100644 --- a/插件库/Lskj.Control/Model/AutoSizeChange.cs +++ b/插件库/Lskj.Control/Model/AutoSizeChange.cs @@ -298,11 +298,18 @@ namespace Lskj.Control.Model break; case ControlType.LabSelectReturnId: case ControlType.LabSelectReturnText: - LabelMultiAutoTextEdit2 moduleReturnsId = ctrol as LabelMultiAutoTextEdit2; + LabelMultiAutoTextEdit4 moduleReturnsId = ctrol as LabelMultiAutoTextEdit4; moduleReturnsId.TextEdit.Size = new Size(Convert.ToInt32(moduleReturnsId.TextEdit.Width * widthZoomValue), Convert.ToInt32(moduleReturnsId.TextEdit.Height * heightZoomValue)); moduleReturnsId.TextEdit.Font = new Font(moduleReturnsId.TextEdit.Font.OriginalFontName, Convert.ToSingle(moduleReturnsId.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); moduleReturnsId.TextEdit.Tag = "Changed"; break; + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: + LabelMultiAutoTextEdit4 moduleReturnsIdNew = ctrol as LabelMultiAutoTextEdit4; + moduleReturnsIdNew.TextEdit.Size = new Size(Convert.ToInt32(moduleReturnsIdNew.TextEdit.Width * widthZoomValue), Convert.ToInt32(moduleReturnsIdNew.TextEdit.Height * heightZoomValue)); + moduleReturnsIdNew.TextEdit.Font = new Font(moduleReturnsIdNew.TextEdit.Font.OriginalFontName, Convert.ToSingle(moduleReturnsIdNew.TextEdit.Font.Size * fontZoomValue * fontZoomValue)); + moduleReturnsIdNew.TextEdit.Tag = "Changed"; + break; case ControlType.LabText: // 文本控件 LabelTextEdit textEdit = ctrol as LabelTextEdit; @@ -516,28 +523,4 @@ namespace Lskj.Control.Model /// 说明:页签控件个数改变时更改标题字体大小 /// 创建人:唐德馨 /// 创建日期:2021-09-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private static void TabPages_CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) - { - try - { - DevExpress.XtraTab.XtraTabPage tabPage = e.Element as DevExpress.XtraTab.XtraTabPage; - if (e.Action.ToString().Equals("Add")) - { - tabPage.Appearance.Header.Font = new Font(tabPage.Appearance.Header.Font.OriginalFontName, Convert.ToSingle(tabPage.Appearance.Header.Font.Size * fontZoomValue * fontZoomValue)); - } - } - catch (Exception ex) - { - string Message = Lskj.Business.Impl.ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - } - #endregion - #endregion - } -} + // \ No newline at end of file diff --git a/插件库/Lskj.Control/Model/ControlType.cs b/插件库/Lskj.Control/Model/ControlType.cs index ab287e2..3189621 100644 --- a/插件库/Lskj.Control/Model/ControlType.cs +++ b/插件库/Lskj.Control/Model/ControlType.cs @@ -400,6 +400,14 @@ namespace Lskj.Control.Model /// 自动模糊匹配弹出模块 /// public const int LabAutoSelectControl = 159; + /// + /// 模块选择返回ID(新版) + /// + public const int LabSelectReturnIdNew = 160; + /// + /// 模块选择返回Text(新版) + /// + public const int LabSelectReturnTextNew = 161; /// @@ -469,32 +477,4 @@ namespace Lskj.Control.Model modelType = 7; break; case "AuditPopupBasicInfoGridView"://单据弹出加载附加信息 - modelType = 8; - break; - default: - modelType = 0; - break; - } - return modelType; - } - /// - /// 说明:是否为日期类型 - /// 创建人:龚宇超 - /// 创建日期: - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// Type of the field. - /// true if the specified field type is date; otherwise, false. - public static bool IsDate(int fieldType) - { - return fieldType == LabDate || - fieldType == LabDateTime || - fieldType == LabDateTimeShort || - fieldType == LabTime || - fieldType == LabShortTime; - } - } -} + modelType = \ No newline at end of file diff --git a/插件库/Lskj.Control/Model/GridColumnModel.cs b/插件库/Lskj.Control/Model/GridColumnModel.cs index 36d03d6..e2e7c23 100644 --- a/插件库/Lskj.Control/Model/GridColumnModel.cs +++ b/插件库/Lskj.Control/Model/GridColumnModel.cs @@ -326,6 +326,12 @@ namespace Lskj.Control.Model /// 条件 /// public string SplicingConditions; + + /// + /// 禁显状态(true是禁显) + /// + public bool isVislble; + #endregion /// @@ -401,4 +407,5 @@ namespace Lskj.Control.Model this.IsRadio = item.Table.Columns.Contains("IsRadio") && !string.IsNullOrWhiteSpace(item["IsRadio"] + "") ? "1".Equals(item["IsRadio"] + "") : false; this.SearchBoxAddition = item.Table.Columns.Contains("SearchBoxAddition") && !string.IsNullOrWhiteSpace(item["SearchBoxAddition"] + "") ? "1".Equals(item["SearchBoxAddition"] + "") : false; this.RepeatedVerification = item.Table.Columns.Contains("RepeatedVerification") && !string.IsNullOrWhiteSpace(item["RepeatedVerification"] + "") ? "1".Equals(item["RepeatedVerification"] + "") : false; - this.SelectionConditions = item.Table.Columns.Contains("SelectionConditions") ? item \ No newline at end of file + this.SelectionConditions = item.Table.Columns.Contains("SelectionConditions") ? item["SelectionConditions"] + "" : string.Empty; + this._frozenFlag = item.Table.Columns.Contains("frozenFlag") && ("1".Equals(item["frozenFlag"] + "") || "Tr \ No newline at end of file diff --git a/插件库/Lskj.Control/Model/MyControl.cs b/插件库/Lskj.Control/Model/MyControl.cs index d801fb8..6210dca 100644 --- a/插件库/Lskj.Control/Model/MyControl.cs +++ b/插件库/Lskj.Control/Model/MyControl.cs @@ -1399,8 +1399,15 @@ namespace Lskj.Control.Model { model.SourceSql += "and 1<>1"; } - DataTable table = BaseImpl.GetDataTableResult(model.SourceSql); - + DataTable table = (model.FieldType == ControlType.LabSelectReturnIdNew || model.FieldType == ControlType.LabSelectReturnTextNew) ? new DataTable() : BaseImpl.GetDataTableResult(model.SourceSql); + if (mControlSourceDic.ContainsKey(model)) + { + table = mControlSourceDic[model].Result; + } + else + { + table = BaseImpl.GetDataTableResult(model.SourceSql); + } //if (model.FieldType != ControlType.LabAutoCompleteValueParam && model.FieldType != ControlType.LabAutoCompleteTextParam && model.FieldType != ControlType.LabAutoCompleteValue && model.FieldType != ControlType.LabAutoCompleteText) // table = MainImpl.GetDataTableResult(model.SourceSql); //else @@ -2059,6 +2066,11 @@ namespace Lskj.Control.Model LabelMultiAutoTextEdit2 moduleReturnsId = ctr as LabelMultiAutoTextEdit2; value = ControlType.LabSelectReturnId == model.FieldType ? moduleReturnsId.EditValue : moduleReturnsId.EditText; break; + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: + LabelMultiAutoTextEdit4 moduleReturnsIdNew = ctr as LabelMultiAutoTextEdit4; + value = ControlType.LabSelectReturnIdNew == model.FieldType ? moduleReturnsIdNew.EditValue : moduleReturnsIdNew.EditText; + break; case ControlType.DynamicallyGeneratedSql: LabelMultiAutoTextEdit3 moduleSqlGenerated = ctr as LabelMultiAutoTextEdit3; value = moduleSqlGenerated.EditText; @@ -4165,18 +4177,35 @@ namespace Lskj.Control.Model moduleReturnsId.ControlObj = this; moduleReturnsId.UnionModuleCodel = model.AddModuleId; moduleReturnsId.SourceSQL = model.SourceSql; - moduleReturnsId.SplicingConditions = model.SplicingConditions; - moduleReturnsId.IsRadio = model.IsRadio; - moduleReturnsId.ConfigureColumnMode = model.ConfigureColumnMode; - - // DataTable dataSource = new DataTable(); //moduleReturnsId.SetDataSource(dataSource); + moduleReturnsId.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown); moduleReturnsId.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged); if (!isLoadBorder) moduleReturnsId.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; baseControl = moduleReturnsId; break; + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: + LabelMultiAutoTextEdit4 moduleReturnsIdNew = new LabelMultiAutoTextEdit4(); + moduleReturnsIdNew.ValueMember = ControlType.LabSelectReturnIdNew == model.FieldType ? model.ValueMember : model.TextMember; + moduleReturnsIdNew.ValueField = model.ValueMember; + moduleReturnsIdNew.TextField = model.TextMember; + moduleReturnsIdNew.ControlObj = this; + moduleReturnsIdNew.UnionModuleCodel = model.AddModuleId; + moduleReturnsIdNew.SourceSQL = model.SourceSql; + moduleReturnsIdNew.SplicingConditions = model.SplicingConditions; + moduleReturnsIdNew.IsRadio = model.IsRadio; + moduleReturnsIdNew.ConfigureColumnMode = model.ConfigureColumnMode; + moduleReturnsIdNew.InitialFrame(); + + // DataTable dataSource = new DataTable(); + //moduleReturnsIdNew.SetDataSource(dataSource); + moduleReturnsIdNew.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown); + moduleReturnsIdNew.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged); + if (!isLoadBorder) moduleReturnsIdNew.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + baseControl = moduleReturnsIdNew; + break; case ControlType.DynamicallyGeneratedSql: LabelMultiAutoTextEdit3 moduleSqlGenerated = new LabelMultiAutoTextEdit3(); // moduleSqlGenerated.SetDataSource(); @@ -4241,6 +4270,8 @@ namespace Lskj.Control.Model this.mControlList.Add(model); return baseControl; } + + /// /// 限制數值框粘貼不能粘貼中文 /// diff --git a/插件库/Lskj.Control/ModuleGridEx.cs b/插件库/Lskj.Control/ModuleGridEx.cs index d44bc5a..2422318 100644 --- a/插件库/Lskj.Control/ModuleGridEx.cs +++ b/插件库/Lskj.Control/ModuleGridEx.cs @@ -1411,7 +1411,7 @@ namespace Lskj.Control //Tips = "条件判断错误:\r\n" + Tips; //string Message = ErrorMessage.PromptErrorMessage(ex, "", Tips); ////MessageUtil.Show("条件判断错误:\r\n" + Tips); - LogHelper.Instance.WriteError(ex); + if(!ex.Message.Equals("该字符串未被识别为有效的布尔值。")) LogHelper.Instance.WriteError(ex); } return result; } @@ -3233,7 +3233,7 @@ namespace Lskj.Control { this.SysModel = sysModel; this.Model = model; - + this.gcMain.DisableFieldSources = this.SysModel.DisableFieldSources; //if (this.Model is DynamicModuleDetailModelInfo) //{ // DynamicModuleDetailModelInfo dynamic = this.Model as DynamicModuleDetailModelInfo; @@ -5063,4 +5063,42 @@ namespace Lskj.Control int focusedRowHandle = this.gcMain.GridView.FocusedRowHandle; GridColumn[] Columns = this.gcMain.GridView.GetSelectedCells(focusedRowHandle);//当前选中的单元格 //判断是否为最后一行,最后一列 - if (Columns.Length > 0 && Columns[0].VisibleIndex == this.gcMain.GridView.Columns. \ No newline at end of file + if (Columns.Length > 0 && Columns[0].VisibleIndex == this.gcMain.GridView.Columns.Count - 1 && focusedRowHandle == this.gcMain.GridView.RowCount - 1) + { + this.AddGridViewRecord(); + } + //判断表格是否为空 + if (this.gcMain.GridView.RowCount == 0) + { + this.AddGridViewRecord(); + } + } + + + } + } + catch (Exception ex) + { + + } + + } + #endregion + + /// + /// 切换时保存(作为明细页签被切换时) + /// + /// + public bool SaveWhenSwitching() + { + this.SaveResults = false; + if (this.pl_buttom.Visible && this.btnSave.Visible && this.btnSave.Enabled) + { + this.SaveGridRecord(false); + } + return SaveResults; + } + + + } +} diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs index bb55a8e..55b5276 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs @@ -1,5 +1,7 @@ -using DevExpress.XtraEditors; +using DevExpress.Utils.Menu; +using DevExpress.XtraEditors; using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Menu; using DevExpress.XtraGrid.Views.Grid; using Lskj.Business; using Lskj.Business.Impl; @@ -9,10 +11,12 @@ using Lskj.Model; using Lskj.Util; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Data.SqlClient; +using System.Drawing; using System.Linq; -using System.Text.RegularExpressions; +using System.Text; using System.Windows.Forms; namespace Lskj.Control.MultiModelLookUp @@ -20,7 +24,14 @@ namespace Lskj.Control.MultiModelLookUp public partial class FrmModelLookUp : BaseForm { #region 私有字段 - + /// + /// 复选框字段名称 + /// + private string _checkFieldName = "_check"; + /// + /// The _id + /// + private string _id = "_id"; #endregion #region 公有字段 /// @@ -60,7 +71,7 @@ namespace Lskj.Control.MultiModelLookUp /// public string RemarkField = "remark"; /// - /// 数据源(初始) + /// 数据源 /// /// The source SQL. public string SourceSQL { get; set; } @@ -138,19 +149,7 @@ namespace Lskj.Control.MultiModelLookUp /// 左侧树结构、表格主键 /// public string ParentKeyField; - /// - /// 数据源(替换参数后) - /// - /// The source SQL. - public string NewSourceSQL; - /// - /// 关联返回参数的字段组合 - /// - public string AddModuleResult; - /// - /// 返回关联的字典 - /// - public Dictionary ModuleResultDic = new Dictionary(); + #endregion public FrmModelLookUp(string ModuleCodel) { @@ -189,23 +188,29 @@ namespace Lskj.Control.MultiModelLookUp //设置关联模块 bool result = SetAssociatedModules(); - - //单选模式,不显示明细表,主表双击选中后退出选择界面 if (SingleChoiceMode) { this.splitMain_Right.PanelVisibility = SplitPanelVisibility.Panel1; this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClickRadio); + //设置上方条件 + DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段 + this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx); + this.SearchObj.ParentUnionField = this.ParentUnionField; + this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top); + this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack; + this.SourceSQL = this.SysModel.MenuSql; } else { this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick); this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick); + this.pl_top.Height = 0; this.Resize += new System.EventHandler(maximization); this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange); } - this.SourceSQL = this.SysModel.MenuSql; + this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false; this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true; @@ -279,7 +284,7 @@ namespace Lskj.Control.MultiModelLookUp { success = this.gcMain.GridView.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey); } - //this.SetDetailDataSource(); + this.SetDetailDataSource(); MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault); } catch (SqlException sex) @@ -312,17 +317,16 @@ namespace Lskj.Control.MultiModelLookUp /// private void SetDetailDataSource() { - //return; - //DataTable table = this.DataSource.Copy(); - //DataRow[] rows = table.Select(_checkFieldName + "=True"); + DataTable table = this.DataSource.Copy(); + DataRow[] rows = table.Select(_checkFieldName + "=True"); - //if (rows != null && rows.Length > 0) - // this.gcDetail.GridControl.DataSource = rows.CopyToDataTable(); - //else - //{ - // this.gcDetail.GridControl.DataSource = table; - // this.gcDetail.GridControl.DataSourceTable().Clear(); - //} + if (rows != null && rows.Length > 0) + this.gcDetail.GridControl.DataSource = rows.CopyToDataTable(); + else + { + this.gcDetail.GridControl.DataSource = table; + this.gcDetail.GridControl.DataSourceTable().Clear(); + } } #endregion @@ -364,17 +368,22 @@ namespace Lskj.Control.MultiModelLookUp /// private void SetReadOnlyColumns() { - if (this.ConfigureColumnMode)//&& SingleChoiceMode + if (this.ConfigureColumnMode && SingleChoiceMode) { DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.UnionModuleCodel); this.gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey); - this.gcDetail.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey); } else { this.gcMain.GridView.Columns.Clear(); this.gcDetail.GridView.Columns.Clear(); + GridColumn checkColumn = new GridColumn(); + checkColumn.Name = checkColumn.FieldName = this._checkFieldName; + checkColumn.Caption = "选"; + checkColumn.Width = 30; + checkColumn.Visible = true; + checkColumn.OptionsColumn.AllowEdit = false; GridColumn valueColumn = new GridColumn(); valueColumn.FieldName = valueColumn.Name = ValueField; @@ -394,8 +403,8 @@ namespace Lskj.Control.MultiModelLookUp - this.gcMain.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn }); - this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn }); + this.gcMain.GridView.Columns.AddRange(new GridColumn[] { checkColumn, valueColumn, textColumn }); + this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { checkColumn, valueColumn, textColumn }); if (DataSource.Columns.IndexOf("remark") != -1) { @@ -622,17 +631,11 @@ namespace Lskj.Control.MultiModelLookUp /// The menu code. public void InitControls(string UnionModuleCodel) { - - this.SysModel.MenuSql = this.NewSourceSQL; - //设置上方条件 - this.pl_top.Controls.Clear(); - DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段 - this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx); - this.SearchObj.ParentUnionField = this.ParentUnionField; - this.pl_top.Height = 0; - this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top); - this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack; - + //单选模式以模块sql为为准 + if (SingleChoiceMode) + { + this.SourceSQL = this.SysModel.MenuSql; + } if (LeftTreeViewEx != null && LeftTreeViewEx.TreeView.Nodes.Count > 0) { LeftTreeViewEx.TreeView.SelectedNode = LeftTreeViewEx.TreeView.Nodes[0];//重新打开时默认选中第一条 @@ -643,7 +646,7 @@ namespace Lskj.Control.MultiModelLookUp LeftGridEx.GridView.SelectRow(0); } - this.DataSource = BaseImpl.GetDataTableResult(this.NewSourceSQL); + this.DataSource = BaseImpl.GetDataTableResult(this.SourceSQL); this.SetSelectionBox(); //创建表格列 if (isFirst) @@ -661,7 +664,7 @@ namespace Lskj.Control.MultiModelLookUp private void SearchObj_OnSearchAfterCallBack(object sender, EventArgs e) { - //this.SetSelectionBox(); + this.SetSelectionBox(); //this.SetReadOnlyColumns(); } @@ -715,7 +718,8 @@ namespace Lskj.Control.MultiModelLookUp DataRow rowItem = rowItem = this.DataSource.Rows.Cast().FirstOrDefault(x => x[isValue ? ValueMember : TextField] + "" == spilts[i].Trim()); if (rowItem != null) { - (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray); + rowItem[_checkFieldName] = check; + rowItem.AcceptChanges(); } } this.SetDetailDataSource(); @@ -798,10 +802,11 @@ namespace Lskj.Control.MultiModelLookUp DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); if (rowItem != null) { - (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray); + rowItem[_checkFieldName] = "True".Equals(rowItem[_checkFieldName] + "") ? 0 : 1; + //rowItem[_checkFieldName] = rowItem.Table.Columns.Contains(_checkFieldName) : "True".Equals(rowItem[_checkFieldName] + "") ? 0 : 1 ? 0; rowItem.AcceptChanges(); } - + this.SetDetailDataSource(); } /// @@ -819,6 +824,8 @@ namespace Lskj.Control.MultiModelLookUp { DataRow dr = this.gcMain.GridView.GetFocusedDataRow(); + //DataRow[] rowItems = this.DataSource.Select(_checkFieldName + "=True"); + if (dr != null) { this.EditValue = dr[ValueMember] + ""; @@ -848,7 +855,13 @@ namespace Lskj.Control.MultiModelLookUp { if (this.gcDetail.GridView.RowCount == 0) return; DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow(); - (this.gcDetail.GridControl.DataSource as DataTable).Rows.Remove(rowItem); + DataRow[] sourceRowItems = this.DataSource.Select(_id + "=" + rowItem[_id] + ""); + if (rowItem != null && sourceRowItems != null && sourceRowItems.Length > 0) + { + sourceRowItems[0][_checkFieldName] = 0; + sourceRowItems[0].AcceptChanges(); + } + this.SetDetailDataSource(); } #endregion #region 关闭时清空唯一键 @@ -884,49 +897,20 @@ namespace Lskj.Control.MultiModelLookUp /// The instance containing the event data. private void btnOk_Click(object sender, EventArgs e) { - EditValue = string.Empty; - EditText = string.Empty; - ModuleResultDic.Clear(); - DataTable sourceTable = this.gcDetail.GridControl.DataSource as DataTable; - foreach (DataRow item in sourceTable.Rows) + this.EditValue = string.Empty; + this.EditText = string.Empty; + + DataRow[] rowItems = this.DataSource.Select(_checkFieldName + "=True"); + + foreach (DataRow item in rowItems) { this.EditValue += item[ValueMember] + ","; this.EditText += item[TextField] + ","; } - if (!string.IsNullOrEmpty(AddModuleResult)) - { - string[] resultFields = AddModuleResult.Split(','); - foreach (string resultField in resultFields) - { - Match match = Regex.Match(resultField, @"^\s*([^\s]+)\s+AS\s+([^\s]+)\s*$", RegexOptions.IgnoreCase); - if (match.Success) - { - string beforeAs = match.Groups[1].Value.Trim(); - string afterAs = match.Groups[2].Value.Trim(); - string value = ""; - foreach (DataRow item in sourceTable.Rows) - { - if (item.Table.Columns.Contains(beforeAs)) - { - value += item[beforeAs] + ","; - } - } - ModuleResultDic.Add(afterAs, value); - } - else - { - string value = ""; - foreach (DataRow item in sourceTable.Rows) - { - if (item.Table.Columns.Contains(resultField)) - { - value += item[resultField] + ","; - } - } - ModuleResultDic.Add(resultField, value); - } - } - } + + //this.EditValue = this.EditValue.Trim(','); + //this.EditText = this.EditText.Trim(','); + this.DialogResult = DialogResult.OK; this.Close(); } @@ -961,8 +945,9 @@ namespace Lskj.Control.MultiModelLookUp DataTable DataSource = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable(); foreach (DataRow item in DataSource.Rows) { - //DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + "")); - (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(item.ItemArray); + DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + "")); + rowItem[_checkFieldName] = 1; + rowItem.AcceptChanges(); } this.SetDetailDataSource(); } @@ -977,7 +962,16 @@ namespace Lskj.Control.MultiModelLookUp private void btn_cancelAll_Click(object sender, EventArgs e) { - (this.gcDetail.GridControl.DataSource as DataTable).Clear(); + DataTable dt = this.DataSource.Clone(); + foreach (DataRow item in this.DataSource.Rows) + { + if ("True".Equals(item[_checkFieldName] + "")) + { + + item[_checkFieldName] = 0; + } + } + this.SetDetailDataSource(); } #endregion @@ -1038,4 +1032,17 @@ namespace Lskj.Control.MultiModelLookUp case 2: // 左侧为表格 this.gridLeft.Visible = true; this.treeLeft.Visible = false; - this.InitlizeSpiltL \ No newline at end of file + this.InitlizeSpiltLocation(); + this.SetLeftGridView(); + //this.ModuleGridObj.SaveEvent += new Lskj.Control.ModuleGridEx.SaveEventHander(SetDetailGridView); + this.LeftGridEx = this.gridLeft; + break; + case 3: // 左侧为空 + default: + this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2; + break; + } + + } + else + \ No newline at end of file diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.Designer.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.Designer.cs new file mode 100644 index 0000000..da8024d --- /dev/null +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.Designer.cs @@ -0,0 +1,343 @@ +namespace Lskj.Control.MultiModelLookUp +{ + partial class FrmModelLookUp2 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.splitMain = new DevExpress.XtraEditors.SplitContainerControl(); + this.pl_left = new DevExpress.XtraEditors.PanelControl(); + this.pl_left_main = new System.Windows.Forms.Panel(); + this.pl_gridandtree_container = new DevExpress.XtraEditors.PanelControl(); + this.treeLeft = new Lskj.Control.TreeViewEx(); + this.gridLeft = new Lskj.Control.GridControlEx(); + this.pl_left_top = new DevExpress.XtraEditors.PanelControl(); + this.splitMain_Right = new DevExpress.XtraEditors.SplitContainerControl(); + this.gcMain = new Lskj.Control.GridControlEx(); + this.pl_top = new DevExpress.XtraEditors.PanelControl(); + this.gcDetail = new Lskj.Control.GridControlEx(); + this.panelControl1 = new DevExpress.XtraEditors.PanelControl(); + this.btnCancel = new DevExpress.XtraEditors.SimpleButton(); + this.btn_selectAll = new DevExpress.XtraEditors.SimpleButton(); + this.btn_cancelAll = new DevExpress.XtraEditors.SimpleButton(); + this.btnOk = new DevExpress.XtraEditors.SimpleButton(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.tsmi_all = new System.Windows.Forms.ToolStripMenuItem(); + this.tsmi_reserve = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.tsmi_cancel = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.splitMain)).BeginInit(); + this.splitMain.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_left)).BeginInit(); + this.pl_left.SuspendLayout(); + this.pl_left_main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_gridandtree_container)).BeginInit(); + this.pl_gridandtree_container.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_left_top)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitMain_Right)).BeginInit(); + this.splitMain_Right.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); + this.panelControl1.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // splitMain + // + this.splitMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitMain.Location = new System.Drawing.Point(0, 0); + this.splitMain.Margin = new System.Windows.Forms.Padding(4); + this.splitMain.Name = "splitMain"; + this.splitMain.Panel1.Controls.Add(this.pl_left); + this.splitMain.Panel1.Text = "Panel1"; + this.splitMain.Panel2.Controls.Add(this.splitMain_Right); + this.splitMain.Panel2.Text = "Panel2"; + this.splitMain.Size = new System.Drawing.Size(1131, 499); + this.splitMain.SplitterPosition = 260; + this.splitMain.TabIndex = 0; + this.splitMain.Text = "splitContainerControl1"; + // + // pl_left + // + this.pl_left.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_left.Appearance.Options.UseBackColor = true; + this.pl_left.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_left.Controls.Add(this.pl_left_main); + this.pl_left.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_left.Location = new System.Drawing.Point(0, 0); + this.pl_left.Margin = new System.Windows.Forms.Padding(4); + this.pl_left.Name = "pl_left"; + this.pl_left.Size = new System.Drawing.Size(260, 499); + this.pl_left.TabIndex = 1; + // + // pl_left_main + // + this.pl_left_main.BackColor = System.Drawing.Color.Transparent; + this.pl_left_main.Controls.Add(this.pl_gridandtree_container); + this.pl_left_main.Controls.Add(this.pl_left_top); + this.pl_left_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_left_main.Location = new System.Drawing.Point(0, 0); + this.pl_left_main.Margin = new System.Windows.Forms.Padding(4); + this.pl_left_main.Name = "pl_left_main"; + this.pl_left_main.Size = new System.Drawing.Size(260, 499); + this.pl_left_main.TabIndex = 6; + // + // pl_gridandtree_container + // + this.pl_gridandtree_container.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_gridandtree_container.Controls.Add(this.treeLeft); + this.pl_gridandtree_container.Controls.Add(this.gridLeft); + this.pl_gridandtree_container.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_gridandtree_container.Location = new System.Drawing.Point(0, 45); + this.pl_gridandtree_container.Margin = new System.Windows.Forms.Padding(4); + this.pl_gridandtree_container.Name = "pl_gridandtree_container"; + this.pl_gridandtree_container.Size = new System.Drawing.Size(260, 454); + this.pl_gridandtree_container.TabIndex = 9; + // + // treeLeft + // + this.treeLeft.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeLeft.Location = new System.Drawing.Point(0, 0); + this.treeLeft.Margin = new System.Windows.Forms.Padding(4); + this.treeLeft.Name = "treeLeft"; + this.treeLeft.Size = new System.Drawing.Size(260, 454); + this.treeLeft.TabIndex = 7; + this.treeLeft.Visible = false; + // + // gridLeft + // + this.gridLeft.AdapterObj = null; + this.gridLeft.BackColor = System.Drawing.SystemColors.Control; + this.gridLeft.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridLeft.Location = new System.Drawing.Point(0, 0); + this.gridLeft.Margin = new System.Windows.Forms.Padding(5); + this.gridLeft.Name = "gridLeft"; + this.gridLeft.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gridLeft.Size = new System.Drawing.Size(260, 454); + this.gridLeft.TabIndex = 6; + // + // pl_left_top + // + this.pl_left_top.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.pl_left_top.Appearance.Options.UseBackColor = true; + this.pl_left_top.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_left_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_left_top.Location = new System.Drawing.Point(0, 0); + this.pl_left_top.Margin = new System.Windows.Forms.Padding(4); + this.pl_left_top.Name = "pl_left_top"; + this.pl_left_top.Size = new System.Drawing.Size(260, 45); + this.pl_left_top.TabIndex = 8; + // + // splitMain_Right + // + this.splitMain_Right.CollapsePanel = DevExpress.XtraEditors.SplitCollapsePanel.Panel2; + this.splitMain_Right.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitMain_Right.Horizontal = false; + this.splitMain_Right.Location = new System.Drawing.Point(0, 0); + this.splitMain_Right.Margin = new System.Windows.Forms.Padding(4); + this.splitMain_Right.Name = "splitMain_Right"; + this.splitMain_Right.Panel1.Controls.Add(this.gcMain); + this.splitMain_Right.Panel1.Controls.Add(this.pl_top); + this.splitMain_Right.Panel1.Text = "Panel1"; + this.splitMain_Right.Panel2.Controls.Add(this.gcDetail); + this.splitMain_Right.Panel2.Controls.Add(this.panelControl1); + this.splitMain_Right.Panel2.Text = "Panel2"; + this.splitMain_Right.Size = new System.Drawing.Size(866, 499); + this.splitMain_Right.SplitterPosition = 243; + this.splitMain_Right.TabIndex = 4; + this.splitMain_Right.Text = "splitContainerControl1"; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.BackColor = System.Drawing.Color.Transparent; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 34); + this.gcMain.Margin = new System.Windows.Forms.Padding(5); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(866, 209); + this.gcMain.TabIndex = 12; + // + // pl_top + // + this.pl_top.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_top.Appearance.Options.UseBackColor = true; + this.pl_top.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_top.Location = new System.Drawing.Point(0, 0); + this.pl_top.Name = "pl_top"; + this.pl_top.Size = new System.Drawing.Size(866, 34); + this.pl_top.TabIndex = 11; + // + // gcDetail + // + this.gcDetail.AdapterObj = null; + this.gcDetail.BackColor = System.Drawing.Color.Transparent; + this.gcDetail.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcDetail.Location = new System.Drawing.Point(0, 0); + this.gcDetail.Margin = new System.Windows.Forms.Padding(6); + this.gcDetail.Name = "gcDetail"; + this.gcDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcDetail.Size = new System.Drawing.Size(866, 204); + this.gcDetail.TabIndex = 13; + // + // panelControl1 + // + this.panelControl1.Controls.Add(this.btnCancel); + this.panelControl1.Controls.Add(this.btn_selectAll); + this.panelControl1.Controls.Add(this.btn_cancelAll); + this.panelControl1.Controls.Add(this.btnOk); + this.panelControl1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panelControl1.Location = new System.Drawing.Point(0, 204); + this.panelControl1.Margin = new System.Windows.Forms.Padding(4); + this.panelControl1.Name = "panelControl1"; + this.panelControl1.Size = new System.Drawing.Size(866, 47); + this.panelControl1.TabIndex = 8; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.Location = new System.Drawing.Point(772, 5); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(79, 35); + this.btnCancel.TabIndex = 24; + this.btnCancel.Text = "取消(&C)"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btn_selectAll + // + this.btn_selectAll.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_selectAll.Appearance.Options.UseFont = true; + this.btn_selectAll.Location = new System.Drawing.Point(16, 5); + this.btn_selectAll.Margin = new System.Windows.Forms.Padding(4); + this.btn_selectAll.Name = "btn_selectAll"; + this.btn_selectAll.Size = new System.Drawing.Size(76, 35); + this.btn_selectAll.TabIndex = 23; + this.btn_selectAll.TabStop = false; + this.btn_selectAll.Text = "全选"; + this.btn_selectAll.Click += new System.EventHandler(this.btn_selectAll_Click); + // + // btn_cancelAll + // + this.btn_cancelAll.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_cancelAll.Appearance.Options.UseFont = true; + this.btn_cancelAll.Location = new System.Drawing.Point(100, 5); + this.btn_cancelAll.Margin = new System.Windows.Forms.Padding(4); + this.btn_cancelAll.Name = "btn_cancelAll"; + this.btn_cancelAll.Size = new System.Drawing.Size(76, 35); + this.btn_cancelAll.TabIndex = 23; + this.btn_cancelAll.TabStop = false; + this.btn_cancelAll.Text = "全取消"; + this.btn_cancelAll.Click += new System.EventHandler(this.btn_cancelAll_Click); + // + // btnOk + // + this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnOk.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnOk.Appearance.Options.UseFont = true; + this.btnOk.Location = new System.Drawing.Point(688, 5); + this.btnOk.Margin = new System.Windows.Forms.Padding(4); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(76, 35); + this.btnOk.TabIndex = 23; + this.btnOk.TabStop = false; + this.btnOk.Text = "确定(&O)"; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsmi_all, + this.tsmi_reserve, + this.toolStripSeparator1, + this.tsmi_cancel}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(101, 76); + // + // tsmi_all + // + this.tsmi_all.Name = "tsmi_all"; + this.tsmi_all.Size = new System.Drawing.Size(100, 22); + this.tsmi_all.Text = "全选"; + // + // tsmi_reserve + // + this.tsmi_reserve.Name = "tsmi_reserve"; + this.tsmi_reserve.Size = new System.Drawing.Size(100, 22); + this.tsmi_reserve.Text = "反选"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(97, 6); + // + // tsmi_cancel + // + this.tsmi_cancel.Name = "tsmi_cancel"; + this.tsmi_cancel.Size = new System.Drawing.Size(100, 22); + this.tsmi_cancel.Text = "取消"; + // + // FrmModelLookUp + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(1131, 499); + this.Controls.Add(this.splitMain); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(5); + this.Name = "FrmModelLookUp"; + this.Text = "提示:双击选择"; + ((System.ComponentModel.ISupportInitialize)(this.splitMain)).EndInit(); + this.splitMain.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_left)).EndInit(); + this.pl_left.ResumeLayout(false); + this.pl_left_main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_gridandtree_container)).EndInit(); + this.pl_gridandtree_container.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_left_top)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitMain_Right)).EndInit(); + this.splitMain_Right.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit(); + this.panelControl1.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.SplitContainerControl splitMain; + private DevExpress.XtraEditors.PanelControl pl_left; + private System.Windows.Forms.Panel pl_left_main; + private DevExpress.XtraEditors.PanelControl pl_gridandtree_container; + private GridControlEx grid \ No newline at end of file diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs new file mode 100644 index 0000000..8407bab --- /dev/null +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs @@ -0,0 +1,1054 @@ +using DevExpress.XtraEditors; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Grid; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control.Model; +using Lskj.Data; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace Lskj.Control.MultiModelLookUp +{ + public partial class FrmModelLookUp2 : BaseForm + { + #region 私有字段 + + #endregion + #region 公有字段 + /// + /// 数据源 + /// + /// The data source. + public DataTable DataSource + { + get + { + return this.gcMain.gridControl.DataSourceTable(); + } + set + { + this.gcMain.gridControl.DataSource = value; + } + } + /// + /// 控件类型 + /// + /// The type. + public int IsType { get; set; } + /// + /// 绑定ValueMember + /// + public string ValueMember { get; set; } + /// + /// 隐藏值字段 + /// + public string ValueField { get; set; } + /// + /// 显示值字段 + /// + public string TextField { get; set; } + /// + /// 备注字段 + /// + public string RemarkField = "remark"; + /// + /// 数据源(初始) + /// + /// The source SQL. + public string SourceSQL { get; set; } + /// + /// 隐藏值 + /// + /// The edit value. + public string EditValue { get; set; } + /// + /// 显示值 + /// + /// The edit text. + public string EditText { get; set; } + /// + /// CurrentOperColumnKey值 + /// + /// The data source. + public string CurrentOperColumnKey = string.Empty; + /// + /// CurrentOperModel值 + /// + /// The data source. + public GridColumnModel CurrentOperModel = null; + /// + /// 配置的关联ModuleCodel值 + /// + /// The Union ModuleCodel. + public string UnionModuleCodel; + /// + /// 左侧树数据 + /// + public DataRow LeftRowObj; + /// + /// 系统模块实体对象 + /// + /// The system model. + public ModuleModel SysModel { get; private set; } + /// + /// 自定义查询条件 + /// + public MyControl SearchObj { get; private set; } + /// + /// 分割条位置 + /// + public int PositionSplitter; + /// + /// 分割条位置 + /// + public int WindowHeight; + /// + /// 单选模式 + /// + public bool SingleChoiceMode; + /// + /// 表格列根据配置加载(默认是加载sql数据源中的中文列,目前只支持单选模式) + /// + public bool ConfigureColumnMode = false; + /// + /// 第一次进入 + /// + private bool isFirst = true; + /// + /// 第一次进入 + /// + private bool isFirstSearch = true; + /// + /// 左侧树结构 + /// + public TreeViewEx LeftTreeViewEx; + /// + /// 左侧表格 + /// + public GridControlEx LeftGridEx; + /// + /// 左侧结构关联字段 + /// + public string ParentUnionField; + /// + /// 左侧树结构、表格主键 + /// + public string ParentKeyField; + /// + /// 数据源(替换参数后) + /// + /// The source SQL. + public string NewSourceSQL; + /// + /// 关联返回参数的字段组合 + /// + public string AddModuleResult; + /// + /// 返回关联的字典 + /// + public Dictionary ModuleResultDic = new Dictionary(); + #endregion + public FrmModelLookUp2(string ModuleCodel) + { + InitializeComponent(); + this.UnionModuleCodel = ModuleCodel; + this.Disposed += new EventHandler(OnFrmModelLookUp_Disposed); + this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); + this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1; + this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick); + this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick); + GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView); + GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView); + //设置关联模块 + bool result = SetAssociatedModules(); + this.pl_top.Height = 0; + this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false; + this.Resize += new System.EventHandler(maximization); + this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange); + this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true; + this.gcMain.GridView.OptionsView.ColumnAutoWidth = true; + } + + //关联模块号;是否为单选模式 + public FrmModelLookUp2(string ModuleCodel, bool singleChoiceMode) + { + InitializeComponent(); + this.UnionModuleCodel = ModuleCodel; + this.SingleChoiceMode = singleChoiceMode; + this.Disposed += new EventHandler(OnFrmModelLookUp_Disposed); + this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); + this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1; + GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView); + GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView); + //设置关联模块 + bool result = SetAssociatedModules(); + + + + //单选模式,不显示明细表,主表双击选中后退出选择界面 + if (SingleChoiceMode) + { + this.splitMain_Right.PanelVisibility = SplitPanelVisibility.Panel1; + this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClickRadio); + } + else + { + this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick); + this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick); + this.Resize += new System.EventHandler(maximization); + this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange); + } + + this.SourceSQL = this.SysModel.MenuSql; + this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false; + + this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true; + this.gcMain.GridView.OptionsView.ColumnAutoWidth = true; + } + + + + + + #region 方法 + #region 设置分割条位置 + /// + /// 说明:设置分割条位置 + /// 创建人:王一帆 + /// 创建日期:2021-07-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void InitlizeSpiltLocation() + { + try + { + string width = IniHelper.Read(string.Format("base_width_{0}", this.UnionModuleCodel));//通过Key获取Value值 + if (!string.IsNullOrEmpty(width)) + { + this.splitMain.SplitterPosition = Convert.ToInt32(width); + + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + MessageUtil.Show(ex); + } + } + #endregion + #region 保存表格属性 + /// + /// 说明:保存表格属性 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + protected virtual void SaveItemClick(object sender, EventArgs e) + { + DataRow rowItem = null; + bool success = BaseImpl.HasExistsDataRow(ResourceKeys.SettingTableName, "formKey", CurrentOperColumnKey, string.Format(" and OperatorId='{0}' ", ERPInfo.Instance.UserId), out rowItem); + if (!success) + { + MessageUtil.Show(ResourceKeys.NotFoundSettingColumnTable); + return; + } + + if (MessageUtil.Show(ResourceKeys.IsSaveColumn, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + try + { + if (rowItem == null) + { + success = this.gcMain.GridView.SaveCustomColumnToDatabase(this.CurrentOperColumnKey); + } + else + { + success = this.gcMain.GridView.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey); + } + //this.SetDetailDataSource(); + MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault); + } + catch (SqlException sex) + { + if (sex.Message.Contains(ResourceKeys.FieldLenIsShort) && + MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + ResourceKeys.CanUpgradeTable, MessageBoxButtons.YesNo) == DialogResult.Yes && + BaseImpl.UpdateTableField(ResourceKeys.SettingTableName, "formKey", "varchar(200)")) + { + MessageUtil.Show(ResourceKeys.UpdateSuccess); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("保存表格属性出错", ex); + MessageUtil.Show(ex); + } + } + } + #endregion + #region 设置明细数据源 + /// + /// 说明:设置明细数据源 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetDetailDataSource() + { + //return; + //DataTable table = this.DataSource.Copy(); + //DataRow[] rows = table.Select(_checkFieldName + "=True"); + + //if (rows != null && rows.Length > 0) + // this.gcDetail.GridControl.DataSource = rows.CopyToDataTable(); + //else + //{ + // this.gcDetail.GridControl.DataSource = table; + // this.gcDetail.GridControl.DataSourceTable().Clear(); + //} + } + #endregion + + #region 设置默认选中 + /// + /// 说明:设置默认选中 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetDefaultValue() + { + this.gcDetail.gridControl.DataSourceTable().Clear(); + if (!string.IsNullOrEmpty(EditValue) && this.IsType == ControlType.LabSelectReturnIdNew) + { + this.UpdateChecked(EditValue.Trim().Replace(", ", ",").TrimEnd(',').Split(','), ValueMember, true); + } + else + { + if (!string.IsNullOrEmpty(EditText)) + { + this.UpdateChecked(EditText.Trim().Replace(", ", ",").TrimEnd(',').Split(','), TextField, false); + } + } + } + #endregion + #region 设置只读列 + /// + /// 说明:设置只读列 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetReadOnlyColumns() + { + if (true)//this.ConfigureColumnMode&& SingleChoiceMode + { + //默认以模块配置列为准(点击搜索时,固定写的列会清空) + DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.UnionModuleCodel); + this.gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey); + this.gcDetail.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey); + } + else + { + this.gcMain.GridView.Columns.Clear(); + this.gcDetail.GridView.Columns.Clear(); + + + GridColumn valueColumn = new GridColumn(); + valueColumn.FieldName = valueColumn.Name = ValueField; + valueColumn.Caption = "编码"; + valueColumn.Width = 150; + //valueColumn.Visible = true; + valueColumn.Visible = ValueMember.Substring(0, 1) != "_"; + valueColumn.OptionsColumn.AllowEdit = false; + + GridColumn textColumn = new GridColumn(); + textColumn.FieldName = textColumn.Name = TextField; + textColumn.Caption = "名称"; + textColumn.Width = 150; + //textColumn.Visible = true; + textColumn.Visible = TextField.Substring(0, 1) != "_"; + textColumn.OptionsColumn.AllowEdit = false; + + + + this.gcMain.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn }); + this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn }); + + if (DataSource.Columns.IndexOf("remark") != -1) + { + DataColumn column = DataSource.Columns.Cast().FirstOrDefault(x => x.ColumnName.ToLower() == RemarkField); + if (column != null) RemarkField = column.ColumnName; + + GridColumn remarkColumn = new GridColumn(); + remarkColumn.Name = remarkColumn.FieldName = RemarkField; + remarkColumn.Caption = "备注"; + remarkColumn.Visible = true; + remarkColumn.Width = 400;//this.gcMain.Width-300; + + //字段第一个字符为下划线代表不显示 + if (RemarkField.Substring(0, 1) == "_") + remarkColumn.Visible = false; + + this.gcMain.GridView.Columns.Add(remarkColumn); + this.gcDetail.GridView.Columns.Add(remarkColumn); + } + + DataTable DT = this.gcMain.gridControl.DataSource == null ? new DataTable() : this.gcMain.gridControl.DataSource as DataTable; + foreach (DataColumn dcol in DT.Columns) + { + if ((dcol.ColumnName.Substring(0, 1) != "_") && (dcol.ColumnName.ToLower() != ValueField.ToLower()) && (dcol.ColumnName.ToLower() != TextField.ToLower()) && ((int)dcol.ColumnName[0] > 127)) + { + GridColumn otherColumn = new GridColumn(); + otherColumn.Name = otherColumn.FieldName = otherColumn.Caption = dcol.ColumnName; + otherColumn.Visible = true; + otherColumn.Width = 150; + this.gcMain.GridView.Columns.Add(otherColumn); + this.gcDetail.GridView.Columns.Add(otherColumn); + } + } + } + SetCustomColumns(); + } + #endregion + #region 加载自定义列 + /// + /// 说明:加载自定义列 + /// 创建人:王一帆 + /// 创建日期:2019-9-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetCustomColumns() + { + if (string.IsNullOrEmpty(this.CurrentOperColumnKey) || !BaseImpl.HasExistsTable(ResourceKeys.SettingTableName)) return; + + DataTable customTable = this.gcMain.GridView.GetCustomColumnByDatabase(this.CurrentOperColumnKey); + if (customTable != null && customTable.Rows.Count > 0) + { + foreach (DataRow rowItem in customTable.Rows) + { + string fieldName = rowItem["fieldName"] + ""; + int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]); + int index = Convert.ToInt32(rowItem["orderid"]); + bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0; + bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase); + + GridColumn gridColumn = this.gcMain.GridView.Columns.ColumnByName(fieldName); + if (gridColumn != null && gridColumn.Visible && gridColumn.Width > 0) + { + GridColumn colObj = this.gcMain.GridView.Columns[fieldName]; + colObj.VisibleIndex = index; + colObj.Width = fieldWidth; + colObj.Visible = visible; + colObj.Fixed = isFix ? FixedStyle.Left : FixedStyle.None; + } + } + } + } + #endregion + #region 获取选中行数据 + /// + /// 说明:获取选中行数据 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// DataRow[]. + public DataRow[] GetViewFocusedDataRows(GridView gridView) + { + int[] rows = gridView.GetSelectedRows(); + DataRow[] dataRows = new DataRow[rows.Length]; + for (int i = 0; i < rows.Length; i++) + { + dataRows[i] = gridView.GetDataRow(rows[i]); + } + return dataRows; + } + #endregion + #region 刷新左侧树数据 + /// + /// 说明:设置左侧树数据 + /// 创建人:王一帆 + /// 创建日期:2021-07-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void SetLeftTreeView() + { + this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.UnionModuleCodel);//获取表格左侧树字段 + if (this.LeftRowObj != null) + { + //this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentKeyField = this.LeftRowObj["fieldsqlid"] + ""; + this.treeLeft.TreeNodeKeyField = this.LeftRowObj["fieldsqlid"] + ""; + this.treeLeft.TreeNodeTextField = this.LeftRowObj["fieldsqlname"] + ""; + this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected); + this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.LeftRowObj["fieldsql"] + "")); + } + else + { + // 根据模块上配置的sql加载树 + if (this.SysModel != null && !string.IsNullOrEmpty(this.SysModel.TreeSQL)) + { + this.ParentUnionField = "SpeciesNo"; + this.ParentKeyField = "SpeciesNo"; + this.treeLeft.TreeNodeKeyField = "SpeciesNo"; + this.treeLeft.TreeNodeTextField = "SpeciesName"; + this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected); + this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.SysModel.TreeSQL)); + } + } + } + /// + /// 说明:树节点点击后刷新数据 + /// 创建人:龚宇超 + /// 创建日期:2017-10-26 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnTreeLeftTreeNodeSelected(object sender, TreeViewEventArgs e) + { + string where = string.Format(" and {0} like '{1}%' ", this.treeLeft.TreeNodeKeyField, e.Node.Name); + + string sqlValue = ReplaceHelper.IsProcedure(NewSourceSQL) ? + ReplaceHelper.ReplaceTreeViewParentKeyCond(NewSourceSQL, treeLeft.GetSelectNodeValue()) : + ReplaceHelper.ReplaceWhereCond(this.NewSourceSQL) + where; + this.DataSource = MainImpl.GetDataTableResult(sqlValue); + this.SetSelectionBox(); + this.SetDefaultValue(); + + } + /// + /// 说明:加载主表格数据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-31 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The where key. + protected void SetMainGridView(string where = "") + { + //string sqlValue = ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql); + //sqlValue = this.SysModel.MenuSql.StartsWith("select", StringComparison.OrdinalIgnoreCase) ? sqlValue + where : sqlValue; + //if (IsExcel && !string.IsNullOrEmpty(this._labPicName)) + //{ + // string sql = MainImpl.GetDefaultValue(sqlValue, this.ModuleGridObj.ParentKeyField, Model.OtherParams()); + // DataTable dt = MainImpl.GetDataTableResult(ReplaceLeftOrGridValue(sql)); + // if (dt.Rows.Count > 0) + // { + // this._currentRow = dt.Rows[0]; + // Byte[] file = (byte[])this._currentRow[this._labPicName]; + // if (file.Length <= 0) + // { + // this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument(); + // } + // else + // { + // if (!string.IsNullOrEmpty(this.excelControlEx1.CurrentPath) && File.Exists(this.excelControlEx1.CurrentPath)) + // { + // File.Delete(this.excelControlEx1.CurrentPath); + // } + // this.excelControlEx1.LoadFileSteam(file); + // } + // } + // else + // { + // this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument(); + // MessageUtil.Show(ResourceKeys.NotConfigExcel); + // } + //} + //else + //{ + // // 左侧gridView时,需要替换sql参数(包含查询条件、表格选中行). + // if (this.gridLeft.Visible) + // { + // sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue; + // sqlValue = ReplaceHelper.ReplaceRowParam(this.gridLeft.GridView.GetFocusedDataRow(), sqlValue); + // } + + // this.ModuleGridObj.SearchObj.SearchGrid(sqlValue); + // if (!this.IsDragDetail) + // this.ModuleGridDetailObj.SetDetailGridDataSource(); + //} + } + #endregion + #region 创建界面 + /// + /// 说明:创建界面 + /// 创建人:王一帆 + /// 创建日期:2021-07-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The menu code. + public void InitControls(string UnionModuleCodel) + { + + this.SysModel.MenuSql = this.NewSourceSQL; + //设置上方条件 + this.pl_top.Controls.Clear(); + DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段 + this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx); + this.SearchObj.ParentUnionField = this.ParentUnionField; + this.pl_top.Height = 0; + this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top); + this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack; + + if (LeftTreeViewEx != null && LeftTreeViewEx.TreeView.Nodes.Count > 0) + { + LeftTreeViewEx.TreeView.SelectedNode = LeftTreeViewEx.TreeView.Nodes[0];//重新打开时默认选中第一条 + LeftTreeViewEx.TreeView.Nodes[0].Expand(); + } + else if (LeftGridEx != null) + { + LeftGridEx.GridView.SelectRow(0); + } + + this.DataSource = BaseImpl.GetDataTableResult(this.NewSourceSQL + "and 1<>1"); + this.gcDetail.GridControl.DataSource = this.gcMain.gridControl.DataSourceTable().Clone(); + //创建表格列 + if (isFirst) + { + this.SetReadOnlyColumns(); + this.isFirst = false; + } + this.SetDefaultValue(); + + //单选模式不需要设置下方表中选中行 + //if (!SingleChoiceMode) this.SetDefaultValue(); + + } + + + private void SearchObj_OnSearchAfterCallBack(object sender, EventArgs e) + { + if (isFirstSearch) + { + //this.SetSelectionBox(); + this.SetDefaultValue(); + } + isFirstSearch = false; + //this.SetSelectionBox(); + //this.SetReadOnlyColumns(); + } + + #endregion + #region 设置左侧表格数据 + /// + /// 说明:设置左侧表格数据 + /// 创建人:龚宇超 + /// 创建日期:2017-10-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void SetLeftGridView() + { + this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(UnionModuleCodel);//获取表格左侧树字段 + if (this.LeftRowObj != null) + { + DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(UnionModuleCodel); + DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + ""); + this.gridLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick); + this.gridLeft.SetGridRowColors(dtColorTable); + this.gridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + UnionModuleCodel); + this.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentKeyField = this.LeftRowObj["fieldname"] + ""; + } + } + #endregion + + #region 更新选中状态 + /// + /// 说明:更新选中状态 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The spilts. + /// Name of the field. + /// if set to true [check]. + private void UpdateChecked(string[] spilts, string fieldName, bool isValue, bool check = true) + { + if (spilts == null || spilts.Length == 0 || string.IsNullOrEmpty(fieldName) || this.DataSource == null) + return; + + for (int i = 0; i < spilts.Length; i++) + { + string detileRowSql = string.Format(@"SELECT * FROM({0}) AS t WHERE {1} = '{2}';", this.NewSourceSQL, isValue ? ValueMember : TextField, spilts[i].Trim()); + DataRow rowItem = rowItem = BaseImpl.GetDataRowResult(detileRowSql); + if (rowItem != null) + { + (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray); + } + } + this.SetDetailDataSource(); + } + #endregion + #region 刷新右侧表格数据 + /// + /// 说明:刷新右侧表格数据 + /// 创建人:龚宇超 + /// 创建日期:2018-03-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnGridViewRowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) + { + try + { + this.SetMainGridView(); + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + #endregion + #endregion + #region 事件 + #region 分割条位置改变 + /// + /// 说明:分割条位置包含时记录位置 + /// 创建人:曹屹峰 + /// 创建日期:2021-08-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void PositionChange(object sender, EventArgs e) + { + PositionSplitter = this.splitMain_Right.SplitterPosition; + } + #endregion + #region 窗口大小改变 + /// + /// 说明:窗口大小改变时改变分割条位置 + /// 创建人:曹屹峰 + /// 创建日期:2021-08-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void maximization(object sender, EventArgs e) + { + double a = (double)PositionSplitter / (double)WindowHeight; + this.splitMain_Right.SplitterPosition = Convert.ToInt32(Math.Round((double)this.Height * a)); + WindowHeight = this.Height; + } + #endregion + #region 选中行 + /// + /// 说明:选中行 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnRowCellClick(object sender, EventArgs e) + { + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem != null) + { + DataRow Item = (this.gcDetail.GridControl.DataSource as DataTable).Rows.Cast().FirstOrDefault(x => x[ValueMember] + "" == rowItem[ValueMember]+""); + if (Item == null) (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray); + rowItem.AcceptChanges(); + } + + } + + /// + /// 说明:选中行(单选模式) + /// 创建人:曹屹峰 + /// 创建日期:2024-01-02 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnRowCellClickRadio(object sender, EventArgs e) + { + + DataRow dr = this.gcMain.GridView.GetFocusedDataRow(); + if (dr != null) + { + this.EditValue = dr[ValueMember] + ""; + this.EditText = dr[TextField] + ""; + + this.DialogResult = DialogResult.OK; + this.Close(); + } + + + } + + #endregion + #region 取消选择 + /// + /// 说明:取消选择 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnDoubleClick(object sender, EventArgs e) + { + if (this.gcDetail.GridView.RowCount == 0) return; + DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow(); + (this.gcDetail.GridControl.DataSource as DataTable).Rows.Remove(rowItem); + } + #endregion + #region 关闭时清空唯一键 + /// + /// 说明:关闭时清空唯一键 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnFormClosing(object sender, FormClosingEventArgs e) + { + CurrentOperColumnKey = ""; + CurrentOperModel = null; + } + #endregion + + #region 确定 + /// + /// 说明:确定 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnOk_Click(object sender, EventArgs e) + { + EditValue = string.Empty; + EditText = string.Empty; + ModuleResultDic.Clear(); + DataTable sourceTable = this.gcDetail.GridControl.DataSource as DataTable; + foreach (DataRow item in sourceTable.Rows) + { + this.EditValue += item[ValueMember] + ","; + this.EditText += item[TextField] + ","; + } + if (!string.IsNullOrEmpty(AddModuleResult)) + { + string[] resultFields = AddModuleResult.Split(','); + foreach (string resultField in resultFields) + { + Match match = Regex.Match(resultField, @"^\s*([^\s]+)\s+AS\s+([^\s]+)\s*$", RegexOptions.IgnoreCase); + if (match.Success) + { + string beforeAs = match.Groups[1].Value.Trim(); + string afterAs = match.Groups[2].Value.Trim(); + string value = ""; + foreach (DataRow item in sourceTable.Rows) + { + if (item.Table.Columns.Contains(beforeAs)) + { + value += item[beforeAs] + ","; + } + } + ModuleResultDic.Add(afterAs, value); + } + else + { + string value = ""; + foreach (DataRow item in sourceTable.Rows) + { + if (item.Table.Columns.Contains(resultField)) + { + value += item[resultField] + ","; + } + } + ModuleResultDic.Add(resultField, value); + } + } + } + this.DialogResult = DialogResult.OK; + this.Close(); + } + #endregion + + #region 取消 + /// + /// 说明:取消 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + #endregion + + #region 全选所有数据 + /// + /// 全选所有数据 + /// + /// + /// + private void btn_selectAll_Click(object sender, EventArgs e) + { + DataTable DataSource = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable(); + foreach (DataRow item in DataSource.Rows) + { + //DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + "")); + (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(item.ItemArray); + } + this.SetDetailDataSource(); + } + #endregion + + #region 取消全选 + /// + /// 取消全选 + /// + /// + /// + private void btn_cancelAll_Click(object sender, EventArgs e) + { + + (this.gcDetail.GridControl.DataSource as DataTable).Clear(); + } + #endregion + + #region 释放时清理数据源 + /// + /// 说明:释放时清理数据源 + /// 创建人:龚宇超 + /// 创建日期:2018-03-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + private void OnFrmModelLookUp_Disposed(object sender, EventArgs e) + { + if (this.DataSource != null) + { + this.DataSource = null; + } + GC.Collect(); + } + #endregion + + #region 设置关联模块 + /// + /// 说明:设置管理模块 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private bool SetAssociatedModules() + { + if (!string.IsNullOrWhiteSpace(this.UnionModuleCodel)) + { + DataRow modelRow = MainImpl.GetSystemdllTab(this.UnionModuleCodel);//获取单个模块信息 + if (modelRow == null) + { + MessageUtil.Show("模块编号[" + UnionModuleCodel + "],配置错误!\r\n该模块信息未找到!"); + return false; + } + this.SysModel = new ModuleModel(modelRow);// 系统模块实体对象 + if (this.SysModel != null) + { + + + switch (this.SysModel.MenuType) + { + case 1: // 左侧为树节点 + this.pl_left_top.Visible = false; + this.gridLeft.Visible = false; + this.treeLeft.Visible = true; + this.InitlizeSpiltLocation();//设置分割条位置 + this.SetLeftTreeView();//设置左侧树数据 + this.LeftTreeViewEx = this.treeLeft; + break; + case 2: // 左侧为表格 + this.gridLeft.Visible = true; + this.treeLeft.Visible = false; + this.InitlizeSpiltL \ No newline at end of file diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.resx b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.resx new file mode 100644 index 0000000..ad53752 --- /dev/null +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUp.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUp.cs index 4dba324..22e440b 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUp.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUp.cs @@ -1142,37 +1142,4 @@ namespace Lskj.Control.MultiModelLookUp private void btn_cancelAll_Click(object sender, EventArgs e) { - DataTable dt = this.DataSource.Clone(); - foreach (DataRow item in this.DataSource.Rows) - { - if ("True".Equals(item[_checkFieldName] + "")) - { - - item[_checkFieldName] = 0; - } - } - this.btnOk_Click(sender, e); - } - #endregion - - #region 释放时清理数据源 - /// - /// 说明:释放时清理数据源 - /// 创建人:龚宇超 - /// 创建日期:2018-03-16 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - private void OnFrmModelLookUp_Disposed(object sender, EventArgs e) - { - if (this.DataSource != null) - { - this.DataSource = null; - } - GC.Collect(); - } - #endregion - #endregion - } -} + DataTabl \ No newline at end of file diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUpNew.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUpNew.cs index 00e97f9..ce7364e 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUpNew.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmRowsModelLookUpNew.cs @@ -864,34 +864,4 @@ namespace Lskj.Control.MultiModelLookUp this.gcMain.GridView.SelectionChanged -= OnGridViewSelectionChanged; if (SingleChoiceMode) { - //清除所有选择 - this.gcMain.GridView.ClearSelection(); - } - if (e.Action == CollectionChangeAction.Add)//选中 - { - this.gcMain.GridView.SelectRow(e.ControllerRow); - } - this.gcMain.GridView.SelectionChanged += OnGridViewSelectionChanged; - } - #endregion - #region 释放时清理数据源 - /// - /// 说明:释放时清理数据源 - /// 创建人:龚宇超 - /// 创建日期:2018-03-16 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - private void OnFrmModelLookUp_Disposed(object sender, EventArgs e) - { - if (this.DataSource != null) - { - this.DataSource = null; - } - GC.Collect(); - } - #endregion - #endregion - } -} + //清除所有选 \ No newline at end of file diff --git a/插件库/Lskj.Control/TreeBandedGridControlEx.cs b/插件库/Lskj.Control/TreeBandedGridControlEx.cs index 0ac4843..4183661 100644 --- a/插件库/Lskj.Control/TreeBandedGridControlEx.cs +++ b/插件库/Lskj.Control/TreeBandedGridControlEx.cs @@ -667,8 +667,8 @@ namespace Lskj.Control case ControlType.LabPic: InitPicEdit(column); break; - case ControlType.LabSelectReturnId: - case ControlType.LabSelectReturnText: + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: InitSelectReturnId(column, model); break; case ControlType.LabSelectReturnRows: @@ -1194,12 +1194,12 @@ namespace Lskj.Control /// private void InitSelectReturnId(TreeListColumn gridColumn, GridColumnModel model) { - FrmModelLookUp modelLookUp = new FrmModelLookUp(model.addModuleld); + FrmModelLookUp2 modelLookUp = new FrmModelLookUp2(model.addModuleld); modelLookUp.ValueField = model.ValueMember; modelLookUp.TextField = model.TextMember; modelLookUp.SourceSQL = model.SqlSource; modelLookUp.IsType = model.FieldType; - modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnId ? model.ValueMember : model.TextMember; + modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; modelLookUp.Tag = model; RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit(); @@ -1208,7 +1208,7 @@ namespace Lskj.Control btnEdit.AllowNullInput = DefaultBoolean.False; btnEdit.DisplayMember = model.TextMember; btnEdit.SeparatorChar = ','; - btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnId ? model.ValueMember : model.TextMember; + btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; btnEdit.DataSource = MainImpl.GetDataTableResult(model.SqlSource); btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用. btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) }); @@ -1242,7 +1242,7 @@ namespace Lskj.Control modelLookUp.TextField = model.TextMember; modelLookUp.SourceSQL = model.SqlSource; modelLookUp.IsType = model.FieldType; - modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnId ? model.ValueMember : model.TextMember; + modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; modelLookUp.selectField = gridColumn.FieldName; modelLookUp.Tag = model; @@ -2378,7 +2378,7 @@ namespace Lskj.Control try { CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender; - FrmModelLookUp modelLookUp = e.Button.Tag as FrmModelLookUp; + FrmModelLookUp2 modelLookUp = e.Button.Tag as FrmModelLookUp2; GridColumnModel model = modelLookUp.Tag as GridColumnModel; modelLookUp.EditText = btnEdit.Text; @@ -2693,36 +2693,4 @@ namespace Lskj.Control } table.Rows.Add(newRow); //this.gridView.FocusedRowHandle = _rowNumber - 1; - } - else - { - //this.gcMain.UpdateCurrentRow(); - } - } - this.gcMain.ShowEditor(); - e.Handled = true; - //SendKeys.Send("{Esc}"); - } - } - } - /// - /// 去除多选框中的空格 - /// - private object ReplaceMultiSpace(object text) - { - if (string.IsNullOrEmpty(text + "")) - { - return text; - } - string[] keyValues = (text + "").Split(','); - string returnText = ""; - foreach (string keyValue in keyValues) - { - string newKeyValue = keyValue.Trim(); - returnText += string.Format("{0},", newKeyValue); - } - returnText = returnText.TrimEnd(','); - return returnText + ","; - } - } -} \ No newline at end of file + \ No newline at end of file diff --git a/插件库/Lskj.Control/TreeGridControlEx.cs b/插件库/Lskj.Control/TreeGridControlEx.cs index 37dcaab..8d93005 100644 --- a/插件库/Lskj.Control/TreeGridControlEx.cs +++ b/插件库/Lskj.Control/TreeGridControlEx.cs @@ -483,6 +483,10 @@ namespace Lskj.Control case ControlType.LabSelectReturnText: InitSelectReturnId(column, model); break; + case ControlType.LabSelectReturnIdNew: + case ControlType.LabSelectReturnTextNew: + InitSelectReturnIdNew(column, model); + break; case ControlType.LabSelectReturnRows: InitSelectReturnRows(column, model); break; @@ -1036,6 +1040,47 @@ namespace Lskj.Control this.mControlList.Add(model); } + /// + /// 说明:创建 模块返回ID + /// 创建人:曹屹峰 + /// 创建日期:2021-08-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitSelectReturnIdNew(TreeListColumn gridColumn, GridColumnModel model) + { + FrmModelLookUp2 modelLookUp = new FrmModelLookUp2(model.addModuleld); + modelLookUp.ValueField = model.ValueMember; + modelLookUp.TextField = model.TextMember; + modelLookUp.SourceSQL = model.SqlSource; + modelLookUp.IsType = model.FieldType; + modelLookUp.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; + modelLookUp.Tag = model; + + RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit(); + btnEdit.NullText = ""; + btnEdit.PopupBorderStyle = PopupBorderStyles.Flat; + btnEdit.AllowNullInput = DefaultBoolean.False; + btnEdit.DisplayMember = model.TextMember; + btnEdit.SeparatorChar = ','; + btnEdit.ValueMember = model.FieldType == ControlType.LabSelectReturnIdNew ? model.ValueMember : model.TextMember; + btnEdit.DataSource = MainImpl.GetDataTableResult(model.SqlSource); + btnEdit.Buttons[0].Visible = false; // 不能移除,移除后事件不起作用. + btnEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) }); + + btnEdit.Tag = model; + btnEdit.Buttons[1].Tag = modelLookUp; + btnEdit.ButtonClick += new ButtonPressedEventHandler(OnModuleChoiceNew); + + gridControl.RepositoryItems.Add(btnEdit); + gridColumn.OptionsColumn.ReadOnly = true; + gridColumn.ColumnEdit = btnEdit; + + this.mControlList.Add(model); + } + /// /// 说明:创建 模块返回行数据 /// 创建人:唐德馨 @@ -2526,7 +2571,6 @@ namespace Lskj.Control } - /// /// 说明:表格打开模块返回id /// 创建人:曹屹峰 @@ -2543,6 +2587,59 @@ namespace Lskj.Control CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender; FrmModelLookUp modelLookUp = e.Button.Tag as FrmModelLookUp; + GridColumnModel model = modelLookUp.Tag as GridColumnModel; + modelLookUp.EditText = btnEdit.Text; + modelLookUp.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName; + if (model.FieldType == ControlType.LabMultiSelectValue || model.FieldType == ControlType.LabMultiSelectValueParam) + { + modelLookUp.EditValue = btnEdit.EditValue + ""; + modelLookUp.EditText = string.Empty; + } + else + { + modelLookUp.EditText = btnEdit.Text; + modelLookUp.EditValue = string.Empty; + } + //多选关联单据头 + modelLookUp.SourceSQL = model.SqlSource.Replace("#", ""); + //单据头关联取值 + if (this.ParentControl != null) + { + modelLookUp.SourceSQL = this.ParentControl.ReplaceControlValue(modelLookUp.SourceSQL); + } + + modelLookUp.SourceSQL = ReplaceHelper.ReplaceRowParam(this.GetViewFocusedDataRow(), modelLookUp.SourceSQL); + //modelLookUp.DataSource = BaseImpl.GetDataTableResult(modelLookUp.SourceSQL); + modelLookUp.InitControls(modelLookUp.UnionModuleCodel); + DialogResult result = modelLookUp.ShowDialog(); + if (result == DialogResult.OK) + { + btnEdit.EditValue = modelLookUp.EditValue; + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode); + MessageUtil.Show(Message, ex.Message); + } + } + /// + /// 说明:表格打开模块返回id + /// 创建人:曹屹峰 + /// 创建日期:2021-08-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void OnModuleChoiceNew(object sender, ButtonPressedEventArgs e) + { + try + { + CheckedComboBoxEdit btnEdit = (CheckedComboBoxEdit)sender; + FrmModelLookUp2 modelLookUp = e.Button.Tag as FrmModelLookUp2; + GridColumnModel model = modelLookUp.Tag as GridColumnModel; modelLookUp.EditText = btnEdit.Text; modelLookUp.CurrentOperColumnKey = Model.ModuleCode + "_" + model.FieldName;