Files
lserp_cs_6.0/插件库/Lskj.PubAccraditation/FrmAccraditation.cs
T
wyf 0c35b18c44 SVN r622
SVN-Revision: r622
2025-05-22 08:42:22 +00:00

3193 lines
149 KiB
C#

/***********************
* 说明:单据审批弹出模块
* 创建人:龚宇超
* 创建日期:2018-01-02
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
***********************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control;
using Lskj.Control.Model;
using Lskj.Util;
using Lskj.Data;
using Lskj.Model;
using Lskj.Business.Impl;
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;
using Lskj.Business;
using DevExpress.XtraBars;
using System.Collections;
using Lskj.Core;
using System.Threading.Tasks;
using DevExpress.Utils;
using DevExpress.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Lskj.PubAccraditation
{
/// <summary>
/// 单据审批弹出模块
/// </summary>
public partial class FrmAccraditation : BaseForm
{
public FrmAccraditation()
{
InitializeComponent();
}
#region 公有变量
/// <summary>
/// 单据结构明细
/// </summary>
public AccraditationModel AuditModelObj;
/// <summary>
/// 单据模型
/// </summary>
public BillAuditModel BillModelObj;
/// <summary>
/// 单据审批表模型
/// </summary>
public BillAuditCommonModel BillAuditComObj;
/// <summary>
/// 单据入口参数模型
/// </summary>
public DynamicPubAccraditionPopModel SysModel;
/// <summary>
/// 主表控件
/// </summary>
public MyControl ControlObj;
/// <summary>
/// 是否是Brp模块加载审核明细
/// </summary>
public bool isBrpAccrad = false;
#endregion
/// <summary>
/// 调用动态链接库默认传递参数
/// </summary>
public DynamicModel syModel { get; private set; }
/// <summary>
/// 关闭当前审核界面,刷新打开界面
/// </summary>
/// <param name="sender">The sender.</param>
public event RefreshThePage refreshThePage;
public delegate void RefreshThePage(string promptInformation, string id);
/// <summary>
/// 主表动态生成的日期列
/// </summary>
public List<GridColumn> DateColumnList = new List<GridColumn>();
#region 私有变量
/// <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>
/// 获取隐藏的x轴距
/// </summary>
private ArrayList LocationX = new ArrayList();
/// <summary>
/// 是否执行了加载储存过程
/// </summary>
public bool ProcessExists = false;
#endregion
/// <summary>
/// <para>说明:窗体加载时</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-01-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected override void OnLoad(EventArgs e)
{
WaitForm.ShowForm();
try
{
string results = BaseImpl.GetResult("IF EXISTS(SELECT *FROM SYSOBJECTS WHERE NAME ='p_Get_NewDesignPlatform_DocumentsReview' AND TYPE = 'P') begin select 1 end else Begin select 2 end").ToString();
if (results.Equals("1") && SystemInfo.Instance.isExecload)
{
System.Data.DataSet dsConfig = BillImpl.GetNewDesignPlatformDocumentsReview(SysModel, Lskj.Data.ResourceKeys.SettingTableName);
Lskj.Data.Caches.CacheSYSConfig.Instance().SetData(dsConfig);
ProcessExists = true;
}
this._isInitFinish = false;
this.splitMain.Visible = false;
this.InitializeSetting();
this.InitializeControl();
this.InitializeSplitterPosition();
if (SystemInfo.Instance.ReviewCommentsRequired)
{
label_auditPerson.ForeColor = string.IsNullOrEmpty(SystemInfo.Instance.ControlRequiredColor) ? Color.Blue : ColorTranslator.FromHtml(SystemInfo.Instance.ControlRequiredColor);
this.txtRemark.Text = "";
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule);
LogUtil.WriteError("单据审批初始化出错!", ex);
//MessageUtil.Show(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
//2023-10-13 丁哥规定在明细的附加信息中配置双击参数(DBClickEvent),上方的AuditLoadDetailFlag失效
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).TreeListObj.FocusedNodeChanged += TreeListObj_FocusedNodeChanged;
(this.gridBillInfo as TreeGridControlEx).TreeListObj.DoubleClick += new EventHandler(gridView_DoubleClick);
}
else
{
this.gridBillInfo.GridView.FocusedRowObjectChanged += GridView_FocusedRowObjectChanged;//SelectionChanged事件会执行2次,故改成焦点行改变事件
this.gridBillInfo.GridView.DoubleClick += new EventHandler(gridView_DoubleClick);
}
WaitForm.HideForm();
this._isInitFinish = true;
this.splitMain.Visible = true;
InitButLocation();
}
}
#region 获取数据源缓存
/// <summary>
/// 获取数据源缓存
/// </summary>
/// <param name="cachesDic"></param>
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
{
//全局数据
Task<DynamicModel> dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task<DynamicModel>(() =>
{
return SysModel;//动态链接库对象
}));
DynamicPubAccraditionPopModel dynamicModel = (DynamicPubAccraditionPopModel)dynamicModelTask.Result;
#region InitializeSetting
Task<DataRow> accraditationModelRowTask = cachesDic.AddTask(this, "AccraditationModelRow", new Task<DataRow>(() =>
{
return BillAuditImpl.GetBillFlowData(dynamicModel.ModuleCode, dynamicModel.StepCode);
}));
Task<AccraditationModel> accraditationModelTask = cachesDic.AddTask(this, "AccraditationModel", new Task<AccraditationModel>(() =>
{
return new AccraditationModel(accraditationModelRowTask.Result);
}));
Task<DataRow> billInfoTask = cachesDic.AddTask(this, "BillInfo", new Task<DataRow>(() =>
{
return BillImpl.GetBillInfo(dynamicModel.ModuleCode);//获取单个模块信息
}));
Task<BillAuditModel> billAuditModelTask = cachesDic.AddTask(this, "BillAuditModel", new Task<BillAuditModel>(() =>
{
BillAuditModel billAuditModel = new BillAuditModel(billInfoTask.Result);
Task<string> masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task<string>(() =>
{
return BaseImpl.GetColumnPrefix(billAuditModel.MasterTable);
}));
Task<string> detailPreFixTask = cachesDic.AddTask(this, "DetailPreFix", new Task<string>(() =>
{
return BaseImpl.GetColumnPrefix(billAuditModel.DetailTable);// 明细表列前缀
}));
billAuditModel.MasterPreFix = masterPreFixTask.Result;
billAuditModel.DetailPreFix = detailPreFixTask.Result;
billAuditModel.DetailOrderField = detailPreFixTask.Result + "lsidx_id";// 单据来源id
return billAuditModel;
}));
Task<BillAuditCommonModel> billAuditCommonModelTask = cachesDic.AddTask(this, "BillAuditCommonModel", new Task<BillAuditCommonModel>(() =>
{
return new BillAuditCommonModel();
}));
Task<DataRow> menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task<DataRow>(() =>
{
return BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); //获取菜单其他配置
}));
Task<int> fileCountTask = cachesDic.AddTask(this, "FileCount", new Task<int>(() =>
{
return AttachImpl.GetFileCount(billAuditModelTask.Result.DirId + "", dynamicModel.BillDocumentId);
}));
//记录推送用户
Task<DataRow> pushedOpersTask = cachesDic.AddTask(this, "PushedOpers", new Task<DataRow>(() =>
{
return BillAuditImpl.GetPushedOpers(dynamicModel.BillDocumentId, dynamicModel.StepCode);
}));
Task<DataTable> billInfoDataTask = cachesDic.AddTask(this, "BillInfoData", new Task<DataTable>(() =>
{
return BillAuditImpl.GetBillInfoData(dynamicModel.ModuleCode);
}));
#endregion
#region InitializeControl
Task<DataTable> readOnlyColumnsTask = cachesDic.AddTask(gridFlow, "ReadOnlyColumns", new Task<DataTable>(() =>
{
return BaseAuditImpl.GetFlowRecordColumn();
}));
string customColumKey = GridCustomColumnStruct.AuditPopupAttachGridView + billAuditModelTask.Result.FormKey;
cachesDic.AddTask(gridFlow, "DynamicModel", dynamicModelTask);
gridFlow.GetDataCaches(cachesDic, customColumKey);
Task<DataTable> gridViewDataSourceTask = cachesDic.AddTask(gridFlow, "GridViewDataSource", new Task<DataTable>(() =>
{
return BaseAuditImpl.GetFlowRecordData(billAuditCommonModelTask.Result.SystemTabFlowStep, dynamicModel.BillDocumentId, dynamicModel.ModuleCode);
}));
//BindTab
Task<List<GridDetailModel>> detailTask = cachesDic.AddTask(gridFlow, "Details", new Task<List<GridDetailModel>>(() =>
{
List<GridDetailModel> details = new List<GridDetailModel>();
DataTable table = BaseAuditImpl.GetAttachTabs(dynamicModel.ModuleCode, dynamicModel.StepCode);
foreach (DataRow item in table.Rows)
{
if (table.Columns.Contains("privilegeoper"))
{
string privilegeoper = item["privilegeoper"] + "";//配置的权限人员
if (string.IsNullOrWhiteSpace(privilegeoper) || privilegeoper.Split(',').Contains(ERPInfo.Instance.UserName))
{
GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.AuditPopupBasicInfoGridView + item["formKey"] + "");
details.Add(gridDetailModel);
Task<DataTable> addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task<DataTable>(() =>
{
DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
gridDetailModel.GridColumns = gridColumns;
return gridColumns;
}));
}
}
else
{
GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.AuditPopupBasicInfoGridView + item["formKey"] + "");
details.Add(gridDetailModel);
Task<DataTable> addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task<DataTable>(() =>
{
DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
gridDetailModel.GridColumns = gridColumns;
return gridColumns;
}));
}
}
return details;
}));
cachesDic.AddTask(tab_basicInfo, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(tab_basicInfo, "Details", detailTask);
tab_basicInfo.GetDataCaches(cachesDic);
//BindBill
Task<DataTable> controlLocationTask = cachesDic.AddTask(this, "ControlLocation", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetControlLocation(billAuditModelTask.Result.FormKey, dynamicModel.ModuleCode);
}));
Task<MyControl> controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task<MyControl>(() =>
{
MyControl myControl = new MyControl();
myControl.Model = SysModel;
myControl.PrimaryValue = dynamicModel.BillDocumentId;
cachesDic.AddTask(myControl, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(myControl, "ControlsTable", controlLocationTask);
myControl.GetControlDataCaches(cachesDic);
return myControl;
}));
Task<DataTable> detailColumnsTask = cachesDic.AddTask(gridBillInfo, "DetailColumns", new Task<DataTable>(() =>
{
return BillImpl.GetDetailColumns(dynamicModel.ModuleCode);
}));
string gridBillCustomColumKey = GridCustomColumnStruct.AuditPopupDetailGridView + billAuditModelTask.Result.FormKey;
cachesDic.AddTask(gridBillInfo, "DynamicModel", dynamicModelTask);
gridBillInfo.GetDataCaches(cachesDic, gridBillCustomColumKey);
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(gridBillInfo, "BaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(accraditationModelTask.Result.BillGridMenuFlag + dynamicModel.ModuleCode, ModuleType.BillAuditDetail);
}));
Task<DataTable> baseGridRowColorsTask = cachesDic.AddTask(gridBillInfo, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + billAuditModelTask.Result.FormKey);
}));
//设置必填和修改字段
Task<DataRow> currentFlowRowDataTask = cachesDic.AddTask(this, "CurrentFlowRowData", new Task<DataRow>(() =>
{
DataRow currentFlowRowData = BaseAuditImpl.GetCurrentFlowRowData(billAuditModelTask.Result.MasterTable, billAuditModelTask.Result.PrimaryKey, dynamicModel.BillDocumentId);
if (currentFlowRowData != null)
{
string mainBillTypeValue = currentFlowRowData[billAuditModelTask.Result.BillType] + "";
if (!string.IsNullOrEmpty(mainBillTypeValue) && mainBillTypeValue != "0")
{
//SetButtonsStatus
Task<DataRow> billFlowStepTask = cachesDic.AddTask(this, "BillFlowStep", new Task<DataRow>(() =>
{
DataRow billFlowStep = BillAuditImpl.GetBillFlowStep(dynamicModel.ModuleCode, mainBillTypeValue, dynamicModel.StepCode);
if (billFlowStep != null)
{
Task<FlowTypeStepModel> flowTypeStepModelTask = cachesDic.AddTask(this, "FlowTypeStepModel", new Task<FlowTypeStepModel>(() =>
{
FlowTypeStepModel flowTypeStepModel = new FlowTypeStepModel(billFlowStep);
//LoadRemindRecord
if (flowTypeStepModel != null && !string.IsNullOrEmpty(flowTypeStepModel.RemindSelect))
{
Task<DataTable> remindinRecordTask = cachesDic.AddTask(gridRemind, "RemindinRecord", new Task<DataTable>(() =>
{
DataTable dt = BaseAuditImpl.GetRemindinRecord(billAuditCommonModelTask.Result.FlowStepTable, billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode);
if (dt != null && dt.Rows.Count > 0)
{
Task<DataTable> gridRemindReadOnlyColumnsTask = cachesDic.AddTask(gridRemind, "ReadOnlyColumns", new Task<DataTable>(() =>
{
return BaseAuditImpl.GetRemindColumn();
}));
cachesDic.AddTask(gridRemind, "DynamicModel", dynamicModelTask);
gridRemind.GetDataCaches(cachesDic);
}
return dt;
}));
}
return new FlowTypeStepModel(billFlowStep);
}));
string operUser = flowTypeStepModelTask.Result.OperUser;
Task<DataRow> operatorsTask = cachesDic.AddTask(this, "Operators", new Task<DataRow>(() =>
{
DataRow operators = BillAuditImpl.GetOperators(dynamicModel.ModuleCode, dynamicModel.BillDocumentId, dynamicModel.StepCode);
operUser = operators != null ? operators["operators"] + "" : operUser;
if (operUser.StartsWith("@"))
{
string sql = string.Format("select count(1) from p_employeetab where ({0}) and employeeid='{1}' ", ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, ReplaceHelper.ReplaceUserInfo(operUser)).Replace("@", "").Replace("''", "'"), ERPInfo.Instance.UserId);
Task<string> numberTask = cachesDic.AddTask(this, "Number", new Task<string>(() =>
{
return BaseImpl.GetResult(sql) + "";
}));
}
return operators;
}));
Task<bool> billComfirmTask = cachesDic.AddTask(this, "BillComfirm", new Task<bool>(() =>
{
return BillAuditImpl.GetBillComfirm(this.SysModel.ConfirmId) < 0;
}));
//代理权限
Task<DataRow> agencyAuthorityTask = cachesDic.AddTask(this, "AgencyAuthority", new Task<DataRow>(() =>
{
return BillAuditImpl.GetAgencyAuthority(dynamicModel.ModuleCode);
}));
}
return billFlowStep;
}));
}
}
return currentFlowRowData;
}));
//LoadSignRecord
if (billAuditCommonModelTask.Result != null)
{
Task<DataTable> signRecordTask = cachesDic.AddTask(gridSign, "SignRecord", new Task<DataTable>(() =>
{
DataTable dt = BaseAuditImpl.GetSignRecord(billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode);
if (dt != null && dt.Rows.Count > 0)
{
Task<DataTable> gridSignReadOnlyColumnsTask = cachesDic.AddTask(gridSign, "ReadOnlyColumns", new Task<DataTable>(() =>
{
return BaseAuditImpl.GetSignRecordCoulumn();
}));
cachesDic.AddTask(gridSign, "DynamicModel", dynamicModelTask);
gridSign.GetDataCaches(cachesDic);
}
return dt;
}));
}
//InitCommonMenu
Task<DataTable> tableCommonTask = cachesDic.AddTask(this, "TableCommon", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.BillDetail);
}));
//InitOtherParms
Task<DataTable> checkSuggestionDataSourceTask = cachesDic.AddTask(this, "CheckSuggestionDataSource", new Task<DataTable>(() =>
{
return BaseImpl.GetDataTableResult(accraditationModelTask.Result.SuggestionSql);
}));
#endregion
}
#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 InitializeSetting()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "AccraditationModel", out this.AuditModelObj))
{
this.AuditModelObj = new AccraditationModel(BillAuditImpl.GetBillFlowData(this.SysModel.ModuleCode, this.SysModel.StepCode));
}
if (!dataCaches.GetValue(this, "BillInfo", out DataRow modelRow))
{
modelRow = BillImpl.GetBillInfo(this.SysModel.ModuleCode);//获取单个模块信息
}
if (modelRow == null)
{
throw new Exception("模块编号[" + this.SysModel.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
}
if (!dataCaches.GetValue(this, "BillAuditModel", out this.BillModelObj))
{
this.BillModelObj = new BillAuditModel(modelRow);
this.BillModelObj.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.MasterTable);
this.BillModelObj.DetailPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.DetailTable);// 明细表列前缀
this.BillModelObj.DetailOrderField = this.BillModelObj.DetailPreFix + "lsidx_id";// 单据来源id
}
if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序
{
this.BillModelObj.DetailOrderField = string.Empty;
}
if (!dataCaches.GetValue(this, "BillAuditCommonModel", out this.BillAuditComObj))
{
this.BillAuditComObj = new BillAuditCommonModel();
}
this.Text = this.SysModel.FormText + "—" + this.AuditModelObj.CurstepName + " " + string.Format(ResourceKeys.BillNoTitle, this.SysModel.BillDocumentId);
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.label_auditPerson.Text = this.label_managerAudit.LabelText = this.AuditModelObj.CurstepName;
this.label_managerAudit.EditText = this.SysModel.UserName;
this.pl_right_bottom.Tag = this.p_right_bottom.Tag = "NotChangeLocation";
if (!dataCaches.GetValue(this, "MenuConfigTab", out DataRow menuCondRow))
{
menuCondRow = BaseImpl.GetMenuConfigTab(this.SysModel.ModuleId); //获取菜单其他配置
}
if (!dataCaches.GetValue(this, "FileCount", out int fileCount))
{
fileCount = AttachImpl.GetFileCount(this.BillModelObj.DirId + "", this.SysModel.BillDocumentId);
}
this.btnAttach.Text += "(" + fileCount + ")";
if (menuCondRow != null)
{
if (menuCondRow["DllFileName"].Equals("Lskj.PubAccraditationBrp.dll")) this.isBrpAccrad = true;// 是否是Brp模式加载
}
if (this.BillModelObj.AutoMultiHeader == 1)
{
this.pl_detail.Controls.Clear();
this.gridBillInfo = new BandedGridControlEx();
this.gridBillInfo.Model = this.SysModel;
this.gridBillInfo.Dock = DockStyle.Fill;
this.pl_detail.Controls.Add(this.gridBillInfo);
}
//树表格
if (this.BillModelObj.DetailTreeTable)
{
this.pl_detail.Controls.Clear();
this.gridBillInfo = new TreeGridControlEx();
this.gridBillInfo.Dock = DockStyle.Fill;
this.pl_detail.Controls.Add(this.gridBillInfo);
(this.gridBillInfo as TreeGridControlEx).Expansion = this.BillModelObj.DetailTreeTableExpansion;
(this.gridBillInfo as TreeGridControlEx).AddRightButton();
//节点编号
(this.gridBillInfo as TreeGridControlEx).TreeListObj.KeyFieldName = "tap_id";
//父节点编号
(this.gridBillInfo as TreeGridControlEx).TreeListObj.ParentFieldName = "tap_pid";
(this.gridBillInfo as TreeGridControlEx).SortField = this.BillModelObj.DetailOrderField;
(this.gridBillInfo as TreeGridControlEx).InitializedragState();
}
//记录推送用户
this.GetPushOpers();
this.gridFlow.GridView.RowStyle += new RowStyleEventHandler(gridFlowInfo_RowStyle);
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).TreeListObj.Paint += new PaintEventHandler(gridBillInfo_Panint);
(this.gridBillInfo as TreeGridControlEx).TreeListObj.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor);
}
else
{
this.gridBillInfo.gridControl.Paint += new PaintEventHandler(gridBillInfo_Panint);
this.gridBillInfo.GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor);
}
if (!dataCaches.GetValue(this, "BillInfoData", out this._dtBillInfoFiled))
{
this._dtBillInfoFiled = BillAuditImpl.GetBillInfoData(this.SysModel.ModuleCode);
}
}
#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.gridBillInfo.GridView.GetDataRow(this.gridBillInfo.GridView.FocusedRowHandle);
if (this.BillModelObj.DetailTreeTable)
{
rowItem = (this.gridBillInfo as TreeGridControlEx).GetViewFocusedDataRow();
}
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);
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 gridFlowInfo_RowStyle(object sender, RowStyleEventArgs e)
{
try
{
if (e.RowHandle > 0)
{
DataRow dr = this.gridFlow.GridView.GetDataRow(e.RowHandle);
if (dr["sh"].ToString() == "审") e.Appearance.ForeColor = Color.Blue;
}
}
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 InitializeControl()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(gridFlow, "ReadOnlyColumns", out DataTable dtReadOnlyColumns))
{
dtReadOnlyColumns = BaseAuditImpl.GetFlowRecordColumn();
}
if (!dataCaches.GetValue(gridFlow, "GridViewDataSource", out DataTable dtridViewDataSource))
{
dtridViewDataSource = BaseAuditImpl.GetFlowRecordData(this.BillAuditComObj.SystemTabFlowStep, this.SysModel.BillDocumentId, this.SysModel.ModuleCode);
}
this.gridFlow.Model = SysModel;
this.gridFlow.SetReadOnlyColumns(dtReadOnlyColumns, GridCustomColumnStruct.AuditPopupAttachGridView + this.BillModelObj.FormKey);
this.gridFlow.SetGridViewDataSource(dtridViewDataSource);
this.SetFormSize();
this.BindTab();
this.BindBill();
this.LoadRemindRecord();
this.LoadSignRecord();
this.InitCommonMenu();
this.InitOtherParms();
this.InitOkBtn();
}
#endregion
#region
/// <summary>
/// <para>说明:录所有按钮的位置</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2020-11-25 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void InitButLocation()
{
LocationX.Clear();
int newlocationX = 0;
foreach (System.Windows.Forms.Control control in pl_bottom.Controls)
{
int x = control.Location.X;
bool isvisbel = control.Visible;
if (!control.Visible)
{
LocationX.Add(x);
}
}
foreach (System.Windows.Forms.Control control in pl_bottom.Controls)
{
int x = control.Location.X;
newlocationX = control.Location.X;
foreach (int b in LocationX)
{
if (x < b)
{
newlocationX += 73;
}
}
control.Location = new Point(newlocationX, control.Location.Y);
}
if (!btnRemindAccradit.Visible)
{
CheckSuggestion.Width = btnRemindAccradit.Location.X + btnRemindAccradit.Width - CheckSuggestion.Location.X;
}
if (!btnRemindBack.Visible)
{
label_managerAudit.Width = btnRemindBack.Location.X + btnRemindBack.Width - label_managerAudit.Location.X;
if (!btnBack.Visible)
{
label_managerAudit.Width = btnBack.Location.X + btnBack.Width - label_managerAudit.Location.X;
}
}
if (!btnClose.Visible)
{
label_date.Width = btnClose.Location.X + btnClose.Width - label_date.Location.X;
}
}
#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()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "TableCommon", out DataTable tableCommon))
{
tableCommon = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail);
}
if (tableCommon == null && tableCommon.Rows.Count <= 0)
{
dpb_Tools.Enabled = false;
return;
}
foreach (DataRow item in tableCommon.Rows)
{
BarButtonItem itemCommon = new BarButtonItem();
itemCommon.Caption = item["menuname"] + "";
itemCommon.Tag = item;
itemCommon.ItemClick += new ItemClickEventHandler(itemCommon_ItemClick);
this.pMenu.AddItem(itemCommon);
}
}
#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)
{
try
{
DataRow rowItem = e.Item.Tag as DataRow;
CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj);
menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
menu.Apply(rowItem);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:执行前单独替换BilldocumentId</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2020-07-24 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="e">The e.</param>
protected void OnMenuApplyBefore(ApplyArgs e)
{
try
{
string[] paramList = new string[e.MemuModel.ParamList.Count];
for (int i = 0; i < e.MemuModel.ParamList.Count; i++)
{
string item = e.MemuModel.ParamList[i];
List<string> condition = ReplaceHelper.GetParamFields(item);
foreach (string cond in condition)
{
string value = this.BillModelObj.PrimaryKey.Equals(cond.Replace("{", "").Replace("}", "").ToLower(), StringComparison.OrdinalIgnoreCase) ? this.SysModel.BillDocumentId : cond;
item = item.Replace(cond, value); ;
}
paramList[i] = item;
}
e.MemuModel.ParamList = paramList.ToList();
}
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.gridFlow.Width;
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-03 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void BindTab()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
this.tab_basicInfo.Model = this.SysModel;
this.tab_basicInfo.ParentGridEx = this.gridBillInfo;
if (this.BillModelObj.SaveRefresh)
{
this.tab_basicInfo.OnDetailSaveGridCallBack += Tab_basicInfo_OnDetailSaveGridCallBack;
}
if (!dataCaches.GetValue(tab_basicInfo, "Details", out List<GridDetailModel> details))
{
details = GetTabDetails();
}
this.tab_basicInfo.InitTabPages(details);
this.splitLeft.PanelVisibility = tab_basicInfo.TabControlObj.TabPages.Count == 0 ? SplitPanelVisibility.Panel1 : SplitPanelVisibility.Both;
this.tab_basicInfo.OnRightCallback += new EventHandler(AuditTab_OnRightCallback);
}
/// <summary>
/// <para>说明:获取选项卡数据</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-01-15 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <returns>List&lt;GridDetailModel&gt;.</returns>
private List<GridDetailModel> GetTabDetails()
{
List<GridDetailModel> details = new List<GridDetailModel>();
DataTable table = BaseAuditImpl.GetAttachTabs(this.SysModel.ModuleCode, this.SysModel.StepCode);
foreach (DataRow item in table.Rows)
{
if (table.Columns.Contains("privilegeoper"))
{
string privilegeoper = item["privilegeoper"] + "";//配置的权限人员
if (string.IsNullOrWhiteSpace(privilegeoper) || privilegeoper.Split(',').Contains(ERPInfo.Instance.UserName))
{
DataTable dtGridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.AuditPopupBasicInfoGridView + item["formKey"] + ""));
}
}
else
{
DataTable dtGridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + "");
details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.AuditPopupBasicInfoGridView + item["formKey"] + ""));
}
}
return details;
}
#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()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
// 初始化表头
if (!dataCaches.GetValue(this, "ControlObj", out this.ControlObj))
{
this.ControlObj = new MyControl();
}
if (!dataCaches.GetValue(this, "ControlLocation", out DataTable dtControlLocation))
{
dtControlLocation = BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode);
}
this.ControlObj.PrimaryValue = this.SysModel.BillDocumentId;
this.ControlObj.InitControl(dtControlLocation, this.pl_left_top);
if (SystemInfo.Instance.AuditAutoScroll)
{
this.pl_left_top.AutoScroll = true;
}
this.ControlObj.OnDataSourceBindCallBack += new EventHandler(OnControlObjOnDataSourceBindCallBack);
this.ControlObj.OnDataFileRefrshCallBack += OnDataFileRefrshFile;
this.pl_left_top.Height = this.BillModelObj.ParentHeight - 36 > this.pl_left_top.Height ? this.pl_left_top.Height : this.BillModelObj.ParentHeight;
//初始明细数据
this.gridBillInfo.Model = this.SysModel;
this.gridBillInfo.ParentControl = this.ControlObj;
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).OnDataSourceBindCallBack += new EventHandler(OnGridBillInfoOnDataSourceBindCallBack);
}
else
{
this.gridBillInfo.OnDataSourceBindCallBack += new EventHandler(OnGridBillInfoOnDataSourceBindCallBack);
}
if (!dataCaches.GetValue(gridBillInfo, "DetailColumns", out DataTable dtDetailColumns))
{
dtDetailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode);
}
this.gridBillInfo.SetEditColumns(dtDetailColumns, GridCustomColumnStruct.AuditPopupDetailGridView + this.BillModelObj.FormKey);
if (!dataCaches.GetValue(gridBillInfo, "BaseGridRightMenus", out DataTable dtGridRightMenu))
{
dtGridRightMenu = BaseModuleImpl.GetBaseGridRightMenus(this.AuditModelObj.BillGridMenuFlag + this.SysModel.ModuleCode, ModuleType.BillAuditDetail);
}
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).SetGridRightMenus(dtGridRightMenu, this.SysModel, OnGridViewRightCallBack);
}
else
{
if (this.gridBillInfo is BandedGridControlEx)// 判断是不是多表头表格
{
//设置表格右键菜单
(this.gridBillInfo as BandedGridControlEx).SetGridRightMenus(dtGridRightMenu, this.SysModel, OnGridViewRightCallBack);
}
else
{
this.gridBillInfo.SetGridRightMenus(dtGridRightMenu, this.SysModel, OnGridViewRightCallBack);
}
}
if (!dataCaches.GetValue(gridBillInfo, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModelObj.FormKey);
}
this.gridBillInfo.SetGridRowColors(dtBaseGridRowColors);
////修改字段
//if (!string.IsNullOrEmpty(this.AuditModelObj.DetailModifyFields) && this.AuditModelObj.DetailModifyFields != "-1")
//{
// gridBillInfo.GridView.OptionsBehavior.Editable = true;
// GridColumnCollection gc = this.gridBillInfo.GridView.Columns;
// this.AuditModelObj.DetailModifyFields = this.AuditModelObj.DetailModifyFields + ",";
// foreach (GridColumn item in gc)
// {
// GridColumnModel model = item.Tag as GridColumnModel;
// item.OptionsColumn.AllowEdit = this.AuditModelObj.DetailModifyFields.IndexOf(item.FieldName + ",", StringComparison.OrdinalIgnoreCase) != -1;
// item.OptionsColumn.ReadOnly = !item.OptionsColumn.AllowEdit;
// if (model.FieldType == ControlType.LabMemoEdit) item.OptionsColumn.AllowEdit = true;
// }
//}
////必填字段
//if (!string.IsNullOrEmpty(this.AuditModelObj.RequiredDetailFields) && this.AuditModelObj.RequiredDetailFields != "-1")
//{
// GridColumnCollection gc = this.gridBillInfo.GridView.Columns;
// string[] RequiredDetail = this.AuditModelObj.RequiredDetailFields.Split(',');
// Color RequiredForceColor = string.IsNullOrEmpty(SystemInfo.Instance.ControlRequiredColor) ? Color.Blue : ColorTranslator.FromHtml(SystemInfo.Instance.ControlRequiredColor);
// foreach (GridColumn item in gc)
// {
// GridColumnModel model = item.Tag as GridColumnModel;
// if (RequiredDetail.Contains(model.FieldName))
// {
// item.AppearanceHeader.Options.UseForeColor = true;
// item.AppearanceHeader.ForeColor = RequiredForceColor;
// }
// }
//}
if (this.AuditModelObj.DetailModifyFields != "-1")
{
this.gridBillInfo.SetReadOnlyAllColumn();
}
//设置必填和修改字段
this.gridBillInfo.SetFieldStatus(this.AuditModelObj.DetailModifyFields, this.AuditModelObj.RequiredDetailFields);
this.SetBillControl(this.AuditModelObj.BillModifyFields, this.AuditModelObj.RequiredFields);
this.InitPrint();
}
/// <summary>
/// <para>说明:数据绑定完后刷新数据</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void OnGridBillInfoOnDataSourceBindCallBack(object sender, EventArgs e)
{
try
{
WaitForm.ShowForm("正在加载数据");
// 设置Brp模版
if (this.isBrpAccrad)
{
this.SetTempleteSelectedValue(this.ControlObj.GetControlValue("brpId"));
}
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId));
if (this.BillModelObj.DetailTreeTable)
{
if (this._dtSourceData.Columns.Contains(this.BillModelObj.DetailOrderField))
{
DataView dataView = this._dtSourceData.AsDataView();
dataView.Sort = this.BillModelObj.DetailOrderField;
this._dtSourceData = dataView.ToTable();
}
(this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData);
}
else
{
this._dtSourceData.OrderBy(this.BillModelObj.DetailOrderField);
this.gridBillInfo.SetGridViewDataSource(_dtSourceData);
}
if (_dtSourceData != null) this._dtSpareSourceData = this._dtSourceData.Clone();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
WaitForm.HideForm();
}
}
/// <summary>
/// <para>说明:设置Brp模版加载明细</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2021-03-02 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void SetTempleteSelectedValue(string id)
{
DataTable detailTable = this.BillModelObj.DetailTreeTable ? (this.gridBillInfo as TreeGridControlEx).GetGridViewDataSource() : gridBillInfo.GridControl.DataSourceTable();
string brpId = id;
// 清空明细
detailTable.Clear();
// 重新设置明细列
DataTable columns = BillImpl.GetBillDetailBrpColumns(brpId);
if (columns != null && columns.Rows.Count > 0)
{
gridBillInfo.SetEditColumns(columns);
}
else
{
gridBillInfo.GridView.Columns.Clear();
if (this.BillModelObj.DetailTreeTable) (this.gridBillInfo as TreeGridControlEx).TreeListObj.Columns.Clear();
}
}
/// <summary>
/// <para>说明:数据绑定完后刷新数据</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void OnControlObjOnDataSourceBindCallBack(object sender, EventArgs e)
{
try
{
this.ControlObj.CanExecControl = false;
this.ControlObj.SetAllControlValue(this._drBillInfoMsg);
this.ControlObj.CanExecControl = true;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:刷新表格列(时间)</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2018-08-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnDataFileRefrshFile(object sender, EventArgs e)
{
BaseUserControl baseControl = (sender as System.Windows.Forms.Control).ToBaseUserControl();
if (baseControl is LabelDateEdit labelDateEdit)
{
DateTime dateTime = labelDateEdit.TextEdit.DateTime;
if (DateColumnList.Count == 0)
{
AddDataColumns();
}
UpdateDynamicColumns(dateTime);
OnGcMainDataSourceChanged(gridBillInfo.GridView, null);//手动刷新日期合计数据源
}
}
private void AddDataColumns()
{
foreach (GridColumn gridColumn in gridBillInfo.GridView.Columns)
{
gridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
}
for (int i = 0; i < 7; i++)
{
GridColumn gridColumn = new GridColumn();
gridColumn.AppearanceCell.Options.UseTextOptions = true;
gridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
gridColumn.AppearanceHeader.Options.UseTextOptions = true;
gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
gridColumn.OptionsColumn.AllowMove = false;
gridColumn.OptionsColumn.AllowSize = false;
gridColumn.OptionsFilter.AllowFilter = false;
gridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False;
gridColumn.OptionsColumn.AllowSort = DefaultBoolean.False;
gridColumn.FieldName = $"DDay_{i}";
gridColumn.Width = 70;
gridColumn.DisplayFormat.FormatType = FormatType.Numeric;
gridColumn.DisplayFormat.FormatString = "{0:#,##0.####}";
gridColumn.Visible = false;
gridColumn.SummaryItem.SummaryType = SummaryItemType.Sum;
gridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}";
gridBillInfo.GridView.Columns.Add(gridColumn);
DateColumnList.Add(gridColumn);
}
}
/// <summary>
/// 根据日期修改列状态
/// </summary>
/// <param name="currentDate"></param>
private void UpdateDynamicColumns(DateTime currentDate)
{
DateTime endDate = currentDate.AddDays(7);
gridBillInfo.GridView.BeginUpdate();
try
{
for (int i = 0; i < DateColumnList.Count; i++)
{
GridColumn gridColumn = DateColumnList[i];
// 当前列对应的日期 = 起始日期加 i 天
DateTime dateForColumn = currentDate.AddDays(i);
if (dateForColumn <= endDate)
{
gridColumn.FieldName = dateForColumn.ToString("yyyy-MM-dd");
gridColumn.Caption = dateForColumn.ToString("MM-dd");
gridColumn.Visible = true;
gridColumn.Tag = dateForColumn;
}
else
{
gridColumn.Visible = false;
}
}
}
finally
{
gridBillInfo.GridView.EndUpdate();
}
}
/// <summary>
/// 主表数据源改变时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnGcMainDataSourceChanged(object sender, EventArgs e)
{
if (DateColumnList.Count > 0 && DateColumnList[0].Tag is DateTime dateTime)
{
string billNo = SysModel.BillDocumentId;
this.gridBillInfo.GridControl.DataSourceChanged -= OnGcMainDataSourceChanged;
DataTable dataTable = gridBillInfo.GridControl.DataSource as DataTable;
if (dataTable != null)
{
//DataTable dataMain = dataTable.Copy();
//string sqlValue = "select * from RD_worktimetab where 1 = 1";
//sqlValue = $"{sqlValue} and lblOrderNo = '{billNo}' and showday >= '{dateTime.ToString("yyyy-MM-dd")}'";
//DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue);
//---------- 查询①:渲染表格排程” ----------
string sqlExcludePlan = "SELECT * FROM RD_worktimetab WHERE 1 = 1";
sqlExcludePlan += $" AND lblOrderNo = '{billNo}'";
sqlExcludePlan += $" AND showday >= '{dateTime:yyyy-MM-dd}'";
sqlExcludePlan += " AND billdocument_id NOT LIKE N'计划文件%'";
// 获取结果
DataTable dataNoPlanFile = BaseImpl.GetDataTableResult(sqlExcludePlan);
// ---------- 查询②:只包含“计划文件” ----------
string sqlIncludePlan = "SELECT billdocument_id FROM RD_worktimetab WHERE 1 = 1";
sqlIncludePlan += $" AND lblOrderNo = '{billNo}'";
sqlIncludePlan += $" AND showday >= '{dateTime:yyyy-MM-dd}'";
sqlIncludePlan += " AND billdocument_id LIKE N'计划文件%'";
// 获取结果
DataTable dataOnlyPlanFile = BaseImpl.GetDataTableResult(sqlIncludePlan);
MergeMainDataWithDayPlan(dataTable, dataNoPlanFile, dateTime);
//若存在缓存计划数据则渲染合计
if (dataOnlyPlanFile.Rows.Count > 0)
{
string jhrowtiemjson = (dataOnlyPlanFile.Rows[0]["billdocument_id"] + "").Replace("计划文件", "");
try
{
JObject rowObject = JsonConvert.DeserializeObject<JObject>(jhrowtiemjson);
JArray jArray = new JArray();
jArray.Add(rowObject);
DataRow jhrowitem = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(jArray)).Rows[0];
//渲染计划合计
gridBillInfo.AddHeadquarters(jhrowitem);
}
catch (Exception)
{
}
}
this.gridBillInfo.GridControl.DataSource = null;
this.gridBillInfo.GridControl.DataSource = dataTable;
}
this.gridBillInfo.GridControl.DataSourceChanged += OnGcMainDataSourceChanged;
}
}
/// <summary>
/// 构建带日期的数据源
/// </summary>
/// <param name="dataMain"></param>
/// <param name="dataDayPlan"></param>
/// <param name="startDate"></param>
/// <returns></returns>
private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate)
{
string rightPrimaryKey = "billdocument_id";
string dateField = "showday";
string amountField = "amount";
string topPrimaryKey = BillModelObj.DetailUUIDKey;
DateTime endDate = startDate.AddDays(7); // 计算结束日期
// **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)**
Dictionary<string, List<DataRow>> dayPlanMap = new Dictionary<string, List<DataRow>>();
foreach (DataRow row in dataDayPlan.Rows)
{
string billId = row[rightPrimaryKey].ToString();
if (!dayPlanMap.ContainsKey(billId))
{
dayPlanMap[billId] = new List<DataRow>();
}
dayPlanMap[billId].Add(row);
}
// **2. 预构建主数据的列**
for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1))
{
string colName = dt.ToString("yyyy-MM-dd");
if (!dataMain.Columns.Contains(colName))
{
dataMain.Columns.Add(colName, typeof(decimal)); // 确保列存在
}
}
// **3. 预构建数据填充映射表**
Dictionary<string, Dictionary<string, decimal>> dataMap = new Dictionary<string, Dictionary<string, decimal>>();
foreach (DataRow row in dataMain.Rows)
{
string key = row[topPrimaryKey].ToString();
if (!dataMap.ContainsKey(key))
{
dataMap[key] = new Dictionary<string, decimal>();
}
// **查找 key 关联的时间数据**
if (dayPlanMap.ContainsKey(key))
{
foreach (DataRow dayRow in dayPlanMap[key])
{
if (dayRow[dateField] != DBNull.Value)
{
DateTime dayValue = Convert.ToDateTime(dayRow[dateField]);
string colName = dayValue.ToString("yyyy-MM-dd");
if (dayValue >= startDate && dayValue <= endDate && dataMain.Columns.Contains(colName))
{
decimal.TryParse(dayRow[amountField] + "", out decimal amountValue);
dataMap[key][colName] = amountValue;
}
}
}
}
}
// **4. 一次性填充 DataTable(避免逐行赋值带来的性能问题)**
foreach (DataRow row in dataMain.Rows)
{
string key = row[topPrimaryKey].ToString();
if (dataMap.ContainsKey(key))
{
foreach (var col in dataMap[key])
{
row[col.Key] = col.Value;
}
}
}
return dataMain;
}
#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.OrderBy(this.BillModelObj.DetailOrderField);
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData);
}
else
{
this.gridBillInfo.SetGridViewDataSource(_dtSourceData);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:单据右键菜单执行后刷新Tab标签数据</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-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>
protected void AuditTab_OnRightCallback(object sender, EventArgs e)
{
try
{
GridDetailModel model = this.tab_basicInfo.GetFocusTabPageGridDetailModel();
DataRow dataRow = this.BillModelObj.DetailTreeTable ? (this.gridBillInfo as TreeGridControlEx).GetViewFocusedDataRow() : this.gridBillInfo.GridView.GetFocusedDataRow();
string sqlValue = ReplaceHelper.ReplaceRowParam(dataRow, model.DetailSql);
this.tab_basicInfo.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
}
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()
{
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);
}
}
}
#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 = txt_billDocumentId.EditText;
string printPath = PubUtil.PrintFileAbsolutelyPath;
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);
DelphiHelper.LoadDelphiDll(printPath, printPath, e.Item.Tag + "", tmpSql, tmpSql1, this.BillModelObj.PrintFileType, tmpSql2);
}
}
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 gridBillInfo_Panint(object sender, PaintEventArgs e)
{
try
{
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.gridBillInfo.Width - 90) / 2;
int y = (this.gridBillInfo.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.gridBillInfo.Width - 120) / 2;
int y1 = (this.gridBillInfo.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.gridBillInfo.Width - 90) / 2;
int y2 = (this.gridBillInfo.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));
}
}
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, string RequiredFields)
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "CurrentFlowRowData", out this._drBillInfoMsg))
{
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId);
}
if (this._drBillInfoMsg == null)
{
MessageUtil.Show(ResourceKeys.NotFindAuditRecord);
return;
}
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.AuditModelObj.BillModifyFields != "-1")
this.ControlObj.SetReadOnlyAllControl(true, false);
//改变控件状态 必填字段
if (!string.IsNullOrEmpty(RequiredFields) && RequiredFields != "-1")
{
foreach (DataRow dr in this._dtBillInfoFiled.Rows)
{
string fieldName = dr["fieldName"] + "";
this.ControlObj.SetRequiredControl(fieldName, RequiredFields.Split(',').Contains(fieldName), false);
}
}
//改变控件状态 操作字段
if (!string.IsNullOrEmpty(billFields) && billFields != "-1")
{
foreach (DataRow dr in this._dtBillInfoFiled.Rows)
{
string fieldName = dr["fieldName"] + "";
this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), false);
}
}
}
#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()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "BillFlowStep", out DataRow dr))
{
dr = BillAuditImpl.GetBillFlowStep(this.SysModel.ModuleCode, this._mainBillTypeValue, this.SysModel.StepCode);
}
if (dr == null)
{
MessageUtil.Show(ResourceKeys.FlowStepConfigError);
return;
}
if (!dataCaches.GetValue(this, "FlowTypeStepModel", out this._flowTypeStepModel))
{
this._flowTypeStepModel = new FlowTypeStepModel(dr);
}
string operUser = this._flowTypeStepModel.OperUser;
if (!dataCaches.GetValue(this, "Operators", out DataRow drOper))
{
drOper = BillAuditImpl.GetOperators(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.SysModel.StepCode);
}
this.btnAccradit.Visible = BillAuditImpl.GetBillComfirm(this.SysModel.ConfirmId) < 0;
operUser = drOper != null ? drOper["operators"] + "" : operUser;
if (operUser.StartsWith("@"))
{
if (!dataCaches.GetValue(this, "Number", out string number))
{
string sql = string.Format("select count(1) from p_employeetab where ({0}) and employeeid='{1}' ", ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, ReplaceHelper.ReplaceUserInfo(operUser)).Replace("@", "").Replace("''", "'"), ERPInfo.Instance.UserId);
number = BaseImpl.GetResult(sql) + "";
}
this.btnSave.Enabled = this.btnClose.Enabled = this.btnBack.Enabled = this.btnAccradit.Enabled = int.Parse(string.IsNullOrWhiteSpace(number + "") ? "0" : number + "") > 0;
}
else
{
this.btnSave.Enabled = this.btnClose.Enabled = this.btnBack.Enabled = this.btnAccradit.Enabled = operUser.Contains(this.SysModel.UserName);
}
//代理权限
if (!dataCaches.GetValue(this, "AgencyAuthority", out DataRow agency))
{
agency = BillAuditImpl.GetAgencyAuthority(this.SysModel.ModuleCode);
}
if (agency != null)
{
string sourceuser = agency["sourceuser"] + "";
foreach (string item in sourceuser.Split(','))
{
if (operUser.Contains(item))
{
this.btnSave.Enabled = this.btnClose.Enabled = this.btnBack.Enabled = this.btnAccradit.Enabled = true;
break;
}
}
}
this.btnClose.Visible = this._flowTypeStepModel.StepClosed == 1;
this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this._flowTypeStepModel.RemindSelect == "1";
//终审
if (this.SysModel.StepOver == "1")
{
this.btnSave.Visible = this.btnClose.Visible = this.btnBack.Visible = this.txtRemark.Visible = this.pl_right_bottom.Visible = this.label_auditPerson.Visible = false;
this.p_right_bottom.Height = 60;
this.btnPrint.Parent = this.p_right_bottom;
this.btnPrint.Visible = true;
this.btnPrint.Left = 15;
this.btnPrint.Top = 20;
this.btnPrint.Height = 30;
this.btnPrint.Width = (this.p_right_bottom.Width - 55) / 2;
this.btnAttach.Parent = this.p_right_bottom;
this.btnAttach.Visible = true;
this.btnAttach.Left = this.btnPrint.Left + this.btnPrint.Width + 15;
this.btnAttach.Top = 20;
this.btnAttach.Height = 30;
this.btnAttach.Width = (this.p_right_bottom.Width - 55) / 2;
}
}
#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 LoadRemindRecord()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (this._flowTypeStepModel != null && !string.IsNullOrEmpty(this._flowTypeStepModel.RemindSelect))
{
if (!dataCaches.GetValue(gridRemind, "RemindinRecord", out DataTable dt))
{
dt = BaseAuditImpl.GetRemindinRecord(this.BillAuditComObj.FlowStepTable, this.BillAuditComObj.ComfrimTable, this.SysModel.BillDocumentId, this.SysModel.ModuleCode);
}
if (dt != null && dt.Rows.Count > 0)
{
if (!dataCaches.GetValue(gridRemind, "ReadOnlyColumns", out DataTable dtReadOnlyColumns))
{
dtReadOnlyColumns = BaseAuditImpl.GetRemindColumn();
}
this.gridRemind.SetReadOnlyColumns(dtReadOnlyColumns);
this.gridRemind.SetGridViewDataSource(dt);
this.tabpage_remind.Text = this.tabpage_remind.Text + "(" + dt.Rows.Count + ")";
}
else
{
this.TabControl.TabPages.Remove(this.tabpage_remind);
}
}
}
#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 LoadSignRecord()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (this.BillAuditComObj == null) return;
if (!dataCaches.GetValue(gridSign, "SignRecord", out DataTable dt))
{
dt = BaseAuditImpl.GetSignRecord(this.BillAuditComObj.ComfrimTable, this.SysModel.BillDocumentId, this.SysModel.ModuleCode);
}
if (dt != null && dt.Rows.Count > 0)
{
if (!dataCaches.GetValue(gridSign, "ReadOnlyColumns", out DataTable dtReadOnlyColumns))
{
dtReadOnlyColumns = BaseAuditImpl.GetSignRecordCoulumn();
}
this.gridSign.SetReadOnlyColumns(dtReadOnlyColumns);
this.gridSign.SetGridViewDataSource(dt);
this.tabpage_sign.Text = this.tabpage_sign.Text + "(" + dt.Rows.Count + ")";
}
else
{
this.TabControl.TabPages.Remove(this.tabpage_sign);
}
}
#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 InitOtherParms()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "CheckSuggestionDataSource", out DataTable dt))
{
dt = BaseImpl.GetDataTableResult(this.AuditModelObj.SuggestionSql);
}
this.CheckSuggestion.ValueField = this.CheckSuggestion.TextField = "Mix_apellation";
this.CheckSuggestion.SetDataSource(dt);
this.CheckSuggestion.TextEdit.SelectedIndex = 0;
this.CheckSuggestion.TextEdit.SelectedValueChanged += new EventHandler(CheckSuggestion_Click);
this.txt_billDocumentId.EditText = this.SysModel.BillDocumentId;
this.label_date.EditText = DateTime.Now.ToString();
if (!string.IsNullOrWhiteSpace(this.AuditModelObj.StepApplyContent))
{
this.txtRemark.Text = this.AuditModelObj.StepApplyContent;
}
}
#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 InitOkBtn()
{
if (this.SysModel.ConfirmId == "1")
{
this.btnAccradit.Enabled = true;
this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this.btnSave.Visible = this.btnClose.Visible = this.btnSpare.Visible = this.btnBack.Visible = false;
this.btnAccradit.Text = "确认(&Y)";
this.btnAccradit.Text = "确认(&Y)";
this.label_auditPerson.Text = "确认意见";
this.label_date.EditText = "会签人";
this.txtRemark.Text = "确认";
}
}
#endregion
#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
{
this.txtRemark.Text = this.CheckSuggestion.EditText;
}
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 gridView_DoubleClick(object sender, EventArgs e)
{
try
{
GridViewClick("2");
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 表格选中双击共用函数
/// <summary>
/// <para>说明:gridBillInfo点击事件共用函数</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-01-08</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// <param name="frequency">1表示点击进入,2表示双击进入</param>
/// </summary>
private void GridViewClick(string frequency)
{
foreach (XtraTabPage tabPage in this.tab_basicInfo.TabControlObj.TabPages)
{
GridDetailModel model = this.tab_basicInfo.GetGridDetailModel(tabPage);
//是否为双击进入
if (model.DBClickEvent && !frequency.Equals("2")) return;
DataRow dataRow = this.BillModelObj.DetailTreeTable ? (this.gridBillInfo as TreeGridControlEx).GetViewFocusedDataRow() : this.gridBillInfo.GridView.GetFocusedDataRow();
//条件判断
if (!string.IsNullOrWhiteSpace(model.Enablecond) && !this.ValidateCond(model.Enablecond, dataRow))
{
//配置了条件,并且不满足条件
this.tab_basicInfo.SetGridDataSource(tabPage, new DataTable());
continue;
}
bool isDetailAttach = (model.IsReadOnly || model.IsChart);
string sqlValue = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, model.DetailSql) : GetSearchSql(model);
GridControlEx grdExMain = (tabPage.Tag as GridControlEx);
if (!isDetailAttach) grdExMain.LastSearchSql = sqlValue;
//this.tab_basicInfo.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue));
this.tab_basicInfo.SetGridDataSource(tabPage, sqlValue);
}
}
#endregion
#region 获取查询条件
/// <summary>
/// <para>说明:获取查询条件</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2021-01-22 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="model">The model.</param>
/// <param name="rowItem">The row item.</param>
/// <returns>System.String.</returns>
protected string GetSearchSql(GridDetailModel model)
{
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) ? model.UnionParentField : BaseImpl.GetBasePrimaryKey(model.UnionModule);
DataRow dr = this.BillModelObj.DetailTreeTable ? (this.gridBillInfo as TreeGridControlEx).GetViewFocusedDataRow() : this.gridBillInfo.GridView.GetFocusedDataRow();
fieldName = dr.Table.Columns.Contains(fieldName) ? dr[fieldName].ToString() : this.ControlObj.PrimaryValue;
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
{
string[] sqlValues = sqlValue.Split(new string[] { "where " }, StringSplitOptions.None);
if (sqlValues.Length > 1)
{
string sql = string.Empty;
for (int i = 0; i < sqlValues.Length; i++)
{
if (i == sqlValues.Length - 2)
{
sql += sqlValues[i] + string.Format(" where {0}='{1}' and ", model.UnionValue, fieldName) + sqlValues[i + 1];
break;
}
sql += sqlValues[i] + " where ";
}
sqlValue = sql;
}
else
{
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, fieldName);
}
}
if (!string.IsNullOrEmpty(model.UnionCond))
{
string UnionCond = ReplaceHelper.ReplaceRowParam(dr, model.UnionCond);
sqlValue += UnionCond;
}
return sqlValue;
}
#endregion
#region 表格选中改变事件
/// <summary>
/// <para>说明:gridBillInfo选中事件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-01-08</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void gridBillInfo_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
{
try
{
GridViewClick("1");
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:gridBillInfo焦点行改变事件</para>
/// <para>创建人:曹屹峰</para>
/// <para>创建日期:2023-10-13</para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void GridView_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
{
try
{
GridViewClick("1");
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
private void TreeListObj_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
{
try
{
GridViewClick("1");
}
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>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void btnClose_Click(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(this.AuditModelObj.StepCloseTip) && MessageUtil.Show(this.AuditModelObj.StepCloseTip, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
string nextSelectStepCode = string.Empty;
string nextSelectStepOper = string.Empty;
this._auditAdvice = txtRemark.Text;
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", "p_BillAudit", "Q", "0", this.txtRemark.Text, "", "", true, -1);
if ("1".Equals(result))
{
MessageUtil.Show(ResourceKeys.CloseSuccess);
this.DialogResult = DialogResult.OK;
}
else
{
MessageUtil.Show(ResourceKeys.CloseFail + "\r\n" + result);
}
}
}
catch (Exception ex)
{
LogUtil.WriteError("关闭出错!", ex);
//MessageUtil.Show("关闭出错!" + 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")
{
FrmBackSelect frmBackSelNew = new FrmBackSelect();
//frmBackSelNew.FrmBackSelectEx.StepSelection.Hide();
frmBackSelNew.SysModel = this.SysModel;
frmBackSelNew.BillModelObj = this.BillModelObj;
frmBackSelNew.FrmBackSelectEx.LabelAdvice.EditText = this.CheckSuggestion.EditText;
frmBackSelNew.InitControlSpecial();
if (frmBackSelNew.ShowDialog() != DialogResult.OK) return -9;
this._auditAdvice = frmBackSelNew.ComfirmMsg;
return 0;
}
FrmBackSelect frmBackSel = new FrmBackSelect();
frmBackSel.SysModel = this.SysModel;
frmBackSel.BillModelObj = this.BillModelObj;
frmBackSel.FrmBackSelectEx.LabelAdvice.EditText = this.CheckSuggestion.EditText;
frmBackSel.InitControl();
if (frmBackSel.ShowDialog() != DialogResult.OK) return -9;
this._auditAdvice = frmBackSel.ComfirmMsg;
return frmBackSel.SelectStepCode;
}
#endregion
#region 审核事件
/// <summary>
/// <para>说明:提醒审核事件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2020-08-20</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 btnRemindAccradit_Click(object sender, EventArgs e)
{
try
{
if (VerificationRequired()) return;
if (this.SysModel.ConfirmId == "1" || this.SysModel.StepOver == "1")
{
if (BillAuditImpl.ConfirmAudit(this.SysModel.UserId, this.txtRemark.Text, this.SysModel.ModuleCode, this.SysModel.BillDocumentId) > 0)
{
MessageUtil.Show(ResourceKeys.ConfirmSuccess);
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
this.Close();
}
else
{
MessageUtil.Show(ResourceKeys.ConfirmFail);
}
}
else
{
bool isAudit = true;
string confirmOpers = string.Empty, remindOpers = string.Empty;
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;
string nextSelectStepCode = string.Empty;
string nextSelectStepOper = string.Empty;
if (isAudit)
{
if (this.ControlObj.isRequiredFields(this.AuditModelObj.RequiredFields))
{
if (this.BillModelObj.DetailTreeTable)
{
if (!(this.gridBillInfo as TreeGridControlEx).isRequiredFields(this.AuditModelObj.RequiredDetailFields)) return;
}
else
{
if (!this.gridBillInfo.GridControl.isRequiredFields(this.AuditModelObj.RequiredDetailFields, this.gridBillInfo.GridView)) return;
}
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, this.txtRemark.Text, remindOpers, confirmOpers);
if ("1".Equals(result))
{
PushHelper push = new PushHelper(this.SysModel.BillDocumentId, this.SysModel.StepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId);
push.Push_Bill_Oper_Message();
this.DialogResult = DialogResult.OK;
if (refreshThePage != null) refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + result);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.WriteError("提醒审核事件出错!", ex);
//MessageUtil.Show("提醒审核事件出错!" + ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <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 btnAccradit_Click(object sender, EventArgs e)
{
try
{
if (VerificationRequired()) return;
WaitForm.ShowForm(ResourceKeys.Handing);
if (this.SysModel.ConfirmId == "1")
{
if (BillAuditImpl.ConfirmAudit(this.SysModel.UserId, this.txtRemark.Text, this.SysModel.ModuleCode, this.SysModel.BillDocumentId) > 0)
{
MessageUtil.Show(ResourceKeys.ConfirmSuccess);
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
this.Close();
}
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 (isAudit)
{
if (SystemInfo.Instance.auditComfirmOpers.Split(',').Contains(ERPInfo.Instance.UserName) || "1".Equals(SystemInfo.Instance.auditComfirmOpers))
{
if (MessageUtil.Show(string.Format(ResourceKeys.ConfirmIsAudit), MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
}
if (this.ControlObj.isRequiredFields(this.AuditModelObj.RequiredFields))
{
if (this.BillModelObj.DetailTreeTable)
{
if (!(this.gridBillInfo as TreeGridControlEx).isRequiredFields(this.AuditModelObj.RequiredDetailFields)) return;
}
else
{
if (!this.gridBillInfo.GridControl.isRequiredFields(this.AuditModelObj.RequiredDetailFields, this.gridBillInfo.GridView)) return;
}
if (!SaveBillData(0, false)) return;
string opinion = this.txtRemark.Text;//审核意见
if (this.CheckSuggestion.EditText.Equals("不同意"))
{
opinion = this.CheckSuggestion.EditText + "^" + opinion;
}
//审核前调用
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, this.SysModel.ModuleCode, 0))
{
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.BillModelObj.PrimaryKey, this.BillModelObj.MasterTable, 0);
apiHelper.OnEvent(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, Interface.Api.ActionType.Audit);//审核
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
{
DialogResult dialogResult = MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + apiHelper.apiResutMsg);
return;
}
}
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,
this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, opinion, remindOpers, confirmOpers);
WaitForm.HideForm();
if ("1".Equals(result))
{
//推送消息
PushHelper push = new PushHelper(this.SysModel.BillDocumentId, this.SysModel.StepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId);
push.Push_Bill_Oper_Message();
#region 审核成功后调用API
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleAuditStateChange, this.SysModel.ModuleCode, 0))
{
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.BillModelObj.PrimaryKey, this.BillModelObj.MasterTable, 0);
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleAuditStateChange, Interface.Api.ActionType.Audit);//审核
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
{
MessageUtil.Show(apiHelper.apiResutMsg);
}
}
#endregion
if (refreshThePage != null)
{
refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
MessageUtil.Show("审核成功");
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
removePage.Dispose();
}
}
}
this.DialogResult = DialogResult.OK;
}
else
{
MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + result);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.WriteError("审核事件出错!", ex);
MessageUtil.Show("审核事件出错!" + ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
WaitForm.HideForm();
}
}
#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 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);
}
}
#endregion
#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)
{
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData);
}
else
{
this.gridBillInfo.SetGridViewDataSource(_dtSourceData);
}
}
}
}
catch (Exception ex)
{
//MessageUtil.Show(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
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)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 导出单据明细
private void btnExport_Click(object sender, EventArgs e)
{
try
{
this.gridBillInfo.GridControl.ToExcel(this.SysModel.FormText);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 分配明细
private void OnBtnFPClick(object sender, EventArgs e)
{
try
{
this.gridBillInfo.GridControl.ToExcel(this.SysModel.FormText);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#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 defaultValue = SqlHelper.ExecuteScalar(string.Format("select defaultValue from p_systembillinfo where typecode = '{0}' and fieldName = '{1}'", this.SysModel.ModuleCode, this.BillModelObj.MasterPreFix + "billdocument_id")) + "";
if (!string.IsNullOrEmpty(defaultValue))
{
defaultValue = BaseImpl.GetDefaultValue(defaultValue);
}
string billNo = this.BillModelObj.NewVer == 1 || SystemInfo.Instance.SplitOrderNewVer ? BillImpl.GetBillNo(this.BillModelObj.BillSeq) : defaultValue;
//构造表头
string masterSql = this.GetBillHearder(billNo);
//构造明细"@billdocument_id@"
string detailSql = this.GetBillDetail(this.BillModelObj.NewVer == 1 ? billNo : billNo);
//分单处理
string msg = string.Empty;
string detailGuid = Guid.NewGuid().ToString();
//int returnValue = BillImpl.BillSave(masterSql, detailSql, BillModelObj.DetailTable, ref billNo, detailGuid, BillModelObj.BillSeq, BillModelObj.SaveState ? 2 : 1, 0, out msg, 0, this.BillModelObj.NewVer);
int returnValue = BillAuditImpl.SpliteBill(out msg, masterSql, detailSql, billNo, this.SysModel.ModuleCode, this.SysModel.BillDocumentId);
if (returnValue == 1)
{
MessageUtil.Show(ResourceKeys.SpliterBillSuccess);
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId));
this._dtSourceData.OrderBy(this.BillModelObj.DetailOrderField);
this._dtSpareSourceData.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();
DataTable rowTab = SqlHelper.ExecuteDataTable(string.Format("select * from {0} where {1} = '{2}'", this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId));
if (rowTab != null && rowTab.Rows.Count > 0)
{
DataRow row = rowTab.Rows[0];
string autogrowcolumn = SqlHelper.ExecuteScalar(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", this.BillModelObj.MasterTable)) + "";//自增长列
foreach (DataColumn column in row.Table.Columns)
{
if (column.ColumnName.Equals(autogrowcolumn) || column.ColumnName.Equals(this.BillModelObj.PrimaryKey, StringComparison.CurrentCultureIgnoreCase))
continue;
string fieldValue = row[column] + "";
fieldBuilder.Append(column.ColumnName + ",");
valueBuilder.AppendFormat("'{0}',", fieldValue);
}
}
//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 返退
/// <summary>
/// <para>说明:提醒返回审核</para>
/// <para>创建人:王一帆</para>
/// <para>创建日期:2020-08-20</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 btnRemindReturn_Click(object sender, EventArgs e)
{
try
{
if (VerificationRequired()) return;
this._auditAdvice = txtRemark.Text;
int ret = ExecuteBackSelect(this._drBillInfoMsg);
if (ret == -9) return;
string nextSelectStepCode = string.Empty;
string nextSelectStepOper = string.Empty;
if (this.SysModel.StepOver == "1")
{
if (MessageUtil.Show(ResourceKeys.ConfimAuditFailAndReturnBill, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,
this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, "", "", true, ret, 0, true);
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();
this.DialogResult = DialogResult.OK;
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, result));
}
}
}
else
{
bool isAudit = true;
string confirmOpers = string.Empty, remindOpers = string.Empty;
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)
{
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,
this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, remindOpers, confirmOpers, 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();
this.DialogResult = DialogResult.OK;
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, result));
}
}
}
}
catch (Exception ex)
{
LogUtil.WriteError("提醒返回审核出错!", ex);
//MessageUtil.Show("提醒返回审核出错!" + ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <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
{
if (VerificationRequired()) return;
this._auditAdvice = txtRemark.Text;
int ret = ExecuteBackSelect(this._drBillInfoMsg);
if (ret == -9) return;
string nextSelectStepCode = string.Empty;
string nextSelectStepOper = string.Empty;
if (this.SysModel.StepOver == "1")
{
if (MessageUtil.Show(ResourceKeys.ConfimAuditFailAndReturnBill, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (!SaveBillData(0, false)) return;
//反退前调用
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, this.SysModel.ModuleCode, 0))
{
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.BillModelObj.PrimaryKey, this.BillModelObj.MasterTable, 0);
apiHelper.OnEvent(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, Interface.Api.ActionType.AuditBack);//审核
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
{
DialogResult dialogResult = MessageUtil.Show(ResourceKeys.ForcedFail + "\r\n" + apiHelper.apiResutMsg);
return;
}
}
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,
this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, "", "", true, ret, 0, true);
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();
//反退后调用
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleAuditStateChange, this.SysModel.ModuleCode, 0))
{
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.BillModelObj.PrimaryKey, this.BillModelObj.MasterTable, 0);
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleAuditStateChange, Interface.Api.ActionType.AuditBack);
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
{
MessageUtil.Show(apiHelper.apiResutMsg);
}
}
this.DialogResult = DialogResult.OK;
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, result));
}
}
}
else
{
if (SystemInfo.Instance.backAuditComfirmOpers.Split(',').Contains(ERPInfo.Instance.UserName) || "1".Equals(SystemInfo.Instance.backAuditComfirmOpers))
{
if (MessageUtil.Show(string.Format(ResourceKeys.ConfimAuditFailAndReturnBill), MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
}
bool isAudit = true;
string confirmOpers = string.Empty, remindOpers = string.Empty;
if (isAudit)
{
string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper,
this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, remindOpers, confirmOpers, 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();
this.DialogResult = DialogResult.OK;
if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
}
else
{
MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, result));
}
}
}
}
catch (Exception ex)
{
LogUtil.WriteError("返回审核出错!", ex);
MessageUtil.Show("返回审核出错!" + 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()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (!dataCaches.GetValue(this, "PushedOpers", out DataRow beforeOpers))
{
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 保存单据
/// <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
{
SaveBillData();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <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 HeaderError = string.Empty;//表头错误
string FormError = string.Empty;//表格内容错误
string SaveErrorMessage = string.Empty;//提示错误
string guid = Guid.NewGuid().ToString();
string masterSql = GetUpdateBillHeader(out HeaderError);
string detailSql = GetDetailRecord(guid, out FormError);
if (string.IsNullOrEmpty(detailSql) && !this.BillModelObj.SaveNullDetail)
{
MessageUtil.Show(ResourceKeys.BillDetailIsNotNull);
return false;
}
string tipMsg = string.Empty;
if (!this.ControlObj.VerifyNull()) return false;
SaveErrorMessage = HeaderError + FormError;
if (!string.IsNullOrEmpty(SaveErrorMessage))
{
MessageUtil.Show(SaveErrorMessage);
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);
save = true;
#region 修改保存成功后调用API
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataChange, this.SysModel.ModuleCode, 0))
{
ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, this.SysModel.BillDocumentId, this.BillModelObj.PrimaryKey, this.BillModelObj.MasterTable, 0);
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Update);//修改
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
{
MessageUtil.Show(apiHelper.apiResutMsg);
}
}
#endregion
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)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
// 刷新主表
this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId);
this.ControlObj.CanExecControl = false;
this.ControlObj.SetAllControlValue(this._drBillInfoMsg);//刷新表头数据
this.ControlObj.CanExecControl = true;
// 刷新明细表
this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId));
this._dtSourceData.OrderBy(this.BillModelObj.DetailOrderField);
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData);
}
else
{
this.gridBillInfo.SetGridViewDataSource(_dtSourceData);
}
return save;
}
#endregion
#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(out string SaveErrorMessage)
{
StringBuilder updateBuilder = new StringBuilder();
DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", this.BillModelObj.MasterTable));
string errorMessage = string.Empty;
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);
string newfieldValue = fieldValue;
if (fieldValue == "****") continue;
if ((model.FieldType == ControlType.LabDate ||
model.FieldType == ControlType.LabDate ||
model.FieldType == ControlType.LabDate ||
model.FieldType == ControlType.LabDate ||
model.FieldType == ControlType.LabDate) && string.IsNullOrEmpty(fieldValue))
{
fieldValue = "NULL";
}
else
{
fieldValue = "N'" + fieldValue + "'";
}
updateBuilder.AppendFormat("{0}={1},", model.FieldName, fieldValue);
errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, newfieldValue);
}
}
SaveErrorMessage = errorMessage;
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, out string SaveErrorMessage)
{
// 构造明细
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"));//单据明细性表
string errorMessage = string.Empty;
DataTable detailTable = this.gridBillInfo.GridControl.DataSourceTable().TrimDeleteRows();
if (this.BillModelObj.DetailTreeTable)
{
detailTable = ((this.gridBillInfo as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows();
}
if (detailTable.Rows.Count > 0)
{
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)
{
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("'',");
}
errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, dataRow, item, fieldValue);
}
detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(','));
}
}
SaveErrorMessage = errorMessage;
return detailBuilder.ToString();
}
#endregion
#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}&dllcoid={4}&isview={3}", ERPInfo.Instance.UserName, ERPInfo.Instance.Password, this.SysModel.BillDocumentId, this.btnAccradit.Enabled ? "0" : "1", this.SysModel.ModuleCode);
// 固定传入参数(窗口标题、操作员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 + "", "", "", "", "", this.SysModel.StepOver };
string[] args = defaultArgs.Concat(menuArgs).ToArray();
IForm form = FormHelper.LoadDllForm(SystemInfo.Instance.BsAttachFlag.Equals("1") ? ResourceDynamic.PubBrower : ResourceDynamic.PhotoView, args);
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
DialogResult result = form.SubForm.ShowDialog();
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
#region 记载分割条位置
private void splitLeft_SplitterPositionChanged(object sender, EventArgs e)
{
if (this._isInitFinish)
{
IniHelper.Write(string.Format("base_spliterPositionLeft_{0}", this.SysModel.ModuleCode), this.splitLeft.SplitterPosition + "");
}
}
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
/// <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);
string splitterLeftPosition = IniHelper.Read(string.Format("base_spliterPositionLeft_{0}", this.SysModel.ModuleCode));
if (!string.IsNullOrEmpty(splitterLeftPosition)) this.splitLeft.SplitterPosition = Convert.ToInt32(splitterLeftPosition);
}
catch (Exception ex)
{
LogHelper.Instance.WriteError(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
private bool VerificationRequired()
{
bool results = false;
if (SystemInfo.Instance.ReviewCommentsRequired && string.IsNullOrWhiteSpace(this.txtRemark.Text))
{
MessageUtil.Show("请输入审核意见");
results = true;
}
return results;
}
/// <summary>
/// 页签里数据修改后刷新明细
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Tab_basicInfo_OnDetailSaveGridCallBack(object sender, EventArgs e)
{
// 刷新主表
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.OrderBy(this.BillModelObj.DetailOrderField);
if (this.BillModelObj.DetailTreeTable)
{
(this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData);
}
else
{
this.gridBillInfo.SetGridViewDataSource(_dtSourceData);
}
}
/// <summary>
/// <para>说明:检查可用条件</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11