SVN-Revision: r747
This commit is contained in:
tdx
2025-06-16 12:05:46 +00:00
parent 8f29f7a48b
commit 849c41b246
2 changed files with 186 additions and 57 deletions
+151 -36
View File
@@ -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,65 +1324,179 @@ namespace Lskj.Control
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
//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);
// }
//}
/// <summary>
/// 说明:表格拖拽完成
/// 创建人:龚宇超
/// 创建日期:2017-11-14
/// 版本:1.1 (2025-06-16 增加动态存储过程调用)
/// </summary>
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;
try
{
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
int[] records = new int[e.GridViewSelectRows.Length];
string fieldName = this.LeftRowObj["fieldName"] + "";
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
//拖拽条件 替换左侧表格拖拽目标行
string DragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
string fieldName = string.IsNullOrEmpty(SysModel.leftprimFile)? this.LeftRowObj["fieldName"] + "": SysModel.leftprimFile;
for (int i = 0; i < e.GridViewSelectRows.Length; i++)
/* ───── ① 有配置存储过程:只执行存储过程 ───── */
if (!string.IsNullOrWhiteSpace(SysModel.DragprocessFile))
{
DataRow item = e.GridViewSelectRows[i];
try
{
records[i] = ReplaceHelper.ReplaceRowParamCond(item, DragCond)
? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectGridRow[fieldName] + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
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
{
string dragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
int successCount = 0, faultCount = 0;
foreach (DataRow item in e.GridViewSelectRows)
{
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 (records[i] == 1)
if (result == 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 + "");
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 ex)
catch (Exception ex1)
{
LogHelper.Instance.WriteError(ex);
MessageUtil.Show("表格拖拽出错!" + ex);
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);
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(tipMsg);
MessageUtil.Show(tip);
SearchObj.SearchLastGrid();
//this.SetMainGridView(string.Format(" and {0} like '{1}%' ", fieldName, e.SelectGridRow[fieldName]));
}
}
catch (Exception ex)
catch (Exception ex2)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
LogHelper.Instance.WriteError(ex2);
MessageUtil.Show(ErrorMessage.PromptErrorMessage(ex2), ex2.Message);
}
}
LogHelper.Instance.WriteError(ex);
//MessageUtil.Show(ResourceKeys.OperFault);
}
}
/// <summary>
+21 -7
View File
@@ -71,7 +71,6 @@ namespace Lskj.Control
/// 底部多标签表格数据
/// </summary>
public List<GridDetailModel> GridDetailList;
/// <summary>
/// 左边查询条件
/// </summary>
@@ -612,16 +611,25 @@ namespace Lskj.Control
/// <param name="gridControl">The grid control.</param>
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,直接退出
@@ -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;
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)
{