diff --git a/插件库/Lskj.Control/ModuleEx.cs b/插件库/Lskj.Control/ModuleEx.cs
index a463075..428d993 100644
--- a/插件库/Lskj.Control/ModuleEx.cs
+++ b/插件库/Lskj.Control/ModuleEx.cs
@@ -38,6 +38,7 @@ using DevExpress.XtraTreeList;
using System.Collections;
using System.Threading.Tasks;
using DevExpress.XtraRichEdit;
+using System.Data.SqlClient;
namespace Lskj.Control
{
@@ -1323,67 +1324,181 @@ namespace Lskj.Control
///
/// The sender.
/// The e.
+ //protected void OnDragGridCompleted(object sender, GridDragGridArgs e)
+ //{
+ // if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || e.SelectGridRow == null) return;
+
+ // try
+ // {
+ // if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
+ // {
+ // int[] records = new int[e.GridViewSelectRows.Length];
+ // string fieldName = this.LeftRowObj["fieldName"] + "";
+
+ // //拖拽条件 替换左侧表格拖拽目标行
+ // string DragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
+
+ // for (int i = 0; i < e.GridViewSelectRows.Length; i++)
+ // {
+ // DataRow item = e.GridViewSelectRows[i];
+ // try
+ // {
+ // if (!string.IsNullOrEmpty(SysModel.DragprocessFile))//若配置存储
+ // {
+
+ // }
+ // records[i] = ReplaceHelper.ReplaceRowParamCond(item, DragCond)
+ // ? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectGridRow[fieldName] + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
+ // : 0;
+
+ // if (records[i] == 1)
+ // {
+ // string text = string.Format("{0}表{1}=''{2}''的数据,对应{3}修改为{4}", this.SysModel.MenuTable, this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "", fieldName, e.SelectGridRow[fieldName] + "");
+ // //记录拖拽成功信息
+ // LogUtil.WriteDebug(this.Model.ModuleCode, "拖拽修改", this.Model.FormText + item[this.ModuleGridObj.ParmaryKey] + "", text, this.Model.ModuleId + "");
+ // }
+
+ // }
+ // catch (Exception ex)
+ // {
+ // LogHelper.Instance.WriteError(ex);
+ // MessageUtil.Show("表格拖拽出错!" + ex);
+ // }
+ // }
+ // int successCount = records.Contains(1) ? records.Where(x => x == 1).Count() : 0;
+ // int faultCount = records.Contains(0) ? records.Where(x => x == 0).Count() : 0;
+
+ // string tipMsg = string.Empty;
+ // if (successCount > 0) tipMsg = string.Format(ResourceKeys.DragSuccessCount, successCount);
+ // if (faultCount > 0) tipMsg += successCount > 0 ? "\r\n" : "" + string.Format(ResourceKeys.DragFaultCount, faultCount);
+
+ // MessageUtil.Show(tipMsg);
+ // SearchObj.SearchLastGrid();
+ // //this.SetMainGridView(string.Format(" and {0} like '{1}%' ", fieldName, e.SelectGridRow[fieldName]));
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // string Message = ErrorMessage.PromptErrorMessage(ex);
+ // MessageUtil.Show(Message, ex.Message);
+
+ // LogHelper.Instance.WriteError(ex);
+ // //MessageUtil.Show(ResourceKeys.OperFault);
+ // }
+ //}
+ ///
+ /// 说明:表格拖拽完成
+ /// 创建人:龚宇超
+ /// 创建日期:2017-11-14
+ /// 版本:1.1 (2025-06-16 增加动态存储过程调用)
+ ///
protected void OnDragGridCompleted(object sender, GridDragGridArgs e)
{
- if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || e.SelectGridRow == null) return;
+ if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || e.SelectGridRow == null)
+ return;
+ if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) != DialogResult.Yes)
+ return;
+
+ string fieldName = string.IsNullOrEmpty(SysModel.leftprimFile)? this.LeftRowObj["fieldName"] + "": SysModel.leftprimFile;
+
+ /* ───── ① 有配置存储过程:只执行存储过程 ───── */
+ if (!string.IsNullOrWhiteSpace(SysModel.DragprocessFile))
+ {
+ try
+ {
+
+ string moduleCode = this.Model.ModuleCode;
+ string leftValue = e.SelectGridRow[fieldName] + "";
+ string rightKeys = string.Join(",", e.GridViewSelectRows
+ .Select(r => r[this.ModuleGridObj.ParmaryKey] + ""));
+ string operatorNm = ERPInfo.Instance.UserName;
+
+ /* 1. 构造 SqlParameter[] */
+ var ps = new[]
+ {
+ new SqlParameter("@ModuleCode", moduleCode),
+ new SqlParameter("@LeftValue", leftValue),
+ new SqlParameter("@RightKeys", rightKeys),
+ new SqlParameter("@Operator", operatorNm),
+ new SqlParameter("@msg", SqlDbType.NVarChar, 4000)
+ { Direction = ParameterDirection.Output }
+ };
+
+ /* 2. 执行存储过程 */
+ int rows = BaseImpl.ExecProcedure(SysModel.DragprocessFile, ps); // ← 关键调用
+
+ /* 3. 提示信息 */
+ string rtnMsg = Convert.ToString(ps[4].Value); // 读取 @msg
+ if (string.IsNullOrWhiteSpace(rtnMsg))
+ rtnMsg = rows > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault;
+
+ MessageUtil.Show(rtnMsg);
+ SearchObj.SearchLastGrid();
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Instance.WriteError(ex);
+ MessageUtil.Show("拖拽存储过程执行失败!\r\n" + ex.Message);
+ }
+ return; // 只走这一条路径
+ }
+
+
+ /* ───── ② 无存储过程:逐行 UpdateRecord ───── */
try
{
- if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
+ string dragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
+ int successCount = 0, faultCount = 0;
+
+ foreach (DataRow item in e.GridViewSelectRows)
{
- int[] records = new int[e.GridViewSelectRows.Length];
- string fieldName = this.LeftRowObj["fieldName"] + "";
-
- //拖拽条件 替换左侧表格拖拽目标行
- string DragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
-
- for (int i = 0; i < e.GridViewSelectRows.Length; i++)
+ try
{
- DataRow item = e.GridViewSelectRows[i];
- try
+ bool needUpdate = ReplaceHelper.ReplaceRowParamCond(item, dragCond);
+ int result = needUpdate
+ ? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable,
+ fieldName,
+ e.SelectGridRow[fieldName] + "",
+ this.ModuleGridObj.ParmaryKey,
+ item[this.ModuleGridObj.ParmaryKey] + "")
+ : 0;
+
+ if (result == 1)
{
-
- records[i] = ReplaceHelper.ReplaceRowParamCond(item, DragCond)
- ? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectGridRow[fieldName] + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
- : 0;
-
- if (records[i] == 1)
- {
- string text = string.Format("{0}表{1}=''{2}''的数据,对应{3}修改为{4}", this.SysModel.MenuTable, this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "", fieldName, e.SelectGridRow[fieldName] + "");
- //记录拖拽成功信息
- LogUtil.WriteDebug(this.Model.ModuleCode, "拖拽修改", this.Model.FormText + item[this.ModuleGridObj.ParmaryKey] + "", text, this.Model.ModuleId + "");
- }
-
- }
- catch (Exception ex)
- {
- LogHelper.Instance.WriteError(ex);
- MessageUtil.Show("表格拖拽出错!" + ex);
+ successCount++;
+ string log = $"{this.SysModel.MenuTable}表{this.ModuleGridObj.ParmaryKey}='{item[this.ModuleGridObj.ParmaryKey]}' 的 {fieldName} 修改为 {e.SelectGridRow[fieldName]}";
+ LogUtil.WriteDebug(this.Model.ModuleCode, "拖拽修改",
+ this.Model.FormText + item[this.ModuleGridObj.ParmaryKey], log,
+ this.Model.ModuleId + "");
}
+ else
+ faultCount++;
+ }
+ catch (Exception ex1)
+ {
+ faultCount++;
+ LogHelper.Instance.WriteError(ex1);
}
- int successCount = records.Contains(1) ? records.Where(x => x == 1).Count() : 0;
- int faultCount = records.Contains(0) ? records.Where(x => x == 0).Count() : 0;
-
- string tipMsg = string.Empty;
- if (successCount > 0) tipMsg = string.Format(ResourceKeys.DragSuccessCount, successCount);
- if (faultCount > 0) tipMsg += successCount > 0 ? "\r\n" : "" + string.Format(ResourceKeys.DragFaultCount, faultCount);
-
- MessageUtil.Show(tipMsg);
- SearchObj.SearchLastGrid();
- //this.SetMainGridView(string.Format(" and {0} like '{1}%' ", fieldName, e.SelectGridRow[fieldName]));
}
- }
- catch (Exception ex)
- {
- string Message = ErrorMessage.PromptErrorMessage(ex);
- MessageUtil.Show(Message, ex.Message);
- LogHelper.Instance.WriteError(ex);
- //MessageUtil.Show(ResourceKeys.OperFault);
+ string tip = "";
+ if (successCount > 0) tip = string.Format(ResourceKeys.DragSuccessCount, successCount);
+ if (faultCount > 0) tip += (tip == "" ? "" : "\r\n") +
+ string.Format(ResourceKeys.DragFaultCount, faultCount);
+
+ MessageUtil.Show(tip);
+ SearchObj.SearchLastGrid();
+ }
+ catch (Exception ex2)
+ {
+ LogHelper.Instance.WriteError(ex2);
+ MessageUtil.Show(ErrorMessage.PromptErrorMessage(ex2), ex2.Message);
}
}
+
///
/// 说明:多表头表格拖拽完成
/// 创建人:曹屹峰
diff --git a/插件库/Lskj.Control/ModuleGridDetailEx.cs b/插件库/Lskj.Control/ModuleGridDetailEx.cs
index d1861b7..864a2f1 100644
--- a/插件库/Lskj.Control/ModuleGridDetailEx.cs
+++ b/插件库/Lskj.Control/ModuleGridDetailEx.cs
@@ -71,7 +71,6 @@ namespace Lskj.Control
/// 底部多标签表格数据
///
public List GridDetailList;
-
///
/// 左边查询条件
///
@@ -383,7 +382,7 @@ namespace Lskj.Control
//this.ModuleGridObj.GridControlObj.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnGridViewFocusedRowChanged);
}
}
-
+
}
else
{
@@ -480,7 +479,7 @@ namespace Lskj.Control
else
{
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
- string mainModuleCode = (rowItem[SysModel.MainModuleCodeField] + "").ToLower();
+ string mainModuleCode = (rowItem[SysModel.MainModuleCodeField] + "").ToLower();
//mainModuleCode = String.Empty;
this.TabObj.TabPages.Clear();
//if (string.IsNullOrWhiteSpace(mainModuleCode)) return;
@@ -612,16 +611,25 @@ namespace Lskj.Control
/// The grid control.
protected void SetTabPageDataSource(XtraTabPage tabPage, bool isNull = false)
{
+ GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
if (isNull)
{
+ DataRow leftrow = _leftGridSearchObj!=null?_leftGridSearchObj.MainGridEx.GetViewFocusedDataRow():null;
+ if (model.IsUnionleft&& leftrow!=null)//为空状态下若明细关联左侧则去替换数据源
+ {
+ string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
+ sqlValue = ReplaceHelper.ReplaceRowParam(leftrow, sqlValue);
+ this.tcButtom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue));
+ return;
+ }
this.tcButtom.SetGridDataSource(tabPage, new DataTable());
return;
}
- GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
+
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
- if (!string.IsNullOrEmpty(SysModel.PageVisbleCond) )
+ if (!string.IsNullOrEmpty(SysModel.PageVisbleCond))
{
- string condSql= ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(SysModel.PageVisbleCond));
+ string condSql = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(SysModel.PageVisbleCond));
// 形如 "1,2,3" 的返回值
string numberList = MainImpl.GetResult(condSql) + "";
@@ -630,7 +638,7 @@ namespace Lskj.Control
string[] idArr = numberList.Split(new[] { ',' },
StringSplitOptions.RemoveEmptyEntries);
- if (!string.IsNullOrEmpty(numberList)&&!idArr.Contains(orderIdStr))
+ if (!string.IsNullOrEmpty(numberList) && !idArr.Contains(orderIdStr))
{
tabPage.PageVisible = false;
return; // 不包含当前 orderid,直接退出
@@ -641,7 +649,7 @@ namespace Lskj.Control
}
}
-
+
if (IsDynamicDetailType)
{
//string mainModuleCode = model.ParentModuleCode;
@@ -769,7 +777,7 @@ namespace Lskj.Control
}
}
- if (moduleGridEx != null)
+ if (moduleGridEx != null)
{
moduleGridEx.ParentButtonState(rowItem);
moduleGridEx.SelectTheSpecifiedRow();
@@ -845,9 +853,15 @@ namespace Lskj.Control
{
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ModuleGridObj.ParmaryKey;
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
-
-
- sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
+ if (model.IsUnionleft)
+ {
+ DataRow leftrow = _leftGridSearchObj.MainGridEx.GetViewFocusedDataRow();
+ sqlValue = ReplaceHelper.ReplaceRowParam(leftrow, sqlValue);
+ }
+ else
+ {
+ sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
+ }
DataRow row = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
if (row != null && isLeft)
{