3652 lines
169 KiB
C#
3652 lines
169 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Business;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraBars;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.PubAccraditation2;
|
|
using System.Threading;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using DevExpress.Utils;
|
|
using Lskj.Core;
|
|
using System.Diagnostics;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class AuditPanel2 : UserControl
|
|
{
|
|
private readonly AltButtonShortcutManager mAltButtonShortcuts =
|
|
new AltButtonShortcutManager();
|
|
|
|
public AuditPanel2()
|
|
{
|
|
InitializeComponent();
|
|
InitializeAltButtonShortcuts();
|
|
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
|
|
}
|
|
|
|
private void InitializeAltButtonShortcuts()
|
|
{
|
|
mAltButtonShortcuts.Register(btnClose, Keys.Q);
|
|
mAltButtonShortcuts.Register(btnBack, Keys.N);
|
|
mAltButtonShortcuts.Register(btnSave, Keys.S);
|
|
mAltButtonShortcuts.Register(btnAccradit, Keys.Y);
|
|
mAltButtonShortcuts.Register(btnSpare, Keys.P);
|
|
mAltButtonShortcuts.Register(btnReflash, Keys.R);
|
|
mAltButtonShortcuts.Register(btnSearch, Keys.Q);
|
|
mAltButtonShortcuts.Register(btnBackTop, Keys.W);
|
|
}
|
|
|
|
protected override bool ProcessCmdKey(
|
|
ref System.Windows.Forms.Message msg, Keys keyData)
|
|
{
|
|
return mAltButtonShortcuts.ProcessKey(keyData) ||
|
|
base.ProcessCmdKey(ref msg, keyData);
|
|
}
|
|
|
|
#region 公有变量
|
|
public string modelkeyName = "";
|
|
/// <summary>
|
|
/// 是否完成界面加载
|
|
/// </summary>
|
|
public bool isFinish;
|
|
/// <summary>
|
|
/// 是否是单据审核
|
|
/// </summary>
|
|
public bool isBillFlag;
|
|
/// <summary>
|
|
/// 确认用户
|
|
/// </summary>
|
|
public string ConfirmOpers = "";
|
|
/// <summary>
|
|
/// 提醒用户
|
|
/// </summary>
|
|
public string RemindOpers = "";
|
|
/// <summary>
|
|
/// 单据前缀
|
|
/// </summary>
|
|
public string TmpPrefix = string.Empty;
|
|
/// <summary>
|
|
/// 单据结构明细
|
|
/// </summary>
|
|
public AccraditationModel AuditModelObj;
|
|
/// <summary>
|
|
/// 单据模型
|
|
/// </summary>
|
|
public BillAuditModel BillModelObj;
|
|
/// <summary>
|
|
/// 基础档案模型
|
|
/// </summary>
|
|
public BaseAuditModel ModuleModelObj;
|
|
/// <summary>
|
|
/// 单据审批表模型
|
|
/// </summary>
|
|
public BillAuditCommonModel BillAuditComObj;
|
|
/// <summary>
|
|
/// 基础审批模型
|
|
/// </summary>
|
|
public BaseAccraditationModel BaseAccraditModelObj;
|
|
|
|
private DynamicPubAccraditionPopModel _sysModel;
|
|
/// <summary>
|
|
/// 单据入口参数模型
|
|
/// </summary>
|
|
public DynamicPubAccraditionPopModel SysModel
|
|
{
|
|
get
|
|
{
|
|
return _sysModel;
|
|
}
|
|
set
|
|
{
|
|
_sysModel = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 主表控件
|
|
/// </summary>
|
|
public MyControl ControlObj;
|
|
/// <summary>
|
|
/// 已完成表格
|
|
/// </summary>
|
|
/// <value>The finish grid object.</value>
|
|
public GridControlEx FinishGridObj { get { return this.gridFinish; } }
|
|
/// <summary>
|
|
/// tabpages集合
|
|
/// </summary>
|
|
private List<TabPageObj> _tabPageObjs = new List<TabPageObj>();
|
|
/// <summary>
|
|
/// <para>说明:审批表格双击弹出模块审批回调</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public event EventHandler RefreshTabCallBack;
|
|
public event BtnSearchGridFinishEventHandler OnBtnSearchCallBack;
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// 表格列头颜色
|
|
/// </summary>
|
|
protected string HeaderColor = "#A0A0A0";
|
|
/// <summary>
|
|
/// 必填颜色
|
|
/// </summary>
|
|
protected Color RequiredForceColor = string.IsNullOrEmpty(SystemInfo.Instance.ControlRequiredColor) ? Color.Blue : ColorTranslator.FromHtml(SystemInfo.Instance.ControlRequiredColor);
|
|
/// <summary>
|
|
/// 调用动态链接库默认传递参数
|
|
/// </summary>
|
|
public DynamicModel DynamicsyModel { get; private set; }
|
|
/// <summary>
|
|
/// 审批公用模型
|
|
/// </summary>
|
|
public AuditCommonModel AuditComModelObj;
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string KeyValue;
|
|
/// <summary>
|
|
/// 默认查询框
|
|
/// </summary>
|
|
public bool PanelCondVisible;
|
|
/// <summary>
|
|
/// 分段审批
|
|
/// </summary>
|
|
public DataRow SectionAccradit;
|
|
/// <summary>
|
|
/// 辅助功能按钮菜单集合
|
|
/// </summary>
|
|
public List<SimpleButton> itemCommonList = new List<SimpleButton>();
|
|
#region 私有变量
|
|
/// <summary>
|
|
/// 数量名称
|
|
/// </summary>
|
|
public string NumberMc;
|
|
/// <summary>
|
|
/// 主键字段
|
|
/// </summary>
|
|
private string mRecordPrimaryField;
|
|
private string guidField = "xxxxx_guid";
|
|
/// <summary>
|
|
/// 自定义搜索控件
|
|
/// </summary>
|
|
private MyControl _searchContrl;
|
|
/// <summary>
|
|
/// id(推送记录)
|
|
/// </summary>
|
|
private int _beforeId;
|
|
/// <summary>
|
|
/// 是否初始化完成
|
|
/// </summary>
|
|
private bool _isInitFinish;
|
|
/// <summary>
|
|
/// 意见
|
|
/// </summary>
|
|
private string _auditAdvice;
|
|
/// <summary>
|
|
/// 菜单模块名(推送记录)
|
|
/// </summary>
|
|
private string _beforeMenuName;
|
|
/// <summary>
|
|
/// 用户(推送记录)
|
|
/// </summary>
|
|
private string _beforeUsers;
|
|
/// <summary>
|
|
/// 单据类别值
|
|
/// </summary>
|
|
private string _mainBillTypeValue;
|
|
/// <summary>
|
|
/// 单据信息
|
|
/// </summary>
|
|
private DataRow _drBillInfoMsg;
|
|
/// <summary>
|
|
/// 明细数据
|
|
/// </summary>
|
|
private DataTable _dtSourceData;
|
|
/// <summary>
|
|
/// 单据类别
|
|
/// </summary>
|
|
private DataTable _dtBillType;
|
|
/// <summary>
|
|
/// 单据明细列表
|
|
/// </summary>
|
|
private DataTable _dtBillAttachList;
|
|
/// <summary>
|
|
/// 单据billInfo
|
|
/// </summary>
|
|
private DataTable _dtBillInfoFiled;
|
|
/// <summary>
|
|
/// 分单数据
|
|
/// </summary>
|
|
private DataTable _dtSpareSourceData;
|
|
/// <summary>
|
|
/// 审批流转模型
|
|
/// </summary>
|
|
private FlowTypeStepModel _flowTypeStepModel;
|
|
/// <summary>
|
|
/// 单据水印
|
|
/// </summary>
|
|
private WaterMark _waterMark;
|
|
/// <summary>
|
|
/// 是否在存储过程获得数据
|
|
/// </summary>
|
|
private bool ProcessExists;
|
|
/// <summary>
|
|
/// 明细必须填字段
|
|
/// </summary>
|
|
private List<string> DetailsRequired = new List<string>();
|
|
/// <summary>
|
|
/// 打印完成后添加数据用到的参数
|
|
/// </summary>
|
|
private List<string> _printSaveParams;
|
|
/// <summary>
|
|
/// 主打印Sql
|
|
/// </summary>
|
|
private string _mainPrintSql;
|
|
/// <summary>
|
|
/// 打印主sql中关联打印次数返回条件
|
|
/// </summary>
|
|
private string _printModeCond;
|
|
/// <summary>
|
|
/// 是否直接打印
|
|
/// </summary>
|
|
private bool _isExcPrint;
|
|
|
|
#region 初始化系统配置
|
|
/// <summary>
|
|
/// <para>说明:初始化系统配置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitializeSetting(AuditCommonModel auditComModel, DynamicModel model, BaseAccraditationModel baseAccraditModel, bool isBillFlag = true)
|
|
{ //BillComModelObj SysModel BaseAccraditModelObj
|
|
try
|
|
{
|
|
ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
|
|
this.isBillFlag = isBillFlag;
|
|
this.AuditComModelObj = auditComModel;
|
|
this.modelkeyName = AuditComModelObj.Moduletype == "bill" ? GridCustomColumnStruct.AuditMainGridView : GridCustomColumnStruct.BaseAuditMainGridView;
|
|
this.DynamicsyModel = model;
|
|
this.BaseAccraditModelObj = baseAccraditModel;
|
|
this.labeltxt_dataFlag.LabelText = this.AuditComModelObj.DataFlagLabel;
|
|
DataTable tabPages = new DataTable();
|
|
if (ProcessExists)
|
|
{
|
|
tabPages = Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent();
|
|
}
|
|
else
|
|
{
|
|
tabPages = BaseAuditImpl.GetTabPages(this.DynamicsyModel.ModuleCode, this.BaseAccraditModelObj.MenuCond, AuditComModelObj.FlowStepTable);
|
|
}
|
|
|
|
Init(tabPages);
|
|
this.InitFinishTabPage();
|
|
//this.RefreshTabPage();
|
|
if (SysModel.HasReadPrivilege())
|
|
{
|
|
this.btnBack.Enabled = false;
|
|
}
|
|
this.GetPrintOtherParam();
|
|
|
|
//加载分配
|
|
this.dbpFP.Click += new System.EventHandler(this.OnBtnFPOldClick);
|
|
BarButtonItem itemFPBatch = new BarButtonItem();
|
|
itemFPBatch.Caption = "批量分配";
|
|
itemFPBatch.ItemClick += new ItemClickEventHandler(OnBtnFPNewClick);
|
|
//分配
|
|
this.pmFP.AddItems(new BarItem[] { itemFPBatch });
|
|
|
|
this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModelObj.PopupUnionCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#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 (this.BillModelObj.PrintSql.Contains("<<"))
|
|
{
|
|
string[] strs = this.BillModelObj.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]);
|
|
if (item == null)
|
|
{
|
|
MessageUtil.Show("打印参数有误");
|
|
return;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:初始化审批步骤</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-17 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void Init(DataTable tabPages)
|
|
{
|
|
//this.pcGrid.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnPcgridRowFocusedRowChanged);
|
|
//InitControl();
|
|
InitTabPages(tabPages);
|
|
this.InitializeSplitterPosition();
|
|
|
|
Thread thread = new Thread(CreateGrid);
|
|
thread.IsBackground = true;
|
|
thread.Start();
|
|
}
|
|
#region 初始化已完成页
|
|
/// <summary>
|
|
/// <para>说明:初始化已完成page</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-11 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitFinishTabPage()
|
|
{
|
|
//窗口上的条件筛选面板
|
|
this.PanelCondVisible = this.pl_top_searchCond.Visible = string.IsNullOrWhiteSpace(this.BaseAccraditModelObj.OverBackSql);
|
|
if (this.PanelCondVisible)
|
|
{
|
|
//设置默认自动搜索
|
|
this.SetSearchControl();
|
|
if (ProcessExists)
|
|
{
|
|
this.gridFinish.SetReadOnlyColumns(Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent(), GridCustomColumnStruct.AuditOverMainGridView + this.SysModel.ModuleCode);
|
|
}
|
|
else
|
|
{
|
|
this.gridFinish.SetReadOnlyColumns(BaseAuditImpl.GetDefaultGridMainColumns(this.AuditComModelObj.Moduletype), GridCustomColumnStruct.AuditOverMainGridView + this.SysModel.ModuleCode);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
string key = "FinishFLOWSTEP_" + this.SysModel.ModuleCode + "_" + "999" + "_" + "999" + "";
|
|
this.TmpPrefix = this.BaseAccraditModelObj.ColumnPrefix;
|
|
if (ProcessExists)
|
|
{
|
|
this.gridFinish.SetReadOnlyColumns(Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent(), modelkeyName + key);
|
|
}
|
|
else
|
|
{
|
|
this.gridFinish.SetReadOnlyColumns(BaseAuditImpl.GetAuditMainGridCoulmns(AuditComModelObj.SystemTable, this.SysModel.ModuleCode), modelkeyName + key);
|
|
}
|
|
this.gridFinish.Model = this.SysModel;
|
|
// 创建自定义搜索控件
|
|
this.SearchCreateTopControl();
|
|
}
|
|
|
|
// 上面主表格的事件注册
|
|
this.gridFinish.GridView.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(GvFinish_SelectionChangedClick);
|
|
|
|
}
|
|
#endregion
|
|
#region 单元格点击操作
|
|
/// <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="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void GvFinish_SelectionChangedClick(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
GridView gc = sender as GridView;
|
|
DataRow dr = gc.GetFocusedDataRow();
|
|
if (dr == null) return;
|
|
this.TmpPrefix = this.pl_top_searchCond.Visible ? string.Empty : this.BaseAccraditModelObj.ColumnPrefix;
|
|
//单据审批弹出模块加载
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.DynamicsyModel.FormText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.DynamicsyModel.Privilege, this.DynamicsyModel.ModuleCode).Split('~');
|
|
string[] menuArgs = { this.DynamicsyModel.ModuleId + "", "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultStepField] + "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultParmaryField] + "", "", "1" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
//初始明细数据
|
|
this.SysModel = new DynamicPubAccraditionPopModel(args);
|
|
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, SysModel.BillDocumentId);
|
|
//this.ControlObj.SetAllControlValue(_drBillInfoMsg);
|
|
//初始明细数据
|
|
this.gcDetail.Model = this.SysModel;
|
|
//this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, SysModel.BillDocumentId));
|
|
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(this._drBillInfoMsg, this.BillModelObj.DetailSql));
|
|
this.gcDetail.SetGridViewDataSource(_dtSourceData);
|
|
if (_dtSourceData != null) this._dtSpareSourceData = this._dtSourceData.Clone();
|
|
this.gcDetail.ParentControl = this.ControlObj;
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.AuditModelObj.BillGridMenuFlag + SysModel.ModuleCode, ModuleType.BillAuditDetail), SysModel, OnGridViewRightCallBack);
|
|
this.gcDetail.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModelObj.FormKey));
|
|
this.SetBillControl(this.AuditModelObj.BillModifyFields);
|
|
this.SetDetailedTable(gc);
|
|
this.gcDetail.GridView.OptionsBehavior.Editable = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
#endregion
|
|
#region 初始化自动搜索框
|
|
/// <summary>
|
|
/// <para>说明:初始化配置自动搜索框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-11 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetSearchControl()
|
|
{
|
|
this.labelcheck_finalAuditor.AutoTextEdit.ValueMember = "UserId";
|
|
this.labelcheck_finalAuditor.AutoTextEdit.TextField = "UserName";
|
|
this.labelcheck_finalAuditor.AutoTextEdit.ValueField = "UserId";
|
|
this.labelcheck_finalAuditor.AutoTextEdit.SetDataSource(MainImpl.GetEmployeeList());
|
|
this.labeldate_start.LabelDateEditObj.EditText = DateTime.Now.ToString();
|
|
this.labeldate_end.LabelDateEditObj.EditText = DateTime.Now.ToString();
|
|
}
|
|
#endregion
|
|
#region 顶部查询控件
|
|
/// <summary>
|
|
/// <para>说明:顶部查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-30 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SearchCreateTopControl()
|
|
{
|
|
this._searchContrl = new MyControl(this.BaseAccraditModelObj.OverBackSql, this.gridFinish);
|
|
if (ProcessExists)
|
|
{
|
|
this.pl_top.Height = this._searchContrl.InitSearchControl(Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent(), this.pl_top);
|
|
}
|
|
else
|
|
{
|
|
this.pl_top.Height = this._searchContrl.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(this.BaseAccraditModelObj.OverBackKey), this.pl_top);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 多线程创建明细列
|
|
/// <summary>
|
|
/// <para>说明:创建明细列</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CreateGrid()
|
|
{
|
|
Thread.Sleep(100);
|
|
try
|
|
{
|
|
if (this.InvokeRequired)
|
|
{
|
|
this.Invoke((EventHandler)delegate
|
|
{
|
|
if (isBillFlag)
|
|
{
|
|
InitHeader();
|
|
InitBillInfo();
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
int cnt = 0;
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
DataTable dtColumns = BaseAuditImpl.GetGridColumns(AuditComModelObj.SystemTable, this.DynamicsyModel.ModuleCode, tab.FlowStepModel.StepCode, this.DynamicsyModel.UserName);
|
|
string key = "FLOWSTEP_" + this.DynamicsyModel.ModuleCode + "_" + tab.FlowStepModel.StepCode + "_" + item.AuditModel.Id + "";
|
|
item.GridControlObj.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(key));
|
|
|
|
item.GridControlObj.SetReadOnlyColumns(dtColumns, modelkeyName + key);
|
|
|
|
// 追加复选框用于批量审批
|
|
if (BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag)
|
|
{
|
|
GridDragGrid.GridAddCheckBox(item.GridControlObj.GridView);
|
|
//GridColumn checkColumn = new GridColumn();
|
|
//checkColumn.Name = checkColumn.FieldName = "_check";
|
|
//checkColumn.Caption = "选";
|
|
//checkColumn.Width = 30;
|
|
//checkColumn.Visible = true;
|
|
//checkColumn.VisibleIndex = 0;
|
|
//checkColumn.OptionsColumn.AllowEdit = false;
|
|
//item.GridControlObj.GridView.Columns.Insert(0, checkColumn);
|
|
//item.GridControlObj.GridView.RowCellClick += new RowCellClickEventHandler(OnGridViewRowCellClick);
|
|
}
|
|
item.GridControlObj.SetGridViewDataSource(BaseImpl.GetDataTableResult(item.AuditModel.StepSql));
|
|
item.GridControlObj.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnPcgridRowCellClick);
|
|
// 为表格增加一列复选框列
|
|
DataTable table = item.GridControlObj.gridControl.DataSource as DataTable;
|
|
//if (table != null && !table.Columns.Contains("_check") && (BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag))
|
|
//{
|
|
// table.Columns.Add("_check", typeof(bool));
|
|
// foreach (DataRow row in table.Rows)
|
|
// {
|
|
// row["_check"] = 0;
|
|
// }
|
|
//}
|
|
//item.GridControlObj.GridView.DataSourceChanged += new EventHandler(OnPcgridRowFocusedRowChanged);
|
|
cnt += item.GridControlObj.GridView.RowCount;
|
|
Application.DoEvents();
|
|
}
|
|
tab.TabPage.Text = tab.FlowStepModel.StepGroup + "(" + cnt + ")";
|
|
}
|
|
|
|
//InitFirst();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:绑定选项卡</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitTabPages(DataTable tabPages)
|
|
{
|
|
foreach (DataRow row in tabPages.Rows)
|
|
{
|
|
PanelControl panel = new PanelControl(); //tabpage里面的panel子集
|
|
List<System.Windows.Forms.Control> panelList = new List<System.Windows.Forms.Control>(); //tabpage里面的panel集合进行顺序反转
|
|
XtraTabPage tabPage = new XtraTabPage();
|
|
tabPage.AutoScroll = true;
|
|
string cnt = string.Empty;
|
|
FlowTypeStepModel model = new FlowTypeStepModel(row);
|
|
//创建表格
|
|
DataTable flowList = new DataTable();
|
|
if (ProcessExists)
|
|
{
|
|
flowList = Lskj.Data.Caches.CacheSYSConfig.Instance().AccessToContent();
|
|
}
|
|
else
|
|
{
|
|
flowList = BaseAuditImpl.GetFlowStepTab(AuditComModelObj.SystemFlow, this.DynamicsyModel.ModuleCode, model.StepGroup);
|
|
}
|
|
|
|
|
|
for (int i = 1; i <= flowList.Rows.Count; i++)
|
|
{
|
|
//单个审批小模块面板由表格和label组合
|
|
PanelControl gridPanel = new PanelControl();
|
|
//DataTable dtColumns = BaseAuditImpl.GetGridColumns(AuditComModelObj.SystemTable, this.SysModel.ModuleCode, model.StepCode, this.SysModel.UserName);
|
|
AccraditationModel accrModel = new AccraditationModel(flowList.Rows[i - 1]);
|
|
//string key = "FLOWSTEP_" + this.SysModel.ModuleCode + "_" + accrModel.CurstepName + "_" + accrModel.Id + "";
|
|
//gridPanel.Padding = new System.Windows.Forms.Padding(2);
|
|
gridPanel.BorderStyle = BorderStyles.NoBorder;
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.DynamicsyModel.FormText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.DynamicsyModel.Privilege, this.DynamicsyModel.ModuleCode).Split('~');
|
|
string[] menuArgs = { this.DynamicsyModel.ModuleId + "", "", accrModel.StepCode + "", "", "", "0" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
DynamicPubAccraditionPopModel SysModel = new DynamicPubAccraditionPopModel(args);
|
|
this.isBillFlag = true;
|
|
GridControlEx pcGrid = new GridControlEx();
|
|
pcGrid.Parent = gridPanel;
|
|
pcGrid.Dock = DockStyle.Fill;
|
|
pcGrid.GridView.Tag = accrModel;
|
|
pcGrid.Model = SysModel;
|
|
//pcGrid.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnPcgridRowCellClick);
|
|
//pcGrid.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnPcgridRowFocusedRowChanged);
|
|
LabelControl lab = new LabelControl();
|
|
lab.AutoSizeMode = LabelAutoSizeMode.None;
|
|
lab.Dock = DockStyle.Top;
|
|
lab.ForeColor = Color.Black;
|
|
lab.Parent = gridPanel;
|
|
lab.Height = 20;
|
|
lab.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
|
|
lab.Visible = flowList.Rows.Count > 1;
|
|
panel.Dock = DockStyle.Fill;
|
|
panel.BorderStyle = BorderStyles.NoBorder;
|
|
gridPanel.Dock = DockStyle.Fill;
|
|
gridPanel.Parent = panel;
|
|
panelList.Add(panel);
|
|
TabPageObj tabPageObj = new TabPageObj();
|
|
tabPageObj.FlowStepModel = model;
|
|
tabPageObj.TabPage = tabPage;
|
|
tabPageObj.TabPageItemObjs.Add(new TabPageItemObj()
|
|
{
|
|
LabelObj = lab,
|
|
AuditModel = accrModel,
|
|
GridControlObj = pcGrid
|
|
});
|
|
_tabPageObjs.Add(tabPageObj);
|
|
tabPage.Tag = SysModel;
|
|
}
|
|
//cnt += auditPanel.pcGrid.GridView.RowCount;
|
|
tabMain.BorderStylePage = BorderStyles.NoBorder;
|
|
tabPage.Controls.AddRange(panelList.Reverse<System.Windows.Forms.Control>().ToArray());
|
|
//tabPage.Padding = new System.Windows.Forms.Padding(2);
|
|
tabPage.Text = model.StepGroup;
|
|
|
|
tabMain.TabPages.Insert(tabMain.TabPages.Count - 1, tabPage);
|
|
}
|
|
tabMain.SelectedTabPageIndex = 0;
|
|
}
|
|
/// <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>
|
|
void OnGridViewRowCellClick(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)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:点击初始化所有界面数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-03-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitControl(DynamicPubAccraditionPopModel SysModel)
|
|
{
|
|
try
|
|
{
|
|
this.pMenu.ClearLinks();
|
|
this.pMprint.ClearLinks();
|
|
foreach (SimpleButton item in itemCommonList)
|
|
{
|
|
if (this.pcTool.Contains(item)) this.pcTool.Controls.Remove(item);
|
|
}
|
|
this.itemCommonList.Clear();
|
|
this.SysModel = SysModel;
|
|
this._isInitFinish = false;
|
|
this.splitMain.Visible = false;
|
|
this.InitializeSetting();
|
|
this.InitializeControl();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
|
|
}
|
|
finally
|
|
{
|
|
//默认一开始不加载明细数据
|
|
this._isInitFinish = true;
|
|
this.splitMain.Visible = true;
|
|
this.isFinish = true;
|
|
}
|
|
}
|
|
#region 初始化属性设置
|
|
/// <summary>
|
|
/// <para>说明:初始化属性设置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSetting()
|
|
{
|
|
try
|
|
{
|
|
this.AuditModelObj = new AccraditationModel(BillAuditImpl.GetBillFlowData(this.SysModel.ModuleCode, this.SysModel.StepCode));
|
|
this.BillModelObj = new BillAuditModel(BillImpl.GetBillInfo(this.SysModel.ModuleCode));
|
|
this.BillAuditComObj = new BillAuditCommonModel();
|
|
this.BillModelObj.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.MasterTable);
|
|
this.btnAccradit.Text = this.AuditModelObj.StepApplyText;
|
|
this.btnBack.Text = this.AuditModelObj.StepBackText;
|
|
this.btnClose.Text = this.AuditModelObj.StepCloseText;
|
|
this.btnSpare.Enabled = this.AuditModelObj.StepDivide > 0;
|
|
//this.btnAttach.Text = "附件"+"(" + AttachImpl.GetFileCount(this.BillModelObj.DirId + "", this.SysModel.BillDocumentId) + ")";
|
|
//记录推送用户
|
|
this.GetPushOpers();
|
|
this.gcDetail.gridControl.Paint += new PaintEventHandler(gcDetail_Panint);
|
|
//this.pcGrid.GridView.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(OnPcgridRowCellClick);
|
|
//this.pcGrid.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnPcgridRowFocusedRowChanged);
|
|
this._dtBillInfoFiled = BillAuditImpl.GetBillInfoData(this.SysModel.ModuleCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
#region 绘制水印
|
|
/// <summary>
|
|
/// <para>说明:绘制水印</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-05 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void gcDetail_Panint(object sender, PaintEventArgs e)
|
|
{
|
|
if (this.SysModel.StepOver != "1") return;
|
|
GraphicsText graphicsText = new GraphicsText();
|
|
graphicsText.Graphics = e.Graphics;
|
|
|
|
StringFormat format = new StringFormat();
|
|
format.Alignment = StringAlignment.Center;
|
|
format.LineAlignment = StringAlignment.Center;
|
|
|
|
Pen pen = new Pen(Color.Red, 2f);
|
|
SolidBrush brush = new SolidBrush(Color.Red);
|
|
|
|
if (!string.IsNullOrEmpty(this._waterMark.Text))
|
|
{
|
|
int x = (this.gcDetail.Width - 90) / 2;
|
|
int y = (this.gcDetail.Height - 32) / 2;
|
|
graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 20, FontStyle.Bold), brush, new PointF(x, y), format, -20f);
|
|
e.Graphics.TranslateTransform(x, y);
|
|
e.Graphics.RotateTransform(-20f);
|
|
e.Graphics.DrawRectangle(pen, new Rectangle(-45, -19, 90, 32));
|
|
}
|
|
e.Graphics.ResetTransform();
|
|
if (!string.IsNullOrEmpty(this._waterMark.Print))
|
|
{
|
|
int x1 = (this.gcDetail.Width - 120) / 2;
|
|
int y1 = (this.gcDetail.Height - 90) / 2 + 100;
|
|
graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 18, FontStyle.Bold), brush, new PointF(x1, y1), format, -20f);
|
|
e.Graphics.TranslateTransform(x1, y1);
|
|
e.Graphics.RotateTransform(-20f);
|
|
e.Graphics.DrawRectangle(pen, new Rectangle(-60, -19, 120, 32));
|
|
}
|
|
e.Graphics.ResetTransform();
|
|
if (!string.IsNullOrEmpty(this._waterMark.Collect))
|
|
{
|
|
int x2 = (this.gcDetail.Width - 90) / 2;
|
|
int y2 = (this.gcDetail.Height - 90) / 2 - 40;
|
|
graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 20, FontStyle.Bold), brush, new PointF(x2, y2), format, -20f);
|
|
e.Graphics.TranslateTransform(x2, y2);
|
|
e.Graphics.RotateTransform(-20f);
|
|
e.Graphics.DrawRectangle(pen, new Rectangle(-45, -19, 90, 32));
|
|
}
|
|
}
|
|
#endregion
|
|
#region 点击加载明细
|
|
/// <summary>
|
|
/// <para>说明:行获取焦点触发事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2018-09-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="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPcgridRowFocusedRowChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//if (!isFinish) return;
|
|
// WaitForm.ShowForm();
|
|
GridView gc = sender as GridView;
|
|
DataRow dr = gc.GetFocusedDataRow();
|
|
if (dr == null)
|
|
{
|
|
DataTable detailTable = gcDetail.GridControl.DataSourceTable();
|
|
detailTable.Clear();
|
|
this.ControlObj.ResetControlValue();
|
|
return;
|
|
}
|
|
RefreshAll(dr);
|
|
this.SetDetailedTable(gc);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
//WaitForm.HideForm();
|
|
}
|
|
}
|
|
#endregion
|
|
#region 表格是否可以编辑设置
|
|
/// <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.gcDetail.GridView.GetDataRow(this.gcDetail.GridView.FocusedRowHandle);
|
|
if (!string.IsNullOrWhiteSpace(BillModelObj.UpdateDetailCond))
|
|
{
|
|
string UpdateCond = this.ControlObj.ReplaceParentControlValue(BillModelObj.UpdateDetailCond);
|
|
UpdateCond = ReplaceHelper.ReplaceRowParam(rowItem, UpdateCond);
|
|
if (!ReplaceHelper.EvalCond(UpdateCond))
|
|
{
|
|
e.Cancel = true;//该行不可编辑
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 点击加载明细
|
|
/// <summary>
|
|
/// <para>说明:加载明细数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2018-09-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="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
protected void OnPcgridRowCellClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
GridView gc = sender as GridView;
|
|
DataRow dr = gc.GetFocusedDataRow();
|
|
if (dr == null) return;
|
|
this.TmpPrefix = this.BaseAccraditModelObj.ColumnPrefix;
|
|
//单据审批弹出模块加载
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~');
|
|
string[] menuArgs = { this.SysModel.ModuleId + "", "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultStepField] + "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultParmaryField] + "", "", "0" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
//初始明细数据
|
|
this.SysModel = new DynamicPubAccraditionPopModel(args);
|
|
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, SysModel.BillDocumentId);
|
|
//this.ControlObj.SetAllControlValue(_drBillInfoMsg);
|
|
this.btnAttach.Text = "附件" + "(" + AttachImpl.GetFileCount(this.BillModelObj.DirId + "", this.SysModel.BillDocumentId) + ")";
|
|
//初始明细数据
|
|
this.gcDetail.Model = this.SysModel;
|
|
//this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, SysModel.BillDocumentId));
|
|
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(this._drBillInfoMsg, this.BillModelObj.DetailSql));
|
|
this.gcDetail.SetGridViewDataSource(_dtSourceData);
|
|
if (_dtSourceData != null) this._dtSpareSourceData = this._dtSourceData.Clone();
|
|
this.gcDetail.ParentControl = this.ControlObj;
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.AuditModelObj.BillGridMenuFlag + SysModel.ModuleCode, ModuleType.BillAuditDetail), SysModel, OnGridViewRightCallBack);
|
|
this.gcDetail.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModelObj.FormKey));
|
|
this.SetBillControl(this.AuditModelObj.BillModifyFields);
|
|
this.SetDetailedTable(gc);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 初始化控件
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeControl()
|
|
{
|
|
try
|
|
{
|
|
//this.SetFormSize();
|
|
//this.BindTab();
|
|
this.BindBill();
|
|
this.InitCommonMenu();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region 初始化常用菜单
|
|
/// <summary>
|
|
/// <para>说明:设置初始化常用菜单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitCommonMenu()
|
|
{
|
|
DataTable tableCommon = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail);
|
|
if (tableCommon == null && tableCommon.Rows.Count <= 0)
|
|
{
|
|
dpb_Tools.Enabled = false;
|
|
return;
|
|
}
|
|
int i = 0, x = 4;
|
|
foreach (DataRow item in tableCommon.Rows)
|
|
{
|
|
if (i > 1)
|
|
{
|
|
BarButtonItem itemCommon = new BarButtonItem();
|
|
itemCommon.Caption = item["menuname"] + "";
|
|
itemCommon.Tag = item;
|
|
itemCommon.ItemClick += new ItemClickEventHandler(itemCommon_ItemClick);
|
|
this.pMenu.AddItem(itemCommon);
|
|
}
|
|
else
|
|
{
|
|
SimpleButton itemCommon = new SimpleButton();
|
|
//itemCommon.AutoSize = true;
|
|
itemCommon.Text = item["menuname"] + "";
|
|
itemCommon.Tag = item;
|
|
itemCommon.Size = new System.Drawing.Size(90, 26);
|
|
itemCommon.Click += new EventHandler(itemCommon_Click);
|
|
itemCommon.Location = new Point(x + 6, 6);
|
|
x += itemCommon.Width + 6;
|
|
pcTool.Controls.Add(itemCommon);
|
|
itemCommonList.Add(itemCommon);
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 常用工具
|
|
/// <summary>
|
|
/// <para>说明:常用工具点击</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-01-08 </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 itemCommon_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
DataRow rowItem = e.Item.Tag as DataRow;
|
|
CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj);
|
|
menu.Apply(rowItem);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 常用工具点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void itemCommon_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SimpleButton btn = sender as SimpleButton;
|
|
DataRow rowItem = btn.Tag as DataRow;
|
|
CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj);
|
|
menu.Apply(rowItem);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
#region 设置窗体大小
|
|
/// <summary>
|
|
/// <para>说明:设置窗体大小</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetFormSize()
|
|
{
|
|
int panelWidth = this.BillModelObj.PanelWidth;
|
|
this.Width = panelWidth < Screen.PrimaryScreen.WorkingArea.Width ? panelWidth : Screen.PrimaryScreen.WorkingArea.Width;
|
|
this.Left = (Screen.PrimaryScreen.WorkingArea.Width / 2) - (this.Width / 2);
|
|
this.Top = (Screen.PrimaryScreen.WorkingArea.Height / 2) - (this.Height / 2);
|
|
}
|
|
#endregion
|
|
|
|
#region 绑定审批单据
|
|
/// <summary>
|
|
/// <para>说明:单据管理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void BindBill()
|
|
{
|
|
|
|
//this.ControlObj.InitControl(BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode), this.pcBillMain);
|
|
//this.pcBillMain.Height = this.BillModelObj.ParentHeight - 36 > this.pcBillMain.Height ? this.pcBillMain.Height : this.BillModelObj.ParentHeight;
|
|
////初始明细数据
|
|
//this.gcDetail.SetEditColumns(BillImpl.GetDetailColumns(this.SysModel.ModuleCode), GridCustomColumnStruct.AuditPopupDetailGridView + this.BillModelObj.FormKey);
|
|
////修改字段
|
|
//if (!string.IsNullOrEmpty(this.AuditModelObj.DetailModifyFields))
|
|
//{
|
|
// gcDetail.GridView.OptionsBehavior.Editable = true;
|
|
// this.AuditModelObj.DetailModifyFields = this.AuditModelObj.DetailModifyFields + ",";
|
|
// GridColumnCollection gc = this.gcDetail.GridView.Columns;
|
|
// foreach (GridColumn item in gc)
|
|
// {
|
|
// item.OptionsColumn.AllowEdit = this.AuditModelObj.DetailModifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1;
|
|
// item.OptionsColumn.ReadOnly = !item.OptionsColumn.AllowEdit;
|
|
|
|
// }
|
|
//}
|
|
this.InitPrint();
|
|
}
|
|
#endregion
|
|
#region 初始化表头和明细信息
|
|
/// <summary>
|
|
/// <para>说明:初始化表头</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitHeader()
|
|
{
|
|
// 初始化表头
|
|
this.ControlObj = new MyControl();
|
|
this.pcBillMain.Visible = true;
|
|
this.ControlObj.InitControl(BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode), this.pcBillMain);
|
|
this.pcBillMain.Height = this.BillModelObj.ParentHeight - 36 > this.pcBillMain.Height ? this.pcBillMain.Height : this.BillModelObj.ParentHeight;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitBillInfo()
|
|
{
|
|
// 初始化表头
|
|
this.gcDetail.Model = this.SysModel;
|
|
this.gcDetail.SetEditColumns(BillImpl.GetDetailColumns(this.SysModel.ModuleCode), GridCustomColumnStruct.AuditPopupDetailGridView + this.BillModelObj.FormKey);
|
|
this.gcDetail.ParentControl = this.ControlObj;
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.AuditModelObj.BillGridMenuFlag + this.SysModel.ModuleCode, ModuleType.BillAuditDetail), this.SysModel, OnGridViewRightCallBack);
|
|
this.gcDetail.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModelObj.FormKey));
|
|
}
|
|
/// <summary>
|
|
///默认加载第一次
|
|
/// </summary>
|
|
private void InitFirst()
|
|
{
|
|
try
|
|
{
|
|
TabPageObj tab = this._tabPageObjs[0];
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
DataRow rowItem = item.GridControlObj.GridView.GetDataRow(0);
|
|
if (rowItem == null) return;
|
|
RefreshAll(rowItem);
|
|
Application.DoEvents();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 刷新第一次加载
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
public void RefreshAll(DataRow dr)
|
|
{
|
|
this.TmpPrefix = this.BaseAccraditModelObj.ColumnPrefix;
|
|
//单据审批弹出模块加载
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~');
|
|
string[] menuArgs = { this.SysModel.ModuleId + "", "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultStepField] + "", dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultParmaryField] + "", "", "0" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
//初始明细数据
|
|
this.SysModel = new DynamicPubAccraditionPopModel(args);
|
|
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, SysModel.BillDocumentId);
|
|
//this.ControlObj.SetAllControlValue(_drBillInfoMsg);
|
|
//初始明细数据
|
|
this.gcDetail.Model = this.SysModel;
|
|
//this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, SysModel.BillDocumentId));
|
|
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(this._drBillInfoMsg, this.BillModelObj.DetailSql));
|
|
this.gcDetail.SetGridViewDataSource(_dtSourceData);
|
|
if (_dtSourceData != null) this._dtSpareSourceData = this._dtSourceData.Clone();
|
|
this.gcDetail.ParentControl = this.ControlObj;
|
|
this.gcDetail.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.AuditModelObj.BillGridMenuFlag + SysModel.ModuleCode, ModuleType.BillAuditDetail), SysModel, OnGridViewRightCallBack);
|
|
this.gcDetail.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModelObj.FormKey));
|
|
this.gcDetail.GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor);
|
|
this.SetBillControl(this.AuditModelObj.BillModifyFields);
|
|
}
|
|
#endregion
|
|
#region 点击查看附加信息
|
|
/// <summary>
|
|
/// <para>说明:点击查看会签记录信息</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnbtnRecordClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AuditInformation auditInformation = new AuditInformation();
|
|
auditInformation.InitControl(SysModel, _flowTypeStepModel, BillAuditComObj);
|
|
DialogResult result = auditInformation.ShowDialog();
|
|
if (result == DialogResult.OK) MessageUtil.Show("无提醒和会签记录!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:点击查看明细附加信息</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnbtnAdditionalClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AdditionalFrm additionalFrm = new AdditionalFrm();
|
|
DataRow dr = this.gcDetail.GridView.GetFocusedDataRow();
|
|
if (dr != null)
|
|
{
|
|
additionalFrm.InitControl(this.SysModel, dr);
|
|
DialogResult result = additionalFrm.ShowDialog();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("请选中一行明细信息查看附加内容!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 初始化打印
|
|
/// <summary>
|
|
/// <para>说明:创建打印</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitPrint()
|
|
{
|
|
try
|
|
{
|
|
string[] files = this.BillModelObj.PrintFile.Split('|');
|
|
for (int i = 0; i < files.Length; i++)
|
|
{
|
|
string fileName = files[i];
|
|
if (!string.IsNullOrWhiteSpace(fileName))
|
|
{
|
|
BarButtonItem itemPrint = new BarButtonItem();
|
|
itemPrint.Caption = fileName.Replace(".rmf", "");
|
|
itemPrint.Tag = files[i];
|
|
itemPrint.ItemClick += new ItemClickEventHandler(itemPrint_ItemClick);
|
|
pMprint.AddItem(itemPrint);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 打印
|
|
/// <summary>
|
|
/// <para>说明:打印事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-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>
|
|
protected void itemPrint_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string billNo = this.SysModel.BillDocumentId;
|
|
string printPath = PubUtil.PrintFileAbsolutelyPath;
|
|
string printFile = e.Item.Tag + "";
|
|
if (!string.IsNullOrEmpty(billNo))
|
|
{
|
|
DataRow masterRow = BillImpl.GetDataRowResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.MasterSql, billNo));
|
|
if (masterRow == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DataNotFount);
|
|
return;
|
|
}
|
|
if (!ReplaceHelper.ReplaceRowParamCond(masterRow, this.BillModelObj.PrintCond))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisSatisfyPrintCond);
|
|
return;
|
|
}
|
|
|
|
string tmpSql = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql);
|
|
string tmpSql1 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql1);
|
|
string tmpSql2 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql2);
|
|
|
|
|
|
if (printFile.Contains(PrintUtil.TemplateFlag))
|
|
{
|
|
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[BillModelObj.PrimaryKey] + "";
|
|
tmpSqls.Add(mainSql);
|
|
tmpSqls.Add(tmpSql1);
|
|
tmpSqls.AddRange(tmpSql2.Split(';').ToList());
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(tmpSql)) tmpSqls.Add(tmpSql);
|
|
if (!string.IsNullOrWhiteSpace(tmpSql1)) tmpSqls.Add(tmpSql1);
|
|
if (!string.IsNullOrWhiteSpace(tmpSql2)) 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.BillModelObj.PrintFileType, tmpSql2);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
/// <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>
|
|
void OnReportPrintAfter(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (_printSaveParams != null && _printSaveParams.Count > 0)
|
|
{
|
|
//打印完成后添加数据库
|
|
int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 审批单据管理
|
|
/// <summary>
|
|
/// <para>说明:单据管理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetBillControl(string billFields)
|
|
{
|
|
this._mainBillTypeValue = this._drBillInfoMsg[this.BillModelObj.BillType] + "";
|
|
if (string.IsNullOrEmpty(this._mainBillTypeValue) || this._mainBillTypeValue == "0")
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotSetFlowType);
|
|
return;
|
|
}
|
|
this._waterMark = new WaterMark(this.BillModelObj.MasterPreFix, this._drBillInfoMsg);
|
|
this.SetButtonsStatus();
|
|
if (this.pcBillMain.Visible)
|
|
{
|
|
this.ControlObj.CanExecControl = false;
|
|
this.ControlObj.SetAllControlValue(this._drBillInfoMsg);
|
|
|
|
|
|
this.ControlObj.CanExecControl = true;
|
|
|
|
|
|
|
|
|
|
// 必填字段
|
|
string RequiredFields = this.AuditModelObj.RequiredFields.Trim(',');
|
|
if (!string.IsNullOrEmpty(RequiredFields))
|
|
{
|
|
foreach (DataRow dr in this._dtBillInfoFiled.Rows)
|
|
{
|
|
string fieldName = dr["fieldName"] + "";
|
|
this.ControlObj.SetRequiredControl(fieldName, RequiredFields.Split(',').Contains(fieldName), false);
|
|
}
|
|
}
|
|
//判断操作字段和字段的权限(没测试,先不开放)
|
|
//DataTable AuthorityTable = PowerImpl.GetModuleAuthorityEnable(this.SysModel.ModuleCode);
|
|
//foreach (DataRow dr in this._dtBillInfoFiled.Rows)
|
|
//{
|
|
// string fieldName = dr["fieldName"] + "";
|
|
// BaseUserControl control = this.ControlObj.FindControl(fieldName);
|
|
// if (string.IsNullOrWhiteSpace(control.Model.PrivilegeOper))
|
|
// {
|
|
// //没有人员权限,转成可编辑
|
|
// this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), false);
|
|
// }
|
|
// else
|
|
// {
|
|
// List<int> targetPrivTypeIds = new List<int>();
|
|
// foreach (string permission in control.Model.PrivilegeOper.Split(','))
|
|
// {
|
|
// targetPrivTypeIds.Add(int.Parse(permission));
|
|
// }
|
|
// //获取权限对应的人员名称
|
|
// string userString = string.Join(",", AuthorityTable.AsEnumerable()
|
|
// .Where(row => targetPrivTypeIds.Contains(row.Field<int>("privTypeId")))
|
|
// .Select(row => row.Field<string>("userList"))
|
|
// .Where(value => value != null)
|
|
// .ToList()) + ",";
|
|
// //有权限的字段,转成可编辑
|
|
// if (userString.Contains(ERPInfo.Instance.UserName + ",") || ERPInfo.Instance.UserName.Equals("管理员")) this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), false); ;
|
|
|
|
// }
|
|
//}
|
|
//操作字段
|
|
foreach (DataRow dr in this._dtBillInfoFiled.Rows)
|
|
{
|
|
string fieldName = dr["fieldName"] + "";
|
|
this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), false);
|
|
}
|
|
this.SetColor();
|
|
if (this.BillModelObj.HighlightChangeControl) this.ControlObj.ModifiedDefaultValueHighlight(this._drBillInfoMsg);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 明细表格管理
|
|
/// <summary>
|
|
/// <para>说明:明细表格管理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetDetailedTable(GridView gc)
|
|
{
|
|
//明细必填
|
|
this.DetailsRequired.Clear();
|
|
string detailFields = string.Empty;
|
|
if (gc.Tag != null && gc.Tag is AccraditationModel)
|
|
{
|
|
AccraditationModel am = gc.Tag as AccraditationModel;
|
|
detailFields = am.RequiredDetailFields + ",";
|
|
}
|
|
|
|
//修改字段 和 明细必填字段
|
|
if (!string.IsNullOrEmpty(this.AuditModelObj.DetailModifyFields) || !string.IsNullOrWhiteSpace(detailFields))
|
|
{
|
|
gcDetail.GridView.OptionsBehavior.Editable = true;
|
|
this.AuditModelObj.DetailModifyFields = this.AuditModelObj.DetailModifyFields + ",";
|
|
GridColumnCollection gdc = this.gcDetail.GridView.Columns;
|
|
foreach (GridColumn item in gdc)
|
|
{
|
|
item.OptionsColumn.AllowEdit = this.AuditModelObj.DetailModifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1;
|
|
item.OptionsColumn.ReadOnly = !item.OptionsColumn.AllowEdit;
|
|
if (!item.OptionsColumn.AllowEdit)
|
|
{
|
|
item.AppearanceHeader.Options.UseForeColor = true;
|
|
item.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(HeaderColor);
|
|
}
|
|
else
|
|
{
|
|
item.AppearanceHeader.Options.UseForeColor = true;
|
|
item.AppearanceHeader.ForeColor = Color.Black;
|
|
}
|
|
|
|
if (detailFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
item.OptionsColumn.AllowEdit = true;
|
|
item.AppearanceHeader.Options.UseForeColor = true;
|
|
item.AppearanceHeader.ForeColor = RequiredForceColor;
|
|
this.DetailsRequired.Add(item.FieldName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 设置按钮状态
|
|
/// <summary>
|
|
/// <para>说明:设置按钮状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetButtonsStatus()
|
|
{
|
|
DataRow dr = BillAuditImpl.GetBillFlowStep(this.SysModel.ModuleCode, this._mainBillTypeValue, this.SysModel.StepCode);
|
|
if (dr == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.FlowStepConfigError);
|
|
return;
|
|
}
|
|
|
|
//终审
|
|
if (this.SysModel.StepOver == "1")
|
|
{
|
|
this.btnClose.Enabled = this.btnSave.Enabled = this.btnAccradit.Enabled = this.btnBack.Enabled = this.btnSpare.Enabled = false;
|
|
|
|
this.btnSave.Visible = this.btnClose.Visible = this.btnBack.Visible = this.pcTool.Visible = true;
|
|
this.btnAccradit.Text = "确认(Y)";
|
|
return;
|
|
}
|
|
|
|
this._flowTypeStepModel = new FlowTypeStepModel(dr);
|
|
string operUser = this._flowTypeStepModel.OperUser;
|
|
DataRow drOper = BillAuditImpl.GetOperators(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.SysModel.StepCode);
|
|
operUser = drOper != null ? drOper["operators"] + "" : operUser;
|
|
operUser.Contains(this.SysModel.UserName);
|
|
this.btnSave.Enabled = this.btnClose.Enabled = this.btnBack.Enabled = this.btnAccradit.Enabled = operUser.Contains(this.SysModel.UserName);
|
|
|
|
this.btnClose.Visible = this._flowTypeStepModel.StepClosed == 1;
|
|
//this.btnAccradit.Visible = BillAuditImpl.GetBillComfirm(this.SysModel.ConfirmId) < 0;
|
|
|
|
|
|
}
|
|
#endregion
|
|
#region 右键菜单执行后刷新
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新单据数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// 刷新主表
|
|
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId);
|
|
this.ControlObj.SetAllControlValue(this._drBillInfoMsg);
|
|
|
|
// 刷新明细表
|
|
//this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId));
|
|
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(this._drBillInfoMsg, this.BillModelObj.DetailSql));
|
|
this.gcDetail.SetGridViewDataSource(_dtSourceData);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region 记录本次推送人员
|
|
/// <summary>
|
|
/// <para>说明:记录本次推送人员</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetPushOpers()
|
|
{
|
|
DataRow beforeOpers = BillAuditImpl.GetPushedOpers(this.SysModel.BillDocumentId, this.SysModel.StepCode);
|
|
if (beforeOpers != null)
|
|
{
|
|
//记录本次操作信息
|
|
this._beforeMenuName = beforeOpers["menuname"] + "";
|
|
this._beforeUsers = beforeOpers["operators"] + "";
|
|
this._beforeId = Convert.ToInt32(beforeOpers["id"]);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 记载分割条位置
|
|
private void splitMain_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
if (this._isInitFinish)
|
|
{
|
|
IniHelper.Write(string.Format("base_spliterPositionMain_{0}", this.SysModel.ModuleCode), this.splitMain.SplitterPosition + "");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化分割条位置
|
|
/// <summary>
|
|
/// <para>说明:初始化分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-01-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSplitterPosition()
|
|
{
|
|
try
|
|
{
|
|
string splitterMainPosition = IniHelper.Read(string.Format("base_spliterPositionMain_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(splitterMainPosition)) this.splitMain.SplitterPosition = Convert.ToInt32(splitterMainPosition);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Instance.WriteError(e);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void btnAccradit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//获取当前页签的GridControlEx和选中行行号
|
|
int oldRowHandle = 0;
|
|
GridControlEx SelectGridControlEx = null;
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
if (tab.TabPage == this.tabMain.SelectedTabPage)
|
|
{
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
SelectGridControlEx = item.GridControlObj;
|
|
oldRowHandle = item.GridControlObj.GridView.FocusedRowHandle;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
List<DataRow> rowItems = new List<DataRow>();
|
|
if (BaseAccraditModelObj.MuitlAuditFlag)
|
|
{
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
if (tab.TabPage == this.tabMain.SelectedTabPage)
|
|
{
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
int[] mSelectRows = item.GridControlObj.GridView.GetSelectedRows();
|
|
foreach (int itemIndex in mSelectRows)
|
|
{
|
|
DataRow selectRow = item.GridControlObj.GridView.GetDataRow(itemIndex);
|
|
rowItems.Add(selectRow);
|
|
}
|
|
//DataTable table = item.GridControlObj.gridControl.DataSource as DataTable;
|
|
//foreach (DataRow row in table.Rows)
|
|
//{
|
|
// if ("1".Equals(row["_check"] + "") || "true".Equals(row["_check"] + "", StringComparison.OrdinalIgnoreCase))
|
|
// {
|
|
// rowItems.Add(row);
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (rowItems.Count > 1)
|
|
{
|
|
if (MessageUtil.Show("确定审核通过" + rowItems.Count + "条数据?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
int success = 0, fault = 0;
|
|
string tipMsg = "";
|
|
string nextSelectStepCode = string.Empty;
|
|
string nextSelectStepOper = string.Empty;
|
|
|
|
try
|
|
{
|
|
foreach (DataRow item in rowItems)
|
|
{
|
|
WaitForm.ShowForm("正在审核[" + item[this.BaseAccraditModelObj.TmpParmaryField] + "]单据!");
|
|
bool isComplete = true;//判断必填项
|
|
string BillDocumentId = item[this.BaseAccraditModelObj.TmpParmaryField] + "";//单据号
|
|
//主表必填
|
|
DataRow _baseRowData = BaseAuditImpl.GetCurrentFlowRowData(this.BaseAccraditModelObj.BillTable, this.BaseAccraditModelObj.TmpParmaryField, BillDocumentId);
|
|
if (_baseRowData != null && AuditModelObj != null && !string.IsNullOrEmpty(AuditModelObj.RequiredFields))
|
|
{
|
|
string[] Fields = AuditModelObj.RequiredFields.Split(',');
|
|
|
|
foreach (string RequiredField in Fields)
|
|
{
|
|
if (_baseRowData.Table.Columns.Contains(RequiredField) && string.IsNullOrWhiteSpace(_baseRowData[RequiredField] + ""))
|
|
{
|
|
isComplete = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
//明细必填
|
|
//DataTable SourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(BillModelObj.DetailSql, BillDocumentId));
|
|
DataTable SourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_baseRowData, BillModelObj.DetailSql));
|
|
if (SourceData != null && !string.IsNullOrEmpty(AuditModelObj.RequiredDetailFields))
|
|
{
|
|
string[] Fields = AuditModelObj.RequiredDetailFields.Split(',');
|
|
|
|
foreach (string RequiredField in Fields)
|
|
{
|
|
if (SourceData.Columns.Contains(RequiredField) && SourceData.Rows.Cast<DataRow>().FirstOrDefault(x => string.IsNullOrWhiteSpace(x[RequiredField] + "")) != null)
|
|
{
|
|
isComplete = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isComplete)
|
|
{
|
|
WaitForm.ShowForm("正在审核[" + item[this.BaseAccraditModelObj.TmpParmaryField] + "]单据!");
|
|
//string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, item[this.BaseAccraditModelObj.TmpStepField] + "", item[this.BaseAccraditModelObj.TmpParmaryField] + "", "", this.AuditComModelObj.ProcedureName, "F", "", "批量审批同意");
|
|
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText,this.SysModel, item[this.BaseAccraditModelObj.TmpStepField] + "", item[this.BaseAccraditModelObj.TmpParmaryField] + "", "", this.AuditComModelObj.ProcedureName, "F", "", "批量审批同意");
|
|
|
|
if ("1".Equals(result))
|
|
{
|
|
success++;
|
|
}
|
|
else
|
|
{
|
|
fault++;
|
|
tipMsg = msgText + "\r\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
fault++;
|
|
tipMsg += "[" + item[this.BaseAccraditModelObj.TmpParmaryField] + "]单据内存在必填项未处理" + "\r\n";
|
|
}
|
|
|
|
|
|
}
|
|
MessageUtil.Show("审核成功:" + success + "\r\n" + "审核失败:" + fault + (string.IsNullOrEmpty(tipMsg) ? "" : "\r\n失败原因如下:" + tipMsg));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
if (!this.BaseAccraditModelObj.DisableAutomaticRefresh) RefreshTabPage();
|
|
DataTable detailTable = gcDetail.GridControl.DataSourceTable();
|
|
detailTable.Clear();
|
|
this.ControlObj.ResetControlValue();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//主表必填
|
|
if (!this.ControlObj.isRequiredFields(this.AuditModelObj.RequiredFields))
|
|
{
|
|
MessageUtil.Show("单据内存在必填项未处理");
|
|
return;
|
|
}
|
|
|
|
//明细必填
|
|
if (!this.gcDetail.GridControl.isRequiredFields(this.AuditModelObj.RequiredDetailFields, this.gcDetail.GridView))
|
|
{
|
|
MessageUtil.Show("单据内存在必填项未处理");
|
|
return;
|
|
}
|
|
|
|
FrmExamine frmExamine = new FrmExamine();
|
|
frmExamine.ExamineOkCallBack += new EventHandler(ExamineOkCallBack);
|
|
frmExamine.CheckSuggestion.ValueField = frmExamine.CheckSuggestion.TextField = "Mix_apellation";
|
|
frmExamine.CheckSuggestion.SetDataSource(BaseImpl.GetDataTableResult(this.AuditModelObj.SuggestionSql));
|
|
frmExamine.CheckSuggestion.TextEdit.SelectedIndex = 0;
|
|
frmExamine.ShowDialog();
|
|
}
|
|
|
|
//选中上一次选中行行号
|
|
if (SelectGridControlEx != null && oldRowHandle > 0)
|
|
{
|
|
SelectGridControlEx.GridView.SelectRowHandler(oldRowHandle);
|
|
OnPcgridRowCellClick(SelectGridControlEx.GridView, null);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#region 常用意见
|
|
/// <summary>
|
|
/// <para>说明:常用意见下拉框事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08</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 CheckSuggestion_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FrmExamine frmExamine = sender as FrmExamine;
|
|
frmExamine.txtRemark.Text = frmExamine.CheckSuggestion.EditText;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 审核确定回调
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ExamineOkCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FrmExamine frmExamine = sender as FrmExamine;
|
|
if (this.SysModel.StepOver == "1")
|
|
{
|
|
if (BillAuditImpl.ConfirmAudit(this.SysModel.UserId, frmExamine.txtRemark.EditText, this.SysModel.ModuleCode, this.SysModel.BillDocumentId) > 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ConfirmSuccess);
|
|
frmExamine.Close();
|
|
if (!this.BaseAccraditModelObj.DisableAutomaticRefresh) RefreshTabPage();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ConfirmFail);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bool isAudit = true;
|
|
string confirmOpers = string.Empty, remindOpers = string.Empty;
|
|
string nextSelectStepCode = string.Empty;
|
|
string nextSelectStepOper = string.Empty;
|
|
if (this._flowTypeStepModel.RemindSelect == "1")
|
|
{
|
|
FrmRemindSelectForm formRemind = new FrmRemindSelectForm();
|
|
formRemind.FieldValue = this.SysModel.BillDocumentId;
|
|
formRemind.MenuCode = this.SysModel.ModuleCode;
|
|
isAudit = formRemind.ShowDialog() == DialogResult.Yes;
|
|
confirmOpers = formRemind.ConfirmOpers;
|
|
remindOpers = formRemind.RemindOpers;
|
|
}
|
|
if (isAudit)
|
|
{
|
|
//确认是否审批
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.ConfirmIsAudit), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
|
|
if (!SaveBillData(0, false)) return;
|
|
//string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, frmExamine.txtRemark.EditText, remindOpers, confirmOpers);
|
|
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, frmExamine.txtRemark.EditText, remindOpers, confirmOpers);
|
|
|
|
|
|
if ("1".Equals(result))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AuditSuccess);
|
|
PushHelper push = new PushHelper(this.SysModel.BillDocumentId, this.SysModel.StepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId);
|
|
push.Push_Bill_Oper_Message();
|
|
frmExamine.DialogResult = DialogResult.OK;
|
|
if (!this.BaseAccraditModelObj.DisableAutomaticRefresh) RefreshTabPage();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + msgText);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#region 保存单据
|
|
/// <summary>
|
|
/// <para>说明:保存单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
bool result = SaveBillData();
|
|
|
|
if (result)
|
|
{
|
|
//获取当前页签的GridControlEx和选中行行号
|
|
int oldRowHandle = 0;
|
|
GridControlEx SelectGridControlEx = null;
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
if (tab.TabPage == this.tabMain.SelectedTabPage)
|
|
{
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
SelectGridControlEx = item.GridControlObj;
|
|
oldRowHandle = item.GridControlObj.GridView.FocusedRowHandle;
|
|
}
|
|
}
|
|
}
|
|
|
|
//选中上一次选中行行号
|
|
if (SelectGridControlEx != null && oldRowHandle >= 0)
|
|
{
|
|
SelectGridControlEx.GridView.SelectRowHandler(oldRowHandle);
|
|
OnPcgridRowCellClick(SelectGridControlEx.GridView, null);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#region 修改表头
|
|
/// <summary>
|
|
/// <para>说明:获取修改表头</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
private string GetUpdateBillHeader()
|
|
{
|
|
StringBuilder updateBuilder = new StringBuilder();
|
|
foreach (ControlModel model in this.ControlObj.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx)
|
|
continue;
|
|
if (this.ControlObj.FindControl(model) != null)
|
|
{
|
|
string fieldValue = this.ControlObj.GetControlValue(model);
|
|
if (fieldValue == "****") continue;
|
|
|
|
if (SystemInfo.Instance.IsSpecialAuditSave &&
|
|
this._drBillInfoMsg != null &&
|
|
this._drBillInfoMsg.Table != null &&
|
|
this._drBillInfoMsg.Table.Columns.Contains(model.FieldName) &&
|
|
AuditChangeLog.IsSameValue(this._drBillInfoMsg[model.FieldName] + "", fieldValue))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
|
|
//updateBuilder.AppendFormat("{0}='{1}',", model.FieldName, fieldValue);
|
|
updateBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0}={1}", model.FieldName, this.ControlObj.GetNullValue(model)) : string.Format("{0}=N'{1}',", model.FieldName, fieldValue.Contains("'") ? fieldValue.Replace("'", "''") : fieldValue));
|
|
}
|
|
}
|
|
string updateFields = updateBuilder.ToString().TrimEnd(',');
|
|
if (string.IsNullOrEmpty(updateFields))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return string.Format("update {0} set {1} where {2}='{3}'", this.BillModelObj.MasterTable, updateBuilder.ToString().TrimEnd(','), BillModelObj.PrimaryKey, this.SysModel.BillDocumentId);
|
|
}
|
|
#endregion
|
|
|
|
#region 获取明细
|
|
/// <summary>
|
|
/// <para>说明:获取明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
private string GetDetailRecord(string guid)
|
|
{
|
|
|
|
// 构造明细
|
|
StringBuilder detailBuilder = new StringBuilder();
|
|
DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModelObj.DetailTable + "_temp"));//单据明细性表
|
|
DataTable detailTable = this.gcDetail.GridControl.DataSourceTable().TrimDeleteRows();
|
|
//if (this.BillModelObj.DetailTreeTable)
|
|
//{
|
|
// detailTable = ((this.gcDetail as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows();
|
|
//}
|
|
if (detailTable.Rows.Count > 0)
|
|
{
|
|
DataTable BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable));
|
|
IEnumerable<DataColumn> detailColumns = BillColumns.Columns.Cast<DataColumn>();
|
|
DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable + "_temp"));
|
|
foreach (DataRow dataRow in detailTable.Rows)
|
|
{
|
|
StringBuilder fields = new StringBuilder();
|
|
StringBuilder values = new StringBuilder();
|
|
string detailSql = @"insert into " + BillModelObj.DetailTable + "_temp" + "({0}) values({1})";
|
|
|
|
fields.Append("sysstr,");
|
|
values.Append("'" + guid + "',");
|
|
foreach (DataColumn item in detailTable.Columns)
|
|
{
|
|
var selectColumn = detailColumns.Where(n => n.ColumnName.Equals(item.ColumnName, StringComparison.OrdinalIgnoreCase));
|
|
if (selectColumn.Count() == 0)
|
|
{
|
|
continue;
|
|
}
|
|
fields.Append(item.ColumnName + ",");
|
|
string fieldValue = (dataRow[item] + "").Replace("'", "''");
|
|
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}", BillModelObj.DetailTable + "_temp", item.ColumnName, type));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(fieldValue))
|
|
{
|
|
values.Append(item.DataType == typeof(DateTime) ? "N'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : "N'" + 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("'',");
|
|
}
|
|
}
|
|
detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(','));
|
|
}
|
|
}
|
|
|
|
return detailBuilder.ToString();
|
|
|
|
|
|
// 构造明细
|
|
//StringBuilder detailBuilder = new StringBuilder();
|
|
//DataTable detailTable = this.gcDetail.GridControl.DataSourceTable().TrimDeleteRows();
|
|
//if (detailTable.Rows.Count > 0)
|
|
//{
|
|
// foreach (DataRow dataRow in detailTable.Rows)
|
|
// {
|
|
// StringBuilder fields = new StringBuilder();
|
|
// StringBuilder values = new StringBuilder();
|
|
// string detailSql = @"insert into " + BillModelObj.DetailTable + "_temp" + "({0}) values({1})";
|
|
// fields.Append("sysstr,");
|
|
// values.Append("'" + guid + "',");
|
|
// foreach (DataColumn item in detailTable.Columns)
|
|
// {
|
|
// if (item.ColumnName.Equals(guidField) || item.ColumnName.Equals(mRecordPrimaryField) || item.ColumnName.Equals(ERPInfo.Instance.isAddRows)) continue;
|
|
// fields.Append(item.ColumnName + ",");
|
|
// string fieldValue = (dataRow[item] + "").Replace("'", "''");
|
|
|
|
// if (!string.IsNullOrWhiteSpace(fieldValue))
|
|
// {
|
|
// values.Append(item.DataType == typeof(DateTime) ? "N'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : "N'" + 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("'',");
|
|
// }
|
|
// }
|
|
|
|
// detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(','));
|
|
// }
|
|
//}
|
|
//return detailBuilder.ToString();
|
|
}
|
|
#endregion
|
|
#region 审核保存时候
|
|
/// <summary>
|
|
/// <para>说明:保存和修改的验证</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-9-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <param name="TableProperties">数据库的表格属性表</param>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public string SaveOrModifyBalidation(DataTable TableProperties, DataRow row, DataColumn col, string fieldValue)
|
|
{
|
|
if (!row.Table.Columns.Contains(col.ColumnName)) return "";
|
|
DataRow hasContainRow = BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode).Rows.Cast<DataRow>().FirstOrDefault(x => (x["fieldname"] + "").ToLower() == col.ColumnName.ToLower());
|
|
if (TableProperties.Rows.Count == 0) return "";
|
|
|
|
DataRow[] ListOfAttributes = TableProperties.Select("COLUMN_NAME='" + col.ColumnName + "'");
|
|
if (ListOfAttributes == null || ListOfAttributes.Length == 0) return "";
|
|
string saveErrorMessage = string.Empty;
|
|
int MaxInputLength = 0;
|
|
//判断长度是否超出
|
|
if (ListOfAttributes[0]["DATA_TYPE"].ToString().Equals("varchar"))
|
|
{
|
|
if (int.Parse(ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"].ToString()) == -1)
|
|
{
|
|
ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"] = 8000;
|
|
}
|
|
MaxInputLength = System.Text.Encoding.Default.GetBytes((row[col.ColumnName] + "").Replace("'", "''")).Length;
|
|
}
|
|
else if (ListOfAttributes[0]["DATA_TYPE"].ToString().Equals("nvarchar"))
|
|
{
|
|
if (int.Parse(ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"].ToString()) == -1)
|
|
{
|
|
ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"] = 4000;
|
|
}
|
|
MaxInputLength = (row[col.ColumnName] + "").Replace("'", "''").Length;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"].ToString()) && int.Parse(ListOfAttributes[0]["CHARACTER_MAXIMUM_LENGTH"].ToString()) < MaxInputLength)
|
|
{
|
|
saveErrorMessage = saveErrorMessage + hasContainRow["username"].ToString() + "~" + col.ColumnName + ": 输入内容长度超出限制;\r\n";
|
|
}
|
|
//判断属性是否正确
|
|
if ((ListOfAttributes[0]["DATA_TYPE"].ToString().Equals("int") || ListOfAttributes[0]["DATA_TYPE"].ToString().Equals("decimal")) && !IsNumberic((row[col.ColumnName] + "").Replace("'", "''")) && !string.IsNullOrWhiteSpace((row[col.ColumnName] + "")))
|
|
{
|
|
saveErrorMessage = saveErrorMessage + hasContainRow["username"].ToString() + "~" + col.ColumnName + ": 数据格式错误;\r\n";
|
|
}
|
|
return saveErrorMessage;
|
|
}
|
|
#endregion
|
|
#region 判断输入的字符串是否可以转换成数值类型
|
|
/// <summary>
|
|
/// 判断输入的字符串是否可以转换成数值类型
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <returns></returns>
|
|
public static bool IsNumberic(string str)
|
|
{
|
|
double vsNum;
|
|
bool isNum;
|
|
isNum = double.TryParse(str, System.Globalization.NumberStyles.Float,
|
|
System.Globalization.NumberFormatInfo.InvariantInfo, out vsNum);
|
|
return isNum;
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:保存单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="confirmFlag">保存确认标记</param>
|
|
private bool SaveBillData(int confirmFlag = 0, bool showMsg = true)
|
|
{
|
|
bool save = false;
|
|
try
|
|
{
|
|
string guid = Guid.NewGuid().ToString();
|
|
string masterSql = GetUpdateBillHeader();
|
|
|
|
|
|
string detailSql = GetDetailRecord(guid);
|
|
string SaveErrorMessage = string.Empty;
|
|
if (string.IsNullOrEmpty(detailSql) && !this.BillModelObj.SaveNullDetail)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.BillDetailIsNotNull);
|
|
return false;
|
|
}
|
|
string tipMsg = string.Empty;
|
|
if (!this.ControlObj.VerifyNull()) return false;
|
|
if (!this.gcDetail.GridView.ValidateNullRequired(this.DetailsRequired)) return false;
|
|
int result = BillImpl.BillSave(masterSql, detailSql, this.BillModelObj.DetailTable, ref this.SysModel.BillDocumentId, guid, this.BillModelObj.BillSeq, 2, confirmFlag, out tipMsg, 1, this.BillModelObj.NewVer);
|
|
switch (result)
|
|
{
|
|
case 1:
|
|
if (showMsg)
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
|
|
AuditChangeLog.SaveHeaderChangeLog(this._drBillInfoMsg, this.ControlObj, this.SysModel.BillDocumentId, this.SysModel.StepCode, ERPInfo.Instance.UserId);
|
|
|
|
save = true;
|
|
break;
|
|
case 9:
|
|
if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
save = SaveBillData(1, showMsg);
|
|
break;
|
|
default:
|
|
MessageUtil.Show(string.Format(ResourceKeys.OperateFail, result, tipMsg));
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
// MessageUtil.Show(ex.Message);
|
|
}
|
|
return save;
|
|
}
|
|
#endregion
|
|
#region 返退
|
|
/// <summary>
|
|
/// <para>说明:返回审核</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</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 btnReturn_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//获取当前页签的GridControlEx和选中行行号
|
|
int oldRowHandle = 0;
|
|
GridControlEx SelectGridControlEx = null;
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
if (tab.TabPage == this.tabMain.SelectedTabPage)
|
|
{
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
SelectGridControlEx = item.GridControlObj;
|
|
oldRowHandle = item.GridControlObj.GridView.FocusedRowHandle;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
List<DataRow> rowItems = new List<DataRow>();
|
|
if (BaseAccraditModelObj.MuitlAuditBackFlag)
|
|
{
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
if (tab.TabPage == this.tabMain.SelectedTabPage)
|
|
{
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
int[] mSelectRows = item.GridControlObj.GridView.GetSelectedRows();
|
|
foreach (int itemIndex in mSelectRows)
|
|
{
|
|
DataRow selectRow = item.GridControlObj.GridView.GetDataRow(itemIndex);
|
|
rowItems.Add(selectRow);
|
|
}
|
|
//DataTable table = item.GridControlObj.gridControl.DataSource as DataTable;
|
|
//foreach (DataRow row in table.Rows)
|
|
//{
|
|
// if ("1".Equals(row["_check"] + "") || "true".Equals(row["_check"] + "", StringComparison.OrdinalIgnoreCase))
|
|
// {
|
|
// rowItems.Add(row);
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (rowItems.Count > 1)
|
|
{
|
|
if (MessageUtil.Show("确定回退" + rowItems.Count + "条数据?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
int success = 0, fault = 0;
|
|
string tipMsg = "";
|
|
this._auditAdvice = "批量返退";
|
|
bool firstLoad = true;
|
|
int ret = 0;
|
|
foreach (DataRow item in rowItems)
|
|
{
|
|
if (firstLoad) ret = ExecuteBackSelect(item);
|
|
if (ret == -9) return;
|
|
string nextSelectStepCode = string.Empty;
|
|
string nextSelectStepOper = string.Empty;
|
|
WaitForm.ShowForm("正在返退[" + item[this.BaseAccraditModelObj.TmpParmaryField] + "]单据!");
|
|
//string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", "0", this._auditAdvice, "", "", true, ret);
|
|
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, item[this.BaseAccraditModelObj.TmpStepField] + "", item[this.BaseAccraditModelObj.TmpParmaryField] + "", "", this.BillAuditComObj.ProcedureName, "R", "0", this._auditAdvice, "", "", true, ret);
|
|
|
|
if ("1".Equals(result))
|
|
{
|
|
success++;
|
|
}
|
|
else
|
|
{
|
|
fault++;
|
|
tipMsg = msgText + "\r\n";
|
|
}
|
|
firstLoad = false;
|
|
}
|
|
MessageUtil.Show("返退成功:" + success + "\r\n" + "返退失败:" + fault + (string.IsNullOrEmpty(tipMsg) ? "" : "\r\n失败原因如下:" + tipMsg));
|
|
RefreshTabPage();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this._auditAdvice = "拒绝";
|
|
int ret = ExecuteBackSelect(this._drBillInfoMsg);
|
|
if (ret == -9) return;
|
|
if (MessageUtil.Show(ResourceKeys.ConfimAuditFailAndReturnBill, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
string nextSelectStepCode = string.Empty;
|
|
string nextSelectStepOper = string.Empty;
|
|
//string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", "0", this._auditAdvice, "", "", true, ret);
|
|
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", "0", this._auditAdvice, "", "", true, ret);
|
|
|
|
if (result == "1")
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ForcedSuccess);
|
|
PushHelper push = new PushHelper(this.SysModel.BillDocumentId, this.SysModel.StepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId);
|
|
push.Push_Bill_Oper_Message();
|
|
RefreshTabPage();
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 返回审核
|
|
/// <summary>
|
|
/// <para>说明:返回审核</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="row">The row.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
private int ExecuteBackSelect(DataRow row)
|
|
{
|
|
if (row == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NoFindAntiauditBill);
|
|
return -9;
|
|
}
|
|
if (this.BillModelObj.BackSelected == "0") return -1;
|
|
if (this.SysModel.StepCode == "100")
|
|
{
|
|
string billDocumentId = this.PanelCondVisible && row.Table.Columns.Contains(this.BaseAccraditModelObj.DefaultParmaryField) ? row[this.BaseAccraditModelObj.DefaultParmaryField] + "" : row[string.IsNullOrEmpty(this.BaseAccraditModelObj.KeyField + "") ? this.BaseAccraditModelObj.TmpParmaryField : this.BaseAccraditModelObj.KeyField + ""] + "";
|
|
FrmBack cfd = new FrmBack((string.Format(ResourceKeys.ForcedReturnBill, billDocumentId)));
|
|
DialogResult backResult = cfd.ShowDialog();
|
|
if (backResult == DialogResult.OK)
|
|
{
|
|
this._auditAdvice = cfd.ComfirmMsg;
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return -9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
FrmBackSelect frmBackSel = new FrmBackSelect();
|
|
frmBackSel.SysModel = this.SysModel;
|
|
frmBackSel.BillModelObj = this.BillModelObj;
|
|
frmBackSel.InitControl();
|
|
if (frmBackSel.ShowDialog() != DialogResult.OK) return -9;
|
|
this._auditAdvice = frmBackSel.ComfirmMsg;
|
|
return frmBackSel.SelectStepCode;
|
|
}
|
|
#endregion
|
|
|
|
private void btnSpare_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FrmSpare spare = new FrmSpare();
|
|
spare.SysModel = this.SysModel;
|
|
spare.BillModel = this.BillModelObj;
|
|
spare.DtSource = this._dtSourceData;
|
|
spare.DetailSql = this.BillModelObj.DetailSql;
|
|
spare.DtNewSource = this._dtSpareSourceData;
|
|
DialogResult result = spare.ShowDialog();
|
|
this._dtSpareSourceData = spare.DtNewSource;
|
|
if (result == DialogResult.OK) checkBillSplite();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#region 检查分单
|
|
/// <summary>
|
|
/// <para>说明:检查分单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Boolean.</returns>
|
|
private bool checkBillSplite()
|
|
{
|
|
bool createResult = false;
|
|
try
|
|
{
|
|
if (this._dtSourceData.Rows.Count > 0)
|
|
{
|
|
createSourceBillId();
|
|
//复制单据数据
|
|
createResult = createBill();
|
|
if (createResult)
|
|
{
|
|
this.gcDetail.SetGridViewDataSource(_dtSourceData);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
return createResult;
|
|
}
|
|
#endregion
|
|
#region 单据来源
|
|
/// <summary>
|
|
/// <para>说明:单据来源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void createSourceBillId()
|
|
{
|
|
try
|
|
{
|
|
BillAuditImpl.CreateSourceBillId(this.BillModelObj.MasterTable);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 分单创建单据
|
|
/// <summary>
|
|
/// <para>说明:分单创建单据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-10</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private bool createBill()
|
|
{
|
|
string billNo = BillImpl.GetBillNo(this.BillModelObj.BillSeq);
|
|
//构造表头
|
|
string masterSql = this.GetBillHearder(billNo);
|
|
//构造明细
|
|
string detailSql = this.GetBillDetail(billNo);
|
|
//分单处理
|
|
string msg = string.Empty;
|
|
int returnValue = BillAuditImpl.SpliteBill(out msg, masterSql, detailSql, billNo, this.SysModel.ModuleCode, this.SysModel.BillDocumentId);
|
|
if (returnValue == 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SpliterBillSuccess);
|
|
this._dtSourceData.Clear();
|
|
return true;
|
|
}
|
|
else if (returnValue != 9)
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.SpliterBillFail, returnValue, msg));
|
|
}
|
|
return false;
|
|
}
|
|
#endregion
|
|
#region 构造表头
|
|
/// <summary>
|
|
/// <para>说明:构造表头</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private string GetBillHearder(string billNo)
|
|
{
|
|
StringBuilder fieldBuilder = new StringBuilder();
|
|
StringBuilder valueBuilder = new StringBuilder();
|
|
|
|
foreach (ControlModel model in this.ControlObj.ControlModels)
|
|
{
|
|
if (!model.IsSave ||
|
|
model.FieldName.Equals(BillModelObj.PrimaryKey, StringComparison.OrdinalIgnoreCase) ||
|
|
model.FieldType == ControlType.LabPic ||
|
|
model.FieldType == ControlType.LabPicEx)
|
|
continue;
|
|
|
|
string fieldValue = this.ControlObj.GetControlValue(model);
|
|
fieldBuilder.Append(model.FieldName + ",");
|
|
valueBuilder.AppendFormat("'{0}',", fieldValue);
|
|
}
|
|
fieldBuilder.Append(this.BillModelObj.PrimaryKey + ",");
|
|
valueBuilder.AppendFormat("'{0}',", billNo);
|
|
return string.Format(@"insert into {0} ({1})values({2})", this.BillModelObj.MasterTable, fieldBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(','));
|
|
}
|
|
#endregion
|
|
|
|
#region 构造明细
|
|
/// <summary>
|
|
/// <para>说明:构造明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="billNo">单据编号.</param>
|
|
private string GetBillDetail(string billNo)
|
|
{
|
|
string ids = string.Empty;
|
|
string detailPrefix = BaseImpl.GetColumnPrefix(this.BillModelObj.DetailTable);
|
|
string sourceId = detailPrefix + "id";
|
|
foreach (DataRow item in _dtSpareSourceData.Rows)
|
|
{
|
|
ids += item[sourceId] + ",";
|
|
}
|
|
return string.Format("update {0} set {1}Billdocument_id='{2}' where {4} in ({3})", this.BillModelObj.DetailTable, detailPrefix, billNo, ids.TrimEnd(','), sourceId);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region tabPage组成类
|
|
/// <summary>
|
|
/// tabPage组成结构
|
|
/// </summary>
|
|
public class TabPageItemObj
|
|
{
|
|
/// <summary>
|
|
/// 审批模型
|
|
/// </summary>
|
|
public AccraditationModel AuditModel;
|
|
/// <summary>
|
|
/// 进度流层表格
|
|
/// </summary>
|
|
public GridControlEx GridControlObj;
|
|
/// <summary>
|
|
/// 进度流层名
|
|
/// </summary>
|
|
public LabelControl LabelObj;
|
|
}
|
|
|
|
/// <summary>
|
|
/// tabpage模型
|
|
/// </summary>
|
|
public class TabPageObj
|
|
{
|
|
/// <summary>
|
|
/// 选项卡
|
|
/// </summary>
|
|
public XtraTabPage TabPage;
|
|
/// <summary>
|
|
/// 表格集合
|
|
/// </summary>
|
|
public List<TabPageItemObj> TabPageItemObjs = new List<TabPageItemObj>();
|
|
/// <summary>
|
|
/// 步骤模型
|
|
/// </summary>
|
|
public FlowTypeStepModel FlowStepModel;
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 切换审批步骤刷新配置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void OnSelectedPageChanged(object sender, TabPageChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
|
|
DynamicPubAccraditionPopModel SysModel = tabPage.Tag as DynamicPubAccraditionPopModel;
|
|
if (SysModel == null)
|
|
{
|
|
this.btnClose.Enabled = this.btnSave.Enabled = this.btnAccradit.Enabled = this.btnBack.Enabled = this.btnSpare.Enabled = false;
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
this.btnClose.Enabled = this.btnSave.Enabled = this.btnAccradit.Enabled = this.btnBack.Enabled = this.btnSpare.Enabled = true;
|
|
}
|
|
InitControl(SysModel);
|
|
|
|
|
|
|
|
//foreach (TabPageObj tab in this._tabPageObjs)
|
|
//{
|
|
// if (tab.TabPage == tabPage)
|
|
// {
|
|
// if (tab.TabPageItemObjs != null && tab.TabPageItemObjs[0].AuditModel != null)
|
|
// {
|
|
// string required = tab.TabPageItemObjs[0].AuditModel.RequiredDetailFields;
|
|
// if (!string.IsNullOrWhiteSpace(required))
|
|
// {
|
|
// GridColumnCollection gdc = this.gcDetail.GridView.Columns;
|
|
// foreach (GridColumn item in gdc)
|
|
// {
|
|
// if (item.OptionsColumn.AllowEdit = required.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1)
|
|
// {
|
|
// item.AppearanceHeader.Options.UseForeColor = true;
|
|
// item.AppearanceHeader.ForeColor = RequiredForceColor;
|
|
// }
|
|
// else if (!item.OptionsColumn.AllowEdit)
|
|
// {
|
|
// item.AppearanceHeader.Options.UseForeColor = true;
|
|
// item.AppearanceHeader.ForeColor = ColorTranslator.FromHtml(HeaderColor);
|
|
// }
|
|
// else
|
|
// {
|
|
// item.AppearanceHeader.Options.UseForeColor = true;
|
|
// item.AppearanceHeader.ForeColor = Color.Black;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 搜索操作
|
|
/// <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 btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.OnBtnSearchCallBack != null)
|
|
{
|
|
string cond = string.Empty;
|
|
bool cancelFlag = false;
|
|
|
|
if (BaseImpl.HasExistsColumn(this.BaseAccraditModelObj.BillTable, this.BaseAccraditModelObj.CancelFlag))
|
|
{
|
|
cancelFlag = true;
|
|
}
|
|
if (this.labeldate_start.CheckEdit.Checked)
|
|
{
|
|
cond = string.Format("and convert(varchar(10),a.{0}stepOverTime,120)>='{1}'", this.BaseAccraditModelObj.ColumnPrefix, this.labeldate_start.TextEdit.Text);
|
|
}
|
|
if (this.labeldate_end.CheckEdit.Checked)
|
|
{
|
|
cond = cond + string.Format("and convert(varchar(10),a.{0}stepOverTime,120)<='{1}'", this.BaseAccraditModelObj.ColumnPrefix, this.labeldate_end.TextEdit.Text);
|
|
}
|
|
if (this.labelcheck_finalAuditor.CheckEdit.Checked)
|
|
{
|
|
cond = cond + string.Format("and a.{0}stepOverId='{1}'", this.BaseAccraditModelObj.ColumnPrefix, this.labelcheck_finalAuditor.AutoTextEdit.EditValue);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.labeltxt_dataFlag.EditText.Trim()))
|
|
{
|
|
cond = cond + string.Format("and a.{0} LIKE '%{1}%'", this.KeyValue, this.labeltxt_dataFlag.EditText.Trim());
|
|
}
|
|
|
|
BtnSearchGridFinishArgs args = new BtnSearchGridFinishArgs();
|
|
args.CancelFlag = cancelFlag;
|
|
args.Cond = cond;
|
|
if (OnBtnSearchCallBack != null)
|
|
OnBtnSearchCallBack(sender, args);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("搜索操作出错!" + Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 返审操作
|
|
/// <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 btnBack_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow dr = this.gridFinish.GridView.GetFocusedDataRow();
|
|
if (dr == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotReturnData);
|
|
return;
|
|
}
|
|
this.TmpPrefix = this.pl_top_searchCond.Visible ? string.Empty : this.BaseAccraditModelObj.ColumnPrefix;
|
|
string billDocumentId = this.PanelCondVisible ? dr[this.BaseAccraditModelObj.DefaultParmaryField] + "" : dr[string.IsNullOrEmpty(this.BaseAccraditModelObj.KeyField + "") ? this.BaseAccraditModelObj.TmpParmaryField : this.BaseAccraditModelObj.KeyField + ""] + "";
|
|
string stepCode = this.PanelCondVisible ? dr[this.TmpPrefix + this.BaseAccraditModelObj.DefaultStepField] + "" : dr[this.BaseAccraditModelObj.TmpStepField] + "";
|
|
|
|
FrmBack cfd = new FrmBack((string.Format(ResourceKeys.ForcedReturnBill, billDocumentId)));
|
|
DialogResult backResult = cfd.ShowDialog();
|
|
|
|
|
|
if (backResult == DialogResult.OK)
|
|
{
|
|
string hintMsg = cfd.ComfirmMsg;
|
|
//记录本次推送人员,审核过清除消息
|
|
string beforeMenuname = string.Empty, beforeUsers = string.Empty;
|
|
string nextSelectStepCode = string.Empty;
|
|
string nextSelectStepOper = string.Empty;
|
|
int beforeId = 0;
|
|
DataRow rowItem = BaseAuditImpl.GetSystemOperators(billDocumentId, stepCode, this.AuditComModelObj.Moduletype);
|
|
if (rowItem != null)
|
|
{
|
|
beforeMenuname = rowItem["menuname"] + "";
|
|
beforeUsers = rowItem["operators"] + "";
|
|
beforeId = Convert.ToInt32(rowItem["id"]);
|
|
}
|
|
bool isBack = string.IsNullOrEmpty(this.BaseAccraditModelObj.MenuCond) ||
|
|
this.SectionAccradit == null ||
|
|
Convert.ToInt32(stepCode) >= Convert.ToInt32(this.SectionAccradit["stepCode"] + "");
|
|
|
|
string prodouceName = isBack ? AuditComModelObj.ProcedureName + "back" : AuditComModelObj.ProcedureName;
|
|
// string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, stepCode, billDocumentId, isBack ? string.Format(ResourceKeys.ForcedReturnBill, billDocumentId) + "" : "", prodouceName, "R", "0", hintMsg, "", "", !isBack, -1, 0, true);
|
|
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,out string msgText, this.SysModel, stepCode, billDocumentId, isBack ? string.Format(ResourceKeys.ForcedReturnBill, billDocumentId) + "" : "", prodouceName, "R", "0", hintMsg, "", "", !isBack, -1, 0, true);
|
|
|
|
string tag = isBack ? "1" : "0";
|
|
if (result == "1")
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ForcedSuccess);
|
|
// 推送消息
|
|
PushHelper push = new PushHelper(billDocumentId, stepCode, this.SysModel.ModuleCode, beforeUsers, beforeMenuname, beforeId);
|
|
if (this.AuditComModelObj.Moduletype == "base")
|
|
{
|
|
push.Push_Base_Oper_Message();
|
|
}
|
|
else
|
|
{
|
|
push.Push_Bill_Oper_Message();
|
|
}
|
|
if (tag == "1")
|
|
{
|
|
if (this.PanelCondVisible)
|
|
{
|
|
btnSearch.PerformClick();
|
|
}
|
|
else
|
|
{
|
|
this._searchContrl.SearchLastGrid();
|
|
}
|
|
RefreshTabPage();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("返审操作出错!" + Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 刷新数据
|
|
/// <summary>
|
|
/// <para>说明:刷新窗体</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
public void RefreshTabPage()
|
|
{
|
|
DataTable detailTable = gcDetail.GridControl.DataSourceTable();
|
|
detailTable.Clear();
|
|
this.ControlObj.ResetControlValue();
|
|
foreach (TabPageObj tab in this._tabPageObjs)
|
|
{
|
|
int cnt = 0;
|
|
foreach (TabPageItemObj item in tab.TabPageItemObjs)
|
|
{
|
|
int oldRowHandle = item.GridControlObj.GridView.FocusedRowHandle;
|
|
item.GridControlObj.SetGridViewDataSource(BaseImpl.GetDataTableResult(item.AuditModel.StepSql));
|
|
cnt += item.GridControlObj.GridView.RowCount;
|
|
// 为表格增加一列复选框列
|
|
//DataTable table = item.GridControlObj.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 (!(BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag))
|
|
{
|
|
item.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
|
}
|
|
Application.DoEvents();
|
|
}
|
|
tab.TabPage.Text = tab.FlowStepModel.StepGroup + "(" + cnt + ")";
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 手动刷新
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnReflash_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
RefreshTabPage();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#region 附件管理
|
|
/// <summary>
|
|
/// <para>说明:附件管理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-01-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.String.</returns>
|
|
private void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(this.SysModel.BillDocumentId))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundBillNo);
|
|
}
|
|
else
|
|
{
|
|
string url = string.Format("pages/PhotoView.html?left=1&username={0}&password={1}&id={2}&isview={3}&dllcoid=", ERPInfo.Instance.UserName, ERPInfo.Instance.Password, this.SysModel.BillDocumentId, this.btnAccradit.Enabled ? "0" : "1");
|
|
// 固定传入参数(窗口标题、操作员ID、操作员名称、权限、模版编号)
|
|
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~');
|
|
string[] menuArgs = SystemInfo.Instance.BsAttachFlag.Equals("1") ? new string[] { "", "", url } : new string[] { this.SysModel.BillDocumentId, "0", this.BillModelObj.DirId + "", "" };
|
|
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
|
IForm form = FormHelper.LoadDllForm(SystemInfo.Instance.BsAttachFlag.Equals("1") ? ResourceDynamic.PubBrower : ResourceDynamic.PhotoView, args);
|
|
DialogResult result = form.SubForm.ShowDialog();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 优化加载速度
|
|
/// </summary>
|
|
protected override CreateParams CreateParams
|
|
{
|
|
get
|
|
{
|
|
CreateParams cp = base.CreateParams;
|
|
cp.ExStyle |= 0x02000000;
|
|
return cp;
|
|
}
|
|
}
|
|
|
|
public EventHandler GridView_DoubleClick { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 导出明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
LogUtil.WriteDebug(this.SysModel.ModuleCode, "导出数据", this.SysModel.FormText, "单据明细导出", this.SysModel.ModuleId + "");
|
|
this.gcDetail.GridControl.ToExcel(this.SysModel.FormText);
|
|
}
|
|
/// <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 OnBtnFPOldClick(object sender, EventArgs e)
|
|
{
|
|
this.gcDetail.GridView.PostEditor();
|
|
FPOld();
|
|
}
|
|
private void OnBtnFPNewClick(object sender, EventArgs e)
|
|
{
|
|
this.gcDetail.GridView.PostEditor();
|
|
FPNew();
|
|
}
|
|
/// <summary>
|
|
/// 新版分配
|
|
/// </summary>
|
|
private void FPNew(int rowHandle = 0)
|
|
{
|
|
try
|
|
{
|
|
this.gcDetail.GridView.FocusedRowHandle = rowHandle;
|
|
DataTable table = this.gcDetail.GridControl.DataSource as DataTable;
|
|
if (!table.Columns.Contains(guidField))
|
|
{
|
|
table.Columns.Add(guidField, typeof(string));
|
|
}
|
|
#region 创建分配界面
|
|
string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" };
|
|
DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args);
|
|
using (FrmBaseSelectBatch frmSelect = new FrmBaseSelectBatch(baseModel, this.ControlObj, this.gcDetail))
|
|
{
|
|
frmSelect.Text = this.BillModelObj.TypeName;
|
|
frmSelect.InitControl();
|
|
frmSelect.OnAfterFPCallback += OnAfterFPCallback;
|
|
#region 初始化第一条数据
|
|
DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow();
|
|
if (rowItem == null)
|
|
{
|
|
return;
|
|
}
|
|
rowItem[guidField] = Guid.NewGuid().ToString();
|
|
if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField))
|
|
{
|
|
// 检查数据是否为分配后的行
|
|
if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + ""))
|
|
{
|
|
if (this.gcDetail.GridView.FocusedRowHandle + 1 <= this.gcDetail.GridView.RowCount - 1)
|
|
{
|
|
int focusedRowHandle = this.gcDetail.GridView.FocusedRowHandle + 1;
|
|
this.gcDetail.GridView.FocusedRowHandle = focusedRowHandle;
|
|
if (this.gcDetail.GridView.FocusedRowHandle == focusedRowHandle)
|
|
{
|
|
FPNew(focusedRowHandle);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("全部分配完毕");
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
frmSelect.InitData(rowItem);
|
|
frmSelect.OnBtnFPClick(null, null);
|
|
#endregion
|
|
//frmSelect.ShowDialog();
|
|
#endregion
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 分配完成后回调
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnAfterFPCallback(object sender, EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
// 临时禁用新增行(空白行)
|
|
if (this.BillModelObj.DefaultAddEmptyRow) this.gcDetail.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.None;
|
|
DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow();
|
|
if (rowItem == null)
|
|
{
|
|
return;
|
|
}
|
|
DataTable table = this.gcDetail.GridControl.DataSource as DataTable;
|
|
FrmBaseSelectBatch frmSelect = (FrmBaseSelectBatch)sender;
|
|
rowItem[guidField] = Guid.NewGuid().ToString();
|
|
if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField))
|
|
{
|
|
// 检查数据是否为分配后的行
|
|
if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + ""))
|
|
{
|
|
if (this.gcDetail.GridView.FocusedRowHandle + 1 <= this.gcDetail.GridView.RowCount - 1)
|
|
{
|
|
this.gcDetail.GridView.FocusedRowHandle += 1;
|
|
OnAfterFPCallback(sender, e);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
frmSelect.InitData(rowItem);
|
|
bool success = frmSelect.FP();
|
|
if (success)
|
|
{
|
|
if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0)
|
|
{
|
|
// 增加标识列
|
|
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];
|
|
DataColumn IsIdentCol = newRow.Table.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + "");
|
|
//自增长列分配按空值取
|
|
if (IsIdentCol != null)
|
|
{
|
|
if (IsIdentCol.DataType == typeof(Decimal) ||
|
|
IsIdentCol.DataType == typeof(Double) ||
|
|
IsIdentCol.DataType == typeof(Int16) ||
|
|
IsIdentCol.DataType == typeof(Int32) ||
|
|
IsIdentCol.DataType == typeof(Int64))
|
|
{
|
|
newRow[IsIdentCol.ColumnName] = 0;
|
|
}
|
|
}
|
|
foreach (DataColumn col in item.Table.Columns)
|
|
{
|
|
if (table.Columns.Contains(col.ColumnName))
|
|
{
|
|
//newRow[col.ColumnName] = item[col.ColumnName];
|
|
newRow[col.ColumnName] = item[col.ColumnName];
|
|
GridColumn column = this.gcDetail.GridView.Columns[col.ColumnName];
|
|
if (column != null)
|
|
{
|
|
GridColumnModel model = column.Tag as GridColumnModel;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[column.FieldName] + "", newRow);
|
|
}
|
|
}
|
|
}
|
|
newRow[frmSelect.AmountField] = item[frmSelect.AmountField];
|
|
newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField];
|
|
table.Rows.Add(newRow);
|
|
}
|
|
NumberMc = frmSelect.AmountField;
|
|
table.Rows.Remove(rowItem);
|
|
// 重排顺序
|
|
table.OrderBy(this.BillModelObj.DetailOrderField);
|
|
this.gcDetail.GridView.UpdateCurrentRow();
|
|
this.gcDetail.GridView.ShowEditor();
|
|
if (frmSelect.isNextOne)
|
|
{
|
|
int SourceRowIndex = this.gcDetail.GridView.GetFocusedDataSourceRowIndex();
|
|
DataRow[] a = table.Rows.Cast<DataRow>().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray();
|
|
if (a.Length != 0)
|
|
{
|
|
this.gcDetail.GridView.FocusedRowHandle = SourceRowIndex;
|
|
OnAfterFPCallback(sender, e);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("全部分配完毕");
|
|
// frmSelect.SelectRowItem = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (this.gcDetail.GridView.FocusedRowHandle + 1 <= this.gcDetail.GridView.RowCount - 1)
|
|
{
|
|
this.gcDetail.GridView.FocusedRowHandle += 1;
|
|
OnAfterFPCallback(sender, e);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("全部分配完毕");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
// 重新开启新增行(空白行)
|
|
if (this.BillModelObj.DefaultAddEmptyRow) this.gcDetail.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom;
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 老版分配
|
|
/// </summary>
|
|
private void FPOld()
|
|
{
|
|
try
|
|
{
|
|
DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow();
|
|
if (rowItem == null)
|
|
{
|
|
MessageUtil.Show("请先选择一条明细在进行分配!");
|
|
return;
|
|
}
|
|
DataTable table = this.gcDetail.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] + "") && !this.BillModelObj.IgnoreAllocated)
|
|
{
|
|
MessageUtil.Show("该行数据为已分配后的数据,无需分配!");
|
|
return;
|
|
}
|
|
}
|
|
string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" };
|
|
DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args);
|
|
using (FrmBaseSelect frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcDetail))
|
|
{
|
|
//if (frmSelect.SelectRowItem == null)
|
|
//{
|
|
// frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain);
|
|
//}
|
|
frmSelect.Text = this.BillModelObj.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)
|
|
{
|
|
if (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];
|
|
DataColumn IsIdentCol = newRow.Table.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + "");
|
|
//自增长列分配按空值取
|
|
if (IsIdentCol != null)
|
|
{
|
|
if (IsIdentCol.DataType == typeof(Decimal) ||
|
|
IsIdentCol.DataType == typeof(Double) ||
|
|
IsIdentCol.DataType == typeof(Int16) ||
|
|
IsIdentCol.DataType == typeof(Int32) ||
|
|
IsIdentCol.DataType == typeof(Int64))
|
|
{
|
|
newRow[IsIdentCol.ColumnName] = 0;
|
|
}
|
|
}
|
|
foreach (DataColumn col in item.Table.Columns)
|
|
{
|
|
if (table.Columns.Contains(col.ColumnName))
|
|
{
|
|
//newRow[col.ColumnName] = item[col.ColumnName];
|
|
newRow[col.ColumnName] = item[col.ColumnName];
|
|
GridColumn column = this.gcDetail.GridView.Columns[col.ColumnName];
|
|
if (column != null)
|
|
{
|
|
GridColumnModel model = column.Tag as GridColumnModel;
|
|
if (!string.IsNullOrEmpty(model.UnionFields))
|
|
{
|
|
this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow);
|
|
}
|
|
SetCalcValue(model, rowItem[column.FieldName] + "", newRow);
|
|
}
|
|
}
|
|
}
|
|
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.BillModelObj.DetailOrderField);
|
|
this.gcDetail.GridView.UpdateCurrentRow();
|
|
this.gcDetail.GridView.ShowEditor();
|
|
}
|
|
}
|
|
if (frmSelect.isNextOne)
|
|
{
|
|
int SourceRowIndex = this.gcDetail.GridView.GetFocusedDataSourceRowIndex();
|
|
DataRow[] a = table.Rows.Cast<DataRow>().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray();
|
|
if (a.Length != 0)
|
|
{
|
|
this.gcDetail.GridView.FocusedRowHandle = SourceRowIndex;
|
|
OnBtnFPOldClick(null, null);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show("全部分配完毕");
|
|
// frmSelect.SelectRowItem = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
/// <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.gcDetail.gridControl.DataSourceTable();
|
|
//DataRow rowItem = this.gridView.GetFocusedDataRow();
|
|
string unionValues = model.UnionValues;
|
|
if (rowItem != null && model != null)
|
|
{
|
|
unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue));
|
|
if (this.ControlObj != null)
|
|
{
|
|
unionValues = ControlObj.ReplaceParentControlValue(unionValues);
|
|
}
|
|
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>创建日期: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.gcDetail.gridControl.DataSourceTable();
|
|
if (rowItem != null && model != null)
|
|
{
|
|
List<GridColumnModel> calcModels = this.gcDetail.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>
|
|
/// 设置修改过的控件颜色
|
|
/// </summary>
|
|
public void SetColor()
|
|
{
|
|
this.ControlObj.SetClearBackgroundColor();
|
|
List<string> FieldList = AuditChangeLog.GetChangeLogFields(this.SysModel.BillDocumentId);
|
|
foreach (string item in FieldList)
|
|
{
|
|
this.ControlObj.SetBackgroundColor(item);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|