SVN r747
SVN-Revision: r747
This commit is contained in:
+151
-36
@@ -38,6 +38,7 @@ using DevExpress.XtraTreeList;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DevExpress.XtraRichEdit;
|
using DevExpress.XtraRichEdit;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace Lskj.Control
|
namespace Lskj.Control
|
||||||
{
|
{
|
||||||
@@ -1323,65 +1324,179 @@ namespace Lskj.Control
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender">The sender.</param>
|
/// <param name="sender">The sender.</param>
|
||||||
/// <param name="e">The e.</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)
|
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)
|
||||||
{
|
return;
|
||||||
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int[] records = new int[e.GridViewSelectRows.Length];
|
|
||||||
string fieldName = this.LeftRowObj["fieldName"] + "";
|
|
||||||
|
|
||||||
//拖拽条件 替换左侧表格拖拽目标行
|
string fieldName = string.IsNullOrEmpty(SysModel.leftprimFile)? this.LeftRowObj["fieldName"] + "": SysModel.leftprimFile;
|
||||||
string DragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
|
|
||||||
|
|
||||||
for (int i = 0; i < e.GridViewSelectRows.Length; i++)
|
/* ───── ① 有配置存储过程:只执行存储过程 ───── */
|
||||||
|
if (!string.IsNullOrWhiteSpace(SysModel.DragprocessFile))
|
||||||
{
|
{
|
||||||
DataRow item = e.GridViewSelectRows[i];
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
records[i] = ReplaceHelper.ReplaceRowParamCond(item, DragCond)
|
string moduleCode = this.Model.ModuleCode;
|
||||||
? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectGridRow[fieldName] + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
|
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;
|
: 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] + "");
|
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] + "", text, this.Model.ModuleId + "");
|
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);
|
faultCount++;
|
||||||
MessageUtil.Show("表格拖拽出错!" + ex);
|
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;
|
string tip = "";
|
||||||
if (successCount > 0) tipMsg = string.Format(ResourceKeys.DragSuccessCount, successCount);
|
if (successCount > 0) tip = string.Format(ResourceKeys.DragSuccessCount, successCount);
|
||||||
if (faultCount > 0) tipMsg += successCount > 0 ? "\r\n" : "" + string.Format(ResourceKeys.DragFaultCount, faultCount);
|
if (faultCount > 0) tip += (tip == "" ? "" : "\r\n") +
|
||||||
|
string.Format(ResourceKeys.DragFaultCount, faultCount);
|
||||||
|
|
||||||
MessageUtil.Show(tipMsg);
|
MessageUtil.Show(tip);
|
||||||
SearchObj.SearchLastGrid();
|
SearchObj.SearchLastGrid();
|
||||||
//this.SetMainGridView(string.Format(" and {0} like '{1}%' ", fieldName, e.SelectGridRow[fieldName]));
|
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex2)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
LogHelper.Instance.WriteError(ex2);
|
||||||
MessageUtil.Show(Message, ex.Message);
|
MessageUtil.Show(ErrorMessage.PromptErrorMessage(ex2), ex2.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LogHelper.Instance.WriteError(ex);
|
|
||||||
//MessageUtil.Show(ResourceKeys.OperFault);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ namespace Lskj.Control
|
|||||||
/// 底部多标签表格数据
|
/// 底部多标签表格数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<GridDetailModel> GridDetailList;
|
public List<GridDetailModel> GridDetailList;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 左边查询条件
|
/// 左边查询条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -612,16 +611,25 @@ namespace Lskj.Control
|
|||||||
/// <param name="gridControl">The grid control.</param>
|
/// <param name="gridControl">The grid control.</param>
|
||||||
protected void SetTabPageDataSource(XtraTabPage tabPage, bool isNull = false)
|
protected void SetTabPageDataSource(XtraTabPage tabPage, bool isNull = false)
|
||||||
{
|
{
|
||||||
|
GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
|
||||||
if (isNull)
|
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());
|
this.tcButtom.SetGridDataSource(tabPage, new DataTable());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
|
|
||||||
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
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" 的返回值
|
// 形如 "1,2,3" 的返回值
|
||||||
string numberList = MainImpl.GetResult(condSql) + "";
|
string numberList = MainImpl.GetResult(condSql) + "";
|
||||||
|
|
||||||
@@ -630,7 +638,7 @@ namespace Lskj.Control
|
|||||||
string[] idArr = numberList.Split(new[] { ',' },
|
string[] idArr = numberList.Split(new[] { ',' },
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(numberList)&&!idArr.Contains(orderIdStr))
|
if (!string.IsNullOrEmpty(numberList) && !idArr.Contains(orderIdStr))
|
||||||
{
|
{
|
||||||
tabPage.PageVisible = false;
|
tabPage.PageVisible = false;
|
||||||
return; // 不包含当前 orderid,直接退出
|
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 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;
|
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);
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||||
|
}
|
||||||
DataRow row = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
DataRow row = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
||||||
if (row != null && isLeft)
|
if (row != null && isLeft)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user