4636 lines
218 KiB
C#
4636 lines
218 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using Lskj.Data;
|
|
using DevExpress.XtraBars;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.XtraEditors;
|
|
using System.Collections;
|
|
using Lskj.PubBillNewDrag.Model;
|
|
using DevExpress.Data;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using System.IO;
|
|
using Lskj.Business;
|
|
using System.Text.RegularExpressions;
|
|
using DevExpress.XtraTreeList.Nodes;
|
|
using DevExpress.XtraEditors.Repository;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
using System.Threading;
|
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
using Lskj.Core;
|
|
|
|
namespace Lskj.PubBillNewDrag
|
|
{
|
|
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>
|
|
/// 主打印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;
|
|
/// <summary>
|
|
/// 单据来源明细拖拽删除当前行数据集合
|
|
/// </summary>
|
|
private List<DataRow> RemoveRowitem=new List<DataRow>();
|
|
|
|
protected DataRow BillRowItem;
|
|
/// <summary>
|
|
/// 主表控件
|
|
/// </summary>
|
|
protected 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>
|
|
/// <value>The main bottom input object.</value>
|
|
public PanelControl MainBottomInputObj { get { return this.pl_input; } }
|
|
/// <summary>
|
|
/// Brp模版控件
|
|
/// </summary>
|
|
/// <value>The main bottom templete object.</value>
|
|
public PanelControl MainBottomTempleteObj { get { return this.pl_templete; } }
|
|
/// <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>
|
|
public string AssociatedField = string.Empty;
|
|
/// <summary>
|
|
/// 单据明细删除的行
|
|
/// </summary>
|
|
private Dictionary<int, DataRow> ToWithdrawRows = new Dictionary<int, DataRow>();
|
|
|
|
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);
|
|
|
|
this.InitializeSetting();//初始化系统配置
|
|
this.InitializeControl();//初始化控件
|
|
this.InitlizeSpiltLocation();
|
|
|
|
this.gcMain.GridView.KeyDown += new KeyEventHandler(OnToWithdraw);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("单据初始化窗体失败!", ex);
|
|
MessageUtil.Show(ex.StackTrace);
|
|
}
|
|
finally
|
|
{
|
|
this._isInitFinish = true;
|
|
this.ssc_main.Visible = true;
|
|
}
|
|
}
|
|
|
|
/// <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.PanelWidth == 0)
|
|
{
|
|
// 隐藏来源
|
|
this.ssc_main_top.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
}
|
|
else
|
|
{
|
|
string width = IniHelper.Read(string.Format("bill_width_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(width))
|
|
this.ssc_main_top.SplitterPosition = Convert.ToInt32(width);
|
|
}
|
|
|
|
// 设置单据来源底部高度
|
|
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()
|
|
{
|
|
if (ProcessExists)
|
|
{
|
|
this.BillModel = new BillModel(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseDetailPages().Rows[0]);
|
|
if (this.BillModel != null)
|
|
{
|
|
this.BillModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? this.SysModel.FormText : this.BillModel.TypeName;// 模块名称
|
|
this.BillModel.MasterPreFix = Lskj.Data.Caches.CacheSYSConfig.Instance().GetColumnPrefix();
|
|
this.BillModel.DetailPreFix = Lskj.Data.Caches.CacheSYSConfig.Instance().GetColumnPrefix();
|
|
this.BillModel.DetailOrderField = this.BillModel.DetailPreFix + "lsidx_id";// 单据来源id
|
|
}
|
|
DataRow menuRow = Lskj.Data.Caches.CacheSYSConfig.Instance().GetMenuConfigTab();//获取菜单其他配置
|
|
if (menuRow != null)
|
|
{
|
|
this.BillModel.BillSourceIds = Lskj.Data.Caches.CacheSYSConfig.Instance().GetColumnPrefix();
|
|
this.BillModel.BillFlag = int.Parse(Lskj.Data.Caches.CacheSYSConfig.Instance().GetColumnPrefix());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.BillModel = new BillModel(BillImpl.GetBillInfo(this.SysModel.ModuleCode));//初始化类的新实例。
|
|
|
|
if (this.BillModel != null)
|
|
{
|
|
this.BillModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? this.SysModel.FormText : this.BillModel.TypeName;// 模块名称
|
|
this.BillModel.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModel.MasterTable);// 主表列前缀
|
|
this.BillModel.DetailPreFix = BaseImpl.GetColumnPrefix(this.BillModel.DetailTable);// 明细表列前缀
|
|
this.BillModel.DetailOrderField = this.BillModel.DetailPreFix + "lsidx_id";// 单据来源id
|
|
|
|
}
|
|
|
|
DataRow menuRow = BillImpl.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;
|
|
}
|
|
}
|
|
//获取打印其他参数
|
|
GetPrintOtherParam();
|
|
BillImpl.InitBillSetting(this.BillModel);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化分配关联模块</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-02-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeUnionCode()
|
|
{
|
|
if (this.BillModel.PopupUnionCode.Contains(","))
|
|
{
|
|
string[] UnionCodeSplit = this.BillModel.PopupUnionCode.Split(',');
|
|
if (UnionCodeSplit.Length >= 1)
|
|
{
|
|
this.BillModel.PopupUnionCode = this.BillModel.BillFlag == 1 ? UnionCodeSplit[1] + "" : UnionCodeSplit[0] + "";
|
|
rdBlueUnionCode = UnionCodeSplit[0] + "";
|
|
rdRedUnionCode = UnionCodeSplit[1] + "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
rdBlueUnionCode = rdRedUnionCode = this.BillModel.PopupUnionCode;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeControl()
|
|
{
|
|
if (this.IsBrpTemplete)// 是否为Brp模版
|
|
this.InitializeTemplete();
|
|
|
|
this.InitializeStatus();//初始化红蓝字单
|
|
this.InitializeOper();//初始化常用操作等功能
|
|
this.InitializeBillInfo();//初始化单据控件信息
|
|
|
|
if (this.BillModel.PanelWidth > 0)
|
|
this.InitializeBillSource();//初始化单据来源
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化红蓝字单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeStatus()
|
|
{
|
|
// 初始化红、蓝单
|
|
if (this.BillModel.BillFlag == 0)
|
|
{
|
|
this.rdBlue.Checked = true;
|
|
this.rdRed.Checked = false;
|
|
this.lbTitle.ForeColor = Color.Blue;
|
|
this.pl_red.Visible = false;
|
|
}
|
|
if (this.BillModel.BillFlag == 1)
|
|
{
|
|
this.rdRed.Checked = true;
|
|
this.rdBlue.Checked = false;
|
|
this.lbTitle.ForeColor = Color.Red;
|
|
this.pl_blue.Visible = false;
|
|
}
|
|
this.dpCopyBill.Enabled = this.BillModel.CanCopy;
|
|
this.dpbImport.Enabled = this.BillModel.CanImport || this.BillModel.CanExport;
|
|
|
|
if (this.SysModel.HasReadPrivilege())
|
|
this.pl_main_bottom.Enabled = false;
|
|
this.ssc_main_top.SplitterPosition = this.BillModel.PanelWidth;
|
|
InitializeUnionCode();//根据红蓝字段更新分配
|
|
this.btnFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化常用操作等功能</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeOper()
|
|
{
|
|
BarButtonItem itemCopyMaster = new BarButtonItem();
|
|
itemCopyMaster.Caption = "复制表头信息";
|
|
itemCopyMaster.ItemClick += new ItemClickEventHandler(OnCopyMasterItemClick);
|
|
BarButtonItem itemCopyAll = new BarButtonItem();
|
|
itemCopyAll.Caption = "复制整单信息";
|
|
itemCopyAll.ItemClick += new ItemClickEventHandler(OnCopyAllItemClick);
|
|
BarButtonItem itemExport = new BarButtonItem();
|
|
itemExport.Caption = "导出Excel文件";
|
|
itemExport.ItemClick += new ItemClickEventHandler(OnExportItemClick);
|
|
|
|
this._itemImport = new BarButtonItem();
|
|
this._itemImport.Caption = "导入Excel文件";
|
|
this._itemImport.ItemClick += new ItemClickEventHandler(OnImportItemClick);
|
|
this._itemImportUpdate = new BarButtonItem();
|
|
this._itemImportUpdate.Caption = "导入Excel文件(更新)";
|
|
this._itemImportUpdate.ItemClick += new ItemClickEventHandler(OnImportUpdateItemClick);
|
|
|
|
// 复制单据
|
|
this.pmBill.AddItems(new BarItem[] { itemCopyMaster, itemCopyAll });
|
|
|
|
// 导入导出
|
|
if (this.BillModel.CanExport)
|
|
this.pmBillExp.AddItem(itemExport);
|
|
if (this.BillModel.CanImport)
|
|
this.pmBillExp.AddItems(new BarItem[] { _itemImport, _itemImportUpdate });
|
|
|
|
// 打印模版
|
|
string[] files = this.BillModel.PrintFile.Split('|');
|
|
for (int i = 0; i < files.Length; i++)
|
|
{
|
|
string fileName = files[i];
|
|
if (!string.IsNullOrWhiteSpace(fileName))
|
|
{
|
|
BarButtonItem itemPrint = new BarButtonItem();
|
|
int index = i + 1;
|
|
itemPrint.Caption = files[i].Replace(".rmf", "").Replace(".frx", "");
|
|
itemPrint.Tag = files[i];
|
|
itemPrint.ItemClick += new ItemClickEventHandler(OnPrintItemClick);
|
|
pMprint.AddItem(itemPrint);
|
|
}
|
|
}
|
|
|
|
// 常用工具
|
|
bool ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists()&&SystemInfo.Instance.isExecload);
|
|
DataTable tableCommon = new DataTable();
|
|
if (ProcessExists)
|
|
{
|
|
tableCommon = Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus();//获取右键菜单数据
|
|
}
|
|
else
|
|
{
|
|
tableCommon = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail);//获取右键菜单数据
|
|
}
|
|
|
|
foreach (DataRow item in tableCommon.Rows)
|
|
{
|
|
BarButtonItem itemCommon = new BarButtonItem();
|
|
itemCommon.Caption = item["menuname"] + "";
|
|
itemCommon.Tag = item;
|
|
itemCommon.ItemClick += new ItemClickEventHandler(OnCommonItemClick);
|
|
pMenu.AddItem(itemCommon);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化单据控件信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeBillInfo()
|
|
{
|
|
DataTable controls = new DataTable();
|
|
DataTable groups = new DataTable();
|
|
// 初始化表头
|
|
if (ProcessExists)
|
|
{
|
|
controls = Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields();
|
|
groups = Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields(); //获取主信息分组数据
|
|
}
|
|
else
|
|
{
|
|
controls = BaseModuleImpl.GetControlLocation(this.BillModel.FormKey, this.SysModel.ModuleCode);
|
|
groups = BaseModuleImpl.GetAddGroupData(this.BillModel.FormKey);//获取主信息分组数据
|
|
}
|
|
|
|
this.ControlObj = new MyControl();//// 主表控件
|
|
this.ControlObj.OtherParams = this.SysModel.OtherParams();
|
|
this.ControlObj.InitControl(controls, this.pl_main_center_master, groups);
|
|
this.ControlObj.OnSourceRefrshCallBack += OnRefreshBillSource;
|
|
this.ControlObj.OnDataSourceBindCallBack += new EventHandler(OnInitializeHeaderCallBack);
|
|
this.pl_main_center_master.Height = (this.BillModel.ParentHeight - 36) > this.pl_main_center_master.Height ? this.pl_main_center_master.Height : this.BillModel.ParentHeight - 36;
|
|
// 初始化明细
|
|
// 创建多表头,默认标准表格
|
|
if (this.SysModel.GridEnumObj == GridEnum.BandedGridView || this.BillModel.AutoMultiHeader == 1)
|
|
{
|
|
this.pl_main_center_detail.Controls.Clear();
|
|
this.gcMain = new BandedGridControlEx();
|
|
this.gcMain.Model = this.SysModel;
|
|
this.gcMain.Dock = DockStyle.Fill;
|
|
this.pl_main_center_detail.Controls.Add(this.gcMain);
|
|
}
|
|
|
|
if (ProcessExists)
|
|
{
|
|
_detailColumns = Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent();
|
|
}
|
|
else
|
|
{
|
|
_detailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode);//初始化单据明细列
|
|
}
|
|
|
|
this.gcMain.Model = this.SysModel;
|
|
this.gcMain.ParentControl = this.ControlObj;//把主表控件赋给 单据主表控件、基础档案查询条件控件等等
|
|
this.gcMain.SetEditColumns(_detailColumns, GridCustomColumnStruct.BillDetailGridView + this.BillModel.FormKey);//设置可编辑列
|
|
if (this.BillModel.IsBillMainDetailCheck == 1)//加载明细复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.gcMain.GridView);
|
|
}
|
|
if (ProcessExists)
|
|
{
|
|
this.gcMain.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRowColors());
|
|
if (this.gcMain is BandedGridControlEx)// 判断是不是多表头表格
|
|
{
|
|
//设置表格右键菜单
|
|
(this.gcMain as BandedGridControlEx).SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.SysModel, OnGridViewRightCallBack, this.ControlObj);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.SysModel, OnGridViewRightCallBack, this.ControlObj);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModel.FormKey));
|
|
if (this.gcMain is BandedGridControlEx)// 判断是不是多表头表格
|
|
{
|
|
//设置表格右键菜单
|
|
(this.gcMain as BandedGridControlEx).SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLDETAIL_" + this.SysModel.ModuleCode), this.SysModel, OnGridViewRightCallBack, this.ControlObj);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLDETAIL_" + this.SysModel.ModuleCode), this.SysModel, OnGridViewRightCallBack, this.ControlObj);
|
|
}
|
|
}
|
|
|
|
|
|
this.gcMain.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
this.gcMain.GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor);
|
|
if (this.BillModel.DefaultAddEmptyRow)
|
|
{
|
|
this.gcMain.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom;
|
|
this.gcMain.GridView.MouseDown += GridView_MouseDown;
|
|
this.gcMain.GridView.FocusedRowChanged += GridView_FocusedRowChanged;
|
|
}
|
|
//程序若配置扫码框则回车换行
|
|
if (this._detailColumns.Rows.Cast<DataRow>().FirstOrDefault(x => x["fieldsqltag"].ToString() == ControlType.LabSacn + "") != null)
|
|
{
|
|
this.gcMain.GridView.CellValueChanged += new CellValueChangedEventHandler(OnGridViewCellValueChanged);
|
|
}
|
|
//this.gcMain.GridView.InitNewRow += new InitNewRowEventHandler(OnGridViewInitNewRow);
|
|
this.gcMain.GridView.RowCellClick += OngcMainRowCellClick;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:数据绑定后判断是否是右键打开模块赋值</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-03-27 </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="CancelEventArgs"/> instance containing the event data.</param>
|
|
protected void OnInitializeHeaderCallBack(object sender, EventArgs e)
|
|
{
|
|
// 通过右键菜单打开单据时,判断修改还是新增
|
|
if (!string.IsNullOrEmpty(this.SysModel.BillOrderNo))
|
|
{
|
|
// 修改
|
|
string sqlValue = "select * from " + this.BillModel.MasterTable + " where 1=1";
|
|
string sqlCond = string.Format(" and {0}='{1}'", this.BillModel.PrimaryKey, this.SysModel.BillOrderNo);
|
|
DataTable masterTable = BillImpl.GetDataTableResult(sqlValue + sqlCond);
|
|
|
|
this.SetBillStatus(masterTable.Rows.Count > 0 ? masterTable.Rows[0] : null);
|
|
}
|
|
else
|
|
{
|
|
this.SetBillStatus(null);
|
|
// 新增
|
|
if (!string.IsNullOrEmpty(this.SysModel.BillMasterSql))
|
|
{
|
|
// 处理单据表头数据
|
|
DataRow row = BillImpl.GetDataRowResult(this.SysModel.BillMasterSql);
|
|
if (row != null)
|
|
{
|
|
this.ControlObj.SetAllControlValue(row, true);
|
|
// 设置Brp模版
|
|
if (this.IsBrpTemplete)
|
|
{
|
|
this.SetTempleteSelectedValue(row["brpId"] + "");
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(this.SysModel.BillMasterSql))
|
|
{
|
|
// 处理单据明细数据
|
|
this.AddMultiRowToGridView(BillImpl.GetDataTableResult(this.SysModel.BillDetailSql));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格编辑时,判断是否是否编辑</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-03-27 </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="CancelEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewShowingEditor(object sender, CancelEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(this.gcMain.GridView.FocusedRowHandle);
|
|
if (!string.IsNullOrWhiteSpace(BillModel.UpdateDetailCond))
|
|
{
|
|
string UpdateCond = this.ControlObj.ReplaceParentControlValue(BillModel.UpdateDetailCond);
|
|
UpdateCond = ReplaceHelper.ReplaceRowParam(rowItem, UpdateCond);
|
|
if (!ReplaceHelper.EvalCond(UpdateCond))
|
|
{
|
|
e.Cancel = true;//该行不可编辑
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 虚拟行点击添加
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
private void InitNewRowMethod(object sender)
|
|
{
|
|
GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
|
|
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
DataRow tmpRow = gridTable.NewRow();
|
|
gridTable.Rows.Add(tmpRow);
|
|
int position = gridTable.Rows.Count - 1;
|
|
foreach (DataRow dr in _detailColumns.Rows)
|
|
{
|
|
GridColumnModel model = new GridColumnModel(dr);
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
|
|
|
|
if (model.DefaultValue.Contains("{#"))
|
|
{
|
|
fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
tmpRow[model.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
if (model.DefaultValue.Contains("{ROW"))
|
|
{
|
|
if (position > 0)
|
|
{
|
|
|
|
fieldValue = ReplaceHelper.GetParamFields(model.DefaultValue)[0];
|
|
fieldValue = fieldValue.Replace("}", "").Replace("{", "");
|
|
fieldValue = fieldValue.Substring(fieldValue.IndexOf('_') + 1);
|
|
string topFieldValue = gridTable.Rows[position - 1][fieldValue] + "";
|
|
if (gridTable.Columns[model.FieldName].DataType == typeof(DateTime))
|
|
{
|
|
if (!string.IsNullOrEmpty(topFieldValue)) tmpRow[model.FieldName] = Convert.ToDateTime(topFieldValue);
|
|
}
|
|
else
|
|
{
|
|
tmpRow[model.FieldName] = topFieldValue;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
tmpRow[model.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
gridTable.OrderBy(this.BillModel.DetailOrderField);
|
|
|
|
if (tmpRow.Table.Columns.Contains(this.BillModel.DetailOrderField) && gridTable.Rows.Count == 0)
|
|
{
|
|
tmpRow[this.BillModel.DetailOrderField] = 1;
|
|
}
|
|
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
}
|
|
/// <summary>
|
|
/// 切换行判断是否是虚拟行数据进行数据填充
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
|
{
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
|
|
int _rowNumber = this.gcMain.GridView.FocusedRowHandle;
|
|
int _prvFocused = e.PrevFocusedRowHandle;
|
|
int indexNumber = this.gcMain.GridView.RowCount;
|
|
if (_rowNumber < 0 && _prvFocused != gridTable.Rows.Count)
|
|
{
|
|
InitNewRowMethod(sender);
|
|
this.gcMain.GridView.FocusedRowHandle = indexNumber - 1;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据重写明细回车事件(用于扫码回车移动至下一行数据)</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewCellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if (isDragWrap)
|
|
{
|
|
int _rowNumber = this.gcMain.GridView.FocusedRowHandle;
|
|
GridColumn focusColumn = this.gcMain.GridView.FocusedColumn;
|
|
GridColumnModel Columnmodel = focusColumn.Tag as GridColumnModel;
|
|
|
|
if (Columnmodel.FieldType == ControlType.LabSacn)
|
|
{
|
|
this.gcMain.GridView.OptionsNavigation.EnterMoveNextColumn = false;
|
|
if (this.BillModel.DefaultAddEmptyRow && _rowNumber + 1 == this.gcMain.GridView.DataRowCount)
|
|
{
|
|
DataTable gridTable = (this.gcMain.GridView.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
DataRow tmpRow = gridTable.NewRow();
|
|
gridTable.Rows.Add(tmpRow);
|
|
int position = gridTable.Rows.Count - 1;
|
|
foreach (DataRow dr in _detailColumns.Rows)
|
|
{
|
|
GridColumnModel model = new GridColumnModel(dr);
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
if (model.DefaultValue.Contains("{#"))
|
|
{
|
|
fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
tmpRow[model.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
if (model.DefaultValue.Contains("{ROW"))
|
|
{
|
|
if (position > 0)
|
|
{
|
|
|
|
fieldValue = ReplaceHelper.GetParamFields(model.DefaultValue)[0];
|
|
fieldValue = fieldValue.Replace("}", "").Replace("{", "");
|
|
fieldValue = fieldValue.Substring(fieldValue.IndexOf('_') + 1);
|
|
string topFieldValue = gridTable.Rows[position - 1][fieldValue] + "";
|
|
if (gridTable.Columns[model.FieldName].DataType == typeof(DateTime))
|
|
{
|
|
if (!string.IsNullOrEmpty(topFieldValue)) tmpRow[model.FieldName] = Convert.ToDateTime(topFieldValue);
|
|
}
|
|
else
|
|
{
|
|
tmpRow[model.FieldName] = topFieldValue;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
tmpRow[model.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
gridTable.OrderBy(this.BillModel.DetailOrderField);
|
|
|
|
if (tmpRow.Table.Columns.Contains(this.BillModel.DetailOrderField) && gridTable.Rows.Count == 0)
|
|
{
|
|
tmpRow[this.BillModel.DetailOrderField] = 1;
|
|
}
|
|
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
}
|
|
int ColumnIndex = this.gcMain.GridView.FocusedColumn.VisibleIndex;//焦点列的坐标
|
|
this.gcMain.GridView.FocusedRowHandle = _rowNumber + 1;
|
|
this.gcMain.GridView.FocusedColumn.VisibleIndex = ColumnIndex;
|
|
//this.gridView.OptionsNavigation.EnterMoveNextColumn = true;
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.GridView.OptionsNavigation.EnterMoveNextColumn = true;
|
|
}
|
|
}
|
|
}
|
|
/// <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_left_container.TabPages.Clear();
|
|
|
|
List<GridDetailModel> attachModels = GetAttachTabs();
|
|
|
|
DataTable masterTable = new DataTable();
|
|
DataTable detailTable = new DataTable();
|
|
if (ProcessExists)
|
|
{
|
|
masterTable = Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent();
|
|
detailTable = Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent();
|
|
}
|
|
else
|
|
{
|
|
Hashtable htTable = BillImpl.GetSources(this.SysModel.ModuleCode, this.BillModel.BillSourceIds);//获取单据来源
|
|
masterTable = htTable["master"] as DataTable;
|
|
detailTable = htTable["detail"] as DataTable;
|
|
}
|
|
|
|
/* 构造原理
|
|
* 1. 假如存在附加信息,则底部显示来源明细(来源明细摆放在标签第一个位置)+多标签,假如标签只有一个则隐藏标签头.
|
|
* 2. 假如不存在附加信息,则底部只显示来源明细.
|
|
**/
|
|
if (attachModels.Count > 0)
|
|
{
|
|
this.tb_buttom.Model = this.SysModel;
|
|
this.tb_buttom.InitTabPages(attachModels);
|
|
}
|
|
else
|
|
{
|
|
this.tb_buttom.TabControlObj.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
|
|
}
|
|
|
|
for (int i = 0; i < masterTable.Rows.Count; i++)
|
|
{
|
|
BillSourceModel model = new BillSourceModel(masterTable.Rows[i]);
|
|
BillSourceUnionModel unionModel = new BillSourceUnionModel();
|
|
DataTable controls = new DataTable();
|
|
if (ProcessExists)
|
|
{
|
|
controls = Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields();
|
|
}
|
|
else
|
|
{
|
|
controls = BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
|
}
|
|
|
|
XtraTabPage tabPage = new XtraTabPage();
|
|
tabPage.Text = model.UserName;
|
|
|
|
#region 加载快速添加
|
|
if (!string.IsNullOrWhiteSpace(model.CodeInputSql) && !string.IsNullOrWhiteSpace(model.CodeInputCaption))
|
|
{
|
|
ComboBoxEditModel editModel = new ComboBoxEditModel()
|
|
{
|
|
ValuemMeber = "id",
|
|
TextMember = "CodeInputCaption",
|
|
RowItem = masterTable.Rows[i],
|
|
SourceModel = model,
|
|
UnionModel = unionModel
|
|
};
|
|
this.cb_input.Properties.Items.Add(editModel);
|
|
}
|
|
#endregion
|
|
|
|
#region 加载来源表头
|
|
GridControlEx gridControl = null;
|
|
TreeViewEx treeView = null;
|
|
|
|
if (model.SourceType == 1)
|
|
{
|
|
// 来源为树类型
|
|
treeView = new TreeViewEx();
|
|
treeView.BorderStyle = BorderStyle.None;
|
|
treeView.Dock = DockStyle.Fill;
|
|
treeView.TreeNodeKeyField = model.SourceKeyField;
|
|
treeView.TreeNodeTextField = model.SourceResult;
|
|
treeView.BindTreeView(BillImpl.GetDataTableResult(model.SourceSql));
|
|
treeView.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter);
|
|
|
|
tabPage.Controls.Add(treeView);
|
|
}
|
|
else if (model.SourceType == 3 || model.SourceType == 4)
|
|
{
|
|
gridControl = new TreeGridControlEx();
|
|
gridControl.Dock = DockStyle.Fill;
|
|
gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
gridControl.Model = this.SysModel;
|
|
if (ProcessExists)
|
|
{
|
|
gridControl.SetReadOnlyColumns(Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent(), GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
|
gridControl.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRowColors());
|
|
gridControl.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.SysModel, OnGridControlRightCallback);
|
|
}
|
|
else
|
|
{
|
|
gridControl.SetReadOnlyColumns(BillImpl.GetSourceColumns(model.Id), GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
|
gridControl.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey));
|
|
gridControl.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey), this.SysModel, OnGridControlRightCallback);
|
|
}
|
|
unionModel.TreeGridControlObj = gridControl as TreeGridControlEx;
|
|
unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged);
|
|
|
|
tabPage.Controls.Add(gridControl);
|
|
}
|
|
else
|
|
{
|
|
// 来源为表格类型
|
|
gridControl = new GridControlEx();
|
|
gridControl.BorderStyle = BorderStyle.None;
|
|
gridControl.Model = this.SysModel;
|
|
gridControl.Dock = DockStyle.Fill;
|
|
if (ProcessExists)
|
|
{
|
|
gridControl.SetReadOnlyColumns(Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent(), GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
|
gridControl.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRowColors());
|
|
gridControl.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.SysModel, OnGridControlRightCallback);
|
|
}
|
|
else
|
|
{
|
|
gridControl.SetReadOnlyColumns(BillImpl.GetSourceColumns(model.Id), GridCustomColumnStruct.BillSourceGridView + model.FormKey);
|
|
gridControl.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey));
|
|
gridControl.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey), this.SysModel, OnGridControlRightCallback);
|
|
}
|
|
//gridControl.GridView.SelectionChanged += new SelectionChangedEventHandler(OnGridControlSelectionChanged);
|
|
//gridControl.GridView.FocusedRowObjectChanged += OnFocusedRowObjectChanged;
|
|
gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据
|
|
if (BillModel.IsBillSourceCheck == 1)
|
|
{
|
|
GridDragGrid.GridAddCheckBox(gridControl.GridView);
|
|
}
|
|
if (model.SourceType == 0)
|
|
{
|
|
GridDragGrid dragMainGrid = new GridDragGrid(gridControl.GridView, this.gcMain.GridView);
|
|
dragMainGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragMainGridCompleted);
|
|
}
|
|
|
|
tabPage.Controls.Add(gridControl);
|
|
}
|
|
#endregion
|
|
|
|
#region 加载来源明细
|
|
XtraTabPage tabDetail = new XtraTabPage();
|
|
|
|
DataRow[] detailColumns = detailTable.Select("sourceId=" + model.Id);
|
|
GridControlEx gridDetail = 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 (ProcessExists)
|
|
{
|
|
gridDetail.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRowColors());
|
|
gridDetail.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.SysModel, OnGridDetailRightMenuCallback);
|
|
}
|
|
else
|
|
{
|
|
gridDetail.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey));
|
|
gridDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey), this.SysModel, OnGridDetailRightMenuCallback);
|
|
}
|
|
if (BillModel.IsBillDetailCheck == 0)
|
|
{
|
|
gridDetail.GridView.DoubleClick += new EventHandler(OnGridDetailDoubleClick);
|
|
}
|
|
gridDetail.Parent = tabDetail;
|
|
gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
if (i == 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 + "-明细";
|
|
}
|
|
GridDragGrid dragDetailGrid = new GridDragGrid(gridDetail.GridView, this.gcMain.GridView);
|
|
dragDetailGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragDetailGridCompleted);
|
|
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;
|
|
//searchSql = ReplaceHelper.ReplaceParam(searchSql);
|
|
PanelControl searchPanel = new PanelControl();
|
|
MyControl searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView);
|
|
searchControl.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore);
|
|
searchControl.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd);
|
|
if (i == 0)
|
|
{
|
|
// 第一个页面要刷新数据,所以绑定事件用于初始化完成后在查询数据
|
|
searchControl.OnDataSourceBindCallBack += new EventHandler(OnFirstPageDataSourceBindCallBack);
|
|
}
|
|
|
|
searchControl.ParentUnionField = model.SourceKeyField;
|
|
|
|
searchPanel.Dock = DockStyle.Bottom;
|
|
searchPanel.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
searchPanel.BackColor = Color.Transparent;
|
|
searchPanel.Parent = tabPage;
|
|
searchPanel.Height = searchControl.InitSearchControl(controls, searchPanel);
|
|
unionModel.SearchObj = searchControl;
|
|
}
|
|
#endregion
|
|
|
|
unionModel.GridControlObj = gridControl;
|
|
unionModel.GridDetailControlObj = gridDetail;
|
|
unionModel.ModelObj = model;
|
|
unionModel.TreeViewObj = treeView;
|
|
if (i == 0)
|
|
unionModel.IsChange = true;
|
|
tabPage.Tag = unionModel;
|
|
if (model.SourceType == 0)
|
|
{
|
|
// 模块要查看具体条数
|
|
unionModel.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnPageDataSourceBindCallBack);
|
|
pageNumKey.Add(unionModel.SearchObj, tabPage);
|
|
}
|
|
this.xtc_left_container.TabPages.Add(tabPage);
|
|
}
|
|
if (this.cb_input.Properties.Items.Count > 0)
|
|
{
|
|
this.pl_input.Visible = true;
|
|
this.cb_input.SelectedIndex = 0;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:验证单据是否修改过</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void VerfyBillUpdated()
|
|
{
|
|
bool isUpdateDetailed = false;
|
|
DataTable table = this.gcMain.gridControl.DataSource as DataTable;
|
|
if (table != null && table.Rows.Count > 0)
|
|
{
|
|
DataRow updateRow = table.Rows.Cast<DataRow>().FirstOrDefault(x => x.RowState != DataRowState.Unchanged);
|
|
isUpdateDetailed = updateRow != null;
|
|
}
|
|
if (this.BillRowItem != null && (this.ControlObj.VerifyUpdated() || isUpdateDetailed))
|
|
{
|
|
bool isReadOnly2 = !string.IsNullOrEmpty(this.BillModel.ModifyCond) && !ReplaceHelper.ReplaceRowParamCond(this.BillRowItem, this.BillModel.ModifyCond);
|
|
if (!isReadOnly2)
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DataChanged, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
this.BillSave();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化单据按钮状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="isEdit">if set to <c>true</c> [is edit].</param>
|
|
private void SetBillStatus(DataRow rowItem)
|
|
{
|
|
if (this.BillModel.unableToSave.Contains(SysModel.UserName))
|
|
{
|
|
this.btnBillSave.Hide();
|
|
foreach (System.Windows.Forms.Control control in pl_main_bottom.Controls)
|
|
{
|
|
|
|
if (control.Location.X < btnBillSave.Location.X && control is DevExpress.XtraEditors.SimpleButton && control.Name != "btn_input")
|
|
{
|
|
control.Location = new Point(control.Location.X + btnBillSave.Width, control.Location.Y);
|
|
}
|
|
}
|
|
}
|
|
if (rowItem != null)
|
|
{
|
|
// 单据为修改状态,无需设置赋值时不需要计算面板属性
|
|
bool isReadOnly = !string.IsNullOrEmpty(this.BillModel.ModifyCond) && !ReplaceHelper.ReplaceRowParamCond(rowItem, this.BillModel.ModifyCond);
|
|
this.ControlObj.CanExecControl = false; // 单据为修改状态时,无需计算面板属性
|
|
this.lbTitle.Text = this.BillModel.TypeName + "(修改)";
|
|
this.lblOrderNo.Text = rowItem[this.BillModel.PrimaryKey] + "";
|
|
this.rdBlue.Checked = "0".Equals(rowItem[this.BillModel.RtagidKey] + "");
|
|
this.rdRed.Checked = "1".Equals(rowItem[this.BillModel.RtagidKey] + "");
|
|
this.BillModel.SaveState = true;
|
|
this.rdBlue.Enabled = this.rdRed.Enabled = false;
|
|
this._itemImport.Enabled = this._itemImportUpdate.Enabled = !isReadOnly;
|
|
this.ControlObj.SetReadOnlyAllControl(isReadOnly);
|
|
this.ControlObj.SetAllControlValue(rowItem);
|
|
this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = !isReadOnly;
|
|
this.ControlObj.CanExecControl = true;
|
|
this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = !isReadOnly;
|
|
this.BillRowItem = rowItem;
|
|
// 设置Brp模版
|
|
if (this.IsBrpTemplete)
|
|
{
|
|
this.SetTempleteSelectedValue(rowItem["brpId"] + "");
|
|
this.cb_templete.Enabled = !isReadOnly;
|
|
}
|
|
this.BillModel.PopupUnionCode = rdBlue.Checked ? rdBlueUnionCode : rdRedUnionCode;
|
|
this.btnFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode);
|
|
this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = rdBlue.Checked ? Color.Blue : Color.Red;
|
|
this.gcMain.GridView.OptionsBehavior.Editable = !isReadOnly;
|
|
this.gcMain.GridControl.DataSource = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, this.BillModel.DetailSql));
|
|
RefreshPrindMenu();
|
|
|
|
BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey);
|
|
if (userControl != null)
|
|
{
|
|
userControl.EditText = this.rdRed.Checked ? "1" : "0";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 单据为新增状态
|
|
this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true;
|
|
this.lbTitle.Text = this.BillModel.TypeName + "(新增)";
|
|
this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq);
|
|
this._itemImport.Enabled = this._itemImportUpdate.Enabled = true;
|
|
this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true;
|
|
this.cb_templete.Enabled = true;
|
|
this.BillModel.SaveState = false;
|
|
this.ControlObj.SetReadOnlyAllControl(false);
|
|
this.rdBlue.Enabled = this.rdRed.Enabled = true;
|
|
// 通过右键菜单打开单据,假如明细有数据则在初始化时使用传入数据.
|
|
this.gcMain.GridView.OptionsBehavior.Editable = true;
|
|
this.gcMain.GridControl.DataSource = BillImpl.GetDataTableResult(this.BillModel.DetailSql);
|
|
|
|
BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey);
|
|
if (userControl != null)
|
|
{
|
|
userControl.EditText = this.rdRed.Checked ? "1" : "0";
|
|
}
|
|
}
|
|
|
|
this._waterMark = new WaterMark(this.BillModel.MasterPreFix, rowItem);
|
|
this.lbTitle.Invalidate();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 切换红、蓝字单据
|
|
/// <summary>
|
|
/// <para>说明:点击蓝字单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-23 </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 OnBlueStateClick(object sender, EventArgs e)
|
|
{
|
|
this.rdRed.Checked = false;
|
|
this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Blue;
|
|
this.btnFP.Visible = !string.IsNullOrWhiteSpace(rdBlueUnionCode);
|
|
this.BillModel.PopupUnionCode = rdBlueUnionCode;
|
|
|
|
BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey);
|
|
if (userControl != null)
|
|
{
|
|
userControl.EditText = "0";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:点击红字单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-23 </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 OnRedStateClick(object sender, EventArgs e)
|
|
{
|
|
this.rdBlue.Checked = false;
|
|
this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Red;
|
|
this.btnFP.Visible = !string.IsNullOrWhiteSpace(rdRedUnionCode);
|
|
this.BillModel.PopupUnionCode = rdRedUnionCode;
|
|
|
|
BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey);
|
|
if (userControl != null)
|
|
{
|
|
userControl.EditText = "1";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 复制单据
|
|
/// <summary>
|
|
/// <para>说明:复制表头数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnCopyMasterItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true;
|
|
this.lbTitle.Text = this.BillModel.TypeName + "(新增)";
|
|
this.lbTitle.Invalidate();
|
|
this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq);
|
|
this.BillModel.SaveState = false;
|
|
this.rdBlue.Enabled = this.rdRed.Enabled = true;
|
|
this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true;
|
|
this._itemImport.Enabled = this._itemImportUpdate.Enabled = true;
|
|
this.cb_templete.Enabled = true;
|
|
this.ControlObj.CopyControlValue();
|
|
this.ControlObj.SetReadOnlyAllControl(false);
|
|
|
|
this.gcMain.GridControl.DataSourceTable().Clear();
|
|
this.gcMain.GridView.OptionsBehavior.Editable = true;
|
|
|
|
this._waterMark = new WaterMark(this.BillModel.MasterPreFix, null);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:复制整单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnCopyAllItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
this.btnFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true;
|
|
this.lbTitle.Text = this.BillModel.TypeName + "(新增)";
|
|
this.lbTitle.Invalidate();
|
|
this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq);
|
|
this.rdBlue.Enabled = this.rdRed.Enabled = true;
|
|
this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true;
|
|
this._itemImport.Enabled = this._itemImportUpdate.Enabled = true;
|
|
this.cb_templete.Enabled = true;
|
|
this.ControlObj.CopyControlValue();
|
|
this.ControlObj.SetReadOnlyAllControl(false);
|
|
this._waterMark = new WaterMark(this.BillModel.MasterPreFix, null);
|
|
if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows))
|
|
{
|
|
gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String));
|
|
}
|
|
// 处理单据明细
|
|
DataTable detailTable = this.gcMain.GridControl.DataSourceTable();
|
|
bool canCopy = false;
|
|
string defaultValue = string.Empty;
|
|
if (detailTable.Columns.Contains(this.BillModel.PrimaryDetailKey))
|
|
{
|
|
foreach (DataRow item in detailTable.Rows)
|
|
{
|
|
//根据后台列配置可否复制
|
|
if (_detailColumns.Columns.Contains("canCopy"))
|
|
{
|
|
int index = detailTable.Rows.IndexOf(item);
|
|
foreach (DataRow dr in _detailColumns.Rows)
|
|
{
|
|
canCopy = !string.IsNullOrEmpty(dr["canCopy"] + "") ? "1".Equals(dr["canCopy"] + "") : false;
|
|
if (!canCopy)
|
|
{
|
|
GridColumn column = this.gcMain.GridView.Columns.ColumnByFieldName(dr["fieldName"] + "");
|
|
defaultValue = this.ControlObj.ReplaceParentControlValue(dr["defaultdate"] + "");
|
|
defaultValue = BaseImpl.GetDefaultValue(defaultValue);
|
|
if (!string.IsNullOrEmpty(defaultValue))
|
|
{
|
|
this.gcMain.GridView.SetRowCellValue(index, column, defaultValue);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.GridView.SetRowCellValue(index, column, DBNull.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
item[this.BillModel.PrimaryDetailKey] = this.lblOrderNo.Text;
|
|
}
|
|
}
|
|
this.gcMain.GridView.OptionsBehavior.Editable = true;
|
|
this.BillModel.SaveState = false;
|
|
}
|
|
#endregion
|
|
|
|
#region Excel操作
|
|
/// <summary>
|
|
/// <para>说明:导出Excel</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnExportItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
this.gcMain.GridControl.ToExcel(this.SysModel.FormText);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:从Excel导入</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnImportItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
OpenFileDialog dialog = new OpenFileDialog();
|
|
dialog.Title = "选择导入文件";
|
|
dialog.Filter = "Excel文件(*.xls)|*.xls";
|
|
|
|
DialogResult result = dialog.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
string fileName = dialog.FileName;
|
|
string colFields = this.gcMain.GridView.Columns.ToString(',');
|
|
DataTable DataImportTable = this.gcMain.GridView.ToExcelDataTable(fileName, colFields, true, true);
|
|
DataTable NewTable = this.gcMain.GridControl.DataSourceTable();
|
|
GridColumnCollection gridColumns = this.gcMain.GridView.Columns;
|
|
foreach (DataRow rowItem in DataImportTable.Rows)
|
|
{
|
|
DataRow newRow = NewTable.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.BillModel.PrimaryKey)) continue;
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
if (model.DefaultValue.Contains("{#"))
|
|
{
|
|
fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue);
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
NewTable.Rows.Add(newRow);
|
|
}
|
|
this.gcMain.GridControl.DataSource = NewTable;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:导入Excel文件(更新)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnImportUpdateItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 常用工具
|
|
/// <summary>
|
|
/// <para>说明:验证可操作条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-07 </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 OnToolsClick(object sender, EventArgs e)
|
|
{
|
|
foreach (BarItemLink itemLink in pMenu.ItemLinks)
|
|
{
|
|
DataRow rowItem = itemLink.Item.Tag as DataRow;
|
|
if (rowItem != null)
|
|
{
|
|
string menuCond = rowItem["MenuCond"] + "";
|
|
string menuCaption = itemLink.Caption;
|
|
|
|
if (!string.IsNullOrEmpty(menuCond))
|
|
{
|
|
try
|
|
{
|
|
bool result = true;
|
|
menuCond = ReplaceHelper.ReplaceParamToValue(menuCond, "{" + this.BillModel.PrimaryKey + "}", this.lblOrderNo.Text.Trim());
|
|
|
|
if (menuCond.StartsWith("@") || menuCond.StartsWith("!"))
|
|
{
|
|
result = "1".Equals(BaseImpl.GetDefaultValue(menuCond));
|
|
}
|
|
else
|
|
{
|
|
menuCond = this.ControlObj.ReplaceControlValue(menuCond);
|
|
if (this.BillRowItem != null)
|
|
menuCond = ReplaceHelper.ReplaceRowParam(this.BillRowItem, menuCond);
|
|
menuCond = ReplaceHelper.ReplaceParamToValue(menuCond, "0"); // 未替换的参数所有替换为0
|
|
|
|
result = ReplaceHelper.EvalCond(menuCond);
|
|
}
|
|
itemLink.Item.Enabled = result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show("[" + menuCaption + "] " + ResourceKeys.SetRightMenuCondFault);
|
|
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>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnCommonItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
DataRow rowItem = e.Item.Tag as DataRow;
|
|
|
|
CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj);
|
|
menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
|
|
menu.Apply(rowItem);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:执行前单独替换BilldocumentId</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnMenuApplyBefore(ApplyArgs e)
|
|
{
|
|
string[] paramList = new string[e.MemuModel.ParamList.Count];
|
|
|
|
for (int i = 0; i < e.MemuModel.ParamList.Count; i++)
|
|
{
|
|
string item = e.MemuModel.ParamList[i];
|
|
List<string> condition = ReplaceHelper.GetParamFields(item);
|
|
foreach (string cond in condition)
|
|
{
|
|
string value = this.BillModel.PrimaryKey.Equals(cond.Replace("{", "").Replace("}", "").ToLower(), StringComparison.OrdinalIgnoreCase) ? this.lblOrderNo.Text.Trim() : cond;
|
|
item = item.Replace(cond, value); ;
|
|
}
|
|
paramList[i] = item;
|
|
}
|
|
e.MemuModel.ParamList = paramList.ToList();
|
|
}
|
|
#endregion
|
|
|
|
#region 打印模版
|
|
/// <summary>
|
|
/// <para>说明:打印完成需要参数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-07-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void GetPrintOtherParam()
|
|
{
|
|
//取得打印完成后的参数
|
|
if (!string.IsNullOrEmpty(this.BillModel.PrintSql) && this.BillModel.PrintSql.Contains("<<"))
|
|
{
|
|
string[] strs = this.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(';');
|
|
DataRow item = AttachImpl.GetSystemModule(str[0]);
|
|
string tableName = item["TableName"] + "";
|
|
string modetype = item["modType"] + "";
|
|
string comprefix = BaseImpl.GetColumnPrefix(tableName);
|
|
string primaryKey = modetype == "1" ? BaseImpl.GetBasePrimaryKey(str[0]) : comprefix + "billdocument_id";
|
|
//表名,列前缀,主键字段,主键值,模块编号,主打印Sql
|
|
_printSaveParams = new List<string>() { tableName, comprefix, primaryKey, str[1], str[0], _mainPrintSql };
|
|
|
|
//判断是否直接打印 modetype 区别单据和基础档案模块
|
|
switch (modetype)
|
|
{
|
|
case "1":
|
|
ModuleModel mode = new ModuleModel(MainImpl.GetSystemdllTab(str[0]));
|
|
if (mode != null) _isExcPrint = mode.PrintType == 3;
|
|
break;
|
|
case "2":
|
|
BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.GetPubAuditProperty(str[0]));
|
|
if (model != null) _isExcPrint = model.BillPrintType == 3;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:打印模版</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-27 </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="ItemClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPrintItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
string printFile = e.Item.Tag + "";
|
|
string printPath = PubUtil.PrintFileAbsolutelyPath;
|
|
|
|
if (!File.Exists(printPath))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundPrintFile);
|
|
return;
|
|
}
|
|
|
|
bool isPrint = this.BillModel.SaveState;
|
|
if (!isPrint)
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.BillNotSavedAndNotPrint, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
isPrint = this.BillSave();
|
|
}
|
|
|
|
if (isPrint)
|
|
{
|
|
try
|
|
{
|
|
// 判断是否满足打印条件
|
|
|
|
//DataRow masterRow = BillImpl.GetDataRowResult(this.BillModel.MasterSql.Replace("{" + this.BillModel.PrimaryKey + "}", this.lblOrderNo.Text));
|
|
DataRow masterRow = BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, this.lblOrderNo.Text));
|
|
if (masterRow == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DataNotFount);
|
|
return;
|
|
}
|
|
|
|
if (!ReplaceHelper.ReplaceRowParamCond(masterRow, this.BillModel.PrintCond))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisSatisfyPrintCond);
|
|
return;
|
|
}
|
|
|
|
string tmpSql = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql);
|
|
string tmpSql1 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql1);
|
|
string tmpSql2 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql2);
|
|
|
|
if (printFile.Contains(PrintUtil.TemplateFlag))
|
|
{
|
|
//主Sql
|
|
string mainSql = string.Empty;
|
|
List<string> tmpSqls = new List<string>();
|
|
if (_printSaveParams != null && _printSaveParams.Count > 0)
|
|
{
|
|
_printSaveParams[5] = mainSql = ReplaceHelper.ReplaceRowParam(masterRow, _mainPrintSql);
|
|
_printSaveParams[3] = masterRow.Table.Columns.Contains(_printSaveParams[2] + "") ? masterRow[_printSaveParams[2]] + "" : masterRow[BillModel.PrimaryKey] + "";
|
|
tmpSqls.Add(mainSql);
|
|
tmpSqls.Add(tmpSql1);
|
|
tmpSqls.AddRange(tmpSql2.Split(';').ToList());
|
|
}
|
|
PrintUtil.OnAfterPrint -= new EventHandler(OnReportPrintAfter);
|
|
PrintUtil.OnAfterPrint += new EventHandler(OnReportPrintAfter);
|
|
PrintUtil.FastReportPrint(tmpSqls, printFile, _isExcPrint);
|
|
}
|
|
else
|
|
{
|
|
DelphiHelper.LoadDelphiDll(printPath, printPath, printFile, tmpSql, tmpSql1, this.BillModel.PrintFileType, tmpSql2);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace);
|
|
LogUtil.WriteError(ResourceKeys.BillModule + "打印模板错误", ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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()
|
|
{
|
|
XtraTabPage tabPage = this.xtc_left_container.SelectedTabPage;
|
|
BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel;
|
|
if (model.GridControlObj != null) this.RefreshSource(model);
|
|
if (BillModel.drgFinishHide == "1") {
|
|
RemoveRowitem.Clear();
|
|
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);
|
|
}
|
|
this.RefreshSourceDetail(model);
|
|
|
|
}
|
|
if (model.ModelObj.SourceType == 0 && model.SearchObj.GridRowCount > 0) tabPage.Text = model.ModelObj.UserName + "(" + model.SearchObj.GridRowCount + "条)";
|
|
// 假如只有单据来源主表没有记录,则手动调用刷新明细.否则会通过选中行自动刷新明细
|
|
//if (model.GridControlObj != null && model.GridControlObj.DataRowCount() == 0)
|
|
//{
|
|
// this.RefreshSourceDetail(model);
|
|
//}
|
|
}
|
|
/// <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>创建日期:2018-08-16 </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 OnRefreshBillSource(object sender, EventArgs e)
|
|
{
|
|
XtraTabPage tabPage = this.xtc_left_container.SelectedTabPage;
|
|
|
|
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
|
if (unionModel.ModelObj.SourceType != 2)
|
|
{
|
|
IsBillMaster = false;
|
|
int Handle = 0;
|
|
string sql = ReplaceHelper.ReplaceUserInfo(unionModel.ModelObj.SourceSql);
|
|
if (unionModel.GridControlObj != null) Handle = unionModel.GridControlObj.GridView.FocusedRowHandle;
|
|
sql = sql.Replace("#", "");
|
|
List<string> paramList = ReplaceHelper.GetParamFields(sql);
|
|
if (unionModel.SearchObj != null)
|
|
{
|
|
sql = this.ControlObj.ReplaceControlValue(unionModel.SearchObj.SetSearchSqlValue(sql, true));
|
|
}
|
|
if (unionModel.GridControlObj != null)
|
|
{
|
|
unionModel.GridControlObj.gridControl.DataSource = BaseImpl.GetDataTableResult(sql);
|
|
RefreshSourceDetail(unionModel);
|
|
if (unionModel.GridControlObj != null)
|
|
{
|
|
unionModel.GridControlObj.GridView.SelectRowHandler(Handle);
|
|
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
|
}
|
|
}
|
|
if (unionModel.TreeViewObj != null)
|
|
{
|
|
if (unionModel.TreeViewObj.TreeView.SelectedNode == null) unionModel.TreeViewObj.TreeView.SelectedNode = unionModel.TreeViewObj.TreeView.Nodes[0];//选中
|
|
sql = ReplaceHelper.ReplaceUserInfo(ReplaceHelper.ReplaceWhereCond(unionModel.ModelObj.DetailSql));
|
|
sql = sql.Replace("#", "");
|
|
sql = this.ControlObj.ReplaceControlValue(sql);
|
|
sql = ReplaceHelper.ReplaceParamToValue(sql, unionModel.TreeViewObj.TreeView.SelectedNode.Name);
|
|
unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sql);
|
|
}
|
|
}
|
|
}
|
|
/// <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_left_container.SelectedTabPage;
|
|
|
|
if (unionModel.ModelObj.SourceType == 1)
|
|
{
|
|
// 树加载明细
|
|
string fieldName = this.lceCombobox.EditValue;
|
|
string fieldValue = this.textEdit1.Text.Trim();
|
|
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);
|
|
if (BillModel.drgFinishHide == "1")
|
|
{
|
|
DataTable finishHideTb = unionModel.GridDetailControlObj.GridControl.DataSourceTable();
|
|
foreach (DataRow drItem in RemoveRowitem)
|
|
{
|
|
if (finishHideTb.Select().Contains(drItem)) finishHideTb.Rows.Remove(drItem);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(BillModel.TypeName + "模块刷新树加载明细出错!", ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 加载明细
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
if (unionModel.ModelObj.SourceType == 3)
|
|
{
|
|
TreeListNode focusedNode = unionModel.TreeGridControlObj.TreeListObj.FocusedNode;
|
|
unionModel.GridDetailControlObj.GridControl.DataSource = focusedNode == null
|
|
? new DataTable() : BillImpl.GetDataTableResult(ReplaceHelper.ReplaceNodeParam(focusedNode, unionModel.ModelObj.DetailSql));
|
|
|
|
if (this._isLoadRightControlValue)
|
|
{
|
|
string masterSql = focusedNode == null ? BillModel.MasterSql.Replace("{" + BillModel.PrimaryKey + "}", this.lblOrderNo.Text) : ReplaceHelper.ReplaceNodeParam(focusedNode, BillModel.MasterSql);
|
|
// 加载单据信息
|
|
this.SetBillStatus(BillImpl.GetDataRowResult(masterSql));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow();
|
|
unionModel.GridDetailControlObj.GridControl.DataSource = rowItem == null
|
|
? new DataTable() : BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailSql));
|
|
|
|
|
|
DataTable 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 (unionModel.ModelObj.SourceType == 2 && this._isLoadRightControlValue)
|
|
{
|
|
string masterSql = rowItem == null ? BillModel.MasterSql.Replace("{" + BillModel.PrimaryKey + "}", this.lblOrderNo.Text) : ReplaceHelper.ReplaceRowParam(rowItem, BillModel.MasterSql);
|
|
// 加载单据信息
|
|
this.SetBillStatus(BillImpl.GetDataRowResult(masterSql));
|
|
}
|
|
}
|
|
if (BillModel.drgFinishHide=="1") {
|
|
DataTable finishHideTb = unionModel.GridDetailControlObj.GridControl.DataSourceTable();
|
|
//foreach (DataRow drItem in RemoveRowitem)
|
|
//{
|
|
// if (finishHideTb.Select().Contains(drItem)) finishHideTb.Rows.Remove(drItem);
|
|
//}
|
|
}
|
|
if (tb_buttom.TabControlObj.TabPages.Count > 0)
|
|
{
|
|
DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow();
|
|
if (unionModel.ModelObj.SourceType == 3 || unionModel.ModelObj.SourceType == 4)
|
|
{
|
|
rowItem = unionModel.TreeGridControlObj.GetViewFocusedDataRow();
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
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_left_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-12-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="fieldValue">The field value.</param>
|
|
protected virtual void SetUnionValue(GridColumnModel model, string fieldValue, DataRow rowItem)
|
|
{
|
|
DataTable table = this.gcMain.gridControl.DataSourceTable();
|
|
//DataRow rowItem = this.gridView.GetFocusedDataRow();
|
|
string unionValues = model.UnionValues;
|
|
if (rowItem != null && model != null)
|
|
{
|
|
if (this.ControlObj != null)
|
|
unionValues = this.ControlObj.ReplaceParentControlValue(unionValues);
|
|
unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue));
|
|
try
|
|
{
|
|
string[] fields = model.UnionFields.Trim(',').Split(',');
|
|
DataRow rowResult = BaseImpl.GetDataRowResult(unionValues);
|
|
if (rowResult != null)
|
|
{
|
|
for (int i = 0; i < fields.Length; i++)
|
|
{
|
|
string field = fields[i];
|
|
string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null;
|
|
rowItem[field] = value;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 设置为空
|
|
for (int i = 0; i < fields.Length; i++)
|
|
{
|
|
string field = fields[i];
|
|
rowItem[field] = DBNull.Value;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("计算列关联字段--错误-->" + unionValues, ex);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:禁用控件条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-01-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="fieldValue">The field value.</param>
|
|
protected virtual void SetDisableColumn(GridColumnModel model, string fieldValue, DataRow rowItem)
|
|
{
|
|
if (model.EnableCond != string.Empty)
|
|
{
|
|
List<GridColumnModel> columns = this.gcMain.ObjmControlList.FindAll(x => x.EnableCond.Contains("{" + model.FieldName + "}")).ToList();
|
|
foreach (GridColumnModel item in columns)
|
|
{
|
|
try
|
|
{
|
|
string disableCond = ReplaceHelper.ReplaceRowParam(rowItem, item.EnableCond.Replace("{" + model.FieldName + "}", fieldValue));
|
|
string diaableType = item.DisableType;
|
|
this.gcMain.GridView.Columns.ColumnByFieldName(model.FieldName).Visible = ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(disableCond)) + "", StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:计算列计算公式</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="fieldValue">The field value.</param>
|
|
protected virtual void SetCalcValue(GridColumnModel model, string fieldValue, DataRow rowItem)
|
|
{
|
|
try
|
|
{
|
|
DataTable table = this.gcMain.gridControl.DataSourceTable();
|
|
if (rowItem != null && model != null)
|
|
{
|
|
List<GridColumnModel> calcModels = this.gcMain.ObjmControlList.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr)).OrderBy(y => y.CalcOrder).ToList();
|
|
foreach (GridColumnModel gridModel in calcModels)
|
|
{
|
|
// 计算顺序小于当前控件则不计算
|
|
if (gridModel.CalcOrder < model.CalcOrder) continue;
|
|
|
|
if (!gridModel.FieldName.Equals(model.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
bool isTruncate = false;
|
|
string calcExpr = gridModel.CalcExpr;
|
|
if (calcExpr.StartsWith("@truncate:"))
|
|
{
|
|
calcExpr = calcExpr.Substring(10);
|
|
isTruncate = true;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (this.ControlObj != null)
|
|
calcExpr = ControlObj.ReplaceParentControlValue(calcExpr);
|
|
|
|
calcExpr = ReplaceHelper.ReplaceRowParam(rowItem, calcExpr);
|
|
//EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + ""
|
|
string result = EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + "";
|
|
if (isTruncate)
|
|
{
|
|
result += result.Contains(".") ? "0000000000" : ".0000000000";
|
|
rowItem[gridModel.FieldName] = result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1);
|
|
//this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1));
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
double d = 0;
|
|
if (!string.IsNullOrEmpty(result) &&
|
|
!"NaN".Equals(result, StringComparison.OrdinalIgnoreCase) &&
|
|
!"非数字".Equals(result, StringComparison.OrdinalIgnoreCase) &&
|
|
!"undefined".Equals(result, StringComparison.OrdinalIgnoreCase) &&
|
|
result != "∞" && result != "-∞" &&
|
|
!"正无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) &&
|
|
!"负无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) &&
|
|
double.TryParse(result, out d))
|
|
{
|
|
if (string.IsNullOrEmpty(gridModel.DataFormat))
|
|
{
|
|
result = Math.Round(Convert.ToDouble(d), model.Decimals, MidpointRounding.AwayFromZero) + "";
|
|
}
|
|
else
|
|
{
|
|
//计算后先执行保存小数位数
|
|
result = string.Format("{0:" + gridModel.DataFormat + "}", Convert.ToDecimal(result));
|
|
}
|
|
if (model.FieldType == 7 && result.Contains('%'))
|
|
{
|
|
result = (double.Parse(result.Replace("%", "")) * 0.01).ToString();
|
|
}
|
|
rowItem[gridModel.FieldName] = result;
|
|
// 判断计算列有无关联值
|
|
GridColumnModel UnionModel = calcModels.FirstOrDefault(x => x.FieldName == gridModel.FieldName);
|
|
if (!string.IsNullOrEmpty(UnionModel.UnionFields))
|
|
{
|
|
this.SetUnionValue(UnionModel, rowItem[gridModel.FieldName] + "", rowItem);
|
|
}
|
|
//this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("计算列计算公式--错误-->" + rowItem[gridModel.FieldName], ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
// MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加行到单据明细中</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <param name="unionModel">The union model.</param>
|
|
private void AddRowToGridView(DataRow rowItem)
|
|
{
|
|
GridColumnCollection gridColumns = this.gcMain.GridView.Columns;
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows))
|
|
{
|
|
gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String));
|
|
}
|
|
string repeatProduct = this.gcMain.GridView.Columns["ProductId"] != null && rowItem.Table.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId";
|
|
AssociatedField = repeatProduct;
|
|
if ("1".Equals(this.BillModel.DetailDoubleClickTip) && this.gcMain.GridView.Columns[repeatProduct] != null && rowItem.Table.Columns.Contains(repeatProduct))
|
|
{
|
|
// 需要提示编码重复
|
|
GridView view = this.gcMain.GridView;
|
|
bool result = (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0);
|
|
if (result)
|
|
{
|
|
DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo);
|
|
if (dialog != DialogResult.Yes)
|
|
return;
|
|
}
|
|
}
|
|
|
|
DataRow newRow = gridTable.NewRow();
|
|
//if (gridTable.Columns.Contains(guidField))
|
|
//{
|
|
// newRow[guidField] = Guid.NewGuid().ToString();
|
|
//}
|
|
int position = this.gcMain.GridView.FocusedRowHandle;
|
|
bool isLastRow = this.gcMain.GridView.IsLastVisibleRow;
|
|
this.gcMain.GridView.BeginDataUpdate();
|
|
GridView gridView = this.gcMain.GridView;
|
|
// 赋值明细字段
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
try
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 来源列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (col.FieldName.Contains("_Ls"))
|
|
{
|
|
string[] unioFielName = col.FieldName.Split('_');
|
|
string UnioValue = unioFielName[unioFielName.Length - 1];
|
|
DataColumn grid = rowItem.Table.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue));
|
|
if (grid != null && !string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
else
|
|
{
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
//int nowPositon = !isLastRow ? position : gridTable.Rows.Count - 1;
|
|
|
|
if (model.DefaultValue.Contains("{#"))
|
|
{
|
|
fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, fieldValue + "", newRow);
|
|
}
|
|
SetCalcValue(model, fieldValue + "", newRow);
|
|
//计算规则配置在结果字段上,所以无需验证当前操作控件
|
|
//this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue);
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, fieldValue + "", newRow);
|
|
}
|
|
SetCalcValue(model, fieldValue + "", newRow);
|
|
//this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue);
|
|
}
|
|
}
|
|
}
|
|
SetDisableColumn(model, newRow[col.FieldName] + "", newRow);
|
|
//GridColumnModel model = col.Tag as GridColumnModel;
|
|
if (model.LimitLength > 0)
|
|
{
|
|
DataRow HandleRow = newRow;
|
|
int MaxInputLength = System.Text.Encoding.Default.GetBytes(newRow[col.FieldName] + "").Length;
|
|
if (model.LimitLength < MaxInputLength)
|
|
HandleRow.SetColumnError(HandleRow.Table.Columns[col.ColumnHandle], "当前输入文本超过设定长度!");//满足条件设置错误信息
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(col.FieldName + "添加出错!", ex);
|
|
}
|
|
}
|
|
this.gcMain.GridView.EndDataUpdate();
|
|
if (!isLastRow)
|
|
{
|
|
// 插入数据行
|
|
gridTable.Rows.InsertAt(newRow, position);
|
|
this.gcMain.GridView.ClearSelection();
|
|
this.gcMain.GridView.SelectRowHandler(position);
|
|
}
|
|
else
|
|
{
|
|
// 添加数据行
|
|
gridTable.Rows.Add(newRow);
|
|
this.gcMain.GridView.ClearSelection();
|
|
this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1);
|
|
}
|
|
|
|
|
|
// 插入数据后
|
|
if (isLastRow)
|
|
{
|
|
this.gcMain.GridView.ClearSelection();
|
|
this.gcMain.GridView.SelectRowHandler(position + 1);
|
|
}
|
|
if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField))
|
|
{
|
|
DataRow[] rt = gridTable.Rows.Cast<DataRow>().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray();
|
|
foreach (DataRow item in rt)
|
|
{
|
|
if (newRow != null)
|
|
{
|
|
newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]);
|
|
}
|
|
this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(position + 1, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + ""));
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0)
|
|
{
|
|
gridTable.Rows.Remove(newRow);
|
|
MessageUtil.Show("数量已分配完毕!无需再进行拖拽!");
|
|
}
|
|
}
|
|
}
|
|
gridTable.OrderBy(this.BillModel.DetailOrderField);
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加多行到单据明细中</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <param name="unionModel">The union model.</param>
|
|
private void AddRowsToGridView(DataTable dataTable, BillSourceUnionModel unionModel)
|
|
{
|
|
WaitForm.ShowForm();
|
|
GridColumnCollection gridColumns = this.gcMain.GridView.Columns;
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows().Copy();
|
|
if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows))
|
|
{
|
|
gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String));
|
|
}
|
|
int position = this.gcMain.GridView.FocusedRowHandle;
|
|
bool isLastRow = this.gcMain.GridView.IsLastVisibleRow;
|
|
foreach (DataRow rowItem in dataTable.Rows)
|
|
{
|
|
if (unionModel == null || ValidateDetailCond(rowItem, unionModel))
|
|
{
|
|
string repeatProduct = this.gcMain.GridView.Columns["ProductId"] != null && dataTable.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId";
|
|
AssociatedField = repeatProduct;
|
|
if ("1".Equals(this.BillModel.DetailDoubleClickTip) && this.gcMain.GridView.Columns[repeatProduct] != null && dataTable.Columns.Contains(repeatProduct))
|
|
{
|
|
// 需要提示编码重复
|
|
GridView view = this.gcMain.GridView;
|
|
bool result = (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) |
|
|
(view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0);
|
|
if (result)
|
|
{
|
|
DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo);
|
|
if (dialog != DialogResult.Yes)
|
|
return;
|
|
}
|
|
}
|
|
DataRow newRow = gridTable.NewRow();
|
|
newRow.BeginEdit();
|
|
// 赋值明细字段
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
try
|
|
{
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
if (dataTable.Columns.Contains(col.FieldName))
|
|
{
|
|
// 来源列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[col.FieldName] + "", newRow);
|
|
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
if (col.FieldName.Contains("_Ls"))
|
|
{
|
|
string[] unioFielName = col.FieldName.Split('_');
|
|
string UnioValue = unioFielName[unioFielName.Length - 1];
|
|
DataColumn grid = dataTable.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue));
|
|
if (grid != null && !string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[col.FieldName] + "", newRow);
|
|
|
|
}
|
|
else
|
|
{
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
//int nowPositon = !isLastRow ? position : gridTable.Rows.Count - 1;
|
|
if (model.DefaultValue.Contains("{#"))
|
|
{
|
|
fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, fieldValue + "", newRow);
|
|
}
|
|
SetCalcValue(model, fieldValue + "", newRow);
|
|
|
|
//计算规则配置在结果字段上,所以无需验证当前操作控件
|
|
//this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue);
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, fieldValue + "", newRow);
|
|
}
|
|
SetCalcValue(model, fieldValue + "", newRow);
|
|
|
|
//this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue);
|
|
}
|
|
}
|
|
}
|
|
SetDisableColumn(model, newRow[col.FieldName] + "", newRow);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(col.FieldName + "添加出错!", ex);
|
|
}
|
|
}
|
|
newRow.EndEdit();
|
|
if (!isLastRow)
|
|
{
|
|
// 插入数据行
|
|
gridTable.Rows.InsertAt(newRow, position);
|
|
//this.gcMain.GridView.ClearSelection();
|
|
//this.gcMain.GridView.SelectRowHandler(position);
|
|
}
|
|
else
|
|
{
|
|
// 添加数据行
|
|
gridTable.Rows.Add(newRow);
|
|
// this.gcMain.GridView.ClearSelection();
|
|
// this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1);
|
|
}
|
|
position++;
|
|
//if (isLastRow)
|
|
//{
|
|
// this.gcMain.GridView.ClearSelection();
|
|
// this.gcMain.GridView.SelectRowHandler(position + 1);
|
|
//}
|
|
if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField))
|
|
{
|
|
DataRow[] rt = gridTable.Rows.Cast<DataRow>().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray();
|
|
foreach (DataRow item in rt)
|
|
{
|
|
if (newRow != null)
|
|
{
|
|
newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]);
|
|
}
|
|
this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(position + 1, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + ""));
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0)
|
|
{
|
|
gridTable.Rows.Remove(newRow);
|
|
MessageUtil.Show("数量已分配完毕!无需再进行拖拽!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.gcMain.GridControl.DataSource = gridTable;
|
|
if (position >= 0)
|
|
this.gcMain.GridView.SelectRowHandler(position);
|
|
else
|
|
this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1);
|
|
//this.gcMain.GridView.SelectRowHandler(position);
|
|
gridTable.OrderBy(this.BillModel.DetailOrderField);
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
WaitForm.HideForm();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查添加数据到表格中是否包含
|
|
/// </para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <param name="unionModel">The union model.</param>
|
|
/// <param name="onlyPopup">if set to <c>true</c> [only popup].</param>
|
|
private void AddRowToGridViewByBom(DataRow rowItem, BillSourceUnionModel unionModel, ref bool onlyPopup)
|
|
{
|
|
if (!string.IsNullOrEmpty(unionModel.ModelObj.BomSql))
|
|
{
|
|
string bomSql = unionModel.ModelObj.BomSql;
|
|
// 检查是否有bom配置
|
|
if (unionModel.ModelObj.LoadBom == 1)
|
|
{
|
|
// 自动带出bom数据,不弹出选择
|
|
DataTable table = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, bomSql));
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
this.AddRowToGridView(item);
|
|
}
|
|
}
|
|
else if (unionModel.ModelObj.LoadBom == 2)
|
|
{
|
|
DataTable table = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, bomSql));
|
|
|
|
if (!onlyPopup && table.Rows.Count > 0)
|
|
{
|
|
// 自动带出bom数据,弹出选择
|
|
FrmBomSelect frmSelect = new FrmBomSelect();
|
|
frmSelect.Caption = unionModel.ModelObj.BomCaption;
|
|
frmSelect.GridColumns = unionModel.GridDetailControlObj.GridView.Columns;
|
|
frmSelect.BomDataTable = table;
|
|
|
|
DialogResult result = frmSelect.ShowDialog();
|
|
onlyPopup = frmSelect.OnlyPopup;
|
|
|
|
if (result == DialogResult.OK && frmSelect.SelectBomRows != null && frmSelect.SelectBomRows.Length > 0)
|
|
{
|
|
foreach (DataRow item in frmSelect.SelectBomRows)
|
|
{
|
|
this.AddRowToGridView(item);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
this.AddRowToGridView(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加多条数据到单据明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void AddMultiRowToGridView(DataRow[] rowItems)
|
|
{
|
|
bool onlyPopup = false;
|
|
this.isDragWrap = false;//用于设置拖拽时不允许扫码控件换行
|
|
XtraTabPage tabPage = this.xtc_left_container.SelectedTabPage;
|
|
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
|
if (unionModel != null)
|
|
{
|
|
bool onlyOne = true;
|
|
DataTable dt = unionModel.GridDetailControlObj.GridControl.DataSourceTable();
|
|
|
|
for (int i = 0; i < rowItems.Length; i++)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
DataRow rowItem = rowItems[i]; //unionModel.GridDetailControlObj.GridView.GetDataRow(selectedRows[i]);
|
|
// 检查当前记录是否满足条件
|
|
if (ValidateDetailCond(rowItem, unionModel))
|
|
{
|
|
this.AddRowToGridView(rowItem);
|
|
this.AddRowToGridViewByBom(rowItem, unionModel, ref onlyPopup);
|
|
|
|
if (unionModel.GridDetailControlObj != null)
|
|
{
|
|
dr.ItemArray= rowItem.ItemArray;
|
|
unionModel.GridDetailControlObj.GridControl.DataSourceTable().Rows.Remove(rowItem);
|
|
RemoveRowitem.Add(dr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (onlyOne)
|
|
{
|
|
onlyOne = false;
|
|
if (!string.IsNullOrEmpty(unionModel.ModelObj.DetailEnableMsg))
|
|
{
|
|
if (unionModel.ModelObj.DetailEnableMsg.StartsWith("select", StringComparison.OrdinalIgnoreCase) ||
|
|
unionModel.ModelObj.DetailEnableMsg.StartsWith("exec", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
MessageUtil.Show(BaseImpl.GetResult(unionModel.ModelObj.DetailEnableMsg) + "");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(unionModel.ModelObj.DetailEnableMsg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.isDragWrap = true;//用于设置拖拽时不允许扫码控件换行
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加多条数据到单据明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-05-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
private void AddMultiRowToGridView(DataTable table, BillSourceUnionModel unionModel = null)
|
|
{
|
|
if (table == null) return;
|
|
this.AddRowsToGridView(table, unionModel);
|
|
Application.DoEvents();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:是否允许添加明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if this instance [can add detail row]; otherwise, <c>false</c>.</returns>
|
|
private bool CanAddDetailRow()
|
|
{
|
|
// 检测是否正在筛选数据
|
|
if (!string.IsNullOrEmpty(gcMain.GridView.FindFilterText.Trim()) ||
|
|
!string.IsNullOrEmpty(gcMain.GridView.FilterPanelText.Trim()))
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.GridViewSearching, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
this.gcMain.GridView.FindFilterText = "";
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
// 检测是否点击了排序表格
|
|
if (this.gcMain.GridView.HasSortColumn())
|
|
{
|
|
//if (MessageUtil.Show(ResourceKeys.GridViewColumnSorting, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
//{
|
|
this.gcMain.GridView.Columns.ClearAllSort();
|
|
// return true;
|
|
//}
|
|
//return false;
|
|
}
|
|
// 检测是否为提交或者终审模块
|
|
if (_waterMark.Text.Contains("已终审"))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AddBillDetailed);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:单据明细撤回操作</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnToWithdraw(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Control && e.KeyCode == Keys.Z)
|
|
{
|
|
if (ToWithdrawRows.Count < 1) return;
|
|
DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows();
|
|
foreach (int key in ToWithdrawRows.Keys)
|
|
{
|
|
DataRow dr = gridTable.NewRow();
|
|
dr.ItemArray = ToWithdrawRows[key].ItemArray;
|
|
gridTable.Rows.InsertAt(dr, key);
|
|
this.gcMain.GridView.ClearSelection();
|
|
this.gcMain.GridView.SelectRowHandler(key);
|
|
}
|
|
gridTable.OrderBy(this.BillModel.DetailOrderField);
|
|
ToWithdrawRows.Clear();
|
|
}
|
|
}
|
|
|
|
/// <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);
|
|
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_left_container.SelectedTabPage;
|
|
BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel;
|
|
if (model.ModelObj.SourceType == 2 && this._isLoadRightControlValue)
|
|
{
|
|
DataRow rowItem = null;
|
|
if (model.GridControlObj.DataRowCount() > 0)
|
|
{
|
|
DataRow selectRow = model.GridControlObj.GridView.GetFocusedDataRow();
|
|
rowItem = BillImpl.GetDataRowResult(ReplaceHelper.ReplaceRowParam(selectRow, BillModel.MasterSql));
|
|
}
|
|
// 加载单据信息
|
|
this.SetBillStatus(rowItem);
|
|
if (rowItem == null)
|
|
{
|
|
this.ControlObj.ResetControlValue();
|
|
}
|
|
}
|
|
}
|
|
/// <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_left_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>();
|
|
if (ProcessExists)
|
|
{
|
|
DataTable table = Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseDetailPages();
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = Lskj.Data.Caches.CacheSYSConfig.Instance().GetReportDetailColumns(item["formKey"] + "");//获取报表明细列
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BillSourceDetailAttachGridView));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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>创建日期:2017-12-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="parmaryValue">The parmary value.</param>
|
|
/// <returns>System.String.</returns>
|
|
private string GetAddRecord(ref string parmaryValue)
|
|
{
|
|
if (BillModel.NewVer == 0)
|
|
{
|
|
// 检查当前的单据号是否已被占用.
|
|
string newBillNo = BillImpl.GetBillNo(this.BillModel.BillSeq);
|
|
|
|
if (!parmaryValue.Equals(newBillNo))
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.BillRecordRepeat, MessageBoxButtons.YesNo) == DialogResult.No)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
else
|
|
{
|
|
this.lblOrderNo.Text = newBillNo;
|
|
parmaryValue = newBillNo;
|
|
}
|
|
}
|
|
}
|
|
|
|
StringBuilder fieldBuilder = new StringBuilder();
|
|
StringBuilder valueBuilder = new StringBuilder();
|
|
|
|
DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.MasterTable));
|
|
|
|
|
|
foreach (ControlModel model in this.ControlObj.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
model.FieldName.Equals(BillModel.PrimaryKey, StringComparison.OrdinalIgnoreCase) ||
|
|
model.FieldName.Equals(BillModel.RtagidKey, StringComparison.OrdinalIgnoreCase) ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx)
|
|
continue;
|
|
|
|
string fieldValue = this.ControlObj.GetControlValue(model);
|
|
if (fieldValue == "****") continue;
|
|
|
|
fieldBuilder.Append(model.FieldName + ",");
|
|
valueBuilder.Append(string.IsNullOrEmpty(fieldValue) ? this.ControlObj.GetNullValue(model) : string.Format("'{0}',", fieldValue));
|
|
|
|
SaveErrorMessage = SaveErrorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, fieldValue);
|
|
|
|
}
|
|
// 增加主键
|
|
fieldBuilder.Append(BillModel.PrimaryKey);
|
|
valueBuilder.Append("'" + parmaryValue + "'");
|
|
// 增加红蓝字单标记
|
|
fieldBuilder.Append("," + BillModel.RtagidKey);
|
|
valueBuilder.Append(",'" + (rdRed.Checked ? 1 : 0) + "'");
|
|
|
|
return string.Format("insert into {0}({1}) values ({2})", BillModel.MasterTable, fieldBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(','));
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取修改表头数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="parmaryValue">单据值.</param>
|
|
/// <returns>System.String.</returns>
|
|
private string GetUpdateRecord(string parmaryValue)
|
|
{
|
|
StringBuilder updateBuilder = new StringBuilder();
|
|
|
|
|
|
DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.MasterTable));
|
|
|
|
|
|
// 修改单据
|
|
foreach (ControlModel model in this.ControlObj.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
model.FieldName.Equals(BillModel.RtagidKey, StringComparison.OrdinalIgnoreCase) ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx)
|
|
continue;
|
|
|
|
BaseUserControl userControl = this.ControlObj.FindControl(model);
|
|
if (userControl != null)
|
|
{
|
|
string fieldValue = this.ControlObj.GetControlValue(model);
|
|
if (fieldValue == "****") continue;
|
|
|
|
updateBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0}={1}", model.FieldName, this.ControlObj.GetNullValue(model)) : string.Format("{0}='{1}',", model.FieldName, fieldValue.Contains("'") ? fieldValue.Replace("'", "''") : fieldValue));
|
|
SaveErrorMessage = SaveErrorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, fieldValue);
|
|
}
|
|
|
|
}
|
|
return string.Format("update {0} set {1} where {2}='{3}'", BillModel.MasterTable, updateBuilder.ToString().TrimEnd(','), BillModel.PrimaryKey, parmaryValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取保存明细数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
private StringBuilder GetDetailRecord(string guid, string billNo)
|
|
{
|
|
// 构造明细
|
|
StringBuilder detailBuilder = new StringBuilder();
|
|
DataTable detailTable = this.gcMain.GridControl.DataSourceTable().TrimDeleteRows();
|
|
DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.DetailTable + "_temp"));//单据明细性表
|
|
|
|
|
|
if (detailTable.Rows.Count > 0)
|
|
{
|
|
DataTable BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModel.DetailTable));
|
|
DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModel.DetailTable + "_temp"));
|
|
foreach (DataRow dataRow in detailTable.Rows)
|
|
{
|
|
StringBuilder fields = new StringBuilder();
|
|
StringBuilder values = new StringBuilder();
|
|
string detailSql = @"insert into " + BillModel.DetailTable + "_temp" + "({0}) values({1})";
|
|
fields.Append("sysstr,");
|
|
values.Append("'" + guid + "',");
|
|
|
|
foreach (DataColumn item in BillColumns.Columns)
|
|
{
|
|
//GridColumn col = this.gcMain.GridView.VisibleColumns.OfType<GridColumn>().FirstOrDefault(x => x.FieldName == item.ColumnName);
|
|
//if (col == null)
|
|
//{
|
|
// continue;
|
|
//}
|
|
if (item.ColumnName.Equals(guidField) || item.ColumnName.Equals(mRecordPrimaryField) || item.ColumnName.Equals(ERPInfo.Instance.isAddRows)) continue;
|
|
if (!BillTempColumns.Columns.Contains(item.ColumnName))
|
|
{
|
|
string type = "varchar(50)";
|
|
if (item.DataType == typeof(DateTime))
|
|
{
|
|
type = "datetime";
|
|
}
|
|
BaseImpl.ExecSqlValue(string.Format("alter table {0} add {1} {2}", BillModel.DetailTable + "_temp", item.ColumnName, type));
|
|
}
|
|
fields.Append(item.ColumnName + ",");
|
|
string fieldValue = dataRow.Table.Columns.Contains(item.ColumnName) ? dataRow[item.ColumnName] + "" : string.Empty;
|
|
if (item.ColumnName.Equals(BillModel.PrimaryDetailKey, StringComparison.OrdinalIgnoreCase))
|
|
fieldValue = billNo;
|
|
if (!string.IsNullOrWhiteSpace(fieldValue))
|
|
{
|
|
values.Append(item.DataType == typeof(DateTime) ? "'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : fieldValue.Contains("'") ? "'" + fieldValue.Replace("'", "''") + "'," : "'" + fieldValue + "',");
|
|
}
|
|
else
|
|
{
|
|
if (item.DataType == typeof(Decimal) ||
|
|
item.DataType == typeof(Double) ||
|
|
item.DataType == typeof(Int16) ||
|
|
item.DataType == typeof(Int32) ||
|
|
item.DataType == typeof(Int64))
|
|
values.Append("0,");
|
|
else if (item.DataType == typeof(DateTime))
|
|
values.Append("NULL,");
|
|
else
|
|
values.Append("'',");
|
|
}
|
|
|
|
SaveErrorMessage = SaveErrorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(_detailColumns,DetailedProperties, dataRow, item, fieldValue);
|
|
}
|
|
detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(','));
|
|
}
|
|
}
|
|
return detailBuilder;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="comfirm">是否继续执行(0.1).</param>
|
|
/// <param name="canTipMsg">是否显示成功提示信息</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
private bool BillSave(int comfirm = 0, bool canTipMsg = true)
|
|
{
|
|
bool saveResult = false;
|
|
if (this.ControlObj.VerifyNull())
|
|
{
|
|
// 保存之前先进行表格更新
|
|
this.gcMain.GridView.PostEditor();
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
try
|
|
{
|
|
if (this.gcMain.VerifyNull())
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.DataSaving);
|
|
string billNo = this.lblOrderNo.Text.Trim();
|
|
string detailGuid = Guid.NewGuid().ToString();
|
|
|
|
string masterSql = BillModel.SaveState ? GetUpdateRecord(billNo) : GetAddRecord(ref billNo);
|
|
string detailSql = GetDetailRecord(detailGuid, billNo).ToString();
|
|
|
|
// 检查单据头数据合法性
|
|
if (string.IsNullOrEmpty(masterSql)) return false;
|
|
|
|
// 验证明细合法性
|
|
if (string.IsNullOrEmpty(detailSql) && !this.BillModel.SaveNullDetail)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.BillDetailIsNotNull);
|
|
return false;
|
|
}
|
|
|
|
|
|
string tipMsg = string.Empty;
|
|
|
|
int result = BillImpl.BillSave(masterSql, detailSql, BillModel.DetailTable, ref billNo, detailGuid, BillModel.BillSeq, BillModel.SaveState ? 2 : 1, comfirm, out tipMsg, 0, this.BillModel.NewVer);
|
|
switch (result)
|
|
{
|
|
case 1:
|
|
// 保存成功
|
|
if (canTipMsg) MessageUtil.Show(BillModel.TypeName + ResourceKeys.SaveSuccess);
|
|
#region 单据保存成功调用Api接口
|
|
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataChange, this.SysModel.ModuleCode, 0))
|
|
{
|
|
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, billNo, BillModel.PrimaryKey, BillModel.MasterTable, 0);
|
|
switch (BillModel.SaveState)
|
|
{
|
|
case false:
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Add);//添加
|
|
break;
|
|
case true:
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Update);//更新
|
|
break;
|
|
}
|
|
if (!string.IsNullOrEmpty(apiHelper.apiResutMsg) && canTipMsg)
|
|
MessageUtil.Show(apiHelper.apiResutMsg);
|
|
}
|
|
#endregion
|
|
this.lblOrderNo.Text = billNo;
|
|
this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo)));
|
|
saveResult = true;
|
|
SaveRefreshSource();
|
|
|
|
RefreshPrindMenu();
|
|
break;
|
|
case 9:
|
|
// 继续执行保存
|
|
if (string.IsNullOrWhiteSpace(tipMsg)) tipMsg = "保存单据临时表失败";
|
|
if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
this.BillSave(1, canTipMsg);
|
|
saveResult = true;
|
|
break;
|
|
default:
|
|
// 保存失败
|
|
//MessageUtil.Show(BillModel.TypeName + ResourceKeys.SaveFault + "\r\n" + tipMsg);
|
|
SaveErrorMessage = SaveErrorMessage + "\r\n" + "出错原因:\r\n" + tipMsg;
|
|
MessageUtil.Show(BillModel.TypeName + ResourceKeys.SaveFault + "\r\n" + SaveErrorMessage);
|
|
SaveErrorMessage = string.Empty;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(SaveErrorMessage))
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("保存单据失败!\r\n" + SaveErrorMessage);
|
|
}
|
|
SaveErrorMessage = string.Empty;
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("保存单据失败!", ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
return saveResult;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:通过配置条件刷新打印菜单</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="hintMsg">The hint MSG.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
public void RefreshPrindMenu()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(BillModel.BillPrintTag))
|
|
{
|
|
pMprint.ClearLinks();
|
|
// 打印模版
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(this.gcMain.GridView.FocusedRowHandle);
|
|
string BillPrintTag = this.ControlObj.ReplaceParentControlValue(BillModel.BillPrintTag);
|
|
BillPrintTag = ReplaceHelper.ReplaceRowParam(rowItem, BillPrintTag);
|
|
// BillPrintTag = ReplaceHelper.ReplaceParamToValue(BillPrintTag,this.lblOrderNo.Text.Trim());
|
|
string value = MainImpl.GetResult(ReplaceHelper.ReplaceRowParam(rowItem, BillPrintTag)) + "";
|
|
string[] files = value.Split('|');
|
|
for (int i = 0; i < files.Length; i++)
|
|
{
|
|
string fileName = files[i];
|
|
if (!string.IsNullOrWhiteSpace(fileName))
|
|
{
|
|
BarButtonItem itemPrint = new BarButtonItem();
|
|
int index = i + 1;
|
|
itemPrint.Caption = files[i].Replace(".rmf", "").Replace(".frx", "");
|
|
itemPrint.Tag = files[i];
|
|
itemPrint.ItemClick += new ItemClickEventHandler(OnPrintItemClick);
|
|
pMprint.AddItem(itemPrint);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据提交</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="hintMsg">The hint MSG.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
private void BillApply(string hintMsg, int comfirm = 0)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.Handing);
|
|
string tipMsg = string.Empty;
|
|
string billNo = this.lblOrderNo.Text.Trim();
|
|
|
|
|
|
int result = BillImpl.BillApply(this.SysModel.ModuleCode, billNo, "", 1, out tipMsg, comfirm);
|
|
WaitForm.HideForm();
|
|
switch (result)
|
|
{
|
|
case 1:
|
|
// 提交成功
|
|
MessageUtil.Show(BillModel.TypeName + ResourceKeys.ApplySuccess);
|
|
this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo)));
|
|
this.RefreshSource(GetBillSourceManager());
|
|
this.RefreshSelectedSource();
|
|
|
|
if (this.BillModel.ApplyRefresh)
|
|
{
|
|
this.SetBillStatus(null);
|
|
this.ControlObj.ResetControlValue();
|
|
}
|
|
|
|
#region 提交审核成功后调用API
|
|
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleAuditStateChange, this.SysModel.ModuleCode, 0))
|
|
{
|
|
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, billNo, this.BillModel.PrimaryKey, this.BillModel.MasterTable, 0);
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleAuditStateChange, Interface.Api.ActionType.Audit);//审核
|
|
if (!string.IsNullOrEmpty(apiHelper.apiResutMsg))
|
|
MessageUtil.Show(apiHelper.apiResutMsg);
|
|
}
|
|
#endregion
|
|
// 推送消息
|
|
PushHelper push = new PushHelper(billNo, "0", this.SysModel.ModuleCode, "", "", 0);
|
|
push.Push_Bill_Oper_Message();
|
|
break;
|
|
case 9:
|
|
// 继续执行保存
|
|
if (string.IsNullOrWhiteSpace(tipMsg)) tipMsg = "提交单据失败";
|
|
if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
this.BillApply("", 1);
|
|
break;
|
|
case 99:
|
|
// 继续执行提交
|
|
if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
FrmPrompt prompt = new FrmPrompt(tipMsg);
|
|
prompt.Size = new Size(300, 200);
|
|
|
|
DialogResult dialog = prompt.ShowDialog();
|
|
if (dialog == DialogResult.OK)
|
|
{
|
|
this.BillApply(prompt.PromptMsg);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
// 提交失败
|
|
MessageUtil.Show(BillModel.TypeName + ResourceKeys.ApplyFault + "\r\n" + tipMsg);
|
|
break;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 事件相关
|
|
/// <summary>
|
|
/// <para>说明:点击空白界面后需要获取焦点</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-09-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnMainFocusAfter(object sender, EventArgs e)
|
|
{
|
|
this.pl_main_center_master.Focus();
|
|
}
|
|
/// <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.Left)
|
|
this.ssc_main_top.Collapsed = true;
|
|
if (e.KeyCode == Keys.Right)
|
|
this.ssc_main_top.Collapsed = false;
|
|
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_left_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);
|
|
sqlValue = ReplaceHelper.ReplaceParamToValue(sqlValue, e.Node.Name);
|
|
|
|
unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue);
|
|
//if (BillModel.drgFinishHide == "1")
|
|
//{
|
|
// DataTable finishHideTb = unionModel.GridDetailControlObj.GridControl.DataSourceTable();
|
|
//foreach (DataRow drItem in RemoveRowitem)
|
|
//{
|
|
// if (finishHideTb.Select().Contains(drItem)) finishHideTb.Rows.Remove(drItem);
|
|
// //IEqualityComparer<DataRow> comparer = DataRowComparer.Default;
|
|
// //foreach (DataRow dr in finishHideTb.Select())
|
|
// //{
|
|
// // if (comparer.Equals(drItem, dr)) finishHideTb.Rows.Remove(dr);
|
|
// //}
|
|
//}
|
|
//并集
|
|
//IEnumerable<DataRow> QBJ = finishHideTb.Select().AsEnumerable().Union(RemoveRowitem.AsEnumerable(), DataRowComparer.Default);
|
|
//交集
|
|
//IEnumerable<DataRow> QJJ = finishHideTb.Select().AsEnumerable().Intersect(RemoveRowitem.AsEnumerable(), DataRowComparer.Default);
|
|
//差集
|
|
//IEnumerable<DataRow> QCJ = finishHideTb.Select().AsEnumerable().Except(RemoveRowitem.AsEnumerable(), DataRowComparer.Default);
|
|
//try
|
|
//{
|
|
// DataTable jg = QCJ.CopyToDataTable();
|
|
// unionModel.GridDetailControlObj.GridControl.DataSource = jg;
|
|
//}
|
|
//catch (System.InvalidOperationException ex) //如果差集为null,就回进当前报错
|
|
//{
|
|
// unionModel.GridDetailControlObj.GridControl.DataSource = null;
|
|
//}
|
|
//}
|
|
}
|
|
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)
|
|
{
|
|
BillSourceUnionModel unionModel = e.Page.Tag as BillSourceUnionModel;
|
|
if (unionModel != null)
|
|
{
|
|
this.RefreshSelectedSource();
|
|
this.tb_buttom.TabControlObj.TabPages[0].Controls.Clear();
|
|
this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailControlObj);
|
|
this.tb_buttom.TabControlObj.TabPages[0].Text = unionModel.ModelObj.UserName + "-明细";
|
|
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_left_container.SelectedTabPage;
|
|
|
|
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
|
}
|
|
/// <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);
|
|
DataTable dt = MainImpl.GetDataTableResult(searchSql);
|
|
if (dt.Rows.Count > 0) tabPage.Text += "(" + dt.Rows.Count + "条)";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("单据条件绑定失败失败!", ex);
|
|
}
|
|
}
|
|
/// <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_left_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_left_container.SelectedTabPage;
|
|
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
|
|
|
this.RefreshSourceDetail(unionModel);
|
|
|
|
}
|
|
/// <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>
|
|
/// <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 = this.gcMain.GridView.GetFocusedDataRow();
|
|
int i = 0;
|
|
foreach (XtraTabPage page in this.tb_buttom.TabControlObj.TabPages)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
i++;
|
|
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 = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
ModuleWebView webView = tabPage.Tag as ModuleWebView;
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
webView.Navigate(ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(url)));
|
|
}
|
|
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();
|
|
tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)";
|
|
}
|
|
}
|
|
}
|
|
else if (rowItem != null && tabPage.Tag is TabMultipledetails)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
|
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
|
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
|
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
|
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
|
DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
|
grdExMain.LastSearchSql = searchMainSql;
|
|
grdExAdditional.LastSearchSql = searchAddSql;
|
|
grdExMain.SetGridViewDataSource(firstTable);
|
|
tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
|
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
|
}
|
|
}
|
|
/// <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_left_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_left_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="EventArgs"/> instance containing the event data.</param>
|
|
private void OnGridDetailDoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (this.CanAddDetailRow())
|
|
{
|
|
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
|
|
XtraTabPage tabPage = this.xtc_left_container.SelectedTabPage;
|
|
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
|
DataRow rowItem = unionModel.GridDetailControlObj.GridView.GetFocusedDataRow();
|
|
this.AddMultiRowToGridView(new DataRow[] { rowItem });
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据明细点击加载tab数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-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="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i < this.tb_buttom.TabControlObj.TabPages.Count; i++)
|
|
{
|
|
XtraTabPage tabPage = this.tb_buttom.TabControlObj.TabPages[i];
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
GridDetailModel model = this.tb_buttom.GetGridDetailModel(tabPage);
|
|
|
|
if (rowItem != null && tabPage != null)
|
|
{
|
|
string searchSql = ReplaceHelper.ReplaceRowParam(rowItem, model.DetailSql);
|
|
this.tb_buttom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据空行新增时初始化默认值</para>
|
|
/// <para>创建人:dl</para>
|
|
/// <para>创建日期:2019-01-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
private void OnGridViewInitNewRow(object sender, InitNewRowEventArgs e)
|
|
{
|
|
InitNewRowMethod(sender);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-02 </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 OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
string billNo = this.lblOrderNo.Text.Trim();
|
|
this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo)));
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:重绘单据水印</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-04 </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="PaintEventArgs"/> instance containing the event data.</param>
|
|
private void OnLabelTitlePaint(object sender, PaintEventArgs e)
|
|
{
|
|
if (this._waterMark != null)
|
|
{
|
|
GraphicsText graphicsText = new GraphicsText();
|
|
graphicsText.Graphics = e.Graphics;
|
|
|
|
// 绘制围绕点旋转的文本
|
|
StringFormat format = new StringFormat();
|
|
format.Alignment = StringAlignment.Center;
|
|
format.LineAlignment = StringAlignment.Center;
|
|
|
|
// 绘制单据状态文本
|
|
if (!string.IsNullOrEmpty(this._waterMark.Text))
|
|
{
|
|
graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(50, 21), format, -15f);
|
|
|
|
e.Graphics.TranslateTransform(0, 0);
|
|
e.Graphics.RotateTransform(-15f);
|
|
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(14, 20, 55, 21));
|
|
}
|
|
|
|
// 绘制打印次数文本
|
|
e.Graphics.ResetTransform();
|
|
if (!string.IsNullOrEmpty(this._waterMark.Print))
|
|
{
|
|
graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 70), 21), format, -15f);
|
|
|
|
e.Graphics.TranslateTransform(this.lbTitle.Width - 70, 21);
|
|
e.Graphics.RotateTransform(-15f);
|
|
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-35, -14, 70, 21));
|
|
}
|
|
|
|
// 绘制收款文本
|
|
e.Graphics.ResetTransform();
|
|
if (!string.IsNullOrEmpty(this._waterMark.Collect))
|
|
{
|
|
graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 170), 21), format, -15f);
|
|
|
|
e.Graphics.TranslateTransform(this.lbTitle.Width - 100, 21);
|
|
e.Graphics.RotateTransform(-15f);
|
|
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-100, -32, 55, 21));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据来源拖动数据到单据明细表格后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-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 OnDragDetailGridCompleted(object sender, GridDragGridArgs e)
|
|
{
|
|
DataRow[] dragRows = e.GridViewSelectRows;
|
|
if (dragRows != null && dragRows.Length > 0)
|
|
{
|
|
this.AddMultiRowToGridView(dragRows);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据来源表格拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-21 </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 OnDragMainGridCompleted(object sender, GridDragGridArgs e)
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0) return;
|
|
|
|
try
|
|
{
|
|
if (this.CanAddDetailRow())
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
XtraTabPage tabPage = this.xtc_left_container.SelectedTabPage;
|
|
BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel;
|
|
int FocuseIndex = e.SourceGridViewObj.FocusedRowHandle;
|
|
int[] rows = e.SourceGridViewObj.GetSelectedRows();
|
|
foreach (int rowIndex in rows)
|
|
{
|
|
// 拖动多行,所以明细数据改为动态查询
|
|
DataRow rowItem = e.SourceGridViewObj.GetDataRow(rowIndex);
|
|
this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel);
|
|
DataTable details = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailSql));
|
|
if (unionModel.GridDetailControlObj.GridView != null && rowIndex == FocuseIndex) details = unionModel.GridDetailControlObj.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
//details = GetGridViewFilteredAndSortedDataToDataTable(unionModel.GridDetailControlObj.GridView);
|
|
//DataTable details = unionModel.GridDetailControlObj.GridView.DataController.GetAllFilteredAndSortedRows().OfType<DataRow>().CopyToDataTable();
|
|
this.ControlObj.SetAllControlValue(rowItem, true);
|
|
|
|
if (unionModel.ModelObj.CadDragDetail)
|
|
{
|
|
this.AddMultiRowToGridView(details, unionModel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("单据来源表格拖拽完出错!", ex);
|
|
MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:新增单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-14 </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 OnBillAddClick(object sender, EventArgs e)
|
|
{
|
|
if (!this.BillModel.SaveState && this.gcMain.DataRowCount() > 0)
|
|
{
|
|
DialogResult result = MessageUtil.Show(("数据未保存,是否确定新建单据?"), MessageBoxButtons.YesNo);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
this.SetBillStatus(null);
|
|
this.ControlObj.ResetControlValue();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.SetBillStatus(null);
|
|
this.ControlObj.ResetControlValue();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除明细记录</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-05 </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 OnDeleteClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] rows = this.gcMain.GridView.GetSelectedRows();
|
|
|
|
|
|
if (rows.Length < 1)
|
|
return;
|
|
DataTable dt = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
if (string.IsNullOrEmpty(BillModel.DeleteDetailCond))
|
|
{
|
|
DialogResult result = MessageUtil.Show(string.Format(ResourceKeys.DeleteRows, rows.Length), MessageBoxButtons.YesNo);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
//保存删除的行和对应的行号
|
|
ToWithdrawRows.Clear();
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]);
|
|
DataRow dr = dt.NewRow();
|
|
dr.ItemArray = rowItem.ItemArray;
|
|
ToWithdrawRows.Add(rows[i], dr);
|
|
}
|
|
|
|
////获得要删除RemoveRowitem中的内容的关联字段
|
|
//List<string> deleteRowslist = new List<string>();
|
|
//foreach (int rowIndex in rows)
|
|
//{
|
|
// DataRow rowItem = this.gcMain.GridView.GetDataRow(rowIndex);
|
|
// deleteRowslist.Add(rowItem[AssociatedField].ToString());
|
|
//}
|
|
////删除RemoveRowitem中的内容
|
|
//foreach (string key in deleteRowslist) {
|
|
// //RemoveRowitem.Remove();
|
|
// //DataRow i = (DataRow)RemoveRowitem.Cast<DataRow>().Where(x => x[AssociatedField].ToString().Equals(key));
|
|
// for (int i=0;i< RemoveRowitem.Count;i++) {
|
|
// string removeKey = RemoveRowitem[i][AssociatedField].ToString();
|
|
// if (removeKey.Equals(key)) {
|
|
// RemoveRowitem.RemoveAt(i);
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
|
|
|
|
this.gcMain.GridView.Columns.ClearAllSort();
|
|
this.gcMain.GridView.DeleteSelectedRows();
|
|
this.gcMain.GridView.ClearSelection();
|
|
this.gcMain.GridView.SelectRow(this.gcMain.GridView.FocusedRowHandle);
|
|
this.gcMain.GridControl.DataSourceTable().OrderBy(this.BillModel.DetailOrderField);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string successMsg = string.Empty, faultMsg = string.Empty;
|
|
string deleteCond = this.ControlObj.ReplaceParentControlValue(BillModel.DeleteDetailCond);
|
|
List<DataRow> deleteRows = new List<DataRow>();
|
|
List<int> faultInts = new List<int>();
|
|
//删除RemoveRowitem中的内容的关联字段
|
|
//List<string> deleteRowslist = new List<string>();
|
|
ToWithdrawRows.Clear();//清空上一次记录的删除行
|
|
|
|
foreach (int rowIndex in rows)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetDataRow(rowIndex);
|
|
|
|
string deleteCond2 = ReplaceHelper.ReplaceRowParam(rowItem, deleteCond);
|
|
|
|
if (ReplaceHelper.EvalCond(deleteCond2))
|
|
{
|
|
deleteRows.Add(rowItem);
|
|
//deleteRowslist.Add(rowItem[AssociatedField].ToString());
|
|
DataRow dr = dt.NewRow();
|
|
dr.ItemArray = rowItem.ItemArray;
|
|
ToWithdrawRows.Add(rowIndex, dr);
|
|
}
|
|
else
|
|
{
|
|
faultInts.Add(rowIndex);
|
|
}
|
|
}
|
|
|
|
DataTable table = this.gcMain.GridControl.DataSourceTable();
|
|
foreach (DataRow item in deleteRows)
|
|
{
|
|
table.Rows.Remove(item);
|
|
}
|
|
|
|
//删除RemoveRowitem中的内容
|
|
//foreach (string key in deleteRowslist)
|
|
//{
|
|
// for (int i = 0; i < RemoveRowitem.Count; i++)
|
|
// {
|
|
// string removeKey = RemoveRowitem[i][AssociatedField].ToString();
|
|
// if (removeKey.Equals(key))
|
|
// {
|
|
// RemoveRowitem.RemoveAt(i);
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
if (faultInts != null && faultInts.Count > 0)
|
|
{
|
|
MessageUtil.Show("发现如下:" + string.Join(",", faultInts.ToArray()) + "行不满足条件无法删除!");
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("删除成功!");
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:单据保存</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-07 </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 OnBillSaveClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.BillSave())
|
|
{
|
|
ToWithdrawRows.Clear();
|
|
this.RefreshSelectedSource();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据保存提交</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-07 </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 OnBillApplyClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DialogResult result = MessageUtil.Show(ResourceKeys.BillApply, MessageBoxButtons.YesNo);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
if (this.BillSave(0, false))
|
|
{
|
|
ToWithdrawRows.Clear();
|
|
this.BillApply("");
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
/// <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 OnTopSplitterMoved(object sender, EventArgs e)
|
|
{
|
|
if (this._isInitFinish)// 是否为初始化创建
|
|
{
|
|
IniHelper.Write(string.Format("bill_width_{0}", this.SysModel.ModuleCode), this.ssc_main_top.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 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 sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
private void OnSearchBefore(object sender, SearchArgs e)
|
|
{
|
|
|
|
// 用户搜索时不加载右侧控件值,只有点击、人为选中行在加载右侧控件值.
|
|
this._isLoadRightControlValue = false;
|
|
XtraTabPage tabPage = this.xtc_left_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_left_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 = this.ControlObj.ReplaceControlValue(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);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
sql = this.ControlObj.ReplaceControlValue(sql);
|
|
unionModel.GridControlObj.gridControl.DataSource = BaseImpl.GetDataTableResult(sql);
|
|
if (unionModel.ModelObj.SourceType == 0 && unionModel.SearchObj.GridRowCount > 0) tabPage.Text = unionModel.ModelObj.UserName + "(" + unionModel.SearchObj.GridRowCount + "条)";
|
|
|
|
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;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:帮助文档</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2020-01-15 </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 OnHelpClick(object sender, EventArgs e)
|
|
{
|
|
WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, this.BillModel.TypeName);
|
|
}
|
|
|
|
|
|
FrmBaseSelect frmSelect = new FrmBaseSelect();
|
|
/// <summary>
|
|
/// <para>说明:分配明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2020-01-15 </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 OnBtnFPClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (rowItem == null)
|
|
{
|
|
MessageUtil.Show("请先选择一条明细在进行分配!");
|
|
return;
|
|
}
|
|
|
|
DataTable table = this.gcMain.GridControl.DataSource as DataTable;
|
|
if (!table.Columns.Contains(guidField))
|
|
{
|
|
table.Columns.Add(guidField, typeof(String));
|
|
}
|
|
rowItem[guidField] = Guid.NewGuid().ToString(); ;
|
|
if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField))
|
|
{
|
|
// 检查数据是否为分配后的行
|
|
if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + ""))
|
|
{
|
|
MessageUtil.Show("该行数据为已分配后的数据,无需分配!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" };
|
|
DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args);
|
|
frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain);
|
|
//if (frmSelect.SelectRowItem == null)
|
|
//{
|
|
// frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain);
|
|
//}
|
|
|
|
frmSelect.Text = this.BillModel.TypeName;
|
|
frmSelect.SelectRowItem = rowItem;
|
|
bool isNextOne = false;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(mRecordPrimaryField))
|
|
{
|
|
frmSelect.FpRows = table.Rows.Cast<DataRow>().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray();
|
|
if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0)
|
|
{
|
|
List<DataRow> rows = frmSelect.FpRows.ToList();
|
|
rows.Remove(rowItem);
|
|
frmSelect.FpRows = rows.ToArray();
|
|
}
|
|
if (table.Columns.Contains(mRecordPrimaryField))
|
|
{
|
|
frmSelect.FpOtherRows = table.Rows.Cast<DataRow>().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray();
|
|
}
|
|
}
|
|
if (frmSelect.ShowDialog() == DialogResult.OK && frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0)
|
|
{
|
|
//if (frmSelect.isNextOne)
|
|
//{
|
|
// isNextOne = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// isNextOne = false;
|
|
//}
|
|
// 增加标识列
|
|
if (!table.Columns.Contains(frmSelect.RecordPrimaryField))
|
|
{
|
|
this.mRecordPrimaryField = frmSelect.RecordPrimaryField;
|
|
table.Columns.Add(this.mRecordPrimaryField, typeof(String));
|
|
}
|
|
|
|
foreach (DataRow item in frmSelect.SelectedRows)
|
|
{
|
|
DataRow newRow = table.NewRow();
|
|
newRow.ItemArray = rowItem.ItemArray;
|
|
newRow[guidField] = rowItem[guidField];
|
|
|
|
foreach (DataColumn col in item.Table.Columns)
|
|
{
|
|
if (table.Columns.Contains(col.ColumnName))
|
|
{
|
|
newRow[col.ColumnName] = item[col.ColumnName];
|
|
}
|
|
}
|
|
newRow[frmSelect.AmountField] = item[frmSelect.AmountField];
|
|
newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField];
|
|
table.Rows.Add(newRow);
|
|
}
|
|
NumberMc = frmSelect.AmountField;
|
|
//double syAmount = frmSelect.GetSyAmount();
|
|
//if (syAmount > 0)
|
|
//{
|
|
// rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount();
|
|
//}
|
|
//else
|
|
//{
|
|
// table.Rows.Remove(rowItem);
|
|
//}
|
|
table.Rows.Remove(rowItem);
|
|
// 重排顺序
|
|
table.OrderBy(this.BillModel.DetailOrderField);
|
|
this.gcMain.GridView.UpdateCurrentRow();
|
|
this.gcMain.GridView.ShowEditor();
|
|
}
|
|
if (frmSelect.isNextOne)
|
|
{
|
|
int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex();
|
|
DataRow[] a = table.Rows.Cast<DataRow>().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray();
|
|
if (a.Length != 0)
|
|
{
|
|
this.gcMain.GridView.FocusedRowHandle = SourceRowIndex;
|
|
OnBtnFPClick(sender, e);
|
|
}
|
|
else {
|
|
MessageUtil.Show("全部分配完毕");
|
|
// frmSelect.SelectRowItem = null;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
|
|
}
|
|
private void cb_templete_QueryCloseUp(object sender, CancelEventArgs e)
|
|
{
|
|
this.SetTempSelect(true);
|
|
}
|
|
#endregion
|
|
|
|
#region 单据快速录入相关
|
|
/// <summary>
|
|
/// <para>说明:快速录入明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-08-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InputGridView()
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
string inputText = txt_input.Text.Trim();
|
|
ComboBoxEditModel editObj = cb_input.SelectedItem as ComboBoxEditModel;
|
|
|
|
if (string.IsNullOrWhiteSpace(inputText))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.KeyWordNotNull);
|
|
return;
|
|
}
|
|
if (editObj != null)
|
|
{
|
|
DataTable table = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceSearchControlCond(editObj.SourceModel.CodeInputSql, inputText));
|
|
if (table.Rows.Count == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundKeyWord);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
bool onlyPopup = false;
|
|
foreach (DataRow rowItem in table.Rows)
|
|
{
|
|
this.AddRowToGridView(rowItem);
|
|
this.AddRowToGridViewByBom(rowItem, editObj.UnionModel, ref onlyPopup);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
LogUtil.WriteError("单据快速录入明细出错!", ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据快速录入</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-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 OnInputClick(object sender, EventArgs e)
|
|
{
|
|
this.InputGridView();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-08-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
|
private void OnInputKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.InputGridView();
|
|
this.txt_input.EditValue = "";
|
|
this.txt_input.Focus();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 单据模版录入相关
|
|
private void SetTempSelect(bool isTip)
|
|
{
|
|
ComboBoxEditModel model = this.cb_templete.SelectedItem as ComboBoxEditModel;
|
|
|
|
if (model != null)
|
|
{
|
|
bool isExec = true;
|
|
DataTable detailTable = gcMain.GridControl.DataSourceTable();
|
|
if (detailTable != null && detailTable.Rows.Count > 0 && isTip)
|
|
{
|
|
DialogResult result = XtraMessageBox.Show("确定要切换模版?\r\n注:切换模版会清空明细数据.", "系统提示", MessageBoxButtons.YesNo);
|
|
isExec = result == DialogResult.Yes;
|
|
}
|
|
if (isExec)
|
|
{
|
|
if (isExec)
|
|
{
|
|
string title = model.RowItem["rpname"] + "";
|
|
string brpId = model.RowItem["id"] + "";
|
|
|
|
// 设置标题
|
|
this.Parent.Text = title;
|
|
// 清空明细
|
|
detailTable.Clear();
|
|
|
|
// 设置主表固定字段
|
|
LabelTextEdit textEdit = this.ControlObj.FindControl("brpid") as LabelTextEdit;
|
|
if (textEdit == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFountBrpID);
|
|
return;
|
|
}
|
|
textEdit.EditText = brpId;
|
|
|
|
// 重新设置明细列
|
|
DataTable columns = BillImpl.GetBillDetailBrpColumns(brpId);
|
|
if (columns != null && columns.Rows.Count > 0)
|
|
gcMain.SetEditColumns(columns);
|
|
else
|
|
gcMain.GridView.Columns.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化Brp模版</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeTemplete()
|
|
{
|
|
DataTable table = BillImpl.GetBillBrp(this.SysModel.ModuleCode);
|
|
List<ComboBoxEditModel> tempModels = new List<ComboBoxEditModel>();
|
|
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
ComboBoxEditModel editModel = new ComboBoxEditModel()
|
|
{
|
|
ValuemMeber = "id",
|
|
TextMember = "RpName",
|
|
RowItem = item
|
|
};
|
|
this.cb_templete.Properties.Items.Add(editModel);
|
|
tempModels.Add(editModel);
|
|
}
|
|
this.cb_templete.Tag = tempModels;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置Brp模版</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetTempleteSelectedValue(string id)
|
|
{
|
|
List<ComboBoxEditModel> tempModels = this.cb_templete.Tag as List<ComboBoxEditModel>;
|
|
if (tempModels != null)
|
|
{
|
|
ComboBoxEditModel model = tempModels.Find(x => id.Equals(x.RowItem[x.ValuemMeber] + ""));
|
|
if (model == null)
|
|
gcMain.GridView.Columns.Clear();
|
|
else
|
|
{
|
|
this.cb_templete.SelectedItem = model;
|
|
this.SetTempSelect(false);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:手动选择模版</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-23 </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 OnTempleteClick(object sender, EventArgs e)
|
|
{
|
|
this._isSelectedTemplete = true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:单据选中/取消选中数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2020-05-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void OnGridViewIsCheckClick(object sender, RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = (sender as GridView).GetFocusedDataRow();
|
|
if (rowItem != null && e.Column.FieldName == "_check")
|
|
{
|
|
rowItem["_check"] = "True".Equals(rowItem["_check"] + "") ? 0 : 1;
|
|
rowItem.AcceptChanges();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |