2474 lines
114 KiB
C#
2474 lines
114 KiB
C#
using DevExpress.Data;
|
||
using DevExpress.Utils;
|
||
using DevExpress.XtraBars;
|
||
using DevExpress.XtraEditors;
|
||
using DevExpress.XtraGrid.Columns;
|
||
using DevExpress.XtraGrid.Views.Base;
|
||
using DevExpress.XtraGrid.Views.Grid;
|
||
using DevExpress.XtraTab;
|
||
using DevExpress.XtraTreeList.Columns;
|
||
using DevExpress.XtraTreeList.Nodes;
|
||
using Lskj.Business;
|
||
using Lskj.Business.Impl;
|
||
using Lskj.Control;
|
||
using Lskj.Control.BrowserSetting;
|
||
using Lskj.Control.Model;
|
||
using Lskj.Core;
|
||
using Lskj.Data;
|
||
using Lskj.Model;
|
||
using Lskj.PubBillManagement.Model;
|
||
using Lskj.Util;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Lskj.PubBillManagement
|
||
{
|
||
public partial class BillModule : UserControl
|
||
{
|
||
/// <summary>
|
||
/// 是否为初始化创建
|
||
/// </summary>
|
||
private bool _isInitFinish;
|
||
/// <summary>
|
||
/// 是否加载右侧控件数据
|
||
/// </summary>
|
||
private bool _isLoadRightControlValue = true;
|
||
/// <summary>
|
||
/// 是否手动选择了模版
|
||
/// </summary>
|
||
private bool _isSelectedTemplete;
|
||
/// <summary>
|
||
/// 是否直接打印
|
||
/// </summary>
|
||
private bool _isExcPrint;
|
||
/// <summary>
|
||
/// 是否选择关联下发
|
||
/// </summary>
|
||
private bool _isCheck;
|
||
/// <summary>
|
||
/// 主打印Sql
|
||
/// </summary>
|
||
private string _mainPrintSql;
|
||
private string guidField = "xxxxx_guid";
|
||
/// <summary>
|
||
/// 主键字段
|
||
/// </summary>
|
||
private string mRecordPrimaryField;
|
||
/// <summary>
|
||
/// 单据水印
|
||
/// </summary>
|
||
private WaterMark _waterMark;
|
||
/// <summary>
|
||
/// 导入单据明细数据、导入单据明细并更新
|
||
/// </summary>
|
||
private BarButtonItem _itemImport, _itemImportUpdate;
|
||
/// <summary>
|
||
/// 打印主sql中关联打印次数返回条件
|
||
/// </summary>
|
||
private string _printModeCond;
|
||
/// <summary>
|
||
/// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql
|
||
/// </summary>
|
||
private List<string> _printSaveParams;
|
||
/// <summary>
|
||
/// 单据明细列
|
||
/// </summary>
|
||
private DataTable _detailColumns;
|
||
private bool IsCopying = false;
|
||
|
||
|
||
protected DataRow BillRowItem;
|
||
/// <summary>
|
||
/// 主表控件
|
||
/// </summary>
|
||
public MyControl ControlObj;
|
||
/// <summary>
|
||
/// 入口参数
|
||
/// </summary>
|
||
protected DynamicBillModel SysModel;
|
||
/// <summary>
|
||
/// 是否为Brp模版
|
||
/// </summary>
|
||
/// <value><c>true</c> if this instance is BRP templete; otherwise, <c>false</c>.</value>
|
||
protected bool IsBrpTemplete { get { return SysModel is DynamicBillBrpModel; } }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public BillModel BillModel;
|
||
/// <summary>
|
||
/// 数量名称
|
||
/// </summary>
|
||
public string NumberMc;
|
||
/// <summary>
|
||
/// 红字单据的分配管理模块
|
||
/// </summary>
|
||
public string rdRedUnionCode;
|
||
/// <summary>
|
||
/// 蓝字单据的分配管理模块
|
||
/// </summary>
|
||
public string rdBlueUnionCode;
|
||
/// <summary>
|
||
/// 蓝字单据的分配管理模块
|
||
/// </summary>
|
||
Dictionary<MyControl, XtraTabPage> pageNumKey = new Dictionary<MyControl, XtraTabPage>();
|
||
/// <summary>
|
||
/// 是否拖拽换行展示
|
||
/// </summary>
|
||
public bool isDragWrap = true;
|
||
/// <summary>
|
||
/// 触发主表改变刷新来源限制
|
||
/// </summary>
|
||
private bool IsBillMaster = true;
|
||
/// <summary>
|
||
/// 是否执行了加载储存过程
|
||
/// </summary>
|
||
//public bool ProcessExists = false;
|
||
/// <summary>
|
||
/// 保存或修改时报错信息
|
||
/// </summary>
|
||
public string SaveErrorMessage = string.Empty;
|
||
/// <summary>
|
||
/// 单据明细删除的行
|
||
/// </summary>
|
||
// private Dictionary<int,DataRow> ToWithdrawRows = new Dictionary<int,DataRow>();
|
||
private List<Dictionary<int, DataRow>> ToWithdrawRows = new List<Dictionary<int, DataRow>>();
|
||
/// <summary>
|
||
///改变颜色行
|
||
/// </summary>
|
||
private List<DataRow> ChangeColorRow = new List<DataRow>();
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string AssociatedField = string.Empty;
|
||
/// <summary>
|
||
/// 注册设置公共事件私有类
|
||
/// </summary>
|
||
private static PubEvenImpl _eventHandler;
|
||
/// <summary>
|
||
/// 注册设置公共事件类
|
||
/// </summary>
|
||
private static PubEvenImpl eventHandler;
|
||
/// <summary>
|
||
/// 当前人员是否有导出权限
|
||
/// </summary>
|
||
public bool ExportPermission;
|
||
/// <summary>
|
||
/// 是否显示单据管理条数
|
||
/// </summary>
|
||
public bool IsBillShowCount = false;
|
||
/// <summary>
|
||
/// 来源明细的页面名字后缀(设置成全局变量,更好的处理语言翻译的情况)
|
||
/// </summary>
|
||
public string DetailedSuffix = Business.Impl.LanguageTranslation.Translatable ? "-" + Business.Impl.LanguageTranslation.GetTranslatedText("明细") : "-明细";
|
||
/// <summary>
|
||
/// 数量后缀
|
||
/// </summary>
|
||
public string QuantitySuffix = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("条") + ")" : "条)";
|
||
/// <summary>
|
||
/// 新增
|
||
/// </summary>
|
||
public string addText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("新增") + ")" : "(新增)";
|
||
/// <summary>
|
||
/// 修改
|
||
/// </summary>
|
||
public string updateText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("修改") + ")" : "(修改)";
|
||
|
||
|
||
/// <summary>
|
||
/// 单据来源控件集合
|
||
/// </summary>
|
||
public Dictionary<DataRow, BillModuleModel> BillModuleModelDic = new Dictionary<DataRow, BillModuleModel>();
|
||
/// <summary>
|
||
/// 主表动态生成的日期列
|
||
/// </summary>
|
||
public List<GridColumn> DateColumnList = new List<GridColumn>();
|
||
/// <summary>
|
||
/// 主表动态生成的合计列
|
||
/// </summary>
|
||
public GridColumn SumGridColumn = new GridColumn();
|
||
/// <summary>
|
||
/// 附加右键菜单集合
|
||
/// </summary>
|
||
public List<SimpleButton> itemCommonList = new List<SimpleButton>();
|
||
/// <summary>
|
||
/// 是否已经添加了多行汇总
|
||
/// </summary>
|
||
public bool MultiLineSummary;
|
||
/// <summary>
|
||
/// 扫码框
|
||
/// </summary>
|
||
public TextEdit ScanCodeTextEdit = null;
|
||
/// <summary>
|
||
/// 初始化时选中的页签
|
||
/// </summary>
|
||
public XtraTabPage InitialSelectionTab = null;
|
||
/// <summary>
|
||
/// 当前操作的ImageEdit
|
||
/// </summary>
|
||
private LabelImageEdit _imageEdit;
|
||
/// <summary>
|
||
/// 当前来源明细中变色行
|
||
/// </summary>
|
||
private HashSet<int> ColorHandles = new HashSet<int>();
|
||
/// <summary>
|
||
/// 保存验证条件表
|
||
/// </summary>
|
||
public DataTable SaveCondTab = new DataTable();
|
||
|
||
|
||
|
||
public BillModule()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
#region 初始化操作
|
||
/// <summary>
|
||
/// <para>说明:窗口加载</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
public void OnLoad(DynamicBillModel Model)
|
||
{
|
||
try
|
||
{
|
||
this.SysModel = Model;// 单据动态链接库参数,入口参数
|
||
this._isInitFinish = false;// 是否为初始化创建
|
||
this.ssc_main.Visible = false; //获取或设置一个值,该值指示是否显示该控件及其所有子控件。
|
||
//this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
|
||
|
||
|
||
|
||
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
||
dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成
|
||
this.InitializeSetting();//初始化系统配置
|
||
this.InitializeControl();//初始化控件
|
||
this.InitlizeSpiltLocation();
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError("单据初始化窗体失败!", ex);
|
||
MessageUtil.Show(ex.StackTrace);
|
||
}
|
||
finally
|
||
{
|
||
this._isInitFinish = true;
|
||
this.ssc_main.Visible = true;
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取数据源缓存
|
||
/// </summary>
|
||
/// <param name="cachesDic"></param>
|
||
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
|
||
{
|
||
//获取通用数据
|
||
Task<ModuleModel> sysModelTask = cachesDic.GetTask<ModuleModel>(this, "SysModel");
|
||
Task<DataRow> systemDllRowTask = cachesDic.GetTask<DataRow>(this, "SystemDllRow");
|
||
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
||
Task<bool> getDataCachesTask = cachesDic.AddTask(this, "DataCaches", new Task<bool>(() =>
|
||
{
|
||
DynamicBillModel dynamicModel = (DynamicBillModel)dynamicModelTask.Result;
|
||
#region InitializeSetting初始化系统配置
|
||
Task<DataRow> billInfoRowTask = cachesDic.AddTask(this, "BillInfo", new Task<DataRow>(() =>
|
||
{
|
||
return BillImpl.GetBillInfo(dynamicModel.ModuleCode);//获取单个模块信息
|
||
}));
|
||
Task<BillModel> billModelTask = cachesDic.AddTask(this, "BillModel", new Task<BillModel>(() =>
|
||
{
|
||
BillModel model = null;
|
||
if (billInfoRowTask.Result != null)
|
||
{
|
||
model = new BillModel(billInfoRowTask.Result);
|
||
}
|
||
return model;
|
||
}));
|
||
BillModel billModel = billModelTask.Result;
|
||
if (billModel != null)
|
||
{
|
||
Task<string> masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task<string>(() =>
|
||
{
|
||
return BaseImpl.GetColumnPrefix(billModel.MasterTable);// 主表列前缀
|
||
}));
|
||
Task<string> detailPreFixTask = cachesDic.AddTask(this, "DetailPreFix", new Task<string>(() =>
|
||
{
|
||
return BaseImpl.GetColumnPrefix(billModel.DetailTable);// 明细表列前缀
|
||
}));
|
||
}
|
||
Task<DataRow> menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task<DataRow>(() =>
|
||
{
|
||
DataRow dataRow = BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId);
|
||
if (dataRow != null)
|
||
{
|
||
billModel.BillSourceIds = dataRow.Table.Columns.Contains("BillSourceIds") ? (dataRow["BillSourceIds"] + "").Trim(',') : string.Empty;
|
||
billModel.BillFlag = dataRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(dataRow["BillFlag"] + "") ? Convert.ToInt32(dataRow["BillFlag"] + "") : -1;
|
||
//billModel
|
||
}
|
||
return dataRow;//获取菜单其他配置
|
||
}));
|
||
#region GetPrintOtherParam获取打印其他参数
|
||
if (string.IsNullOrEmpty(billModel.PrintSql) && billModel.PrintSql.Contains("<<"))
|
||
{
|
||
string[] strs = billModel.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None);
|
||
_mainPrintSql = strs[1];
|
||
_printModeCond = strs[0].Replace("<<", "");
|
||
}
|
||
if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0)
|
||
{
|
||
string[] str = _printModeCond.Split(';');
|
||
Task<DataRow> printOtherSystemRowTask = cachesDic.AddTask(this, "PrintOtherSystemRow", new Task<DataRow>(() =>
|
||
{
|
||
return AttachImpl.GetSystemModule(str[0]);
|
||
}));
|
||
Task<string> printOtherColumnPrefixTask = cachesDic.AddTask(this, "PrintOtherColumnPrefix", new Task<string>(() =>
|
||
{
|
||
string tableName = printOtherSystemRowTask.Result["TableName"] + "";
|
||
return BaseImpl.GetColumnPrefix(tableName);
|
||
}));
|
||
Task<string> printOtherPrimaryKeyTask = cachesDic.AddTask(this, "PrintOtherPrimaryKey", new Task<string>(() =>
|
||
{
|
||
string modetype = printOtherSystemRowTask.Result["modType"] + "";
|
||
return modetype == "1" ? BaseImpl.GetBasePrimaryKey(str[0]) : printOtherColumnPrefixTask.Result + "billdocument_id";
|
||
}));
|
||
Task<bool> printOtherIsExcPrintTask = cachesDic.AddTask(this, "PrintOtherIsExcPrint", new Task<bool>(() =>
|
||
{
|
||
string modetype = printOtherSystemRowTask.Result["modType"] + "";
|
||
switch (modetype)
|
||
{
|
||
case "1":
|
||
ModuleModel mode = new ModuleModel(MainImpl.GetSystemdllTab(str[0]));
|
||
if (mode != null)
|
||
{
|
||
return mode.PrintType == 3;
|
||
}
|
||
break;
|
||
case "2":
|
||
BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.GetPubAuditProperty(str[0]));
|
||
if (model != null)
|
||
{
|
||
return model.BillPrintType == 3;
|
||
}
|
||
break;
|
||
}
|
||
return false;
|
||
}));
|
||
}
|
||
#endregion
|
||
Task<bool> billSettingTask = cachesDic.AddTask(this, "BillSetting", new Task<bool>(() =>
|
||
{
|
||
BillImpl.InitBillSetting(billModel);
|
||
return true;
|
||
}));
|
||
#endregion
|
||
|
||
|
||
if (billModel.PanelWidth > 0)
|
||
{
|
||
#region InitializeBillSource初始化单据来源
|
||
Task<List<GridDetailModel>> detailTask = cachesDic.AddTask(this, "Details", new Task<List<GridDetailModel>>(() =>
|
||
{
|
||
List<GridDetailModel> details = new List<GridDetailModel>();
|
||
DataTable table = BaseAuditImpl.GetAttachTabs(dynamicModel.ModuleCode, "100", " and orderid < 0 ");
|
||
foreach (DataRow item in table.Rows)
|
||
{
|
||
GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.BillSourceDetailAttachGridView);
|
||
details.Add(gridDetailModel);
|
||
Task<DataTable> addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task<DataTable>(() =>
|
||
{
|
||
DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
|
||
gridDetailModel.GridColumns = gridColumns;
|
||
return gridColumns;
|
||
}));
|
||
}
|
||
return details;
|
||
}));
|
||
Task<Hashtable> sourcesTask = cachesDic.AddTask(this, "Sources", new Task<Hashtable>(() =>
|
||
{
|
||
DataRow menuConfigRow = menuConfigTabTask.Result;
|
||
string SourceIds = (billModel.BillSourceIds + "").Trim(',');
|
||
if (!string.IsNullOrWhiteSpace(dynamicModel.SourceDetailsID))
|
||
{
|
||
SourceIds = (SourceIds + "," + dynamicModel.SourceDetailsID).Trim(',');
|
||
}
|
||
return BillImpl.GetSources(dynamicModel.ModuleCode, SourceIds);//获取单据来源
|
||
}));
|
||
cachesDic.AddTask(tb_buttom, "DynamicModel", dynamicModelTask);
|
||
cachesDic.AddTask(tb_buttom, "Details", detailTask);
|
||
tb_buttom.GetDataCaches(cachesDic);
|
||
Task<bool> initSourcesTask = cachesDic.AddTask(this, "InitSourcesTask", new Task<bool>(() =>
|
||
{
|
||
Hashtable htTable = sourcesTask.Result;
|
||
DataTable masterTable = htTable["master"] as DataTable;
|
||
DataTable detailTable = htTable["detail"] as DataTable;
|
||
for (int i = 0; i < masterTable.Rows.Count; i++)
|
||
{
|
||
DataRow sourceModelRow = masterTable.Rows[i];
|
||
BillModuleModel billModuleModel = new BillModuleModel();
|
||
BillSourceModel model = new BillSourceModel(sourceModelRow);
|
||
billModuleModel.SourceModel = model;
|
||
Task<DataTable> customQueryFieldsTask = cachesDic.AddTask(model, "CustomQueryFields", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
||
}));
|
||
#region 加载来源表头
|
||
GridControlEx gridControl = null;
|
||
TreeViewEx treeView = null;
|
||
if (model.SourceType == 1)
|
||
{
|
||
// 来源为树类型
|
||
treeView = new TreeViewEx();
|
||
billModuleModel.SourceControl = treeView;
|
||
Task<DataTable> bindTreeTableTask = cachesDic.AddTask(treeView, "BindTreeTable", new Task<DataTable>(() =>
|
||
{
|
||
return BaseImpl.GetDataTableResult(model.SourceSql);
|
||
}));
|
||
}
|
||
else if (model.SourceType == 5)
|
||
{
|
||
model.ChangeSourceType(2);//单据来源显示条数
|
||
}
|
||
else if (model.SourceType == 3 || model.SourceType == 4)
|
||
{
|
||
gridControl = new TreeGridControlEx();
|
||
billModuleModel.SourceControl = gridControl;
|
||
Task<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
|
||
{
|
||
return BillImpl.GetSourceColumns(model.Id);
|
||
}));
|
||
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
|
||
}));
|
||
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
|
||
}));
|
||
}
|
||
else
|
||
{
|
||
// 来源为表格类型
|
||
gridControl = new GridControlEx();
|
||
billModuleModel.SourceControl = gridControl;
|
||
Task<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
|
||
{
|
||
return BillImpl.GetSourceColumns(model.Id);
|
||
}));
|
||
//创建表格列
|
||
cachesDic.AddTask(gridControl, "DynamicModel", dynamicModelTask);
|
||
gridControl.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
||
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
|
||
}));
|
||
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
|
||
}));
|
||
}
|
||
#endregion
|
||
#region 加载来源明细
|
||
GridControlEx gridDetail = new GridControlEx();
|
||
if (model.sourceDetailType.Equals("1"))
|
||
{
|
||
//明细为树表格
|
||
gridDetail = new TreeGridControlEx();
|
||
billModuleModel.SourceDetailControl = gridDetail;
|
||
//创建表格列
|
||
cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask);
|
||
gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
|
||
Task<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
|
||
}));
|
||
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
|
||
}));
|
||
|
||
}
|
||
else
|
||
{
|
||
gridDetail = new GridControlEx();
|
||
billModuleModel.SourceDetailControl = gridDetail;
|
||
//创建表格列
|
||
cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask);
|
||
gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
|
||
Task<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
|
||
}));
|
||
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
|
||
}));
|
||
//明细的明细(明细分成左右2个)
|
||
if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql))
|
||
{
|
||
GridControlEx gridDetail_Details = new GridControlEx();
|
||
billModuleModel.SourceDetailDetailControl = gridDetail_Details;
|
||
//创建只读列
|
||
Task<DataTable> detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.getDetail_Details(model.FormKey);
|
||
}));
|
||
//创建表格列
|
||
cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask);
|
||
gridDetail_Details.GetDataCaches(cachesDic);
|
||
Task<DataTable> detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task<DataTable>(() =>
|
||
{
|
||
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
|
||
}));
|
||
}
|
||
}
|
||
#endregion
|
||
BillModuleModelDic.Add(sourceModelRow, billModuleModel);
|
||
#region 加载来源条件
|
||
Task<MyControl> searchControlTask = cachesDic.AddTask(sourceModelRow, "SearchControl", new Task<MyControl>(() =>
|
||
{
|
||
DataTable controls = customQueryFieldsTask.Result;
|
||
MyControl searchControl = null;
|
||
if (model.SourceType != 1 || (controls != null && controls.Rows.Count > 0))
|
||
{
|
||
// 创建自定义条件
|
||
string searchSql = model.SourceType == 1 ? Regex.Replace(model.DetailSql, "{speciesno}", "", RegexOptions.IgnoreCase) : model.SourceSql;
|
||
searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView);
|
||
searchControl.Model = dynamicModel;
|
||
searchControl.OtherParams = dynamicModel.OtherParams();
|
||
cachesDic.AddTask(searchControl, "DynamicModel", dynamicModelTask);
|
||
cachesDic.AddTask(searchControl, "ControlsTable", customQueryFieldsTask);
|
||
searchControl.GetSearchDataCaches(cachesDic);
|
||
}
|
||
return searchControl;
|
||
}));
|
||
#endregion
|
||
}
|
||
return true;
|
||
}));
|
||
#endregion
|
||
}
|
||
return true;
|
||
}));
|
||
#endregion
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化分割条位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-06 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitlizeSpiltLocation()
|
||
{
|
||
try
|
||
{
|
||
// 设置单据来源底部高度
|
||
if (this.BillModel.PanelHeight == 0)
|
||
{
|
||
// 隐藏来源明细
|
||
this.ssc_main.PanelVisibility = SplitPanelVisibility.Panel1;
|
||
}
|
||
else
|
||
{
|
||
string height = IniHelper.Read(string.Format("bill_height_{0}", this.SysModel.ModuleCode));
|
||
if (!string.IsNullOrEmpty(height))
|
||
this.ssc_main.SplitterPosition = Convert.ToInt32(height);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:初始化系统配置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-27 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitializeSetting()
|
||
{
|
||
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
|
||
if (!dataCaches.GetValue(this, "BillInfo", out DataRow modelRow))
|
||
{
|
||
modelRow = BillImpl.GetBillInfo(this.SysModel.ModuleCode);//获取单个模块信息
|
||
}
|
||
if (modelRow == null)
|
||
{
|
||
throw new Exception("模块编号[" + this.SysModel.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
||
}
|
||
if (!dataCaches.GetValue(this, "BillModel", out BillModel))
|
||
{
|
||
this.BillModel = new BillModel(modelRow);//初始化类的新实例。
|
||
}
|
||
|
||
if (this.BillModel != null)
|
||
{
|
||
this.BillModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? this.SysModel.FormText : this.BillModel.TypeName;// 模块名称
|
||
if (!string.IsNullOrWhiteSpace(this.SysModel.DocumentName)) this.BillModel.TypeName = this.SysModel.DocumentName;
|
||
|
||
if (!dataCaches.GetValue(this, "MasterPreFix", out string masterPreFix))
|
||
{
|
||
masterPreFix = BaseImpl.GetColumnPrefix(this.BillModel.MasterTable);// 主表列前缀
|
||
}
|
||
this.BillModel.MasterPreFix = masterPreFix;
|
||
if (!dataCaches.GetValue(this, "DetailPreFix", out string detailPreFix))
|
||
{
|
||
detailPreFix = BaseImpl.GetColumnPrefix(this.BillModel.DetailTable);// 明细表列前缀
|
||
}
|
||
this.BillModel.DetailPreFix = detailPreFix;
|
||
this.BillModel.DetailOrderField = this.BillModel.DetailPreFix + "lsidx_id";// 单据来源id
|
||
if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序
|
||
this.BillModel.DetailOrderField = string.Empty;
|
||
}
|
||
if (!dataCaches.GetValue(this, "MenuConfigTab", out DataRow menuRow))
|
||
{
|
||
menuRow = BaseImpl.GetMenuConfigTab(this.SysModel.ModuleId);//获取菜单其他配置
|
||
}
|
||
if (menuRow != null)
|
||
{
|
||
this.BillModel.BillSourceIds = menuRow.Table.Columns.Contains("BillSourceIds") ? (menuRow["BillSourceIds"] + "").Trim(',') : string.Empty;
|
||
this.BillModel.BillFlag = menuRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(menuRow["BillFlag"] + "") ? Convert.ToInt32(menuRow["BillFlag"] + "") : -1;
|
||
}
|
||
if (this.SysModel.HideSource)
|
||
{
|
||
this.BillModel.PanelWidth = 0;
|
||
this.BillModel.PanelHeight = 0;
|
||
}
|
||
|
||
if (!dataCaches.GetValue(this, "BillSetting", out bool _))
|
||
{
|
||
BillImpl.InitBillSetting(this.BillModel);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化控件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitializeControl()
|
||
{
|
||
this.InitializeBillSource();//初始化单据来源
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 点击第一个默认新增行新增默认数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GridView_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化单据来源</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-28 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitializeBillSource()
|
||
{
|
||
this.xtc_main_container.TabPages.Clear();
|
||
|
||
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
|
||
if (!dataCaches.GetValue(this, "Details", out List<GridDetailModel> attachModels))
|
||
{
|
||
attachModels = GetAttachTabs();
|
||
}
|
||
if (!dataCaches.GetValue(this, "Sources", out Hashtable htTable))
|
||
{
|
||
string SourceIds = (this.BillModel.BillSourceIds + "").Trim(',');
|
||
if (!string.IsNullOrWhiteSpace(this.SysModel.SourceDetailsID))
|
||
{
|
||
SourceIds = (SourceIds + "," + this.SysModel.SourceDetailsID).Trim(',');
|
||
}
|
||
htTable = BillImpl.GetSources(this.SysModel.ModuleCode, SourceIds);//获取单据来源
|
||
}
|
||
DataTable masterTable = htTable["master"] as DataTable;
|
||
DataTable detailTable = htTable["detail"] as DataTable;
|
||
|
||
|
||
|
||
|
||
/* 构造原理
|
||
* 1. 假如存在附加信息,则底部显示来源明细(来源明细摆放在标签第一个位置)+多标签,假如标签只有一个则隐藏标签头.
|
||
* 2. 假如不存在附加信息,则底部只显示来源明细.
|
||
**/
|
||
if (attachModels.Count > 0)
|
||
{
|
||
this.tb_buttom.Model = this.SysModel;
|
||
this.tb_buttom.ParentControlEx = this.ControlObj;
|
||
//this.tb_buttom.ParentGridEx = this.gcMain;
|
||
if (this.BillModel.RefreshSelectedDetail)
|
||
{
|
||
//配置了只刷新当前页签后,切换页签时刷新
|
||
this.tb_buttom.TabControlObj.SelectedPageChanged += TabControlObj_SelectedPageChanged;
|
||
}
|
||
this.tb_buttom.InitTabPages(attachModels);
|
||
|
||
}
|
||
else
|
||
{
|
||
this.tb_buttom.TabControlObj.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
|
||
}
|
||
dataCaches.GetValue(this, "InitSourcesTask", out bool _);
|
||
|
||
int SerialNumber = 0;
|
||
for (int i = 0; i < masterTable.Rows.Count; i++)
|
||
{
|
||
DataRow sourceModelRow = masterTable.Rows[i];
|
||
BillModuleModel billModuleModel = BillModuleModelDic.ContainsKey(sourceModelRow) ? BillModuleModelDic[sourceModelRow] : new BillModuleModel();
|
||
BillSourceModel model = billModuleModel.SourceModel != null ? billModuleModel.SourceModel : new BillSourceModel(sourceModelRow);
|
||
object sourceControl = billModuleModel.SourceControl != null ? billModuleModel.SourceControl : null;
|
||
object sourceDetailControl = billModuleModel.SourceDetailControl != null ? billModuleModel.SourceDetailControl : null;
|
||
object sourceDetailDetailControl = billModuleModel.SourceDetailDetailControl != null ? billModuleModel.SourceDetailDetailControl : null;
|
||
BillSourceUnionModel unionModel = new BillSourceUnionModel();
|
||
if (!dataCaches.GetValue(model, "CustomQueryFields", out DataTable controls))
|
||
{
|
||
controls = BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
||
}
|
||
|
||
|
||
XtraTabPage tabPage = new XtraTabPage();
|
||
tabPage.Text = model.UserName;
|
||
|
||
//只加载单据管理类型
|
||
if (!(model.SourceType == 2 || model.SourceType == 4)) continue;
|
||
|
||
|
||
#region 加载来源表头
|
||
GridControlEx gridControl = null;
|
||
TreeViewEx treeView = null;
|
||
|
||
if (model.SourceType == 1)
|
||
{
|
||
// 来源为树类型
|
||
treeView = sourceControl != null ? (TreeViewEx)sourceControl : new TreeViewEx();
|
||
treeView.BorderStyle = BorderStyle.None;
|
||
treeView.Dock = DockStyle.Fill;
|
||
treeView.TreeNodeKeyField = model.SourceKeyField;
|
||
treeView.TreeNodeTextField = model.SourceResult;
|
||
if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable))
|
||
{
|
||
bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql);
|
||
}
|
||
treeView.TreeInhibitSort = model.TreeInhibitSort;
|
||
treeView.BindTreeView(bindTreeTable);
|
||
treeView.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter);
|
||
|
||
tabPage.Controls.Add(treeView);
|
||
}
|
||
else if (model.SourceType == 5)
|
||
{
|
||
model.ChangeSourceType(2);//单据来源显示条数
|
||
this.IsBillShowCount = true;
|
||
}
|
||
else if (model.SourceType == 3 || model.SourceType == 4)
|
||
{
|
||
//类型为3,是树表格类型的单据管理。
|
||
//类型为4,是树表格类型的数据来源
|
||
gridControl = sourceControl != null ? (TreeGridControlEx)sourceControl : new TreeGridControlEx();
|
||
gridControl.Dock = DockStyle.Fill;
|
||
gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||
gridControl.Model = this.SysModel;
|
||
|
||
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
|
||
{
|
||
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
|
||
}
|
||
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
|
||
{
|
||
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
|
||
}
|
||
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
|
||
{
|
||
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
|
||
}
|
||
|
||
//节点编号
|
||
if (!string.IsNullOrWhiteSpace(model.SourceKeyFieldName)) (gridControl as TreeGridControlEx).TreeListObj.KeyFieldName = model.SourceKeyFieldName;
|
||
//父节点编号
|
||
if (!string.IsNullOrWhiteSpace(model.SourceParentFieldName)) (gridControl as TreeGridControlEx).TreeListObj.ParentFieldName = model.SourceParentFieldName;
|
||
|
||
gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
||
gridControl.SetGridRowColors(dtBaseGridRowColors);
|
||
//gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback);
|
||
(gridControl as TreeGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback);
|
||
unionModel.TreeGridControlObj = gridControl as TreeGridControlEx;
|
||
unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged);
|
||
|
||
|
||
if (BillModel.IsBillSourceCheck == 1)
|
||
{
|
||
GridDragGrid.TreeListAddCheckBox((gridControl as TreeGridControlEx).TreeListObj);
|
||
}
|
||
tabPage.Controls.Add(gridControl);
|
||
}
|
||
else
|
||
{
|
||
// 来源为表格类型
|
||
gridControl = sourceControl != null ? (GridControlEx)sourceControl : new GridControlEx();
|
||
gridControl.BorderStyle = BorderStyle.None;
|
||
gridControl.Model = this.SysModel;
|
||
gridControl.Dock = DockStyle.Fill;
|
||
gridControl.ExportPermission = this.BillModel.ExportPermission;
|
||
|
||
if (model.LoadFilter)
|
||
{
|
||
gridControl.GridView.OptionsView.ShowAutoFilterRow = true;
|
||
}
|
||
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
|
||
{
|
||
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
|
||
}
|
||
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
|
||
{
|
||
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
|
||
}
|
||
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
|
||
{
|
||
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
|
||
}
|
||
gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
||
gridControl.SetGridRowColors(dtBaseGridRowColors);
|
||
gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback);
|
||
//gridControl.GridView.SelectionChanged += new SelectionChangedEventHandler(OnGridControlSelectionChanged);
|
||
//gridControl.GridView.FocusedRowObjectChanged += OnFocusedRowObjectChanged;
|
||
//if (model.DetailsDoubleClick)
|
||
//{
|
||
// gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick; // 2023-3-11 增加双击配置
|
||
//}
|
||
//else
|
||
//{
|
||
// gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据
|
||
//}
|
||
|
||
gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据
|
||
|
||
gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick;//双击事件改成打开单据主消息控件
|
||
|
||
|
||
if (BillModel.IsBillSourceCheck == 1)
|
||
{
|
||
GridDragGrid.GridAddCheckBox(gridControl.GridView);
|
||
}
|
||
tabPage.Controls.Add(gridControl);
|
||
}
|
||
#endregion
|
||
|
||
#region 加载来源明细
|
||
XtraTabPage tabDetail = new XtraTabPage();
|
||
|
||
if (SystemInfo.Instance.GridRowFontSize > 0)
|
||
{
|
||
//页签大小
|
||
FontFamily fontFamily = tabDetail.Appearance.Header.Font.FontFamily;
|
||
tabDetail.Appearance.Header.Font = new System.Drawing.Font(fontFamily, SystemInfo.Instance.GridRowFontSize);
|
||
}
|
||
|
||
DataRow[] detailColumns = detailTable.Select("sourceId=" + model.Id);
|
||
|
||
|
||
//明细为表格
|
||
GridControlEx gridDetail = new GridControlEx();
|
||
|
||
|
||
|
||
if (!string.IsNullOrWhiteSpace(model.DetailMenuCode))
|
||
{
|
||
//来源明细配置了模块号,根据模块号创建对应的ModuleGridEx
|
||
//ModuleGridEx主要是用保存的功能,数据源sql还是根据配置的为准
|
||
DataRow modelRow = MainImpl.GetSystemdllTab(model.DetailMenuCode);//获取模块信息
|
||
if (modelRow == null)
|
||
{
|
||
MessageUtil.Show($"没有找到编号为 {model.DetailMenuCode} 的模块信息");
|
||
gridDetail.Parent = gridDetail;
|
||
continue;
|
||
}
|
||
|
||
ModuleModel sysModel = new ModuleModel(modelRow);
|
||
//设置主表sql
|
||
//model.SourceSql = sysModel.MenuSql;
|
||
|
||
DynamicModuleModel dyncModel = new DynamicModuleModel(new[]
|
||
{ sysModel.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName,
|
||
this.SysModel.Privilege, sysModel.ModeCode, "0" });
|
||
|
||
ModuleGridEx gridEx = new ModuleGridEx();
|
||
gridEx.Dock = DockStyle.Fill;
|
||
if (model.SourceType == 1)
|
||
{
|
||
gridEx.LeftTreeViewEx = treeView;
|
||
}
|
||
else
|
||
{
|
||
gridEx.LeftGridEx = gridControl;
|
||
gridEx.ParentGridEx = gridControl;
|
||
}
|
||
gridEx.ParentKeyField = model.SourceKeyField;
|
||
gridEx.ParentUnionField = model.SourceKeyField;
|
||
|
||
gridEx.VisibleSearchPanel = false;//禁止上方搜索
|
||
gridEx.InitializeControl(sysModel, dyncModel);
|
||
|
||
|
||
gridDetail = gridEx.GridControlObj;
|
||
gridEx.Parent = tabDetail;
|
||
unionModel.GridDetailModuleGridEx = gridEx;
|
||
|
||
if (sysModel.TreeAutoMultiHeader == 1) model.ChangeSourceDetailType("1");
|
||
|
||
|
||
|
||
if (SerialNumber == 0)
|
||
{
|
||
this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail);
|
||
this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0;
|
||
if (attachModels.Count > 0)
|
||
this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (model.sourceDetailType.Equals("1"))
|
||
{
|
||
//明细为树表格
|
||
gridDetail = sourceDetailControl != null ? (TreeGridControlEx)sourceDetailControl : new TreeGridControlEx();
|
||
gridDetail.Model = this.SysModel;
|
||
gridDetail.Dock = DockStyle.Fill;
|
||
gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
|
||
if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
|
||
{
|
||
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
|
||
}
|
||
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
|
||
{
|
||
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
|
||
}
|
||
gridDetail.SetGridRowColors(dtBaseGridRowColors);
|
||
gridDetail.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback);
|
||
gridDetail.Parent = tabDetail;
|
||
gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||
|
||
if (SerialNumber == 0)
|
||
{
|
||
this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail);
|
||
this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0;
|
||
if (attachModels.Count > 0)
|
||
this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix;
|
||
}
|
||
|
||
if (BillModel.IsBillDetailCheck == 1)//加载复选框
|
||
{
|
||
GridDragGrid.TreeListAddCheckBox((gridDetail as TreeGridControlEx).TreeListObj);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
gridDetail = sourceDetailControl != null ? (GridControlEx)sourceDetailControl : new GridControlEx();
|
||
gridDetail.Model = this.SysModel;
|
||
gridDetail.Dock = DockStyle.Fill;
|
||
gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
|
||
|
||
if (model.DetailedLoadFilter)
|
||
{
|
||
gridDetail.GridView.OptionsView.ShowAutoFilterRow = true;
|
||
}
|
||
if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
|
||
{
|
||
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
|
||
}
|
||
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
|
||
{
|
||
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
|
||
}
|
||
gridDetail.SetGridRowColors(dtBaseGridRowColors);
|
||
gridDetail.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback);
|
||
|
||
//明细的明细(明细分成左右2个)
|
||
if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql))
|
||
{
|
||
GridControlEx gridDetail_Details = sourceDetailDetailControl != null ? (GridControlEx)sourceDetailDetailControl : new GridControlEx();
|
||
gridDetail_Details.Model = this.SysModel;
|
||
gridDetail_Details.Dock = DockStyle.Fill;
|
||
//创建只读列
|
||
if (!dataCaches.GetValue(gridDetail_Details, "Detail_Details", out DataTable dataTable))
|
||
{
|
||
dataTable = BaseModuleImpl.getDetail_Details(model.FormKey);
|
||
}
|
||
gridDetail_Details.SetReadOnlyColumns(dataTable);
|
||
//设置右键
|
||
if (!dataCaches.GetValue(gridDetail_Details, "BaseGridRightMenus", out DataTable dttBaseGridRightMenus))
|
||
{
|
||
dttBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
|
||
}
|
||
gridDetail_Details.SetGridRightMenus(dttBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback);
|
||
//明细点击 更新 明细的明细
|
||
gridDetail.GridView.FocusedRowObjectChanged += GridView_FocusedRowObjectChanged;
|
||
gridDetail.GridView.Tag = model.SourceDetailsDetailsSql;
|
||
//创建SplitContainerControl控件,让下方可以左右拖动
|
||
SplitContainerControl splitContainerControl = new DevExpress.XtraEditors.SplitContainerControl();
|
||
splitContainerControl.Dock = DockStyle.Fill;
|
||
splitContainerControl.Panel1.Controls.Add(gridDetail);
|
||
gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||
splitContainerControl.Panel2.Controls.Add(gridDetail_Details);
|
||
gridDetail_Details.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||
|
||
splitContainerControl.SplitterMoved += new System.EventHandler(this.OnDetailsSplitterMoved);
|
||
string newwidth = IniHelper.Read(string.Format("bill_Details_Width_{0}", this.SysModel.ModuleCode));//通过Key获取Value值
|
||
if (!string.IsNullOrEmpty(newwidth))
|
||
{
|
||
splitContainerControl.SplitterPosition = Convert.ToInt32(newwidth);
|
||
}
|
||
else
|
||
{
|
||
int width = this.tb_buttom.Width;//获取控件宽度
|
||
splitContainerControl.SplitterPosition = width / 2;//然后将分割位置设置在宽度一半位置
|
||
}
|
||
|
||
|
||
splitContainerControl.Parent = tabDetail;
|
||
unionModel.GridDetailDetailControlObj = gridDetail_Details;
|
||
}
|
||
else
|
||
{
|
||
gridDetail.Parent = tabDetail;
|
||
gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||
|
||
}
|
||
|
||
if (SerialNumber == 0)
|
||
{
|
||
this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail);
|
||
this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0;
|
||
if (attachModels.Count > 0)
|
||
this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix;
|
||
}
|
||
if (BillModel.IsBillDetailCheck == 1)//加载复选框
|
||
{
|
||
GridDragGrid.GridAddCheckBox(gridDetail.GridView);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
#region 加载来源条件
|
||
if (model.SourceType == 1 && (controls == null || controls.Rows.Count == 0))
|
||
{
|
||
//// 设置默认下拉列表框
|
||
//DataTable columnTable = detailTable.Select("sourceId=" + model.Id + " and isnull(isVisible,0)=0").CopyToDataTable();
|
||
//this.lceCombobox.ValueMember = this.lceCombobox.ValueField = "fieldName";
|
||
//this.lceCombobox.TextField = "userName";
|
||
//this.lceCombobox.SetDataSource(columnTable);
|
||
//this.lceCombobox.TextEdit.SelectedIndex = 0;
|
||
|
||
//this.pl_treeview_detault_search.Dock = DockStyle.Bottom;
|
||
//this.pl_treeview_detault_search.Visible = true;
|
||
|
||
//tabPage.Controls.Add(pl_treeview_detault_search);
|
||
}
|
||
else
|
||
{
|
||
// 创建自定义条件
|
||
string searchSql = model.SourceType == 1 ? Regex.Replace(model.DetailSql, "{speciesno}", "", RegexOptions.IgnoreCase) : model.SourceSql;
|
||
PanelControl searchPanel = new PanelControl();
|
||
if (!dataCaches.GetValue(sourceModelRow, "SearchControl", out MyControl searchControl))
|
||
{
|
||
searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView);
|
||
}
|
||
searchControl.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore);
|
||
searchControl.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd);
|
||
if (SerialNumber == 0 && !SystemInfo.Instance.IsBillSourceRefushTag.Equals("1") && string.IsNullOrWhiteSpace(this.BillModel.InitialRefreshId))
|
||
{
|
||
// 第一个页面要刷新数据,所以绑定事件用于初始化完成后在查询数据
|
||
searchControl.OnDataSourceBindCallBack += new EventHandler(OnFirstPageDataSourceBindCallBack);
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(this.BillModel.InitialRefreshId) && this.BillModel.InitialRefreshId.Equals(model.Id + ""))
|
||
{
|
||
searchControl.OnDataSourceBindCallBack += SearchControl_OnDataSourceBindCallBack;
|
||
InitialSelectionTab = tabPage;
|
||
}
|
||
|
||
searchControl.ParentUnionField = model.SourceKeyField;
|
||
|
||
searchPanel.Dock = DockStyle.Top;
|
||
searchPanel.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
||
searchPanel.BackColor = Color.Transparent;
|
||
searchPanel.Parent = tabPage;
|
||
searchControl.OtherParams = this.SysModel.OtherParams();
|
||
searchPanel.Height = searchControl.InitSearchControl(controls, searchPanel);
|
||
unionModel.SearchObj = searchControl;
|
||
}
|
||
#endregion
|
||
|
||
unionModel.GridControlObj = gridControl;
|
||
|
||
if (model.sourceDetailType.Equals("1"))
|
||
{
|
||
unionModel.TreeGridDetailControlObj = (gridDetail as TreeGridControlEx);
|
||
}
|
||
else
|
||
{
|
||
unionModel.GridDetailControlObj = gridDetail;
|
||
}
|
||
|
||
|
||
|
||
|
||
unionModel.ModelObj = model;
|
||
unionModel.TreeViewObj = treeView;
|
||
if (SerialNumber == 0)
|
||
unionModel.IsChange = true;
|
||
tabPage.Tag = unionModel;
|
||
if (model.SourceType == 0 && !model.DisableShowSourceCount)
|
||
{
|
||
// 模块要查看具体条数
|
||
unionModel.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnPageDataSourceBindCallBack);
|
||
pageNumKey.Add(unionModel.SearchObj, tabPage);
|
||
}
|
||
this.xtc_main_container.TabPages.Add(tabPage);
|
||
SerialNumber++;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 点击来源明细,加载明细的明细
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
|
||
GridView gridView = sender as GridView;
|
||
DataRow rowItem = gridView.GetFocusedDataRow();
|
||
string sql = gridView.Tag + "";
|
||
BillSourceUnionModel unionModel = this.xtc_main_container.SelectedTabPage.Tag as BillSourceUnionModel;
|
||
if (unionModel.GridDetailDetailControlObj != null)
|
||
{
|
||
unionModel.GridDetailDetailControlObj.gridControl.DataSource = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, sql));
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageUtil.Show(ex);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#region 单据来源相关
|
||
/// <summary>
|
||
/// <para>说明:刷新当前选中的TabPage</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-06-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// </summary>
|
||
private void RefreshSelectedSource()
|
||
{
|
||
if (this.xtc_main_container.SelectedTabPage == null) return;//来源选择为null(不显示左侧来源)。不执行下方刷新
|
||
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel;
|
||
if (model.GridControlObj != null) this.RefreshSource(model);
|
||
if (BillModel.drgFinishHide == "1")
|
||
{
|
||
if (model.ModelObj.SourceType == 1)
|
||
{
|
||
string sqlValue = ReplaceHelper.ReplaceUserInfo(ReplaceHelper.ReplaceWhereCond(model.ModelObj.DetailSql));
|
||
sqlValue = sqlValue.Replace("#", "");
|
||
sqlValue = this.ControlObj.ReplaceControlValue(sqlValue);
|
||
sqlValue = ReplaceHelper.ReplaceParamToValue(sqlValue, model.TreeViewObj.GetSelectValue());
|
||
model.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue);
|
||
}
|
||
else
|
||
{
|
||
this.RefreshSourceDetail(model);
|
||
}
|
||
}
|
||
if (model.ModelObj.SourceType == 0 && model.SearchObj.GridRowCount > 0) tabPage.Text = model.ModelObj.UserName + "(" + model.SearchObj.GridRowCount + QuantitySuffix;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:刷新单据来源主表,未传递时,默认刷新</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-13 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>gcMain
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="unionModel">The union model.</param>
|
||
/// <returns>XtraTabPage.</returns>
|
||
private void RefreshSource(BillSourceUnionModel unionModel = null)
|
||
{
|
||
if (unionModel == null || unionModel.SearchObj == null) return;
|
||
unionModel.SearchObj.SearchLastGrid();
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:刷新单据来源明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="unionModel">The union model.</param>
|
||
private void RefreshSourceDetail(BillSourceUnionModel unionModel)
|
||
{
|
||
if (unionModel == null) return;
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
|
||
if (unionModel.ModelObj.SourceType == 1)
|
||
{
|
||
// 树加载明细
|
||
//string fieldName = this.lceCombobox.EditValue;
|
||
//string fieldValue = this.textEdit1.Text.Trim();
|
||
string fieldName = string.Empty;
|
||
string fieldValue = string.Empty;
|
||
string checkStrs = unionModel.TreeViewObj.GetCheckValues();
|
||
string sqlValue = ReplaceHelper.ReplaceParamToValue(ReplaceHelper.ReplaceUserInfo(unionModel.ModelObj.DetailSql), unionModel.TreeViewObj.GetSelectNodeValue());
|
||
|
||
if (!string.IsNullOrEmpty(checkStrs))
|
||
checkStrs = " and SpeciesNo in (" + checkStrs.TrimEnd(',') + ")";
|
||
sqlValue = string.Format("select * from ({0}) temp where 1=1 ", ReplaceHelper.ReplaceWhereCond(sqlValue) + checkStrs) + string.Format(" and ({0} like '%{1}%' or dbo.P_getpy({0}) like '%{1}%')", fieldName, fieldValue);
|
||
|
||
try
|
||
{
|
||
WaitForm.ShowForm();
|
||
unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageUtil.Show(ex);
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError(BillModel.TypeName + "模块刷新树加载明细出错!", ex);
|
||
}
|
||
finally
|
||
{
|
||
WaitForm.HideForm();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 加载明细
|
||
try
|
||
{
|
||
WaitForm.ShowForm();
|
||
|
||
|
||
DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow();
|
||
//unionModel.GridDetailControlObj.GridControl.DataSource = rowItem == null
|
||
// ? new DataTable() : BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailSql));
|
||
if (unionModel.ModelObj.SourceType == 3 || unionModel.ModelObj.SourceType == 4)
|
||
{
|
||
rowItem = unionModel.TreeGridControlObj.GetViewFocusedDataRow();
|
||
}
|
||
|
||
|
||
string DetailSql = unionModel.ModelObj.DetailSql;
|
||
DetailSql = ReplaceHelper.ReplaceUserInfo(DetailSql);
|
||
DetailSql = ReplaceHelper.ReplaceWhereCond(DetailSql);
|
||
DetailSql = ReplaceHelper.ReplaceRowParam(rowItem, DetailSql);
|
||
if (unionModel.SearchObj != null)
|
||
DetailSql = unionModel.SearchObj.ReplaceParentControlValue(DetailSql);
|
||
|
||
if (unionModel.ModelObj.sourceDetailType == "1")
|
||
{
|
||
unionModel.TreeGridDetailControlObj.SetGridViewDataSource(rowItem == null
|
||
? new DataTable() : BillImpl.GetDataTableResult(DetailSql));
|
||
}
|
||
else
|
||
{
|
||
|
||
|
||
//有复选框的页签在刷新前清空选中行,否则合计在刷新数据源后不会自带改变
|
||
if (unionModel.GridDetailControlObj.GridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && unionModel.GridDetailControlObj.GridView.OptionsSelection.MultiSelect == true)
|
||
{
|
||
//int[] selectIndexs = unionModel.GridDetailControlObj.GridView.GetSelectedRows();
|
||
unionModel.GridDetailControlObj.GridView.ClearSelection();
|
||
}
|
||
|
||
unionModel.GridDetailControlObj.GridControl.DataSource = rowItem == null
|
||
? new DataTable() : BillImpl.GetDataTableResult(DetailSql);
|
||
}
|
||
|
||
if (unionModel.GridDetailModuleGridEx != null)
|
||
{
|
||
unionModel.GridDetailModuleGridEx.GridControlObj.LastSearchSql = DetailSql;
|
||
}
|
||
|
||
|
||
DataTable table = null;
|
||
if (unionModel.ModelObj.sourceDetailType == "1")
|
||
{
|
||
table = unionModel.TreeGridDetailControlObj.TreeListObj.DataSource as DataTable;
|
||
}
|
||
else
|
||
{
|
||
table = unionModel.GridDetailControlObj.GridControl.DataSource as DataTable;
|
||
}
|
||
|
||
if (table != null && !table.Columns.Contains("_check"))
|
||
{
|
||
table.Columns.Add("_check", typeof(bool));
|
||
foreach (DataRow row in table.Rows)
|
||
{
|
||
row["_check"] = 0;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
if (tb_buttom.TabControlObj.TabPages.Count > 0)
|
||
{
|
||
for (int i = 0; i < this.tb_buttom.TabControlObj.TabPages.Count; i++)
|
||
{
|
||
XtraTabPage page = this.tb_buttom.TabControlObj.TabPages[i];
|
||
if (i == 0) continue;
|
||
if (rowItem != null && page != null)
|
||
{
|
||
this.SetTabPageDataSource(page, rowItem);
|
||
}
|
||
}
|
||
//foreach (XtraTabPage AttachPage in this.tb_buttom.TabControlObj.TabPages)
|
||
//{
|
||
// GridDetailModel model = tb_buttom.GetGridDetailModel(AttachPage);
|
||
// if (model == null) continue;
|
||
// string sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, model.DetailSql);
|
||
// this.tb_buttom.SetGridDataSource(AttachPage, sqlValue);
|
||
//}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageUtil.Show(ex);
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError(BillModel.TypeName + "模块加载明细出错!", ex);
|
||
}
|
||
finally
|
||
{
|
||
WaitForm.HideForm();
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:刷新单据来源</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2019-12-16 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void SaveRefreshSource()
|
||
{
|
||
foreach (XtraTabPage tabPage in this.xtc_main_container.TabPages)
|
||
{
|
||
BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel;
|
||
if (model != null && model.GridControlObj != null && model.ModelObj.SaveRefreshFlag)
|
||
{
|
||
this.RefreshSource(model);
|
||
this.RefreshSourceDetail(model);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ValidateDetailCond(DataRow rowItem, BillSourceUnionModel unionModel)
|
||
{
|
||
bool validate = false;
|
||
|
||
try
|
||
{
|
||
string detailCond = ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailEnableCond);
|
||
detailCond = detailCond.ToLower();//2025-09-08 赵坤表示条件全部转成小写判断。 来源明细中不能配置单元格类型(不能配置 复选框条件 {xxx}=0 ),只能写{xxx}='Ture'。这种bit类型容易忘记大小的情况
|
||
if (detailCond.Contains("#"))
|
||
{
|
||
List<string> condition = ReplaceHelper.GetParamFields(detailCond);
|
||
foreach (string item in condition)
|
||
{
|
||
string fieldValue = this.ControlObj.GetControlValue(item.Replace("{#", "").Replace("}", ""));
|
||
detailCond = detailCond.Replace(item, fieldValue);
|
||
}
|
||
}
|
||
if (detailCond.StartsWith("@") || detailCond.StartsWith("!"))
|
||
{
|
||
validate = "1".Equals(BaseImpl.GetDefaultValue(detailCond));
|
||
}
|
||
else
|
||
{
|
||
|
||
validate = ReplaceHelper.EvalCond(detailCond);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteLog(ex.StackTrace);
|
||
LogUtil.WriteError("验证多条添加条件出错!", ex);
|
||
//MessageUtil.Show(ResourceKeys.CondtionError + "\r\n" + unionModel.ModelObj.DetailEnableCond);
|
||
}
|
||
return validate;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源右键菜单执行完后刷新</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-11 </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>
|
||
private void OnGridControlRightCallback(object sender, EventArgs e)
|
||
{
|
||
this.RefreshSelectedSource();
|
||
|
||
// 执行右键菜单后刷新单据状态2020-03-23
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取单据管理的单据来源标签</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-13 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private BillSourceUnionModel GetBillSourceManager()
|
||
{
|
||
foreach (XtraTabPage item in this.xtc_main_container.TabPages)
|
||
{
|
||
BillSourceUnionModel model = item.Tag as BillSourceUnionModel;
|
||
if (model.ModelObj.SourceType == 2)
|
||
return model;
|
||
}
|
||
return null;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:初始化附加信息</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-26 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private List<GridDetailModel> GetAttachTabs()
|
||
{
|
||
List<GridDetailModel> details = new List<GridDetailModel>();
|
||
|
||
DataTable table = BaseAuditImpl.GetAttachTabs(this.SysModel.ModuleCode, "100", " and orderid < 0 ");
|
||
foreach (DataRow item in table.Rows)
|
||
{
|
||
DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
|
||
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BillSourceDetailAttachGridView));
|
||
}
|
||
|
||
return details;
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
#region 事件相关
|
||
/// <summary>
|
||
/// <para>说明:打印完成后回调</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-07-05 </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 OnReportPrintAfter(object sender, EventArgs e)
|
||
{
|
||
//打印完成后添加数据库
|
||
if (_printSaveParams != null && _printSaveParams.Count > 0)
|
||
{
|
||
int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-28 </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="KeyEventArgs"/> instance containing the event data.</param>
|
||
private void OnFrmMainKeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
// 窗口获取按键则表格按键中断.有时间处理
|
||
if (e.Modifiers.CompareTo(Keys.Control) == 0)
|
||
{
|
||
if (e.KeyCode == Keys.Down)
|
||
this.ssc_main.Collapsed = true;
|
||
if (e.KeyCode == Keys.Up)
|
||
this.ssc_main.Collapsed = false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:树节点选中刷新明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-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="TreeViewEventArgs"/> instance containing the event data.</param>
|
||
private void OnTreeNodeSelectAfter(object sender, TreeViewEventArgs e)
|
||
{
|
||
TreeView tree = (TreeView)sender;
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
if (unionModel != null)
|
||
{
|
||
WaitForm.ShowForm();
|
||
try
|
||
{
|
||
|
||
|
||
string sqlValue = ReplaceHelper.ReplaceUserInfo(ReplaceHelper.ReplaceWhereCond(unionModel.ModelObj.DetailSql));
|
||
sqlValue = sqlValue.Replace("#", "");
|
||
sqlValue = this.ControlObj.ReplaceControlValue(sqlValue);
|
||
if (unionModel.SearchObj != null) sqlValue = unionModel.SearchObj.ReplaceControlValue(sqlValue);
|
||
sqlValue = ReplaceHelper.ReplaceParamToValue(sqlValue, e.Node.Name);
|
||
|
||
if (unionModel.GridDetailModuleGridEx != null)
|
||
{
|
||
unionModel.GridDetailModuleGridEx.GridControlObj.LastSearchSql = sqlValue;
|
||
}
|
||
|
||
if (unionModel.ModelObj.sourceDetailType == "1" && unionModel.TreeGridDetailControlObj.TreeListObj != null)
|
||
{
|
||
unionModel.TreeGridDetailControlObj.TreeListObj.DataSource = BillImpl.GetDataTableResult(sqlValue);
|
||
}
|
||
else
|
||
{
|
||
unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue);
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError(BillModel.TypeName + "模块选中树节点" + tree.SelectedNode.Text + "刷新明细失败!", ex);
|
||
}
|
||
finally
|
||
{
|
||
WaitForm.HideForm();
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源切换Tab标签</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-28 </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="TabPageChangedEventArgs"/> instance containing the event data.</param>
|
||
private void OnTabSelectedPageChanged(object sender, TabPageChangedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (_isInitFinish && !SystemInfo.Instance.IsBillSourceRefushTag.Equals("1"))
|
||
{
|
||
BillSourceUnionModel unionModel = e.Page.Tag as BillSourceUnionModel;
|
||
if (unionModel != null)
|
||
{
|
||
this.RefreshSelectedSource();
|
||
this.tb_buttom.TabControlObj.TabPages[0].Controls.Clear();
|
||
if (unionModel.GridDetailModuleGridEx != null)
|
||
{
|
||
this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailModuleGridEx);
|
||
}
|
||
else if (unionModel.GridDetailDetailControlObj == null)
|
||
{
|
||
this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailControlObj != null ? unionModel.GridDetailControlObj : unionModel.TreeGridDetailControlObj);
|
||
}
|
||
else
|
||
{
|
||
//this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailDetailControlObj);
|
||
//创建SplitContainerControl控件,让下方可以左右拖动
|
||
SplitContainerControl splitContainerControl = new DevExpress.XtraEditors.SplitContainerControl();
|
||
splitContainerControl.Dock = DockStyle.Fill;
|
||
splitContainerControl.Panel1.Controls.Add(unionModel.GridDetailControlObj);
|
||
splitContainerControl.Panel2.Controls.Add(unionModel.GridDetailDetailControlObj);
|
||
int width = this.tb_buttom.Width;//获取控件宽度
|
||
splitContainerControl.SplitterPosition = width / 2;//然后将分割位置设置在宽度一半位置
|
||
this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(splitContainerControl);
|
||
}
|
||
this.tb_buttom.TabControlObj.TabPages[0].Text = unionModel.ModelObj.UserName + DetailedSuffix;
|
||
if (unionModel.IsChange == false)
|
||
{
|
||
AutoSizeChange.ControllInitializeSize(this.tb_buttom.TabControlObj.TabPages[0]);
|
||
unionModel.IsChange = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError("单据切换标签失败!", ex);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源树结构默认查询条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-28 </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>
|
||
private void OnTreeSearchClick(object sender, EventArgs e)
|
||
{
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
|
||
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 单据来源树 条件框回车查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnTreeConditionKeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
this.OnTreeSearchClick(null, null);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:第一个页签初始化完成刷新数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期: </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>
|
||
private void OnFirstPageDataSourceBindCallBack(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (IsBillMaster)
|
||
{
|
||
this.RefreshSelectedSource();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError("单据切换标查询失败!", ex);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:第一个页签初始化完成刷新数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期: </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>
|
||
private void OnPageDataSourceBindCallBack(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
MyControl searchControl = sender as MyControl;
|
||
XtraTabPage tabPage = pageNumKey[searchControl];
|
||
if (tabPage.TabIndex == 0) return;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
string searchSql = unionModel.ModelObj.SourceSql;
|
||
searchSql = ReplaceHelper.ReplaceUserInfo(searchSql);
|
||
searchSql = ReplaceHelper.ReplaceWhereCond(searchSql);
|
||
searchSql = unionModel.SearchObj.SetSearchSqlValue(searchSql, true, true);
|
||
// 查找FROM子句的位置
|
||
int fromIndex = searchSql.IndexOf("FROM", StringComparison.OrdinalIgnoreCase);
|
||
if (fromIndex != -1)
|
||
{
|
||
// 生成优化后的SQL查询
|
||
string optimizedSql = "SELECT COUNT(*) " + searchSql.Substring(fromIndex);
|
||
searchSql = optimizedSql;
|
||
}
|
||
DataTable dt = MainImpl.GetDataTableResult(searchSql);
|
||
if (dt.Rows.Count > 0) tabPage.Text += "(" + dt.Rows[0][0] + QuantitySuffix;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
LogUtil.WriteError("单据条件绑定失败失败!", ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 跳转到指定页签,并执行配置条件的搜索
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void SearchControl_OnDataSourceBindCallBack(object sender, EventArgs e)
|
||
{
|
||
if (InitialSelectionTab != null)
|
||
{
|
||
this.xtc_main_container.SelectedTabPage = InitialSelectionTab;
|
||
BillSourceUnionModel model = InitialSelectionTab.Tag as BillSourceUnionModel;
|
||
if (model.SearchObj != null) model.SearchObj.SearchGrid();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:单据来源选中行,加载明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-30 </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="SelectionChangedEventArgs"/> instance containing the event data.</param>
|
||
private void OnGridControlSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||
{
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
|
||
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源选中行,加载明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-30 </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="SelectionChangedEventArgs"/> instance containing the event data.</param>
|
||
private void OnGridViewRowCellClick(object sender, RowCellClickEventArgs e)
|
||
{
|
||
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
this.RefreshSourceDetail(unionModel);
|
||
}
|
||
|
||
|
||
|
||
|
||
private void OnSourceGridViewDoubleClick(object sender, EventArgs e)
|
||
{
|
||
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
//this.RefreshSourceDetail(unionModel);
|
||
DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow();
|
||
if (rowItem == null)
|
||
return;
|
||
//单据号
|
||
string billno = rowItem[BillModel.PrimaryKey] + "";
|
||
|
||
DynamicBillModel model = CloneDynamicBillModel(this.SysModel);
|
||
model.BillOrderNo = billno;
|
||
FrmBill frmBill = new FrmBill(model);
|
||
frmBill.Text = string.Format("{0}-详情[单据编号:{1}]", this.BillModel.TypeName, billno);
|
||
frmBill.ShowDialog();
|
||
//刷新界面
|
||
unionModel.SearchObj.SearchLastGrid();
|
||
|
||
}
|
||
|
||
|
||
// <summary>
|
||
/// 复制单据动态参数,保留原对象的运行时配置和缓存。
|
||
/// </summary>
|
||
private static DynamicBillModel CloneDynamicBillModel(DynamicBillModel source)
|
||
{
|
||
if (source == null)
|
||
return null;
|
||
|
||
MethodInfo method = typeof(object).GetMethod(
|
||
"MemberwiseClone",
|
||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||
|
||
return method.Invoke(source, null) as DynamicBillModel;
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:单据明细选中刷新附件明细</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2021-06-30 </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="SelectionChangedEventArgs"/> instance containing the event data.</param>
|
||
private void OngcMainRowCellClick(object sender, RowCellClickEventArgs e)
|
||
{
|
||
if (this.tb_buttom.TabControlObj.TabPages.Count > 1)
|
||
{
|
||
SetDetailGridDataSource();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 切换下方附加模块页签时,刷新当前页签
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void TabControlObj_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
|
||
{
|
||
if (this.tb_buttom.TabControlObj.TabPages.Count > 1)
|
||
{
|
||
SetDetailGridDataSource();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:获取底部多标签数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
public void SetDetailGridDataSource()
|
||
{
|
||
DataRow rowItem = null;
|
||
//DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
||
//if (this.BillModel.DetailTreeTable)
|
||
//{
|
||
// rowItem = (this.gcMain as TreeGridControlEx).GetViewFocusedDataRow();
|
||
//}
|
||
int i = 0;
|
||
foreach (XtraTabPage page in this.tb_buttom.TabControlObj.TabPages)
|
||
{
|
||
if (i == 0)
|
||
{
|
||
i++;
|
||
continue;
|
||
}
|
||
if (this.BillModel.RefreshSelectedDetail && page != tb_buttom.TabControlObj.SelectedTabPage)
|
||
{
|
||
continue;
|
||
}
|
||
if (rowItem != null && page != null)
|
||
{
|
||
this.SetTabPageDataSource(page, rowItem);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:设置表格数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="tabPage">The tab page.</param>
|
||
/// <param name="gridControl">The grid control.</param>
|
||
public void SetTabPageDataSource(XtraTabPage tabPage, DataRow rowItem)
|
||
{
|
||
|
||
GridDetailModel model = this.tb_buttom.GetGridDetailModel(tabPage);
|
||
if (rowItem != null && model != null)
|
||
{
|
||
if (tabPage.Tag is ModuleWebView)
|
||
{
|
||
// 加载网页
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
ModuleWebView webView = tabPage.Tag as ModuleWebView;
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
webView.Navigate(url);
|
||
}
|
||
else if (tabPage.Tag is FrmWebBrowser)
|
||
{
|
||
// 加载网页
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
webView.LoadUrl(url);
|
||
}
|
||
else if (tabPage.Tag is FrmMiniBlink)
|
||
{
|
||
// 加载网页
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink;
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
webView.LoadUrl(url);
|
||
}
|
||
else if (tabPage.Tag is TabMultipledetails)
|
||
{
|
||
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
||
tabMultipledetails.SetConditionValues(rowItem);
|
||
|
||
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
||
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
||
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
||
DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
||
grdExMain.LastSearchSql = searchMainSql;
|
||
grdExMain.SetGridViewDataSource(firstTable);
|
||
|
||
if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx)
|
||
{
|
||
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
||
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
||
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
||
if (!MainModel.IsUnioDetail)
|
||
{
|
||
grdExAdditional.LastSearchSql = searchAddSql;
|
||
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
||
}
|
||
//右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件)
|
||
if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0)
|
||
{
|
||
grdExAdditional.LastSearchSql = "";
|
||
grdExAdditional.SetGridViewDataSource(new DataTable());
|
||
}
|
||
}
|
||
else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx)
|
||
{
|
||
ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx);
|
||
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
||
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
||
DataTable table = MainImpl.GetDataTableResult(searchAddSql);
|
||
grdExAdditional.CreateChart(table);
|
||
}
|
||
|
||
tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + QuantitySuffix;
|
||
//tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
||
//tabPage.Appearance.Header.ForeColor = firstTable.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
if (tabPage.Tag is GridControlEx)
|
||
{
|
||
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
||
}
|
||
this.tb_buttom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql));
|
||
if (tabPage.Tag is GridControlEx && (tabPage.Tag as GridControlEx).ParentControl != null)
|
||
(tabPage.Tag as GridControlEx).ParentControl.SetAllControlValue(rowItem);
|
||
//配置明细直接根据条件加载
|
||
if (model.SystemModel != null && 1 == model.SystemModel.isFirstLoad)
|
||
{
|
||
(tabPage.Tag as GridControlEx).ParentControl.SearchGrid();
|
||
GridControlEx gridControlEx = tabPage.Tag as GridControlEx;
|
||
|
||
if (gridControlEx.CustomGroupBandEx != null)
|
||
{
|
||
tabPage.Text = model.DetailName + "(" + gridControlEx.CustomGroupBandEx.DataRowCount() + QuantitySuffix;
|
||
}
|
||
else if (gridControlEx.CustomGroupTreeBandEx != null)
|
||
{
|
||
tabPage.Text = model.DetailName + "(" + gridControlEx.CustomGroupTreeBandEx.DataRowCount() + QuantitySuffix;
|
||
}
|
||
else
|
||
{
|
||
tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + QuantitySuffix;
|
||
}
|
||
//tabPage.Text = gridControlEx.CustomGroupBandEx != null ? model.DetailName + "(" + gridControlEx.CustomGroupBandEx.DataRowCount() + "条)" : model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)";
|
||
//tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)";
|
||
}
|
||
//附加信息根据主表明细选中行,判断配置的按钮条件
|
||
Object moduleObject = tabPage.Controls.Cast<Object>().FirstOrDefault();
|
||
ModuleGridEx moduleGridEx = null;
|
||
if (moduleObject is ModuleGridEx)
|
||
{
|
||
moduleGridEx = moduleObject as ModuleGridEx;
|
||
moduleGridEx.ParentButtonState(rowItem);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取查询条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-22 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="model">The model.</param>
|
||
/// <param name="rowItem">The row item.</param>
|
||
/// <returns>System.String.</returns>
|
||
protected string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
||
{
|
||
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : BillModel.PrimaryKey;
|
||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||
string unioValue = string.Empty;
|
||
unioValue = rowItem.Table.Columns.Contains(fieldName) ? rowItem[fieldName] + "" : string.Empty;
|
||
if (this.ControlObj != null && string.IsNullOrEmpty(unioValue))
|
||
{
|
||
unioValue = !string.IsNullOrEmpty(model.UnionParentField) && this.ControlObj.FindControl(model.UnionParentField) != null ? this.ControlObj.GetControlValue(model.UnionParentField) : unioValue;
|
||
}
|
||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||
sqlValue = this.ControlObj.ReplaceControlValue(sqlValue);//后替换主表内容
|
||
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
||
{
|
||
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, unioValue);
|
||
}
|
||
if (!string.IsNullOrEmpty(model.UnionCond))
|
||
{
|
||
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
||
sqlValue += UnionCond;
|
||
}
|
||
return sqlValue;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源选中行,加载明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2019-07-25 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="DevExpress.XtraTreeList.FocusedNodeChangedEventArgs"/> instance containing the event data.</param>
|
||
private void OnTreeListObjFocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
|
||
{
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
|
||
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源明细右键菜单执行后刷新数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-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="EventArgs"/> instance containing the event data.</param>
|
||
private void OnGridDetailRightMenuCallback(object sender, EventArgs e)
|
||
{
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
|
||
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:分割条移动保存位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-06 </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>
|
||
private void OnMainSplitterMoved(object sender, EventArgs e)
|
||
{
|
||
if (this._isInitFinish)
|
||
{
|
||
IniHelper.Write(string.Format("bill_height_{0}", this.SysModel.ModuleCode), this.ssc_main.SplitterPosition + "");
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:明细分割条移动保存位置</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-06 </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>
|
||
private void OnDetailsSplitterMoved(object sender, EventArgs e)
|
||
{
|
||
if (this._isInitFinish)
|
||
{
|
||
SplitContainerControl splitContainerControl = sender as SplitContainerControl;
|
||
IniHelper.Write(string.Format("bill_Details_Width_{0}", this.SysModel.ModuleCode), splitContainerControl.SplitterPosition + "");
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源查询之前处理</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-06 </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 OnSearchBefore(object sender, SearchArgs e)
|
||
{
|
||
|
||
// 用户搜索时不加载右侧控件值,只有点击、人为选中行在加载右侧控件值.
|
||
this._isLoadRightControlValue = false;
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
if (!unionModel.SearchObj.VerifyNull())
|
||
{
|
||
e.Continue = false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:单据来源查询完成</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-03-06 </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>
|
||
/// <exception cref="System.NotImplementedException"></exception>
|
||
private void OnSearchAfterd(object sender, EventArgs e)
|
||
{
|
||
this._isLoadRightControlValue = true;
|
||
|
||
XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage;
|
||
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
||
if (unionModel.ModelObj.SourceType == 1)
|
||
{
|
||
if (unionModel.TreeViewObj != null && unionModel.SearchObj.MainGridEx != null)
|
||
{
|
||
string sql = ReplaceHelper.ReplaceUserInfo(unionModel.SearchObj.MainGridEx.LastSearchSql);
|
||
|
||
//和上一次查询sql相同就不再次查询了
|
||
if (!unionModel.SearchObj.MainGridEx.LastSearchSql.Equals(sql))
|
||
{
|
||
unionModel.SearchObj.MainGridEx.SetGridViewDataSource(BaseImpl.GetDataTableResult(sql));
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (unionModel.GridControlObj != null)
|
||
{
|
||
|
||
string sql = ReplaceHelper.ReplaceUserInfo(unionModel.GridControlObj.LastSearchSql);
|
||
|
||
if (SubstringCount(sql, "#") > 1)
|
||
{
|
||
string fixedSql = sql.Substring(sql.IndexOf('#'), sql.LastIndexOf('#') + 1 - sql.IndexOf('#'));
|
||
string billMainCode = sql.Substring(sql.IndexOf('#'), sql.LastIndexOf('#') + 1 - sql.IndexOf('#')).Replace("#", "");
|
||
var paramList = ReplaceHelper.GetParamFields(billMainCode);
|
||
bool isCondReplace = true;
|
||
foreach (string item in paramList)
|
||
{
|
||
string field = item.Replace("{", "").Replace("}", "");
|
||
if (ControlObj.FindControl(field) != null)
|
||
{
|
||
string value = ControlObj.GetControlValue(field);
|
||
if (string.IsNullOrEmpty(value)) isCondReplace = false;
|
||
billMainCode = billMainCode.Replace(item, value);
|
||
}
|
||
}
|
||
if (!isCondReplace)
|
||
{
|
||
sql = sql.Replace(fixedSql, "1=1");
|
||
}
|
||
else
|
||
{
|
||
sql = sql.Replace(fixedSql, billMainCode);
|
||
|
||
}
|
||
}
|
||
int oldRowHandle = 0;
|
||
if (unionModel.GridControlObj.GridView != null)
|
||
{
|
||
oldRowHandle = unionModel.GridControlObj.GridView.FocusedRowHandle;
|
||
}
|
||
|
||
//和上一次查询sql相同就不再次查询了
|
||
if (!unionModel.GridControlObj.LastSearchSql.Equals(sql))
|
||
{
|
||
unionModel.GridControlObj.gridControl.DataSource = BaseImpl.GetDataTableResult(sql);
|
||
unionModel.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
||
}
|
||
|
||
//如果没有数据,显示 (0条)
|
||
//(unionModel.ModelObj.SourceType == 0 || this.IsBillShowCount) && unionModel.SearchObj.GridRowCount > 0
|
||
if (unionModel.ModelObj.SourceType == 0 || this.IsBillShowCount) tabPage.Text = unionModel.ModelObj.UserName + "(" + unionModel.SearchObj.GridRowCount + QuantitySuffix;
|
||
|
||
RefreshSourceDetail(unionModel);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:判断字符串出现次数</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期: </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="str">The string.</param>
|
||
/// <param name="substring">The substring.</param>
|
||
/// <returns>System.Int32.</returns>
|
||
private static int SubstringCount(string str, string substring)
|
||
{
|
||
if (str.Contains(substring))
|
||
{
|
||
string strReplaced = str.Replace(substring, "");
|
||
return (str.Length - strReplaced.Length) / substring.Length;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
#region
|
||
|
||
private void tb_buttom_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:检查可用条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-09 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="cond">The cond.</param>
|
||
/// <param name="dataRow">The data row.</param>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ValidateCond(string cond, DataRow dataRow)
|
||
{
|
||
bool result = false;
|
||
string condition = cond;
|
||
try
|
||
{
|
||
if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确
|
||
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
||
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
||
{
|
||
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
||
}
|
||
else if (dataRow == null)
|
||
{
|
||
result = ReplaceHelper.EvalCond(cond);
|
||
}
|
||
else
|
||
{
|
||
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
||
}
|
||
return result;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 设置打印按钮条件
|
||
/// </summary>
|
||
/// <param name="dataRow"></param>
|
||
public bool SetPrintButton(DataRow rowItem)
|
||
{
|
||
try
|
||
{
|
||
bool result = false;
|
||
//判断打印按钮条件
|
||
if (!string.IsNullOrWhiteSpace(this.BillModel.PrintingConditions))
|
||
{
|
||
if (rowItem == null) return result;
|
||
|
||
string cond = ReplaceHelper.ReplaceRowParam(rowItem, this.BillModel.PrintingConditions);
|
||
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
||
{
|
||
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
||
}
|
||
else
|
||
{
|
||
result = ReplaceHelper.ReplaceRowParamCond(rowItem, cond);
|
||
}
|
||
return result;
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
} |