2095 lines
99 KiB
C#
2095 lines
99 KiB
C#
/******************************
|
|
* 说明:带左侧树、表格操作右侧表格的自定义控件
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-09-01
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Util;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Data;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using System.IO;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.XtraBars;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using FastReport;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
using System.Diagnostics;
|
|
using Lskj.Core;
|
|
using Lskj.Business;
|
|
using DevExpress.XtraTreeList.Nodes;
|
|
using DevExpress.XtraTreeList;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using DevExpress.XtraRichEdit;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
/// <summary>
|
|
/// 带左侧树、表格操作右侧表格的自定义控件
|
|
/// </summary>
|
|
public partial class ModuleEx : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 当前富文本框是否改变
|
|
/// </summary>
|
|
private bool _richTextDirty;
|
|
/// <summary>
|
|
/// BMP字段
|
|
/// </summary>
|
|
private string _labPicName;
|
|
/// <summary>
|
|
/// 当前行
|
|
/// </summary>
|
|
private DataRow _currentRow;
|
|
/// <summary>
|
|
/// 左侧表格查询条件
|
|
/// </summary>
|
|
private MyControl _leftGridSearchObj;
|
|
|
|
public bool IsExcel { get { return Model is DynamicExcelModel; } }
|
|
/// <summary>
|
|
/// 是否为拖拽明细模式
|
|
/// </summary>
|
|
public bool IsDragDetail;
|
|
/// <summary>
|
|
/// 左侧条件
|
|
/// </summary>
|
|
public string LeftCond;
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
public DataRow LeftRowObj;
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel SysModel { get; private set; }
|
|
/// <summary>
|
|
/// 调用动态链接库默认传递参数对象
|
|
/// </summary>
|
|
public DynamicModel Model { get; private set; }
|
|
/// <summary>
|
|
/// 底部表格数据
|
|
/// </summary>
|
|
public List<GridDetailModel> Details;
|
|
/// <summary>
|
|
/// 查询条件
|
|
/// </summary>
|
|
/// <value>The search object.</value>
|
|
public MyControl SearchObj { get { return this.moduleGridDetailEx1.SearchObj; } }
|
|
|
|
/// <summary>
|
|
/// 常用操作对象,用于加载时暂时获取焦点
|
|
/// </summary>
|
|
/// <value>The title label object.</value>
|
|
public DevExpress.XtraEditors.DropDownButton ddbOperObj { get { return ModuleGridObj.ddbOperObj; } }
|
|
|
|
/// <summary>
|
|
/// 带操作表格的自定义控件对象
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj { get { return this.MainBodyTab.Visible ? (this.MainBodyTab.SelectedTabPage.Tag as ModuleGridDetailEx).ModuleGridObj : this.moduleGridDetailEx1.ModuleGridObj; } }
|
|
/// <summary>
|
|
/// Gets the module grid detail object.
|
|
/// </summary>
|
|
/// <value>The module grid detail object.</value>
|
|
public ModuleGridDetailEx ModuleGridDetailObj { get { return this.MainBodyTab.Visible ? this.MainBodyTab.SelectedTabPage.Tag as ModuleGridDetailEx : this.moduleGridDetailEx1; } }
|
|
/// <summary>
|
|
/// 左侧树结构对象
|
|
/// </summary>
|
|
/// <value>The TreeView object.</value>
|
|
public TreeViewEx LeftTreeViewObj { get { return this.treeLeft; } }
|
|
/// <summary>
|
|
/// 左侧表格对象
|
|
/// </summary>
|
|
/// <value>The left grid view object.</value>
|
|
public GridControlEx LeftGridViewObj { get { return this.gridLeft; } }
|
|
/// <summary>
|
|
/// Excel控件
|
|
/// </summary>
|
|
public ExcelControlEx ExcelControlObj;
|
|
|
|
/// <summary>
|
|
/// 左侧表格行点击事件回调
|
|
/// </summary>
|
|
public event EventHandler OnLeftGridViewRowClickCallBack;
|
|
/// <summary>
|
|
/// 左侧树结构选中节后点回调
|
|
/// </summary>
|
|
public event EventHandler OnLeftTreeViewRowClickCallBack;
|
|
/// <summary>
|
|
/// 禁止刷新主表(树表格节点展开时禁止刷新主表)
|
|
/// </summary>
|
|
public bool RefreshDisable = false;
|
|
/// <summary>
|
|
/// 上一次选中的树表格节点
|
|
/// </summary>
|
|
public TreeListNode treeListNode;
|
|
/// <summary>
|
|
/// 动态列名表
|
|
/// </summary>
|
|
public DataTable ColumnNameTable;
|
|
|
|
|
|
public ModuleEx()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:创建界面</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-09-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitControls(DynamicModel model)
|
|
{
|
|
try
|
|
{
|
|
if (model != null)
|
|
{
|
|
this.Model = model;
|
|
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成
|
|
if (!dataCaches.GetValue(this, "SystemDllRow", out DataRow modelRow))
|
|
{
|
|
modelRow = MainImpl.GetSystemdllTab(Model.ModuleCode);//获取模块信息
|
|
}
|
|
|
|
if (modelRow == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
|
return;
|
|
}
|
|
if (!dataCaches.GetValue(this, "SysModel", out ModuleModel sysModel))
|
|
{
|
|
sysModel = new ModuleModel(modelRow);// 系统模块实体对象
|
|
}
|
|
this.SysModel = sysModel;
|
|
if (!dataCaches.GetValue(this, "MenuConfigTab", out DataRow menuCondRow))
|
|
{
|
|
menuCondRow = BaseImpl.GetMenuConfigTab(this.Model.ModuleId);//获取菜单其他配置
|
|
}
|
|
|
|
|
|
if (menuCondRow != null)
|
|
{
|
|
if (menuCondRow["DllFileName"].Equals("Lskj.PubModuleDetailSearch.dll") || menuCondRow["DllFileName"].Equals("Lskj.PubModuleSearch")) Model.IsDetailSearch = true;// 是否是配置查询明细
|
|
}
|
|
if (this.SysModel.GridObjIsCheck == 1)//主表加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.ModuleGridObj.GridControlObj.GridView);
|
|
}
|
|
switch (this.SysModel.MenuType)
|
|
{
|
|
case 1:
|
|
case 4: // 左侧为树节点
|
|
this.pl_left_top.Visible = false;
|
|
this.gridLeft.Visible = false;
|
|
this.treeLeft.Visible = true;
|
|
this.treeGridLeft.Visible = false;
|
|
this.ModuleGridObj.LeftTreeViewEx = this.treeLeft;
|
|
this.InitlizeSpiltLocation();//设置分割条位置
|
|
this.treeLeft.TreeInhibitSort = this.SysModel.TreeInhibitSort;
|
|
this.SetLeftTreeView();//设置左侧树数据
|
|
if (this.SysModel.IsHideTreeViewBoxs)
|
|
{
|
|
this.treeLeft.TreeView.CheckBoxes = false;
|
|
}
|
|
|
|
if (Model.HasOperPrivilege() && model.IsBaseModule)
|
|
{
|
|
// 有权限则允许拖拽
|
|
GridDragTree dragTree = new GridDragTree(this.ModuleGridObj.GridControlObj.GridView, this.treeLeft.TreeView);
|
|
dragTree.CanDragParentNode = true;
|
|
dragTree.OnDragComplete += new GridDragTreeCompleteEventHandler(OnDragTreeCompleted);
|
|
}
|
|
if (this.SysModel.TreeDoubleClick)
|
|
{
|
|
this.treeLeft.OnTreeNodeMouseDoubleClick += TreeLeft_OnTreeNodeMouseDoubleClick;
|
|
}
|
|
//树节点添加右键刷新数据源
|
|
if (this.SysModel.TreeNodeRefresh)
|
|
{
|
|
ContextMenuStrip contextMenu = new ContextMenuStrip();
|
|
ToolStripMenuItem menuItem1 = new ToolStripMenuItem("刷新");
|
|
menuItem1.ImageIndex = 0;
|
|
menuItem1.Click += TreeNodeRefresh;
|
|
contextMenu.Items.Add(menuItem1);
|
|
this.treeLeft.ContextMenuStrip = contextMenu;
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
case 2:
|
|
case 5: // 左侧为表格
|
|
this.gridLeft.Visible = true;
|
|
this.treeLeft.Visible = false;
|
|
this.treeGridLeft.Visible = false;
|
|
|
|
if (this.SysModel.IsTreeTable)
|
|
{
|
|
this.treeGridLeft.Visible = true;
|
|
this.gridLeft.Visible = false;
|
|
this.treeLeft.Visible = false;
|
|
this.treeGridLeft.Expansion = this.SysModel.TreeTableExpand;
|
|
this.ModuleGridObj.TreeExactQuery = this.SysModel.TreeExactQuery;
|
|
}
|
|
|
|
this.ModuleGridObj.LeftGridEx = this.SysModel.IsTreeTable ? this.treeGridLeft : this.gridLeft;
|
|
this.InitlizeSpiltLocation();
|
|
this.SetLeftGridView();
|
|
this.ModuleGridObj.SaveEvent += new Lskj.Control.ModuleGridEx.SaveEventHander(SetDetailGridView);
|
|
|
|
if (this.SysModel.LeftGridIsCheck == 1 && !this.SysModel.IsTreeTable)
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.gridLeft.GridView);
|
|
}
|
|
if (Model.HasOperPrivilege() && model.IsBaseModule && !this.SysModel.IsTreeTable)
|
|
{
|
|
// 有权限则允许拖拽
|
|
GridDragGrid dragGrid = new GridDragGrid(this.ModuleGridObj.GridControlObj.GridView, this.gridLeft.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
//配置了拖拽条件后,在点击时判断条件
|
|
dragGrid.DragConditions = this.SysModel.DragConditions;
|
|
}
|
|
|
|
break;
|
|
case 3: // 左侧为空
|
|
default:
|
|
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
break;
|
|
}
|
|
if (this.IsExcel)
|
|
{
|
|
//由于创建对象时候要注册,所以动态构造这控件不在设计器进行否则表格模式也会弹出注册
|
|
this.ModuleGridDetailObj.Visible = false;
|
|
this.repModelDetailEx.Visible = false;
|
|
this.excelControlEx1.Visible = true;
|
|
if (!Model.DataCaches.GetValue(this, "BasePrimaryKey", out SysModel.ParmaryKey))
|
|
{
|
|
SysModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
}
|
|
this.excelControlEx1.AddEnabled = this.SysModel.AddEnable;
|
|
this.excelControlEx1.DeleteEnabled = this.SysModel.DeleteEnable;
|
|
this.excelControlEx1.PrintEnabled = !string.IsNullOrWhiteSpace(this.SysModel.PrintFile);
|
|
this.excelControlEx1.SaveEnabled = this.SysModel.ModifyEnable;
|
|
this.excelControlEx1.CreateFile();
|
|
this.excelControlEx1.SaveCallBack += new EventHandler(OnExcelSaveClick);
|
|
if (!Model.DataCaches.GetValue(this, "BaseGridColumns", out DataTable dtGridColumns))
|
|
{
|
|
dtGridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);
|
|
}
|
|
DataRow rowItem = dtGridColumns.Select(string.Format("fieldsqlTag={0}", (int)ControlType.LabPic)).FirstOrDefault();
|
|
if (rowItem != null)
|
|
{
|
|
this._labPicName = rowItem["fieldname"] + "";
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotConfigPic);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
this.excelControlEx1.Visible = false;
|
|
if (SysModel.isReplacMainDetail == "1")
|
|
{
|
|
this.ModuleGridDetailObj.Visible = false;
|
|
this.repModelDetailEx.IsDragDetail = this.IsDragDetail;// 是否为拖拽明细模式
|
|
this.repModelDetailEx.GridDetailList = this.Details;// 底部多标签表格数据
|
|
this.repModelDetailEx._leftGridSearchObj = this._leftGridSearchObj;// 左边查询条件
|
|
this.repModelDetailEx.InitializeControl(this.SysModel, this.Model);//初始化控件
|
|
}
|
|
else
|
|
{
|
|
this.repModelDetailEx.Visible = false;
|
|
this.ModuleGridDetailObj.IsDragDetail = this.IsDragDetail;// 是否为拖拽明细模式
|
|
this.ModuleGridDetailObj.GridDetailList = this.Details;// 底部多标签表格数据
|
|
this.ModuleGridDetailObj._leftGridSearchObj = this._leftGridSearchObj;// 左边查询条件
|
|
this.ModuleGridDetailObj.InitializeControl(this.SysModel, this.Model);//初始化控件
|
|
|
|
if (this.SysModel.MenuType == 5 || this.SysModel.MenuType == 4)
|
|
{
|
|
|
|
this.pl_left_main.Parent = pl_right;
|
|
this.ModuleGridDetailObj.Parent = pl_left;
|
|
}
|
|
//多表头向左侧表拖动数据
|
|
if (Model.HasOperPrivilege() && model.IsBaseModule && !this.SysModel.IsTreeTable && this.ModuleGridObj.GridControlObj.GridView is BandedGridView&&(this.SysModel.MenuType==2 || this.SysModel.MenuType==5))
|
|
{
|
|
// 有权限则允许拖拽
|
|
BandedGridDragGrid BandedDragGrid = new BandedGridDragGrid(this.ModuleGridObj.GridControlObj.GridView as BandedGridView, this.gridLeft.GridView);
|
|
BandedDragGrid.OnDragComplete += new BandedGridFragGridCompleteEventHandler(OnDragBandedGridCompleted);
|
|
}
|
|
}
|
|
|
|
}
|
|
this.ModuleGridObj.OnExportCallBack += new EventHandler(SetExportGridView);
|
|
this.InitializeTab();
|
|
bool isLoadGridSplit = false;
|
|
|
|
if (sysModel.DynamicPrompt)
|
|
{
|
|
this.ModuleGridObj.VisibleSearchPanel = false;
|
|
this.ModuleGridObj.scc_container.PanelVisibility = SplitPanelVisibility.Both;
|
|
this.ModuleGridObj.InitlizeSpiltLocation();
|
|
//代码的方式创建,直接拖的控件会提示线程问题
|
|
this.ModuleGridObj.TipsobjPanel.Controls.Clear();
|
|
this.ModuleGridObj.PromptBox = new LabelRichEdit();
|
|
this.ModuleGridObj.PromptBox.Dock = DockStyle.Fill;
|
|
this.ModuleGridObj.PromptBox.Padding = new Padding(3, 5, 0, 8);
|
|
this.ModuleGridObj.PromptBox.FontSize = this.SysModel.PromptFontSize;//ForceSize;
|
|
this.ModuleGridObj.PromptBox.LabelText = "";
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.PromptForceColor))
|
|
{
|
|
this.ModuleGridObj.PromptBox.TextEdit.ForeColor = ColorTranslator.FromHtml(this.SysModel.PromptForceColor);
|
|
}
|
|
// 重点:针对 TextEdit 绑定
|
|
this.ModuleGridObj.PromptBox.TextEdit.KeyDown += PromptBox_KeyDown;
|
|
//this.ModuleGridObj.PromptBox.TextEdit.ReadOnly = true;
|
|
if (string.IsNullOrWhiteSpace(this.ModuleGridObj.PromptBox.EditText)) this.ModuleGridObj.PromptBox.EditText = "请点击左侧查看备注信息!";
|
|
this.ModuleGridObj.TipsobjPanel.Controls.Add(this.ModuleGridObj.PromptBox);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.MenuCodeIsNotNull);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
//throw;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 当前模块直接保存操作
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void PromptBox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.S)
|
|
{
|
|
e.Handled = true; // 阻止控件继续处理
|
|
e.SuppressKeyPress = true; // 阻止dev功能
|
|
SaveRemark();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 保存编码
|
|
/// </summary>
|
|
private void SaveRemark()
|
|
{
|
|
RichEditControl labelRichEdit = this.ModuleGridObj.PromptBox.TextEdit;
|
|
DataRow dataRow = ModuleGridObj.LeftGridEx.GetViewFocusedDataRow();
|
|
|
|
if (dataRow != null && labelRichEdit != null)
|
|
{
|
|
string msg;
|
|
int ret = BaseModuleImpl.UpdateRemarkByModule(Model.ModuleCode, dataRow[this.ModuleGridObj.ParentKeyField] + "",
|
|
labelRichEdit.Text, out msg);
|
|
MessageUtil.Show(msg);
|
|
this.ModuleGridObj._leftGridSearchObj.SearchLastGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
/// <param name="dynamicModel"></param>
|
|
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
|
|
{
|
|
//获取通用数据
|
|
Task<ModuleModel> sysModelTask = cachesDic.GetTask<ModuleModel>(this, "SysModel");
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
|
Task<List<GridDetailModel>> detailsTask = cachesDic.GetTask<List<GridDetailModel>>(this, "Details");
|
|
Task<bool> getDataCachesTask = cachesDic.AddTask(this, "DataCaches", new Task<bool>(() =>
|
|
{
|
|
ModuleModel sysModel = sysModelTask.Result;
|
|
DynamicModel dynamicModel = dynamicModelTask.Result;
|
|
//创建数据
|
|
if (sysModel != null && dynamicModel != null)
|
|
{
|
|
Task<DataRow> menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task<DataRow>(() =>
|
|
{
|
|
return BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); //获取菜单其他配置
|
|
}));
|
|
switch (sysModel.MenuType)
|
|
{
|
|
case 1:
|
|
case 4://左侧为树节点
|
|
this.ModuleGridObj.LeftTreeViewEx = this.treeLeft;
|
|
Task<DataRow> baseLeftTreeFieldTask = cachesDic.AddTask(this, "BaseLeftTreeField", new Task<DataRow>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseLeftTreeField(dynamicModel.ModuleCode);//获取表格左侧树字段
|
|
}));
|
|
if (baseLeftTreeFieldTask.Result != null)
|
|
{
|
|
Task<DataTable> treeTableTask = cachesDic.AddTask(this, "TreeTable", new Task<DataTable>(() =>
|
|
{
|
|
return BaseImpl.GetDataTableResult(baseLeftTreeFieldTask.Result["fieldsql"] + "");
|
|
}));
|
|
}
|
|
else if (sysModel != null && !string.IsNullOrEmpty(sysModel.TreeSQL))
|
|
{
|
|
Task<DataTable> treeTableTask = cachesDic.AddTask(this, "TreeTable", new Task<DataTable>(() =>
|
|
{
|
|
return BaseImpl.GetDataTableResult(sysModelTask.Result.TreeSQL);
|
|
}));
|
|
}
|
|
else if (sysModelTask.Result.DefaultTreeSql)
|
|
{
|
|
Task<DataTable> treeTableTask = cachesDic.AddTask(this, "TreeTable", new Task<DataTable>(() =>
|
|
{
|
|
return BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0");
|
|
}));
|
|
}
|
|
break;
|
|
case 2:
|
|
case 5: // 左侧为表格
|
|
baseLeftTreeFieldTask = cachesDic.AddTask(this, "BaseLeftTreeField", new Task<DataRow>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseLeftTreeField(dynamicModel.ModuleCode);//获取表格左侧树字段
|
|
}));
|
|
if (baseLeftTreeFieldTask.Result != null)
|
|
{
|
|
Task<DataTable> baseLeftGridFieldTask = cachesDic.AddTask(this, "BaseLeftGridField", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseLeftGridField(dynamicModel.ModuleCode);
|
|
}));
|
|
Task<DataTable> baseGridRowColorsTask = cachesDic.AddTask(this, "BaseGridRowColors", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRowColors(baseLeftTreeFieldTask.Result["fieldKey"] + "");
|
|
}));
|
|
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(this, "BaseGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(baseLeftTreeFieldTask.Result["fieldKey"] + "");
|
|
}));
|
|
Task<DataTable> customQueryFieldsTask = cachesDic.AddTask(this, "CustomQueryFields", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetCustomQueryFields(baseLeftTreeFieldTask.Result["fieldKey"] + "");
|
|
}));
|
|
DataTable customQueryFieldsTab = customQueryFieldsTask.Result;
|
|
if (customQueryFieldsTab != null && customQueryFieldsTab.Rows.Count > 0)
|
|
{
|
|
Task<MyControl> leftGridSearchObjTask = cachesDic.AddTask(this, "LeftGridSearchObj", new Task<MyControl>(() =>
|
|
{
|
|
string searchSql = baseLeftTreeFieldTask.Result["fieldsql"] + "";
|
|
return new MyControl(searchSql, sysModel.IsTreeTable ? this.treeGridLeft as GridControlEx : this.gridLeft);
|
|
}));
|
|
ModuleGridDetailObj._leftGridSearchObj = leftGridSearchObjTask.Result;
|
|
}
|
|
else
|
|
{
|
|
if (!sysModelTask.Result.IsTreeTable)
|
|
{
|
|
Task<DataTable> leftGridCondtionTask = cachesDic.AddTask(this, "LeftGridCondtionTable", new Task<DataTable>(() =>
|
|
{
|
|
string searchSql = string.Empty;
|
|
if (dynamicModel is DynamicModuleModel)
|
|
{
|
|
searchSql = baseLeftTreeFieldTask.Result["fieldsql"] + " " + (dynamicModel as DynamicModuleModel).LeftCond;
|
|
}
|
|
else
|
|
{
|
|
searchSql = baseLeftTreeFieldTask.Result["fieldsql"] + " " + (dynamicModel as DynamicModuleDetailModel).LeftCond;
|
|
}
|
|
return BaseImpl.GetDataTableResult(searchSql);
|
|
}));
|
|
Task<DataTable> customColumnByDatabaseTask = cachesDic.AddTask(gridLeft, "CustomColumnByDatabase", new Task<DataTable>(() =>
|
|
{
|
|
string customColumKey = GridCustomColumnStruct.BaseLeftGridView + dynamicModel.ModuleCode;
|
|
return gridLeft.GridView.GetCustomColumnByDatabase(customColumKey);
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
Task<DataTable> customColumnByDatabaseTask = cachesDic.AddTask(treeGridLeft, "CustomColumnByDatabase", new Task<DataTable>(() =>
|
|
{
|
|
string customColumKey = GridCustomColumnStruct.BaseLeftGridView + dynamicModel.ModuleCode;
|
|
return treeGridLeft.GridView.GetCustomColumnByDatabase(customColumKey);
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
ModuleGridObj.LeftGridEx = sysModel.IsTreeTable ? this.treeGridLeft : this.gridLeft;
|
|
break;
|
|
}
|
|
if (dynamicModel is DynamicExcelModel)//isExcel
|
|
{
|
|
Task<string> basePrimaryKeyTask = cachesDic.AddTask(this, "BasePrimaryKey", new Task<string>(() =>
|
|
{
|
|
return BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
|
|
}));
|
|
Task<DataTable> gridColumnsTask = cachesDic.AddTask(this, "GridColumns", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridColumns(dynamicModel.ModuleCode);
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
if (sysModelTask.Result.isReplacMainDetail == "1")
|
|
{
|
|
cachesDic.AddTask(repModelDetailEx, "DynamicModel", dynamicModelTask);
|
|
cachesDic.AddTask(repModelDetailEx, "SysModel", sysModelTask);
|
|
cachesDic.AddTask(repModelDetailEx, "Details", detailsTask);
|
|
repModelDetailEx.GetDataCaches(cachesDic);//初始化控件
|
|
}
|
|
else
|
|
{
|
|
cachesDic.AddTask(ModuleGridDetailObj, "DynamicModel", dynamicModelTask);
|
|
cachesDic.AddTask(ModuleGridDetailObj, "SysModel", sysModelTask);
|
|
cachesDic.AddTask(ModuleGridDetailObj, "Details", detailsTask);
|
|
ModuleGridDetailObj.GetDataCaches(cachesDic);//初始化控件
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string width = IniHelper.Read(string.Format("base_width_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(width))
|
|
{
|
|
this.scc_container.SplitterPosition = Convert.ToInt32(width);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载主表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="where">The where key.</param>
|
|
protected void SetMainGridView(string where = "")
|
|
{
|
|
ModuleGridDetailEx moduleGridDetailEx = this.MainBodyTab.Visible ? (this.MainBodyTab.SelectedTabPage.Tag as ModuleGridDetailEx) : null;
|
|
string sqlValue = ReplaceHelper.ReplaceWhereCond(moduleGridDetailEx != null ? moduleGridDetailEx.SysModel.MenuSql : this.SysModel.MenuSql);
|
|
if (moduleGridDetailEx != null && moduleGridDetailEx.Tag is DataRow dataRow)
|
|
{
|
|
sqlValue += dataRow["unionCond"];
|
|
}
|
|
//sqlValue = this.SysModel.MenuSql.Trim().StartsWith("select", StringComparison.OrdinalIgnoreCase) ? sqlValue + where : sqlValue;
|
|
//判断是否是select开头,上方的判断可能出现开头是空格或者注释的情况
|
|
sqlValue = IsSelectAtStart(sqlValue) ? 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
|
|
{
|
|
// bool isLoadGridSplit = false;
|
|
// 左侧gridView时,需要替换sql参数(包含查询条件、表格选中行).
|
|
if (this.gridLeft.Visible)
|
|
{
|
|
DataRow rowitem = this.gridLeft.GridView.GetFocusedDataRow();
|
|
sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue;
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowitem, sqlValue);
|
|
//isLoadGridSplit = rowitem != null && rowitem.Table.Columns.Contains("ReminderInformation");
|
|
}
|
|
if (this.treeGridLeft.Visible)
|
|
{
|
|
DataRow rowitem = this.treeGridLeft.GetViewFocusedDataRow();
|
|
sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue;
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(this.treeGridLeft.GetViewFocusedDataRow(), sqlValue);
|
|
//isLoadGridSplit = rowitem != null && rowitem.Table.Columns.Contains("ReminderInformation");
|
|
}
|
|
|
|
|
|
//if (isLoadGridSplit)
|
|
//{
|
|
// this.ModuleGridObj.VisibleSearchPanel = false;
|
|
// this.ModuleGridObj.scc_container.PanelVisibility = SplitPanelVisibility.Both;
|
|
// this.ModuleGridObj.InitlizeSpiltLocation();
|
|
//}
|
|
this.ModuleGridObj.SearchObj.SearchGrid(sqlValue);
|
|
if (!this.IsDragDetail)
|
|
{
|
|
bool enter = false;
|
|
|
|
try
|
|
{
|
|
if (this.ModuleGridObj != null)
|
|
{
|
|
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
if (this.ModuleGridObj.GridControlObj.CustomGroupSelectedRow != null)
|
|
{
|
|
rowItem = this.ModuleGridObj.GridControlObj.CustomGroupSelectedRow;
|
|
}
|
|
if (rowItem != null&& !this.SysModel.DoubleClickDetail) enter = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
//enter判断 2026-7-24 添加 因为主表有行改版后事件,主表赋值后会刷新一次,这里是重复刷新(方法里有判断,主表有值执行的逻辑是相同的)
|
|
//如果是主表有数据,并且绑定了行改变事件,就执行了(重复执行)
|
|
//如果主表没有数据,就执行(清空明细) 或者绑定的是双击加载明细事件也执行(节点改变后刷新主表,顺便刷新明细)
|
|
if (!enter)
|
|
{
|
|
this.ModuleGridDetailObj.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
|
|
if (this.treeGridLeft.Visible && ModuleGridDetailObj.GridDetailList != null && ModuleGridDetailObj.GridDetailList.Count > 0)
|
|
{
|
|
this.ModuleGridDetailObj.scc_container.PanelVisibility = this.ModuleGridObj.GridControlObj.DataRowCount() == 0 ? SplitPanelVisibility.Panel1 : SplitPanelVisibility.Both;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置多标签数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetDetailGridView(string where = "")
|
|
{
|
|
try
|
|
{
|
|
if (!this.SysModel.IsTreeTable)
|
|
{
|
|
this.ModuleGridDetailObj.SetDetailGridDataSource(where, this.SysModel.MenuType == 1, this.treeLeft, this.gridLeft);
|
|
}
|
|
else
|
|
{
|
|
this.ModuleGridDetailObj.SetDetailGridDataSource(where, this.SysModel.MenuType == 1, this.treeLeft, this.treeGridLeft);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
//单击导入全部
|
|
protected void SetExportGridView(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridControl MainTableControl = this.ModuleGridDetailObj.ModuleGridObj.GridControlObj.gridControl;
|
|
bool ifTheExport = MainTableControl.AllToExcel(SysModel.MenuText + ".主表", true);
|
|
if (!ifTheExport) return;
|
|
XtraTabControl tabControl = this.ModuleGridDetailObj.TabObj;
|
|
foreach (XtraTabPage page in tabControl.TabPages)
|
|
{
|
|
|
|
if (page.Tag is GridControlEx)
|
|
{
|
|
GridControl detailControl = (page.Tag as GridControlEx).gridControl;
|
|
GridDetailModel model = this.ModuleGridDetailObj.TcButtom.GetGridDetailModel(page);
|
|
detailControl.AllToExcel(SysModel.MenuText + "." + model.DetailName, false);
|
|
}
|
|
|
|
}
|
|
GridControl leftControl = this.LeftGridViewObj.gridControl;
|
|
DataTable leftControlTable = this.LeftGridViewObj.gridControl.DataSourceTable().Copy();
|
|
if (leftControlTable.Columns.Count != 0)
|
|
{
|
|
leftControl.AllToExcel(SysModel.MenuText + ".左侧", false);
|
|
}
|
|
|
|
|
|
|
|
MessageUtil.Show(ResourceKeys.ExportSuccess);
|
|
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
//修改,删除表格列名
|
|
protected DataTable RemoveHiddenColumns(GridControlEx gx, DataTable dt)
|
|
{
|
|
List<string> columnName = new List<string>();//删除的列名
|
|
|
|
foreach (DataColumn col in dt.Columns)
|
|
{
|
|
GridColumn GridCol = gx.GridView.Columns.Cast<GridColumn>().FirstOrDefault(x => col.ColumnName == x.FieldName);
|
|
if (GridCol != null)
|
|
{
|
|
dt.Columns[col.ColumnName].ColumnName = GridCol.Caption;//修改列名
|
|
}
|
|
else
|
|
{
|
|
columnName.Add(col.ColumnName);
|
|
}
|
|
}
|
|
for (int i = 0; i < columnName.Count; i++)
|
|
{
|
|
dt.Columns.Remove(columnName[i]);//把隐藏的列删除
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置左侧树数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftTreeView()
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
if (!dataCaches.GetValue(this, "BaseLeftTreeField", out this.LeftRowObj))
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.Model.ModuleCode);//获取表格左侧树字段
|
|
}
|
|
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
this.treeLeft.TreeNodeKeyField = this.ModuleGridObj.ParentKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
this.treeLeft.TreeNodeTextField = this.LeftRowObj["fieldsqlname"] + "";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeft.TreeNodeLength = this.LeftRowObj.Table.Columns.Contains("TreeNodeLength") ? this.LeftRowObj["TreeNodeLength"] + "" : "";
|
|
if (!dataCaches.GetValue(this, "TreeTable", out DataTable treeTable))
|
|
{
|
|
treeTable = BaseImpl.GetDataTableResult(this.LeftRowObj["fieldsql"] + "");
|
|
}
|
|
this.treeLeft.BindTreeView(treeTable);
|
|
if (this.LeftRowObj.Table.Columns.Contains("TreeNodeSearch") && "1".Equals(this.LeftRowObj["TreeNodeSearch"] + "")) this.treeLeft.pl_top.Visible = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
// 根据模块上配置的sql加载树
|
|
if (this.SysModel != null && !string.IsNullOrEmpty(this.SysModel.TreeSQL))
|
|
{
|
|
this.ModuleGridObj.ParentUnionField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeKeyField = this.ModuleGridObj.ParentKeyField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
if (!dataCaches.GetValue(this, "TreeTable", out DataTable treeTable))
|
|
{
|
|
treeTable = BaseImpl.GetDataTableResult(this.SysModel.TreeSQL);
|
|
}
|
|
this.treeLeft.BindTreeView(treeTable);
|
|
}
|
|
else if (this.SysModel.DefaultTreeSql)
|
|
{
|
|
this.ModuleGridObj.ParentUnionField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeKeyField = this.ModuleGridObj.ParentKeyField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
if (!dataCaches.GetValue(this, "TreeTable", out DataTable treeTable))
|
|
{
|
|
treeTable = BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0");
|
|
}
|
|
this.treeLeft.BindTreeView(treeTable);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置左侧表格查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftGridCondtion()
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
if (!dataCaches.GetValue(this, "CustomQueryFields", out DataTable table))
|
|
{
|
|
table = BaseModuleImpl.GetCustomQueryFields(this.LeftRowObj["fieldKey"] + "");
|
|
}
|
|
string searchSql = this.LeftRowObj["fieldsql"] + " " + LeftCond;
|
|
if (table != null && table.Rows.Count > 0)
|
|
{
|
|
// 自定义查询条件
|
|
if (!dataCaches.GetValue(this, "LeftGridSearchObj", out this._leftGridSearchObj))
|
|
{
|
|
this._leftGridSearchObj = new MyControl(searchSql, this.SysModel.IsTreeTable ? this.treeGridLeft as GridControlEx : this.gridLeft);
|
|
}
|
|
this._leftGridSearchObj.OtherParams = Model.OtherParams();
|
|
this.pl_left_top.Height = this._leftGridSearchObj.InitSearchControl(table, this.pl_left_top);
|
|
this._leftGridSearchObj.OnDataSourceBindCallBack += new EventHandler(OnLeftControlObjDataSourceBindCallBack);
|
|
}
|
|
else
|
|
{
|
|
if (!dataCaches.GetValue(this, "LeftGridCondtionTable", out DataTable leftGridCondtionTable))
|
|
{
|
|
leftGridCondtionTable = BaseImpl.GetDataTableResult(searchSql);
|
|
}
|
|
if (!this.SysModel.IsTreeTable)
|
|
{
|
|
this.pl_left_top.Visible = false;
|
|
this.gridLeft.GridControl.DataSource = leftGridCondtionTable;
|
|
}
|
|
else
|
|
{
|
|
this.treeGridLeft.TreeListObj.DataSource = leftGridCondtionTable;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置左侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftGridView()
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
if (!dataCaches.GetValue(this, "BaseLeftTreeField", out this.LeftRowObj))
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.Model.ModuleCode);//获取表格左侧树字段
|
|
}
|
|
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
this.ModuleGridObj.ParentKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
//this.ModuleGridObj.LeftGridEx = this.gridLeft;
|
|
this.ModuleGridObj.LeftGridEx = this.SysModel.IsTreeTable ? this.treeGridLeft : this.gridLeft;
|
|
this.ModuleGridObj.ParentGridEx = this.SysModel.IsTreeTable ? this.treeGridLeft : this.gridLeft; // 方便右侧添加数据自动带出相同字段值
|
|
|
|
if (!dataCaches.GetValue(this, "BaseLeftGridField", out DataTable dtTable))
|
|
{
|
|
dtTable = BaseModuleImpl.GetBaseLeftGridField(this.Model.ModuleCode);
|
|
}
|
|
if (!dataCaches.GetValue(this, "BaseGridRowColors", out DataTable dtColorTable))
|
|
{
|
|
dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + "");
|
|
}
|
|
if (!dataCaches.GetValue(this, "BaseGridRightMenus", out DataTable dtRightTable))
|
|
{
|
|
dtRightTable = BaseModuleImpl.GetBaseGridRightMenus(this.LeftRowObj["fieldKey"] + "");
|
|
}
|
|
|
|
|
|
if (!this.SysModel.IsTreeTable)
|
|
{
|
|
this.gridLeft.Model = Model;
|
|
this.gridLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick);
|
|
this.gridLeft.SetGridRightMenus(dtRightTable, this.Model, OnGridViewRightCallBack, this._leftGridSearchObj);
|
|
this.gridLeft.SetGridRowColors(dtColorTable);
|
|
this.gridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + this.Model.ModuleCode);
|
|
}
|
|
else
|
|
{
|
|
this.treeGridLeft.Model = Model;
|
|
this.treeGridLeft.TreeListObj.Click += TreeListObj_Click;
|
|
this.treeGridLeft.TreeListObj.BeforeExpand += TreeListObj_BeforeExpand;
|
|
this.treeGridLeft.TreeListObj.BeforeCollapse += TreeListObj_BeforeCollapse;
|
|
|
|
//节点改变前,改变后事件。无法处理重新点击当前节点时 刷新右侧主表时验证是否有未保存数据 的情况。所以还是使用点击事件判断。
|
|
//this.treeGridLeft.TreeListObj.BeforeFocusNode += TreeListObj_BeforeFocusNode;
|
|
//this.treeGridLeft.TreeListObj.FocusedNodeChanged += TreeListObj_FocusedNodeChanged;
|
|
|
|
this.treeGridLeft.SetGridRightMenus(dtRightTable, this.Model, OnGridViewRightCallBack, this._leftGridSearchObj, this.treeGridLeft.MenuStrip);
|
|
this.treeGridLeft.SetGridRowColors(dtColorTable);
|
|
this.treeGridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + this.Model.ModuleCode);
|
|
//主键字段名称
|
|
this.treeGridLeft.TreeListObj.KeyFieldName = this.LeftRowObj["fieldsqlid"] + "";
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.LeftTreeKeyFieldName)) this.treeGridLeft.TreeListObj.KeyFieldName = this.SysModel.LeftTreeKeyFieldName;
|
|
//父级字段名称
|
|
this.treeGridLeft.TreeListObj.ParentFieldName = "Pid";
|
|
|
|
|
|
}
|
|
|
|
|
|
this.SetLeftGridCondtion();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:拼接右边数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sqlValue">The SQL value.</param>
|
|
/// <returns>System.String.</returns>
|
|
protected string ReplaceLeftOrGridValue(string sqlValue)
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(sqlValue)) return sqlValue;
|
|
// 替换左侧树结构
|
|
if (treeLeft != null && treeLeft.Visible)
|
|
{
|
|
TreeNode tn = treeLeft.TreeView.SelectedNode;
|
|
if (tn == null)
|
|
tn = treeLeft.TreeView.Nodes[0];
|
|
|
|
string ids = treeLeft.GetCheckValues();
|
|
if (!sqlValue.ToUpper().Contains("EXEC"))
|
|
{
|
|
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
if (!string.IsNullOrWhiteSpace(ids))
|
|
{
|
|
sqlValue += " and " + this.ModuleGridObj.ParentUnionField + " in (" + ids.Trim(',') + ")";
|
|
}
|
|
else
|
|
{
|
|
sqlValue += treeLeft.TreeView.Focused ? " and " + this.ModuleGridObj.ParentUnionField + " like '" + tn.Name + "%'" : "";
|
|
}
|
|
}
|
|
sqlValue = ReplaceHelper.ReplaceTreeViewParentKeyCond(sqlValue, ids);
|
|
}
|
|
// 替换左侧表格
|
|
if (gridLeft != null && gridLeft.Visible)
|
|
{
|
|
GridView gridview = gridLeft.GridControl.DefaultView as GridView;
|
|
DataRow rowItem = gridview.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
if (!sqlValue.ToLower().StartsWith("exec"))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
sqlValue += " and " + this.ModuleGridObj.ParentUnionField + "='" + rowItem[this.ModuleGridObj.ParentKeyField] + "'";
|
|
}
|
|
}
|
|
}
|
|
if (treeGridLeft != null && treeGridLeft.Visible)
|
|
{
|
|
GridView gridview = treeGridLeft.GridControl.DefaultView as GridView;
|
|
DataRow rowItem = gridview.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
if (!sqlValue.ToLower().StartsWith("exec"))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
sqlValue += " and " + this.ModuleGridObj.ParentUnionField + "='" + rowItem[this.ModuleGridObj.ParentKeyField] + "'";
|
|
}
|
|
}
|
|
}
|
|
return sqlValue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:数据绑定完成后加载数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnLeftControlObjDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this._leftGridSearchObj.SearchGrid();
|
|
|
|
if (this.SysModel.DefaultClickLeft)
|
|
{
|
|
this.OnGridViewRowClick(null, null);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:刷新右侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="DevExpress.Data.SelectionChangedEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string where = string.Empty;
|
|
if (e != null && e.HitInfo.Column != null && e.HitInfo.Column.Tag is GridColumnModel)
|
|
{
|
|
GridColumnModel gridColumnModel = e.HitInfo.Column.Tag as GridColumnModel;
|
|
where = gridColumnModel.SelectionConditions;
|
|
}
|
|
|
|
if (this.SysModel.DynamicMain && e != null)// e != null就是点击行触发,右键触发此方法不更新主表列
|
|
{
|
|
DataRow dataRow = this.gridLeft.GetViewFocusedDataRow();
|
|
if (dataRow != null && dataRow.Table.Columns.Contains("DisplayColumns"))
|
|
{
|
|
this.ModuleGridObj.GridControlObj.SetDisplayColumns(dataRow["DisplayColumns"] + "");
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.DynamicColumnNameSql) && e != null)
|
|
{
|
|
DataRow dataRow = this.gridLeft.GetViewFocusedDataRow();
|
|
string sql = ReplaceHelper.ReplaceRowParam(dataRow, this.SysModel.DynamicColumnNameSql);
|
|
DataRow row = BaseImpl.GetDataRowResult(sql);
|
|
if (row != null) this.ModuleGridObj.GridControlObj.SetColumnName(row);
|
|
}
|
|
if (this.SysModel.DynamicPrompt && e != null)
|
|
{
|
|
DataRow dataRow = this.gridLeft.GetViewFocusedDataRow();
|
|
if (dataRow != null && dataRow.Table.Columns.Contains("ReminderInformation"))
|
|
{
|
|
this.ModuleGridObj.SetDisplayColumns(dataRow["ReminderInformation"] + "");
|
|
}
|
|
}
|
|
|
|
if (this.SysModel.LeftUnioCond && e != null)
|
|
{
|
|
DataRow dr = this.gridLeft.GetViewFocusedDataRow();
|
|
foreach (ControlModel item in this.ModuleGridObj.SearchObj.ControlModels)
|
|
{
|
|
if (dr.Table.Columns.Contains(item.FieldName))
|
|
{
|
|
this.ModuleGridObj.SearchObj.SetControlValue(item, dr[item.FieldName] + "");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (this.SysModel.IgnoreMainload)
|
|
{
|
|
// 只加载明细
|
|
this.ModuleGridDetailObj.SetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
// 加载主表
|
|
this.SetMainGridView(where);
|
|
}
|
|
|
|
if (this.IsDragDetail)
|
|
this.SetDetailGridView();
|
|
|
|
if (this.OnLeftGridViewRowClickCallBack != null)
|
|
this.OnLeftGridViewRowClickCallBack(this.SysModel.IsTreeTable ? this.treeGridLeft as GridControlEx : this.gridLeft, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 树表格节点收起前
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeListObj_BeforeCollapse(object sender, DevExpress.XtraTreeList.BeforeCollapseEventArgs e)
|
|
{
|
|
RefreshDisable = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 树表格节点展开前
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeListObj_BeforeExpand(object sender, DevExpress.XtraTreeList.BeforeExpandEventArgs e)
|
|
{
|
|
RefreshDisable = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 树表格选中刷新主表
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeListObj_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (RefreshDisable)
|
|
{
|
|
RefreshDisable = false;
|
|
return;
|
|
}
|
|
//验证主表是否有未保存数据
|
|
if (this.SysModel.VerifyRowStatus || this.SysModel.SaveWhenSwitching)
|
|
{
|
|
//右侧主表中是修改或者新增状态的行
|
|
DataTable dataTable = ModuleGridObj.GridControlObj.gridControl.DataSourceTable().GetChanges();
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
{
|
|
|
|
if (this.SysModel.SaveWhenSwitching)
|
|
{
|
|
//优先判断是否保存
|
|
DialogResult dialogResult = MessageUtil.Show(("数据未保存,是否保存?"), MessageBoxButtons.YesNo);
|
|
if (dialogResult == DialogResult.Yes)
|
|
{
|
|
//当前的节点
|
|
//TreeListNode currentNode = this.treeGridLeft.TreeListObj.FocusedNode;
|
|
int lastNodeIndex = this.treeGridLeft.TreeListObj.GetVisibleIndexByNode(this.treeGridLeft.TreeListObj.FocusedNode);
|
|
try
|
|
{
|
|
//设置上一次选中节点,没有保存的节点就默认选中第一个
|
|
this.treeGridLeft.TreeListObj.FocusedNode = treeListNode != null ? treeListNode : this.treeGridLeft.TreeListObj.Nodes[0];
|
|
//保存右侧主表
|
|
this.ModuleGridObj.SaveWhenSwitching();
|
|
//恢复点击节点
|
|
//this.treeGridLeft.TreeListObj.FocusedNode = currentNode;
|
|
this.treeGridLeft.TreeListObj.FocusedNode = this.treeGridLeft.TreeListObj.GetNodeByVisibleIndex(lastNodeIndex);
|
|
RefreshDisable = false;
|
|
}
|
|
catch (Exception ee)
|
|
{
|
|
//保存失败,不跳转点击节点,避免数据被刷新
|
|
string Message = ErrorMessage.PromptErrorMessage(ee);
|
|
MessageUtil.Show(Message, ee.Message);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else if (this.SysModel.VerifyRowStatus)
|
|
{
|
|
//提示有数据不保存,但不自动保存
|
|
DialogResult result = MessageUtil.Show(("数据未保存,是否离开此界面?"), MessageBoxButtons.YesNo);
|
|
if (result == DialogResult.No)
|
|
{
|
|
//设置上一次选中节点,没有保存的节点就默认选中第一个
|
|
this.treeGridLeft.TreeListObj.FocusedNode = treeListNode != null ? treeListNode : this.treeGridLeft.TreeListObj.Nodes[0];
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
treeListNode = this.treeGridLeft.TreeListObj.FocusedNode;
|
|
|
|
if (this.SysModel.DynamicMain)
|
|
{
|
|
DataRow dataRow = this.treeGridLeft.GetViewFocusedDataRow();
|
|
if (dataRow != null && dataRow.Table.Columns.Contains("DisplayColumns"))
|
|
{
|
|
this.ModuleGridObj.GridControlObj.SetDisplayColumns(dataRow["DisplayColumns"] + "");
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.DynamicColumnNameSql))
|
|
{
|
|
DataRow dataRow = this.treeGridLeft.GetViewFocusedDataRow();
|
|
string sql = ReplaceHelper.ReplaceRowParam(dataRow, this.SysModel.DynamicColumnNameSql);
|
|
DataRow row = BaseImpl.GetDataRowResult(sql);
|
|
if (row != null) this.ModuleGridObj.GridControlObj.SetColumnName(row);
|
|
}
|
|
if (this.SysModel.DynamicPrompt)
|
|
{
|
|
DataRow dataRow = this.treeGridLeft.GetViewFocusedDataRow();
|
|
if (dataRow != null && dataRow.Table.Columns.Contains("ReminderInformation"))
|
|
{
|
|
this.ModuleGridObj.SetDisplayColumns(dataRow["ReminderInformation"] + "");
|
|
}
|
|
}
|
|
if (this.SysModel.LeftUnioCond )
|
|
{
|
|
DataRow dr = this.treeGridLeft.GetViewFocusedDataRow();
|
|
foreach (ControlModel item in this.ModuleGridObj.SearchObj.ControlModels)
|
|
{
|
|
if (dr.Table.Columns.Contains(item.FieldName))
|
|
{
|
|
this.ModuleGridObj.SearchObj.SetControlValue(item, dr[item.FieldName] + "");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
this.SetMainGridView();
|
|
if (this.IsDragDetail)
|
|
this.SetDetailGridView();
|
|
|
|
if (this.OnLeftGridViewRowClickCallBack != null)
|
|
this.OnLeftGridViewRowClickCallBack(this.SysModel.IsTreeTable ? this.treeGridLeft as GridControlEx : this.gridLeft, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._leftGridSearchObj != null)
|
|
{
|
|
this._leftGridSearchObj.SearchLastGrid();
|
|
}
|
|
else
|
|
{
|
|
string searchSql = this.LeftRowObj["fieldsql"] + " " + LeftCond;
|
|
|
|
if (this.SysModel.IsTreeTable)
|
|
{
|
|
this.treeGridLeft.GridControl.DataSource = BaseImpl.GetDataTableResult(searchSql);
|
|
}
|
|
else
|
|
{
|
|
this.gridLeft.GridControl.DataSource = BaseImpl.GetDataTableResult(searchSql);
|
|
}
|
|
}
|
|
this.OnGridViewRowClick(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnSplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.Model != null)
|
|
{
|
|
IniHelper.Write(string.Format("base_width_{0}", this.Model.ModuleCode), this.scc_container.SplitterPosition + "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:表格拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </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 (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
|
|
{
|
|
string dragCond = ReplaceHelper.ReplaceRowParam(e.SelectGridRow, this.SysModel.DragCond);
|
|
int successCount = 0, faultCount = 0;
|
|
string ErrorMessage = string.Empty;
|
|
if (SystemInfo.Instance.ModuleSpecialDrag) fieldName = this.LeftRowObj["fieldName"] + "";
|
|
string LeftName = e.SelectGridRow.Table.Columns[0].ColumnName;
|
|
foreach (DataRow item in e.GridViewSelectRows)
|
|
{
|
|
try
|
|
{
|
|
bool needUpdate = ReplaceHelper.ReplaceRowParamCond(item, dragCond);
|
|
int result = 0;
|
|
if (SystemInfo.Instance.ModuleSpecialDrag)
|
|
{
|
|
//2026-4-3 赵坤要求按照他的这个逻辑写
|
|
// update {模块表名} set {树型结点关联的字段名}='{左边第一个字段(工具里第一个)}' where {主表主键}='{主表主键值}'
|
|
|
|
result = needUpdate
|
|
? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable,
|
|
fieldName,
|
|
e.SelectGridRow[LeftName] + "",
|
|
this.ModuleGridObj.ParmaryKey,
|
|
item[this.ModuleGridObj.ParmaryKey] + "")
|
|
: 0;
|
|
}
|
|
else
|
|
{
|
|
// update {模块表名} set {fieldName}='{左侧选中行中的fieldName}' where {主表主键}='{主表主键值}'
|
|
result = needUpdate
|
|
? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable,
|
|
fieldName,
|
|
e.SelectGridRow[fieldName] + "",
|
|
this.ModuleGridObj.ParmaryKey,
|
|
item[this.ModuleGridObj.ParmaryKey] + "")
|
|
: 0;
|
|
}
|
|
|
|
|
|
if (result == 1)
|
|
{
|
|
successCount++;
|
|
string log = string.Empty;
|
|
if (SystemInfo.Instance.ModuleSpecialDrag)
|
|
{
|
|
log = $"{this.SysModel.MenuTable}表{this.ModuleGridObj.ParmaryKey}='{item[this.ModuleGridObj.ParmaryKey]}' 的 {fieldName} 修改为 {e.SelectGridRow[LeftName]}";
|
|
}
|
|
else
|
|
{
|
|
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);
|
|
ErrorMessage += ex1.InnerException.Message + "\r\n";
|
|
}
|
|
}
|
|
|
|
string tip = "";
|
|
if (successCount > 0) tip = string.Format(ResourceKeys.DragSuccessCount, successCount);
|
|
if (faultCount > 0) tip += (tip == "" ? "" : "\r\n") +
|
|
string.Format(ResourceKeys.DragFaultCount, faultCount);
|
|
if (!string.IsNullOrWhiteSpace(ErrorMessage)) tip = tip + "\r\n" + ErrorMessage.TrimEnd('\r', '\n');
|
|
|
|
MessageUtil.Show(tip);
|
|
SearchObj.SearchLastGrid();
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
LogHelper.Instance.WriteError(ex2);
|
|
MessageUtil.Show(ErrorMessage.PromptErrorMessage(ex2), ex2.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:多表头表格拖拽完成</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
private void OnDragBandedGridCompleted(object sender, BandedGridDragGridArgs 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"] + "";
|
|
|
|
for (int i = 0; i < e.GridViewSelectRows.Length; i++)
|
|
{
|
|
DataRow item = e.GridViewSelectRows[i];
|
|
try
|
|
{
|
|
records[i] = ReplaceHelper.ReplaceRowParamCond(item, this.SysModel.DragCond)
|
|
? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectGridRow[fieldName] + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
|
|
: 0;
|
|
}
|
|
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>
|
|
/// <para>说明:树拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnDragTreeCompleted(object sender, GridDragTreeArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridView gridView = this.ModuleGridObj.GridControlObj.GridView;
|
|
int[] selectRows = gridView.GetSelectedRows();
|
|
if (selectRows == null || selectRows.Length == 0 || e.SelectTreeNode == null) return;
|
|
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.DragSelectNode, e.SelectTreeNode.Text), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
int[] records = new int[selectRows.Length];
|
|
string fieldName = this.LeftRowObj["fieldName"] + "";
|
|
|
|
for (int i = 0; i < selectRows.Length; i++)
|
|
{
|
|
DataRow item = gridView.GetDataRow(selectRows[i]);
|
|
try
|
|
{
|
|
//records[i] = ReplaceHelper.ReplaceRowParamCond(item, this.SysModel.DragCond)
|
|
// ? BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectTreeNode.Tag + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
|
|
// : 0;
|
|
records[i] = ReplaceHelper.ReplaceRowParamCond(item, this.SysModel.DragCond)
|
|
? BaseModuleImpl.newUpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectTreeNode.Tag + "", this.ModuleGridObj.ParmaryKey, item[this.ModuleGridObj.ParmaryKey] + "")
|
|
: 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ResourceKeys.OperFault + ex.Message);
|
|
}
|
|
}
|
|
|
|
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} = '{1}' ", fieldName, this.treeLeft.GetSelectValue()));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:树节点点击后刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="TreeViewEventArgs"/> instance containing the event data.</param>
|
|
protected void OnTreeLeftTreeNodeSelected(object sender, TreeViewEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string where = null;
|
|
if (string.IsNullOrWhiteSpace(this.ModuleGridObj.ParentUnionField))
|
|
{
|
|
where = string.Format(this.SysModel.TreeExactQuery ? " and {0} = '{1}' " : " and {0} like '{1}%' ", this.treeLeft.TreeNodeKeyField, e.Node.Name);
|
|
}
|
|
else
|
|
{
|
|
where = string.Format(this.SysModel.TreeExactQuery ? " and {0} = '{1}' " : " and {0} like '{1}%' ", this.ModuleGridObj.ParentUnionField, e.Node.Name);
|
|
}
|
|
if (this.SysModel.DynamicMain)
|
|
{
|
|
DataRow[] dataRows = this.treeLeft.DataSource.Select(this.treeLeft.TreeNodeKeyField + "='" + e.Node.Name + "'");
|
|
if (dataRows != null && dataRows[0].Table.Columns.Contains("DisplayColumns"))
|
|
{
|
|
this.ModuleGridObj.GridControlObj.SetDisplayColumns(dataRows[0]["DisplayColumns"] + "");
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.DynamicColumnNameSql))
|
|
{
|
|
DataRow[] dataRows = this.treeLeft.DataSource.Select(this.treeLeft.TreeNodeKeyField + "='" + e.Node.Name + "'");
|
|
DataRow dataRow = dataRows.Length > 0 ? dataRows[0] : null;
|
|
string sql = ReplaceHelper.ReplaceRowParam(dataRow, this.SysModel.DynamicColumnNameSql);
|
|
DataRow row = BaseImpl.GetDataRowResult(sql);
|
|
if (row != null) this.ModuleGridObj.GridControlObj.SetColumnName(row);
|
|
}
|
|
if (this.SysModel.DynamicPrompt && e != null)
|
|
{
|
|
DataRow[] dataRows = this.treeLeft.DataSource.Select(this.treeLeft.TreeNodeKeyField + "='" + e.Node.Name + "'");
|
|
if (dataRows != null && dataRows[0].Table.Columns.Contains("ReminderInformation"))
|
|
{
|
|
this.ModuleGridObj.SetDisplayColumns(dataRows[0]["ReminderInformation"] + "");
|
|
}
|
|
}
|
|
|
|
this.SetMainGridView(where);
|
|
if (this.IsDragDetail)
|
|
this.SetDetailGridView(where);
|
|
|
|
if (this.OnLeftTreeViewRowClickCallBack != null)
|
|
this.OnLeftTreeViewRowClickCallBack(treeLeft, e);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 树节点双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeLeft_OnTreeNodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
//判断是否为弹出框(lskj。pubadd模块)
|
|
if (this.SysModel.MenuAddName.IndexOf("lskj.pubadd", StringComparison.OrdinalIgnoreCase) >= 0)
|
|
{
|
|
this.ModuleGridObj.ExternallyTriggeredAdd();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 树节点刷新
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void TreeNodeRefresh(object sender, EventArgs e)
|
|
{
|
|
//TreeNode node = this.treeLeft.TreeView.SelectedNode;
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.LeftRowObj["fieldsql"] + ""));
|
|
}
|
|
else
|
|
{
|
|
// 根据模块上配置的sql加载树
|
|
if (this.SysModel != null && !string.IsNullOrEmpty(this.SysModel.TreeSQL))
|
|
{
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.SysModel.TreeSQL));
|
|
}
|
|
else if (this.SysModel.DefaultTreeSql)
|
|
{
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult("select a.SpeciesNo,a.SpeciesName from p_productspeciestab a where a.ban=0"));
|
|
}
|
|
}
|
|
// 选中第一个节点并刷新右侧数据
|
|
//if (this.treeLeft.TreeView.Nodes.Count > 0)
|
|
//{
|
|
// this.treeLeft.TreeView.SelectedNode = this.treeLeft.TreeView.Nodes[0];
|
|
// TreeViewEventArgs viewEventArgs = new TreeViewEventArgs(this.treeLeft.TreeView.SelectedNode, TreeViewAction.ByMouse);
|
|
// this.OnTreeLeftTreeNodeSelected(null, viewEventArgs);
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
protected void OnExcelSaveClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._currentRow == null) return;
|
|
using (FileStream fs = new FileStream(this.excelControlEx1.CurrentPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
|
{
|
|
using (BinaryReader r = new BinaryReader(fs))
|
|
{
|
|
byte[] buffer = r.ReadBytes((int)fs.Length);
|
|
int Result = BaseModuleImpl.SaveImage(this.SysModel.MenuTable, _labPicName, this.SysModel.ParmaryKey, this._currentRow[this.SysModel.ParmaryKey] + "", buffer);
|
|
MessageUtil.Show(Result > 0 ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断有效SQL是否以select开头(忽略前方空格、BOM和注释)
|
|
/// </summary>
|
|
/// <param name="sqlText"></param>
|
|
/// <returns></returns>
|
|
public static bool IsSelectAtStart(string sqlText)
|
|
{
|
|
if (string.IsNullOrEmpty(sqlText))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int index = 0;
|
|
while (index < sqlText.Length)
|
|
{
|
|
while (index < sqlText.Length &&
|
|
(char.IsWhiteSpace(sqlText[index]) || sqlText[index] == '\uFEFF'))
|
|
{
|
|
index++;
|
|
}
|
|
|
|
// 跳过SQL开头连续出现的单行注释。
|
|
if (index + 1 < sqlText.Length && sqlText[index] == '-' && sqlText[index + 1] == '-')
|
|
{
|
|
index += 2;
|
|
while (index < sqlText.Length && sqlText[index] != '\r' && sqlText[index] != '\n')
|
|
{
|
|
index++;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
// 跳过块注释,同时兼容SQL Server支持的嵌套块注释。
|
|
if (index + 1 < sqlText.Length && sqlText[index] == '/' && sqlText[index + 1] == '*')
|
|
{
|
|
index += 2;
|
|
int commentDepth = 1;
|
|
while (index < sqlText.Length && commentDepth > 0)
|
|
{
|
|
if (index + 1 < sqlText.Length && sqlText[index] == '/' && sqlText[index + 1] == '*')
|
|
{
|
|
commentDepth++;
|
|
index += 2;
|
|
}
|
|
else if (index + 1 < sqlText.Length && sqlText[index] == '*' && sqlText[index + 1] == '/')
|
|
{
|
|
commentDepth--;
|
|
index += 2;
|
|
}
|
|
else
|
|
{
|
|
index++;
|
|
}
|
|
}
|
|
|
|
if (commentDepth > 0)
|
|
{
|
|
return false;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
const string selectKeyword = "select";
|
|
if (index + selectKeyword.Length > sqlText.Length ||
|
|
string.Compare(sqlText, index, selectKeyword, 0, selectKeyword.Length,
|
|
StringComparison.OrdinalIgnoreCase) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int nextIndex = index + selectKeyword.Length;
|
|
return nextIndex == sqlText.Length ||
|
|
(!char.IsLetterOrDigit(sqlText[nextIndex]) && sqlText[nextIndex] != '_');
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 关闭模块时调用
|
|
/// </summary>
|
|
public void CloseModule()
|
|
{
|
|
if (this.SysModel != null && this.SysModel.RecordRowUponExit)
|
|
{
|
|
int Handle = this.ModuleGridObj.GridControlObj.GridView.FocusedRowHandle > 0 ? this.ModuleGridObj.GridControlObj.GridView.FocusedRowHandle : 0;
|
|
IniHelper.Write(string.Format("RecordRowUponExit_{0}", this.Model.ModuleCode), Handle + "");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 初始化页签
|
|
/// </summary>
|
|
public void InitializeTab()
|
|
{
|
|
DataTable table = BaseModuleImpl.GetBaseAttachKey(this.SysModel.FormKey);//查看是否有附加模块
|
|
if (table.Rows.Count > 0)
|
|
{
|
|
XtraTabPage MainTableTab = new XtraTabPage();
|
|
MainTableTab.Text = this.SysModel.MenuText;
|
|
MainTableTab.Controls.Add(this.moduleGridDetailEx1);
|
|
MainTableTab.Tag = this.moduleGridDetailEx1;
|
|
this.MainBodyTab.TabPages.Add(MainTableTab);
|
|
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(item["unionModule"] + "");
|
|
|
|
//DataRow LeftRow = BaseModuleImpl.GetBaseLeftTreeField(item["unionModule"] + "");//获取表格左侧树字段
|
|
//modelRow = MainImpl.GetSystemdllTab ("mps001");
|
|
if (modelRow == null) continue;
|
|
ModuleModel addModel = new ModuleModel(modelRow);
|
|
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = item["AttachName"] + "";
|
|
ModuleGridDetailEx modegridEx = new ModuleGridDetailEx();
|
|
modegridEx.Name = "moduleGridDetailEx";
|
|
modegridEx.Dock = DockStyle.Fill;
|
|
DynamicModel dyncModel = new DynamicModuleModel(new string[] { "0", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", item["unionModule"] + "", "0" });
|
|
modegridEx.GridDetailList = GetDetails(addModel.ModeCode);
|
|
modegridEx.InitializeControl(addModel, dyncModel);
|
|
|
|
//modegridEx.SearchObj.OnDataSourceBindCallBack += OnDataSourceBindCallBack;
|
|
|
|
//加载复选框
|
|
if (table.Columns.Contains("gridObjCheck") && "1".Equals(item["gridObjCheck"] + ""))
|
|
{
|
|
GridDragGrid.GridAddCheckBox(modegridEx.ModuleGridObj.GridControlObj.GridView);
|
|
}
|
|
string association = item["unionvalue"] + "";
|
|
if (!string.IsNullOrWhiteSpace(association))
|
|
{
|
|
//配置了树节点关联的页签,就绑定主表的左侧控件
|
|
switch (this.SysModel.MenuType)
|
|
{
|
|
case 1:
|
|
case 4: // 左侧为树节点
|
|
modegridEx.ModuleGridObj.LeftTreeViewEx = this.treeLeft;
|
|
modegridEx.ModuleGridObj.ParentKeyField = association;
|
|
modegridEx.ModuleGridObj.AdditionalAssociatedMain = true;
|
|
//modegridEx.ModuleGridObj.ParentKeyField = LeftRow["fieldsqlid"] + "";
|
|
//modegridEx.ModuleGridObj.ParentUnionField LeftRow["fieldname"] + "";
|
|
break;
|
|
case 2:
|
|
case 5: // 左侧为表格
|
|
modegridEx.ModuleGridObj.LeftGridEx = this.SysModel.IsTreeTable ? this.treeGridLeft : this.gridLeft;
|
|
modegridEx.ModuleGridObj.ParentKeyField = association;
|
|
modegridEx.ModuleGridObj.AdditionalAssociatedMain = true;
|
|
//modegridEx.ModuleGridObj.ParentKeyField = LeftRow["fieldsqlid"] + "";
|
|
//modegridEx.ModuleGridObj.ParentUnionField = LeftRow["fieldname"] + "";
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
page.Controls.Add(modegridEx);
|
|
modegridEx.Tag = item;
|
|
page.Tag = modegridEx;
|
|
this.MainBodyTab.TabPages.Add(page);
|
|
}
|
|
|
|
this.MainBodyTab.SelectedPageChanged += MainBodyTab_SelectedPageChanged;
|
|
this.MainBodyTab.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
this.MainBodyTab.Visible = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:拿到底部表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>List<GridDetailModel>.</returns>
|
|
private List<GridDetailModel> GetDetails(string moduleCode)
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
|
DataTable table = BaseModuleImpl.GetBaseDetailPages(moduleCode);// 根据传入的模块编号获得基础档案底部标签的数据
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(moduleCode, item["id"] + "");//获取报表明细列
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
return details;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主页签切换时刷新
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MainBodyTab_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
|
|
{
|
|
if (this.scc_container.PanelVisibility == SplitPanelVisibility.Both)
|
|
{
|
|
if (this.gridLeft.Visible) this.OnGridViewRowClick(null, null);
|
|
if (this.treeGridLeft.Visible) this.TreeListObj_Click(null, null);
|
|
if (this.treeLeft.Visible)
|
|
{
|
|
TreeViewEventArgs treeViewEventArgs = new TreeViewEventArgs(this.treeLeft.TreeView.SelectedNode);
|
|
this.OnTreeLeftTreeNodeSelected(null, treeViewEventArgs);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|