diff --git a/插件库/Lskj.Control/GridControlEx.cs b/插件库/Lskj.Control/GridControlEx.cs index aba81e7..1be67a1 100644 --- a/插件库/Lskj.Control/GridControlEx.cs +++ b/插件库/Lskj.Control/GridControlEx.cs @@ -5989,7 +5989,7 @@ namespace Lskj.Control modelLookUp.EditValue = string.Empty; } //多选关联单据头 - string SourceSQL = modelLookUp.SysModel.MenuSql.Replace("#", "")+ model.SplicingConditions; + string SourceSQL = modelLookUp.SysModel.MenuSql.Replace("#", "") + model.SplicingConditions; //单据头关联取值 if (this.ParentControl != null) { @@ -5997,6 +5997,7 @@ namespace Lskj.Control } modelLookUp.NewSourceSQL = ReplaceHelper.ReplaceRowParam(this.gridView.GetFocusedDataRow(), SourceSQL); + modelLookUp.AddModuleResult = model.addModuleResult; //modelLookUp.DataSource = BaseImpl.GetDataTableResult(modelLookUp.SourceSQL); modelLookUp.InitControls(modelLookUp.UnionModuleCodel); DialogResult result = modelLookUp.ShowDialog(); @@ -6007,11 +6008,12 @@ namespace Lskj.Control DataRow focusedRow = this.gridView.GetFocusedDataRow(); if (focusedRow != null) { - foreach (string resultField in resultFields) + foreach (string resultKey in modelLookUp.ModuleResultDic.Keys) { - if (focusedRow.Table.Columns.Contains(resultField)) + string resultValue = modelLookUp.ModuleResultDic[resultKey]; + if (focusedRow.Table.Columns.Contains(resultKey)) { - focusedRow[resultField] = modelLookUp.EditText; + focusedRow[resultKey] = resultValue; } } } diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs b/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs index 4cc1156..1192a6a 100644 --- a/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit2.cs @@ -282,11 +282,11 @@ namespace Lskj.Control public void SetDataSource(DataTable dataSource) { _lookUpForm = new FrmModelLookUp(UnionModuleCodel, IsRadio); - _lookUpForm.ConfigureColumnMode =ConfigureColumnMode; + _lookUpForm.ConfigureColumnMode = ConfigureColumnMode; _lookUpForm.ValueField = ValueField; _lookUpForm.ValueMember = ValueMember; _lookUpForm.TextField = TextField; - + //_lookUpForm.SourceSQL = SourceSQL; //_lookUpForm.DataSource = dataSource; } @@ -327,13 +327,14 @@ namespace Lskj.Control _lookUpForm.EditText = this.TextEdit.Text; } - string sqlValue = _lookUpForm.SysModel.MenuSql+ Model.SplicingConditions; + 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; - _l \ No newline at end of file + _lookUpForm.AddModuleResult = Model.AddModuleResult; + _lookUpForm \ No newline at end of file diff --git a/插件库/Lskj.Control/ModuleGridEx.cs b/插件库/Lskj.Control/ModuleGridEx.cs index ee7b79f..e642607 100644 --- a/插件库/Lskj.Control/ModuleGridEx.cs +++ b/插件库/Lskj.Control/ModuleGridEx.cs @@ -1489,6 +1489,7 @@ namespace Lskj.Control } catch (Exception ex) { + Console.WriteLine(ex.Message); } } /// diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs index d830c3e..bb55a8e 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs @@ -8,9 +8,11 @@ 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 @@ -141,8 +143,14 @@ namespace Lskj.Control.MultiModelLookUp /// /// The source SQL. public string NewSourceSQL; - - + /// + /// 关联返回参数的字段组合 + /// + public string AddModuleResult; + /// + /// 返回关联的字典 + /// + public Dictionary ModuleResultDic = new Dictionary(); #endregion public FrmModelLookUp(string ModuleCodel) { @@ -181,7 +189,7 @@ namespace Lskj.Control.MultiModelLookUp //设置关联模块 bool result = SetAssociatedModules(); - + //单选模式,不显示明细表,主表双击选中后退出选择界面 if (SingleChoiceMode) @@ -386,8 +394,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[] { valueColumn, textColumn }); + this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn }); if (DataSource.Columns.IndexOf("remark") != -1) { @@ -614,7 +622,7 @@ namespace Lskj.Control.MultiModelLookUp /// The menu code. public void InitControls(string UnionModuleCodel) { - + this.SysModel.MenuSql = this.NewSourceSQL; //设置上方条件 this.pl_top.Controls.Clear(); @@ -876,17 +884,49 @@ namespace Lskj.Control.MultiModelLookUp /// The instance containing the event data. private void btnOk_Click(object sender, EventArgs e) { - this.EditValue = string.Empty; - this.EditText = string.Empty; - - - foreach (DataRow item in (this.gcDetail.GridControl.DataSource as DataTable).Rows) + 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(); } @@ -998,4 +1038,4 @@ namespace Lskj.Control.MultiModelLookUp case 2: // 左侧为表格 this.gridLeft.Visible = true; this.treeLeft.Visible = false; - this.InitlizeSpiltLocation(); \ No newline at end of file + this.InitlizeSpiltL \ No newline at end of file