diff --git a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs index b331c5d..6db6b4f 100644 --- a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs +++ b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs @@ -1,4004 +1,4302 @@ -/*********************** -* 说明:单据审批弹出模块 -* 创建人:龚宇超 -* 创建日期: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 -{ - - /// - /// 单据审批弹出模块 - /// - public partial class FrmAccraditation : BaseForm - { - public FrmAccraditation() - { - InitializeComponent(); - } - #region 公有变量 - - /// - /// 单据结构明细 - /// - public AccraditationModel AuditModelObj; - /// - /// 单据模型 - /// - public BillAuditModel BillModelObj; - /// - /// 单据审批表模型 - /// - public BillAuditCommonModel BillAuditComObj; - /// - /// 单据入口参数模型 - /// - public DynamicPubAccraditionPopModel SysModel; - /// - /// 主表控件 - /// - public MyControl ControlObj; - /// - /// 是否是Brp模块加载审核明细 - /// - public bool isBrpAccrad = false; - #endregion - /// - /// 调用动态链接库默认传递参数 - /// - public DynamicModel syModel { get; private set; } - /// - /// 关闭当前审核界面,刷新打开界面 - /// - /// The sender. - public event RefreshThePage refreshThePage; - public delegate void RefreshThePage(string promptInformation, string id); - /// - /// 主表动态生成的日期列 - /// - public List DateColumnList = new List(); - /// - /// 主表动态生成的合计列 - /// - public GridColumn SumGridColumn = new GridColumn(); - #region 私有变量 - /// - /// 数量名称 - /// - public string NumberMc; - /// - /// 主键字段 - /// - private string mRecordPrimaryField; - private string guidField = "xxxxx_guid"; - /// - /// id(推送记录) - /// - private int _beforeId; - /// - /// 是否初始化完成 - /// - private bool _isInitFinish; - /// - /// 意见 - /// - private string _auditAdvice; - /// - /// 菜单模块名(推送记录) - /// - private string _beforeMenuName; - /// - /// 用户(推送记录) - /// - private string _beforeUsers; - /// - /// 单据类别值 - /// - private string _mainBillTypeValue; - /// - /// 单据信息 - /// - private DataRow _drBillInfoMsg; - /// - /// 明细数据 - /// - private DataTable _dtSourceData; - /// - /// 单据类别 - /// - private DataTable _dtBillType; - /// - /// 单据明细列表 - /// - private DataTable _dtBillAttachList; - /// - /// 单据billInfo - /// - private DataTable _dtBillInfoFiled; - /// - /// 分单数据 - /// - private DataTable _dtSpareSourceData; - /// - /// 审批流转模型 - /// - private FlowTypeStepModel _flowTypeStepModel; - /// - /// 单据水印 - /// - private WaterMark _waterMark; - /// - /// 获取隐藏的x轴距 - /// - private ArrayList LocationX = new ArrayList(); - /// - /// 是否执行了加载储存过程 - /// - public bool ProcessExists = false; - // - /// 模块对应的权限表信息 - /// - public DataTable AuthorityTable; - #endregion - - /// - /// 说明:窗体加载时 - /// 创建人:龚宇超 - /// 创建日期:2018-01-02 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The instance containing the event data. - 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 获取数据源缓存 - /// - /// 获取数据源缓存 - /// - /// - public void GetDataCaches(Dictionary cachesDic) - { - //全局数据 - Task dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task(() => - { - return SysModel;//动态链接库对象 - })); - DynamicPubAccraditionPopModel dynamicModel = (DynamicPubAccraditionPopModel)dynamicModelTask.Result; - #region InitializeSetting - Task accraditationModelRowTask = cachesDic.AddTask(this, "AccraditationModelRow", new Task(() => - { - return BillAuditImpl.GetBillFlowData(dynamicModel.ModuleCode, dynamicModel.StepCode); - })); - Task accraditationModelTask = cachesDic.AddTask(this, "AccraditationModel", new Task(() => - { - return new AccraditationModel(accraditationModelRowTask.Result); - })); - Task billInfoTask = cachesDic.AddTask(this, "BillInfo", new Task(() => - { - return BillImpl.GetBillInfo(dynamicModel.ModuleCode);//获取单个模块信息 - })); - Task billAuditModelTask = cachesDic.AddTask(this, "BillAuditModel", new Task(() => - { - BillAuditModel billAuditModel = new BillAuditModel(billInfoTask.Result); - Task masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task(() => - { - return BaseImpl.GetColumnPrefix(billAuditModel.MasterTable); - })); - Task detailPreFixTask = cachesDic.AddTask(this, "DetailPreFix", new Task(() => - { - return BaseImpl.GetColumnPrefix(billAuditModel.DetailTable);// 明细表列前缀 - })); - billAuditModel.MasterPreFix = masterPreFixTask.Result; - billAuditModel.DetailPreFix = detailPreFixTask.Result; - billAuditModel.DetailOrderField = detailPreFixTask.Result + "lsidx_id";// 单据来源id - return billAuditModel; - })); - Task billAuditCommonModelTask = cachesDic.AddTask(this, "BillAuditCommonModel", new Task(() => - { - return new BillAuditCommonModel(); - })); - Task menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task(() => - { - return BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); //获取菜单其他配置 - })); - Task fileCountTask = cachesDic.AddTask(this, "FileCount", new Task(() => - { - return AttachImpl.GetFileCount(billAuditModelTask.Result.DirId + "", dynamicModel.BillDocumentId); - })); - //记录推送用户 - Task pushedOpersTask = cachesDic.AddTask(this, "PushedOpers", new Task(() => - { - return BillAuditImpl.GetPushedOpers(dynamicModel.BillDocumentId, dynamicModel.StepCode); - })); - Task billInfoDataTask = cachesDic.AddTask(this, "BillInfoData", new Task(() => - { - return BillAuditImpl.GetBillInfoData(dynamicModel.ModuleCode); - })); - #endregion - #region InitializeControl - Task readOnlyColumnsTask = cachesDic.AddTask(gridFlow, "ReadOnlyColumns", new Task(() => - { - return BaseAuditImpl.GetFlowRecordColumn(); - })); - string customColumKey = GridCustomColumnStruct.AuditPopupAttachGridView + billAuditModelTask.Result.FormKey; - cachesDic.AddTask(gridFlow, "DynamicModel", dynamicModelTask); - gridFlow.GetDataCaches(cachesDic, customColumKey); - Task gridViewDataSourceTask = cachesDic.AddTask(gridFlow, "GridViewDataSource", new Task(() => - { - return BaseAuditImpl.GetFlowRecordData(billAuditCommonModelTask.Result.SystemTabFlowStep, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); - })); - //BindTab - Task> detailTask = cachesDic.AddTask(gridFlow, "Details", new Task>(() => - { - List details = new List(); - 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 addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => - { - 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 addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => - { - 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 controlLocationTask = cachesDic.AddTask(this, "ControlLocation", new Task(() => - { - return BaseModuleImpl.GetControlLocation(billAuditModelTask.Result.FormKey, dynamicModel.ModuleCode); - })); - Task controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task(() => - { - 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 detailColumnsTask = cachesDic.AddTask(gridBillInfo, "DetailColumns", new Task(() => - { - return BillImpl.GetDetailColumns(dynamicModel.ModuleCode); - })); - string gridBillCustomColumKey = GridCustomColumnStruct.AuditPopupDetailGridView + billAuditModelTask.Result.FormKey; - cachesDic.AddTask(gridBillInfo, "DynamicModel", dynamicModelTask); - gridBillInfo.GetDataCaches(cachesDic, gridBillCustomColumKey); - Task baseGridRightMenusTask = cachesDic.AddTask(gridBillInfo, "BaseGridRightMenus", new Task(() => - { - return BaseModuleImpl.GetBaseGridRightMenus(accraditationModelTask.Result.BillGridMenuFlag + dynamicModel.ModuleCode, ModuleType.BillAuditDetail); - })); - Task baseGridRowColorsTask = cachesDic.AddTask(gridBillInfo, "BaseGridRowColors", new Task(() => - { - return BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + billAuditModelTask.Result.FormKey); - })); - //设置必填和修改字段 - Task currentFlowRowDataTask = cachesDic.AddTask(this, "CurrentFlowRowData", new Task(() => - { - 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 billFlowStepTask = cachesDic.AddTask(this, "BillFlowStep", new Task(() => - { - DataRow billFlowStep = BillAuditImpl.GetBillFlowStep(dynamicModel.ModuleCode, mainBillTypeValue, dynamicModel.StepCode); - if (billFlowStep != null) - { - Task flowTypeStepModelTask = cachesDic.AddTask(this, "FlowTypeStepModel", new Task(() => - { - FlowTypeStepModel flowTypeStepModel = new FlowTypeStepModel(billFlowStep); - //LoadRemindRecord - if (flowTypeStepModel != null && !string.IsNullOrEmpty(flowTypeStepModel.RemindSelect)) - { - Task remindinRecordTask = cachesDic.AddTask(gridRemind, "RemindinRecord", new Task(() => - { - DataTable dt = BaseAuditImpl.GetRemindinRecord(billAuditCommonModelTask.Result.FlowStepTable, billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); - if (dt != null && dt.Rows.Count > 0) - { - Task gridRemindReadOnlyColumnsTask = cachesDic.AddTask(gridRemind, "ReadOnlyColumns", new Task(() => - { - return BaseAuditImpl.GetRemindColumn(); - })); - cachesDic.AddTask(gridRemind, "DynamicModel", dynamicModelTask); - gridRemind.GetDataCaches(cachesDic); - } - return dt; - })); - } - return new FlowTypeStepModel(billFlowStep); - })); - string operUser = flowTypeStepModelTask.Result.OperUser; - Task operatorsTask = cachesDic.AddTask(this, "Operators", new Task(() => - { - 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 numberTask = cachesDic.AddTask(this, "Number", new Task(() => - { - return BaseImpl.GetResult(sql) + ""; - })); - } - return operators; - })); - Task billComfirmTask = cachesDic.AddTask(this, "BillComfirm", new Task(() => - { - return BillAuditImpl.GetBillComfirm(this.SysModel.ConfirmId) < 0; - })); - //代理权限 - Task agencyAuthorityTask = cachesDic.AddTask(this, "AgencyAuthority", new Task(() => - { - return BillAuditImpl.GetAgencyAuthority(dynamicModel.ModuleCode); - })); - } - return billFlowStep; - })); - } - } - return currentFlowRowData; - })); - //LoadSignRecord - if (billAuditCommonModelTask.Result != null) - { - Task signRecordTask = cachesDic.AddTask(gridSign, "SignRecord", new Task(() => - { - DataTable dt = BaseAuditImpl.GetSignRecord(billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); - if (dt != null && dt.Rows.Count > 0) - { - Task gridSignReadOnlyColumnsTask = cachesDic.AddTask(gridSign, "ReadOnlyColumns", new Task(() => - { - return BaseAuditImpl.GetSignRecordCoulumn(); - })); - cachesDic.AddTask(gridSign, "DynamicModel", dynamicModelTask); - gridSign.GetDataCaches(cachesDic); - } - return dt; - })); - } - //InitCommonMenu - Task tableCommonTask = cachesDic.AddTask(this, "TableCommon", new Task(() => - { - return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.BillDetail); - })); - //InitOtherParms - Task checkSuggestionDataSourceTask = cachesDic.AddTask(this, "CheckSuggestionDataSource", new Task(() => - { - return BaseImpl.GetDataTableResult(accraditationModelTask.Result.SuggestionSql); - })); - #endregion - } - #endregion - - - - #region 初始化属性设置 - /// - /// 说明:初始化属性设置 - /// 创建人:龚宇超 - /// 创建日期:2018-01-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void InitializeSetting() - { - Dictionary 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 表格是否可以编辑设置 - /// - /// 说明:表格编辑时,判断是否是否编辑 - /// 创建人:王一帆 - /// 创建日期:2020-03-27 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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 流转表格设置行颜色 - /// - /// 说明:流转表格行颜色区分 - /// 创建人:龚宇超 - /// 创建日期:2018-01-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 初始化控件 - /// - /// 说明:初始化控件 - /// 创建人:龚宇超 - /// 创建日期:2018-01-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void InitializeControl() - { - Dictionary 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 - /// - /// 说明:录所有按钮的位置 - /// 创建人:王一帆 - /// 创建日期:2020-11-25 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 初始化常用菜单 - /// - /// 说明:设置初始化常用菜单 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void InitCommonMenu() - { - Dictionary 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 常用工具 - /// - /// 说明:常用工具点击 - /// 创建人:龚宇超 - /// 创建日期:2017-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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); - } - } - /// - /// 说明:执行前单独替换BilldocumentId - /// 创建人:王一帆 - /// 创建日期:2020-07-24 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The e. - 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 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 设置窗体大小 - /// - /// 说明:设置窗体大小 - /// 创建人:龚宇超 - /// 创建日期:2018-01-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 绑定选项卡 - /// - /// 说明:绑定选项卡 - /// 创建人:龚宇超 - /// 创建日期:2018-01-03 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void BindTab() - { - Dictionary 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 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); - } - - - - /// - /// 说明:获取选项卡数据 - /// 创建人:龚宇超 - /// 创建日期:2018-01-15 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// List<GridDetailModel>. - private List GetTabDetails() - { - List details = new List(); - - 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 绑定审批单据 - /// - /// 说明:单据管理 - /// 创建人:龚宇超 - /// 创建日期:2018-01-04 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void BindBill() - { - Dictionary 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.isAuditMain = true; - 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; - // } - // } - //} - - this.AuthorityTable = PowerImpl.GetModuleAuthorityEnable(this.SysModel.ModuleCode); - - if (this.AuditModelObj.DetailModifyFields != "-1") - { - this.gridBillInfo.SetReadOnlyAllColumn(); - this.dbpFP.Enabled = false; - } - //设置必填和修改字段 - this.gridBillInfo.SetFieldStatus(this.AuditModelObj.DetailModifyFields, this.AuditModelObj.RequiredDetailFields, this.AuthorityTable); - - this.SetBillControl(this.AuditModelObj.BillModifyFields, this.AuditModelObj.RequiredFields); - this.InitPrint(); - - //加载分配 - this.dbpFP.Click += new System.EventHandler(this.OnBtnFPOldClick); - BarButtonItem itemFPBatch = new BarButtonItem(); - itemFPBatch.Caption = "批量分配"; - itemFPBatch.ItemClick += new ItemClickEventHandler(OnBtnFPNewClick); - //分配 - this.pmFP.AddItems(new BarItem[] { itemFPBatch }); - - this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModelObj.PopupUnionCode); - } - - /// - /// 说明:数据绑定完后刷新数据 - /// 创建人:龚宇超 - /// 创建日期: - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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)); - this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); - - - 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(); - } - - - } - /// - /// 说明:设置Brp模版加载明细 - /// 创建人:王一帆 - /// 创建日期:2021-03-02 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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(); - } - - } - /// - /// 说明:数据绑定完后刷新数据 - /// 创建人:龚宇超 - /// 创建日期: - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The sender. - /// The instance containing the event data. - 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); - } - } - /// - /// 说明:刷新表格列(时间) - /// 创建人:王一帆 - /// 创建日期:2018-08-16 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// - /// - private void OnDataFileRefrshFile(object sender, EventArgs e) - { - AddDataColumns(); - UpdateDynamicColumns(); - OnGcMainDataSourceChanged(gridBillInfo.GridView, null);//手动刷新日期合计数据源 - } - private void AddDataColumns() - { - foreach (GridColumn gridColumn in gridBillInfo.GridView.Columns) - { - gridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; - } - int dayCount = 0; - BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); - if (baseUserControl != null) - { - int.TryParse(baseUserControl.EditText, out dayCount); - } - if (dayCount <= 0) - { - dayCount = 7; - } - if (DateColumnList.Count != dayCount) - { - foreach (GridColumn item in DateColumnList) - { - gridBillInfo.GridView.Columns.Remove(item); - } - gridBillInfo.GridView.Columns.Remove(SumGridColumn); - DateColumnList.Clear(); - for (int i = 0; i < dayCount; 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 = true; - gridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; - gridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; - gridBillInfo.GridView.Columns.Add(gridColumn); - DateColumnList.Add(gridColumn); - } - GridColumn sumGridColumn = new GridColumn(); - sumGridColumn.AppearanceCell.Options.UseTextOptions = true; - sumGridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center; - sumGridColumn.AppearanceHeader.Options.UseTextOptions = true; - sumGridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; - sumGridColumn.OptionsColumn.AllowEdit = false; - sumGridColumn.OptionsColumn.AllowMove = false; - sumGridColumn.OptionsColumn.AllowSize = false; - sumGridColumn.OptionsFilter.AllowFilter = false; - sumGridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False; - sumGridColumn.OptionsColumn.AllowSort = DefaultBoolean.False; - sumGridColumn.FieldName = $"workingsum"; - sumGridColumn.Caption = $"工时合计"; - sumGridColumn.Width = 70; - sumGridColumn.DisplayFormat.FormatType = FormatType.Numeric; - sumGridColumn.DisplayFormat.FormatString = "{0:#,##0.####}"; - sumGridColumn.Visible = true; - sumGridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; - sumGridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; - SumGridColumn = sumGridColumn; - gridBillInfo.GridView.Columns.Add(sumGridColumn); - } - } - - /// - /// 根据日期修改列状态 - /// - /// - private void UpdateDynamicColumns() - { - DateTime currentDate = DateTime.Now; - BaseUserControl dateUserControl = ControlObj.FindControl("bom_rdm_ksdt"); - if (dateUserControl is LabelDateEdit labelDateEdit) - { - currentDate = labelDateEdit.TextEdit.DateTime; - } - - int dayCount = 0; - BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); - if (baseUserControl != null) - { - int.TryParse(baseUserControl.EditText, out dayCount); - } - if (dayCount <= 0) - { - dayCount = 7; - } - DateTime endDate = currentDate.AddDays(dayCount); - 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(); - } - } - /// - /// 主表数据源改变时 - /// - /// - /// - 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(jhrowtiemjson); - JArray jArray = new JArray(); - jArray.Add(rowObject); - DataRow jhrowitem = JsonConvert.DeserializeObject(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; - } - } - /// - /// 构建带日期的数据源 - /// - /// - /// - /// - /// - private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate) - { - string rightPrimaryKey = "billdocument_id"; - string dateField = "showday"; - string amountField = "amount"; - string topPrimaryKey = BillModelObj.DetailUUIDKey; - int dayCount = 0; - - BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); - if (baseUserControl != null) - { - int.TryParse(baseUserControl.EditText, out dayCount); - } - if (dayCount <= 0) - { - dayCount = 7; - } - DateTime endDate = startDate.AddDays(dayCount); - - // ---------- 1. 预索引 dataDayPlan:billdocument_id -> List ---------- - var dayPlanMap = new Dictionary>(); - foreach (DataRow row in dataDayPlan.Rows) - { - string billId = row[rightPrimaryKey].ToString(); - if (!dayPlanMap.TryGetValue(billId, out var list)) - { - list = new List(); - dayPlanMap[billId] = list; - } - list.Add(row); - } - - // ---------- 2. 为主表添加日期列和合计列 ---------- - for (DateTime d = startDate; d <= endDate; d = d.AddDays(1)) - { - string colName = d.ToString("yyyy-MM-dd"); - if (!dataMain.Columns.Contains(colName)) - dataMain.Columns.Add(colName, typeof(decimal)); - } - if (!dataMain.Columns.Contains("workingsum")) - dataMain.Columns.Add("workingsum", typeof(decimal)); - - // ---------- 3. 预构建填充映射:主键 -> (日期列名, 金额) ---------- - var dataMap = new Dictionary>(); - foreach (DataRow mainRow in dataMain.Rows) - { - string key = mainRow[topPrimaryKey].ToString(); - var inner = new Dictionary(); - dataMap[key] = inner; - - if (dayPlanMap.TryGetValue(key, out var rows)) - { - foreach (DataRow dayRow in rows) - { - if (dayRow[dateField] == DBNull.Value) continue; - - DateTime d = Convert.ToDateTime(dayRow[dateField]); - if (d < startDate || d > endDate) continue; - - string col = d.ToString("yyyy-MM-dd"); - if (!dataMain.Columns.Contains(col)) continue; - - if (decimal.TryParse(dayRow[amountField]?.ToString(), out decimal amt)) - inner[col] = amt; - } - } - } - - // ---------- 4. 一次性填充并计算行合计 ---------- - foreach (DataRow mainRow in dataMain.Rows) - { - string key = mainRow[topPrimaryKey].ToString(); - decimal rowSum = 0m; - - if (dataMap.TryGetValue(key, out var inner)) - { - foreach (var kv in inner) - { - mainRow[kv.Key] = kv.Value; - rowSum += kv.Value; - } - } - - mainRow["workingsum"] = rowSum; // 行汇总 - } - - return dataMain; - } - #endregion - - #region 右键菜单执行后刷新 - /// - /// 说明:右键菜单执行后刷新单据数据 - /// 创建人:龚宇超 - /// 创建日期:2018-03-19 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The sender. - /// The instance containing the event data. - protected void OnGridViewRightCallBack(object sender, EventArgs e) - { - try - { - // 刷新主表 - this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId); - this.ControlObj.SetAllControlValue(this._drBillInfoMsg); - - // 刷新明细表 - //this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId)); - this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); - 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); - } - } - /// - /// 说明:单据右键菜单执行后刷新Tab标签数据 - /// 创建人:龚宇超 - /// 创建日期:2018-01-15 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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)); - - bool isDetailAttach = (model.IsReadOnly || model.IsChart); - string sqlValue = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, model.DetailSql) : GetSearchSql(model); - sqlValue = ReplaceHelper.ReplaceRowParam(dataRow, sqlValue); - //this.tab_basicInfo.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue)); - this.tab_basicInfo.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue)); - } - catch (Exception ex) - { - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - } - #endregion - - #region 初始化打印 - /// - /// 说明:创建打印 - /// 创建人:龚宇超 - /// 创建日期:2018-01-04 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 打印 - /// - /// 说明:打印事件 - /// 创建人:龚宇超 - /// 创建日期:2018-01-05 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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 绘制水印 - /// - /// 说明:绘制水印 - /// 创建人:龚宇超 - /// 创建日期:2018-01-05 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 审批单据管理 - /// - /// 说明:单据管理 - /// 创建人:龚宇超 - /// 创建日期:2018-01-04 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void SetBillControl(string billFields, string RequiredFields) - { - Dictionary 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 (string item in billFields.Split(',')) - { - BaseUserControl control = this.ControlObj.FindControl(item); - if (control == null) continue; - if (string.IsNullOrWhiteSpace(control.Model.PrivilegeOper)) - { - //没有人员权限,转成可编辑 - this.ControlObj.SetReadOnlyControl(item, false, false); - } - else - { - List targetPrivTypeIds = new List(); - foreach (string permission in control.Model.PrivilegeOper.Split(',')) - { - if (!string.IsNullOrWhiteSpace(permission)) targetPrivTypeIds.Add(int.Parse(permission)); - } - //获取权限对应的人员名称 - string userString = string.Join(",", AuthorityTable.AsEnumerable() - .Where(row => targetPrivTypeIds.Contains(row.Field("privTypeId"))) - .Select(row => row.Field("userList")) - .Where(value => value != null) - .ToList()); - //有权限的字段,转成可编辑 - if (userString.Split(',').Contains(ERPInfo.Instance.UserName)) this.ControlObj.SetReadOnlyControl(item, false, false); - - } - } - //foreach (DataRow dr in this._dtBillInfoFiled.Rows) - //{ - // string fieldName = dr["fieldName"] + ""; - // this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), true); - //} - } - - } - #endregion - - #region 设置按钮状态 - /// - /// 说明:设置按钮状态 - /// 创建人:龚宇超 - /// 创建日期:2018-01-04 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void SetButtonsStatus() - { - Dictionary 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 加载提醒记录 - /// - /// 说明:加载提醒记录 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void LoadRemindRecord() - { - Dictionary 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 加载会签记录 - /// - /// 说明:加载会签记录 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void LoadSignRecord() - { - Dictionary 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 加载其他属性 - /// - /// 说明:加载其他属性 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void InitOtherParms() - { - Dictionary 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 是否为确认审核功能 - /// - /// 说明:是否是确认审核 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 常用意见 - /// - /// 说明:常用意见下拉框事件 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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 表格双击事件 - /// - /// 说明:双击表格 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 表格选中双击共用函数 - /// - /// 说明:gridBillInfo点击事件共用函数 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// 1表示点击进入,2表示双击进入 - /// - 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); - if (tabPage.Tag is ModuleWebView) - { - // 加载网页 - string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); - url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; - ModuleWebView webView = tabPage.Tag as ModuleWebView; - webView.Dock = DockStyle.Fill; - webView.Tag = model; - webView.Navigate(url); - } - else if (tabPage.Tag is FrmWebBrowser) - { - // 加载网页 - string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); - url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; - FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser; - webView.Dock = DockStyle.Fill; - webView.Tag = model; - webView.LoadUrl(url); - } - else if (tabPage.Tag is FrmMiniBlink) - { - // 加载网页 - string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); - url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; - FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink; - webView.Dock = DockStyle.Fill; - webView.Tag = model; - webView.LoadUrl(url); - } - else if (tabPage.Tag is GridControlEx) - { - 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); - } - else if (tabPage.Tag is TabMultipledetails) - { - TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails; - tabMultipledetails.SetConditionValues(dataRow); - GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx); - GridDetailModel MainModel = grdExMain.Tag as GridDetailModel; - string searchMainSql = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, MainModel.DetailSql) : this.GetSearchSql(MainModel); - DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql); - grdExMain.LastSearchSql = searchMainSql; - grdExMain.SetGridViewDataSource(firstTable); - if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx) - { - GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx); - GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; - string searchAddSql = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, AdditionalModel.DetailSql) : this.GetSearchSql(AdditionalModel); - if (!MainModel.IsUnioDetail) - { - grdExAdditional.LastSearchSql = searchAddSql; - grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql)); - } - //右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件) - if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0) - { - grdExAdditional.LastSearchSql = ""; - grdExAdditional.SetGridViewDataSource(new DataTable()); - } - } - else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx) - { - ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx); - GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; - string searchAddSql = this.GetSearchSql(AdditionalModel); - DataTable table = MainImpl.GetDataTableResult(searchAddSql); - grdExAdditional.CreateChart(table); - } - - } - - } - } - #endregion - #region 获取查询条件 - /// - /// 说明:获取查询条件 - /// 创建人:王一帆 - /// 创建日期:2021-01-22 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The model. - /// The row item. - /// System.String. - 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 表格选中改变事件 - /// - /// 说明:gridBillInfo选中事件 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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); - } - } - - /// - /// 说明:gridBillInfo焦点行改变事件 - /// 创建人:曹屹峰 - /// 创建日期:2023-10-13 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 关闭 - /// - /// 说明:关闭 - /// 创建人:龚宇超 - /// 创建日期:2018-01-08 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, 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" + msgText); - } - } - } - catch (Exception ex) - { - LogUtil.WriteError("关闭出错!", ex); - //MessageUtil.Show("关闭出错!" + ex); - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - - } - #endregion - - #region 返回审核 - /// - /// 说明:返回审核 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The row. - /// System.Int32. - 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 审核事件 - /// - /// 说明:提醒审核事件 - /// 创建人:龚宇超 - /// 创建日期:2020-08-20 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, 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" + msgText); - } - } - - - } - } - } - catch (Exception ex) - { - LogUtil.WriteError("提醒审核事件出错!", ex); - //MessageUtil.Show("提醒审核事件出错!" + ex); - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - - } - - /// - /// 说明:审核事件 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText,this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "",this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect,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" + msgText); - } - - } - } - - } - } - catch (Exception ex) - { - LogUtil.WriteError("审核事件出错!", ex); - MessageUtil.Show("审核事件出错!" + ex); - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - finally - { - WaitForm.HideForm(); - } - } - #endregion - - #region 分单 - /// - /// 说明:分单 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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 检查分单 - /// - /// 说明:检查分单 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// System.Boolean. - 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 单据来源 - /// - /// 说明:单据来源 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 分单创建单据 - /// - /// 说明:分单创建单据 - /// 创建人:龚宇超 - /// 创建日期:2018-01-10 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); - 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 构造表头 - /// - /// 说明:构造表头 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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 构造明细 - /// - /// 说明:构造明细 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// 单据编号. - 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 返退 - /// - /// 说明:提醒返回审核 - /// 创建人:王一帆 - /// 创建日期:2020-08-20 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, - 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, msgText)); - } - } - } - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, - 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, msgText)); - } - } - } - } - catch (Exception ex) - { - LogUtil.WriteError("提醒返回审核出错!", ex); - //MessageUtil.Show("提醒返回审核出错!" + ex); - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - - } - /// - /// 说明:返回审核 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - private void btnReturn_Click(object sender, EventArgs e) - { - try - { - - if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.AntiAuditUrl) && this.BillModelObj.NewVer == 1) - { - //string url = string.Format("/pages/app/app.html?stepcode=200&id=YQPS250610001&xtype=plugins.BaseAccraditation.AuditBackBox&username={0}&password={1}&dllcoid=", ERPInfo.Instance.UserName, "2383C0ADDCD699FB2CB45079ABB39E3CEF242D98"); - string url = ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.AntiAuditUrl); - url = url.Replace("{stepcode}", this.SysModel.StepCode).Replace("{primaryvalue}", this.SysModel.BillDocumentId).Replace("{remark}", txtRemark.Text).Replace("&isbase=1", ""); - string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~'); - string[] menuArgs = new string[] { "", "", url }; - string[] args = defaultArgs.Concat(menuArgs).ToArray(); - IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubBrower, args); - form.SubForm.WindowState = FormWindowState.Normal; - DialogResult result = form.SubForm.ShowDialog(); - if (result == DialogResult.OK) - { - this.DialogResult = DialogResult.OK; - if (refreshThePage != null) refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + ""); - } - - return; - } - - - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, - 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, msgText)); - } - } - } - 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); - string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, - 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, msgText)); - } - } - } - } - catch (Exception ex) - { - LogUtil.WriteError("返回审核出错!", ex); - MessageUtil.Show("返回审核出错!" + ex); - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - - } - #endregion - - #region 记录本次推送人员 - /// - /// 说明:记录本次推送人员 - /// 创建人:龚宇超 - /// 创建日期:2018-01-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void GetPushOpers() - { - Dictionary 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 保存单据 - /// - /// 说明:保存单据 - /// 创建人:龚宇超 - /// 创建日期:2018-01-10 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - private void btnSave_Click(object sender, EventArgs e) - { - try - { - SaveBillData(); - } - catch (Exception ex) - { - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - } - /// - /// 说明:保存单据 - /// 创建人:龚宇超 - /// 创建日期:2018-01-10 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// 保存确认标记 - 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); - } - - if (this.BillModelObj.SaveSuccessfullyRefresh && !save) return save;//保存成功才刷新 - - // 刷新主表 - 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); - 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 修改表头 - /// - /// 说明:获取修改表头 - /// 创建人:龚宇超 - /// 创建日期:2018-01-10 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// System.String. - 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 获取明细 - /// - /// 说明:获取明细 - /// 创建人:龚宇超 - /// 创建日期:2017-01-10 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// System.String. - 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 BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable)); - IEnumerable detailColumns = BillColumns.Columns.Cast(); - DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable + "_temp")); - foreach (DataRow dataRow in detailTable.Rows) - { - StringBuilder fields = new StringBuilder(); - StringBuilder values = new StringBuilder(); - string detailSql = @"insert into " + BillModelObj.DetailTable + "_temp" + "({0}) values({1})"; - - fields.Append("sysstr,"); - values.Append("'" + guid + "',"); - foreach (DataColumn item in detailTable.Columns) - { - var selectColumn = detailColumns.Where(n => n.ColumnName.Equals(item.ColumnName, StringComparison.OrdinalIgnoreCase)); - if (selectColumn.Count() == 0) - { - continue; - } - fields.Append(item.ColumnName + ","); - string fieldValue = (dataRow[item] + "").Replace("'", "''"); - if (!BillTempColumns.Columns.Contains(item.ColumnName)) - { - string type = "varchar(50)"; - if (item.DataType == typeof(DateTime)) - { - type = "datetime"; - } - BaseImpl.ExecSqlValue(string.Format("alter table {0} add {1} {2}", BillModelObj.DetailTable + "_temp", item.ColumnName, type)); - } - if (!string.IsNullOrWhiteSpace(fieldValue)) - { - values.Append(item.DataType == typeof(DateTime) ? "N'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : "N'" + fieldValue + "',"); - } - else - { - if (item.DataType == typeof(Decimal) || - item.DataType == typeof(Double) || - item.DataType == typeof(Int16) || - item.DataType == typeof(Int32) || - item.DataType == typeof(Int64)) - values.Append("0,"); - else if (item.DataType == typeof(DateTime)) - values.Append("NULL,"); - else - values.Append("'',"); - } - errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, dataRow, item, fieldValue); - } - detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(',')); - } - } - SaveErrorMessage = errorMessage; - return detailBuilder.ToString(); - } - #endregion - - #region 附件管理 - /// - /// 说明:附件管理 - /// 创建人:龚宇超 - /// 创建日期:2017-01-25 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// System.String. - 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 - - /// - /// 说明:初始化分割条位置 - /// 创建人:龚宇超 - /// 创建日期:2017-01-25 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - 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; - } - - - /// - /// 页签里数据修改后刷新明细 - /// - /// - /// - 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); - this._dtSourceData.OrderBy(this.BillModelObj.DetailOrderField); - if (this.BillModelObj.DetailTreeTable) - { - (this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData); - } - else - { - this.gridBillInfo.SetGridViewDataSource(_dtSourceData); - } - } - - /// - /// 说明:检查可用条件 - /// 创建人:龚宇超 - /// 创建日期:2017-11-09 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The cond. - /// The data row. - /// true if XXXX, false otherwise. - private bool ValidateCond(string cond, DataRow dataRow) - { - bool result = false; - cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); - if (cond.StartsWith("@") || cond.StartsWith("!")) - { - result = "1".Equals(BaseImpl.GetDefaultValue(cond)); - } - else if (dataRow == null) - { - result = ReplaceHelper.EvalCond(cond); - } - else - { - result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); - } - return result; - } - /// - /// 说明:分配明细 - /// 创建人:龚宇超 - /// 创建日期:2020-01-15 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The source of the event. - /// The instance containing the event data. - private void OnBtnFPOldClick(object sender, EventArgs e) - { - this.gridBillInfo.GridView.PostEditor(); - FPOld(); - } - private void OnBtnFPNewClick(object sender, EventArgs e) - { - this.gridBillInfo.GridView.PostEditor(); - FPNew(); - } - /// - /// 新版分配 - /// - private void FPNew(int rowHandle = 0) - { - try - { - this.gridBillInfo.GridView.FocusedRowHandle = rowHandle; - DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; - if (!table.Columns.Contains(guidField)) - { - table.Columns.Add(guidField, typeof(string)); - } - #region 创建分配界面 - string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" }; - DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); - using (FrmBaseSelectBatch frmSelect = new FrmBaseSelectBatch(baseModel, this.ControlObj, this.gridBillInfo)) - { - frmSelect.Text = this.BillModelObj.TypeName; - frmSelect.InitControl(); - frmSelect.OnAfterFPCallback += OnAfterFPCallback; - #region 初始化第一条数据 - DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); - if (rowItem == null) - { - return; - } - rowItem[guidField] = Guid.NewGuid().ToString(); - if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) - { - // 检查数据是否为分配后的行 - if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) - { - if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) - { - int focusedRowHandle = this.gridBillInfo.GridView.FocusedRowHandle + 1; - this.gridBillInfo.GridView.FocusedRowHandle = focusedRowHandle; - if (this.gridBillInfo.GridView.FocusedRowHandle == focusedRowHandle) - { - FPNew(focusedRowHandle); - } - else - { - MessageUtil.Show("全部分配完毕"); - } - } - return; - } - } - if (!string.IsNullOrEmpty(mRecordPrimaryField)) - { - frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); - if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) - { - List rows = frmSelect.FpRows.ToList(); - rows.Remove(rowItem); - frmSelect.FpRows = rows.ToArray(); - } - if (table.Columns.Contains(mRecordPrimaryField)) - { - frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); - } - } - frmSelect.InitData(rowItem); - frmSelect.OnBtnFPClick(null, null); - #endregion - //frmSelect.ShowDialog(); - #endregion - } - } - catch (Exception ex) - { - MessageUtil.Show(ex.Message); - } - } - /// - /// 分配完成后回调 - /// - /// - /// - private void OnAfterFPCallback(object sender, EventArgs e) - { - WaitForm.ShowForm(); - try - { - // 临时禁用新增行(空白行) - if (this.BillModelObj.DefaultAddEmptyRow) this.gridBillInfo.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.None; - DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); - if (rowItem == null) - { - return; - } - DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; - FrmBaseSelectBatch frmSelect = (FrmBaseSelectBatch)sender; - rowItem[guidField] = Guid.NewGuid().ToString(); - if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) - { - // 检查数据是否为分配后的行 - if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) - { - if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) - { - this.gridBillInfo.GridView.FocusedRowHandle += 1; - OnAfterFPCallback(sender, e); - } - return; - } - } - if (!string.IsNullOrEmpty(mRecordPrimaryField)) - { - frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); - if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) - { - List rows = frmSelect.FpRows.ToList(); - rows.Remove(rowItem); - frmSelect.FpRows = rows.ToArray(); - } - if (table.Columns.Contains(mRecordPrimaryField)) - { - frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); - } - } - frmSelect.InitData(rowItem); - bool success = frmSelect.FP(); - if (success) - { - if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) - { - // 增加标识列 - if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) - { - this.mRecordPrimaryField = frmSelect.RecordPrimaryField; - table.Columns.Add(this.mRecordPrimaryField, typeof(String)); - } - foreach (DataRow item in frmSelect.SelectedRows) - { - DataRow newRow = table.NewRow(); - newRow.ItemArray = rowItem.ItemArray; - newRow[guidField] = rowItem[guidField]; - DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + ""); - //自增长列分配按空值取 - if (IsIdentCol != null) - { - if (IsIdentCol.DataType == typeof(Decimal) || - IsIdentCol.DataType == typeof(Double) || - IsIdentCol.DataType == typeof(Int16) || - IsIdentCol.DataType == typeof(Int32) || - IsIdentCol.DataType == typeof(Int64)) - { - newRow[IsIdentCol.ColumnName] = 0; - } - } - foreach (DataColumn col in item.Table.Columns) - { - if (table.Columns.Contains(col.ColumnName)) - { - //newRow[col.ColumnName] = item[col.ColumnName]; - newRow[col.ColumnName] = item[col.ColumnName]; - GridColumn column = this.gridBillInfo.GridView.Columns[col.ColumnName]; - if (column != null) - { - GridColumnModel model = column.Tag as GridColumnModel; - if (!string.IsNullOrEmpty(model.UnionFields)) - { - this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); - } - SetCalcValue(model, rowItem[column.FieldName] + "", newRow); - } - } - } - newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; - newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; - table.Rows.Add(newRow); - } - NumberMc = frmSelect.AmountField; - table.Rows.Remove(rowItem); - // 重排顺序 - table.OrderBy(this.BillModelObj.DetailOrderField); - this.gridBillInfo.GridView.UpdateCurrentRow(); - this.gridBillInfo.GridView.ShowEditor(); - if (frmSelect.isNextOne) - { - int SourceRowIndex = this.gridBillInfo.GridView.GetFocusedDataSourceRowIndex(); - DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); - if (a.Length != 0) - { - this.gridBillInfo.GridView.FocusedRowHandle = SourceRowIndex; - OnAfterFPCallback(sender, e); - } - else - { - MessageUtil.Show("全部分配完毕"); - // frmSelect.SelectRowItem = null; - } - } - } - } - else - { - if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) - { - this.gridBillInfo.GridView.FocusedRowHandle += 1; - OnAfterFPCallback(sender, e); - } - else - { - MessageUtil.Show("全部分配完毕"); - } - } - } - catch (Exception) - { - throw; - } - finally - { - // 重新开启新增行(空白行) - if (this.BillModelObj.DefaultAddEmptyRow) this.gridBillInfo.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; - WaitForm.HideForm(); - } - } - /// - /// 老版分配 - /// - private void FPOld() - { - try - { - DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); - if (rowItem == null) - { - MessageUtil.Show("请先选择一条明细在进行分配!"); - return; - } - DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; - if (!table.Columns.Contains(guidField)) - { - table.Columns.Add(guidField, typeof(string)); - } - rowItem[guidField] = Guid.NewGuid().ToString(); ; - if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) - { - // 检查数据是否为分配后的行 - if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) - { - MessageUtil.Show("该行数据为已分配后的数据,无需分配!"); - return; - } - } - string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" }; - DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); - using (FrmBaseSelect frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gridBillInfo)) - { - //if (frmSelect.SelectRowItem == null) - //{ - // frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); - //} - frmSelect.Text = this.BillModelObj.TypeName; - frmSelect.SelectRowItem = rowItem; - bool isNextOne = false; - if (!string.IsNullOrEmpty(mRecordPrimaryField)) - { - frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); - if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) - { - List rows = frmSelect.FpRows.ToList(); - rows.Remove(rowItem); - frmSelect.FpRows = rows.ToArray(); - } - if (table.Columns.Contains(mRecordPrimaryField)) - { - frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); - } - } - if (frmSelect.ShowDialog() == DialogResult.OK) - { - if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) - { - //if (frmSelect.isNextOne) - //{ - // isNextOne = true; - //} - //else - //{ - // isNextOne = false; - //} - // 增加标识列 - if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) - { - this.mRecordPrimaryField = frmSelect.RecordPrimaryField; - table.Columns.Add(this.mRecordPrimaryField, typeof(String)); - } - - foreach (DataRow item in frmSelect.SelectedRows) - { - DataRow newRow = table.NewRow(); - newRow.ItemArray = rowItem.ItemArray; - newRow[guidField] = rowItem[guidField]; - DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + ""); - //自增长列分配按空值取 - if (IsIdentCol != null) - { - if (IsIdentCol.DataType == typeof(Decimal) || - IsIdentCol.DataType == typeof(Double) || - IsIdentCol.DataType == typeof(Int16) || - IsIdentCol.DataType == typeof(Int32) || - IsIdentCol.DataType == typeof(Int64)) - { - newRow[IsIdentCol.ColumnName] = 0; - } - } - foreach (DataColumn col in item.Table.Columns) - { - if (table.Columns.Contains(col.ColumnName)) - { - //newRow[col.ColumnName] = item[col.ColumnName]; - newRow[col.ColumnName] = item[col.ColumnName]; - GridColumn column = this.gridBillInfo.GridView.Columns[col.ColumnName]; - if (column != null) - { - GridColumnModel model = column.Tag as GridColumnModel; - if (!string.IsNullOrEmpty(model.UnionFields)) - { - this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); - } - SetCalcValue(model, rowItem[column.FieldName] + "", newRow); - } - } - } - newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; - newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; - table.Rows.Add(newRow); - } - NumberMc = frmSelect.AmountField; - //double syAmount = frmSelect.GetSyAmount(); - //if (syAmount > 0) - //{ - // rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount(); - //} - //else - //{ - // table.Rows.Remove(rowItem); - //} - table.Rows.Remove(rowItem); - // 重排顺序 - table.OrderBy(this.BillModelObj.DetailOrderField); - this.gridBillInfo.GridView.UpdateCurrentRow(); - this.gridBillInfo.GridView.ShowEditor(); - } - } - if (frmSelect.isNextOne) - { - int SourceRowIndex = this.gridBillInfo.GridView.GetFocusedDataSourceRowIndex(); - DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); - if (a.Length != 0) - { - this.gridBillInfo.GridView.FocusedRowHandle = SourceRowIndex; - OnBtnFPOldClick(null, null); - } - else - { - MessageUtil.Show("全部分配完毕"); - // frmSelect.SelectRowItem = null; - } - } - } - } - catch (Exception ex) - { - MessageUtil.Show(ex); - } - } - /// - /// 说明:计算列关联字段 - /// 创建人:龚宇超 - /// 创建日期:2017-12-18 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The model. - /// The field value. - protected virtual void SetUnionValue(GridColumnModel model, string fieldValue, DataRow rowItem) - { - DataTable table = this.gridBillInfo.gridControl.DataSourceTable(); - //DataRow rowItem = this.gridView.GetFocusedDataRow(); - string unionValues = model.UnionValues; - if (rowItem != null && model != null) - { - unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue)); - if (this.ControlObj != null) - { - unionValues = ControlObj.ReplaceParentControlValue(unionValues); - } - try - { - string[] fields = model.UnionFields.Trim(',').Split(','); - DataRow rowResult = BaseImpl.GetDataRowResult(unionValues); - if (rowResult != null) - { - for (int i = 0; i < fields.Length; i++) - { - string field = fields[i]; - string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null; - rowItem[field] = value; - } - } - else - { - // 设置为空 - for (int i = 0; i < fields.Length; i++) - { - string field = fields[i]; - rowItem[field] = DBNull.Value; - } - } - } - catch (Exception ex) - { - LogHelper.Instance.WriteError(ex); - LogUtil.WriteError("计算列关联字段--错误-->" + unionValues, ex); - } - } - } - /// - /// 说明:计算列计算公式 - /// 创建人:龚宇超 - /// 创建日期:2017-12-18 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// The model. - /// The field value. - protected virtual void SetCalcValue(GridColumnModel model, string fieldValue, DataRow rowItem) - { - try - { - DataTable table = this.gridBillInfo.gridControl.DataSourceTable(); - if (rowItem != null && model != null) - { - List calcModels = this.gridBillInfo.ObjmControlList.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr)).OrderBy(y => y.CalcOrder).ToList(); - - foreach (GridColumnModel gridModel in calcModels) - { - // 计算顺序小于当前控件则不计算 - if (gridModel.CalcOrder < model.CalcOrder) continue; - - if (!gridModel.FieldName.Equals(model.FieldName, StringComparison.OrdinalIgnoreCase)) - { - bool isTruncate = false; - string calcExpr = gridModel.CalcExpr; - if (calcExpr.StartsWith("@truncate:")) - { - calcExpr = calcExpr.Substring(10); - isTruncate = true; - } - - try - { - if (this.ControlObj != null) - calcExpr = ControlObj.ReplaceParentControlValue(calcExpr); - - calcExpr = ReplaceHelper.ReplaceRowParam(rowItem, calcExpr); - //EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + "" - string result = EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + ""; - if (isTruncate) - { - result += result.Contains(".") ? "0000000000" : ".0000000000"; - rowItem[gridModel.FieldName] = result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1); - //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1)); - } - else - { - try - { - double d = 0; - if (!string.IsNullOrEmpty(result) && - !"NaN".Equals(result, StringComparison.OrdinalIgnoreCase) && - !"非数字".Equals(result, StringComparison.OrdinalIgnoreCase) && - !"undefined".Equals(result, StringComparison.OrdinalIgnoreCase) && - result != "∞" && result != "-∞" && - !"正无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && - !"负无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && - double.TryParse(result, out d)) - { - if (string.IsNullOrEmpty(gridModel.DataFormat)) - { - result = Math.Round(Convert.ToDouble(d), model.Decimals, MidpointRounding.AwayFromZero) + ""; - } - else - { - //计算后先执行保存小数位数 - result = string.Format("{0:" + gridModel.DataFormat + "}", Convert.ToDecimal(result)); - } - if (model.FieldType == 7 && result.Contains('%')) - { - result = (double.Parse(result.Replace("%", "")) * 0.01).ToString(); - } - rowItem[gridModel.FieldName] = result; - // 判断计算列有无关联值 - GridColumnModel UnionModel = calcModels.FirstOrDefault(x => x.FieldName == gridModel.FieldName); - if (!string.IsNullOrEmpty(UnionModel.UnionFields)) - { - this.SetUnionValue(UnionModel, rowItem[gridModel.FieldName] + "", rowItem); - } - //this.gridView.SetRowCellValue(this.gri \ No newline at end of file +/*********************** +* 说明:单据审批弹出模块 +* 创建人:龚宇超 +* 创建日期: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 +{ + + /// + /// 单据审批弹出模块 + /// + public partial class FrmAccraditation : BaseForm + { + public FrmAccraditation() + { + InitializeComponent(); + } + #region 公有变量 + + /// + /// 单据结构明细 + /// + public AccraditationModel AuditModelObj; + /// + /// 单据模型 + /// + public BillAuditModel BillModelObj; + /// + /// 单据审批表模型 + /// + public BillAuditCommonModel BillAuditComObj; + /// + /// 单据入口参数模型 + /// + public DynamicPubAccraditionPopModel SysModel; + /// + /// 主表控件 + /// + public MyControl ControlObj; + /// + /// 是否是Brp模块加载审核明细 + /// + public bool isBrpAccrad = false; + #endregion + /// + /// 调用动态链接库默认传递参数 + /// + public DynamicModel syModel { get; private set; } + /// + /// 关闭当前审核界面,刷新打开界面 + /// + /// The sender. + public event RefreshThePage refreshThePage; + public delegate void RefreshThePage(string promptInformation, string id); + /// + /// 主表动态生成的日期列 + /// + public List DateColumnList = new List(); + /// + /// 主表动态生成的合计列 + /// + public GridColumn SumGridColumn = new GridColumn(); + #region 私有变量 + /// + /// 数量名称 + /// + public string NumberMc; + /// + /// 主键字段 + /// + private string mRecordPrimaryField; + private string guidField = "xxxxx_guid"; + /// + /// id(推送记录) + /// + private int _beforeId; + /// + /// 是否初始化完成 + /// + private bool _isInitFinish; + /// + /// 意见 + /// + private string _auditAdvice; + /// + /// 菜单模块名(推送记录) + /// + private string _beforeMenuName; + /// + /// 用户(推送记录) + /// + private string _beforeUsers; + /// + /// 单据类别值 + /// + private string _mainBillTypeValue; + /// + /// 单据信息 + /// + private DataRow _drBillInfoMsg; + /// + /// 明细数据 + /// + private DataTable _dtSourceData; + /// + /// 单据类别 + /// + private DataTable _dtBillType; + /// + /// 单据明细列表 + /// + private DataTable _dtBillAttachList; + /// + /// 单据billInfo + /// + private DataTable _dtBillInfoFiled; + /// + /// 分单数据 + /// + private DataTable _dtSpareSourceData; + /// + /// 审批流转模型 + /// + private FlowTypeStepModel _flowTypeStepModel; + /// + /// 单据水印 + /// + private WaterMark _waterMark; + /// + /// 获取隐藏的x轴距 + /// + private ArrayList LocationX = new ArrayList(); + /// + /// 是否执行了加载储存过程 + /// + public bool ProcessExists = false; + // + /// 模块对应的权限表信息 + /// + public DataTable AuthorityTable; + #endregion + + /// + /// 说明:窗体加载时 + /// 创建人:龚宇超 + /// 创建日期:2018-01-02 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The instance containing the event data. + 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 获取数据源缓存 + /// + /// 获取数据源缓存 + /// + /// + public void GetDataCaches(Dictionary cachesDic) + { + //全局数据 + Task dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task(() => + { + return SysModel;//动态链接库对象 + })); + DynamicPubAccraditionPopModel dynamicModel = (DynamicPubAccraditionPopModel)dynamicModelTask.Result; + #region InitializeSetting + Task accraditationModelRowTask = cachesDic.AddTask(this, "AccraditationModelRow", new Task(() => + { + return BillAuditImpl.GetBillFlowData(dynamicModel.ModuleCode, dynamicModel.StepCode); + })); + Task accraditationModelTask = cachesDic.AddTask(this, "AccraditationModel", new Task(() => + { + return new AccraditationModel(accraditationModelRowTask.Result); + })); + Task billInfoTask = cachesDic.AddTask(this, "BillInfo", new Task(() => + { + return BillImpl.GetBillInfo(dynamicModel.ModuleCode);//获取单个模块信息 + })); + Task billAuditModelTask = cachesDic.AddTask(this, "BillAuditModel", new Task(() => + { + BillAuditModel billAuditModel = new BillAuditModel(billInfoTask.Result); + Task masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task(() => + { + return BaseImpl.GetColumnPrefix(billAuditModel.MasterTable); + })); + Task detailPreFixTask = cachesDic.AddTask(this, "DetailPreFix", new Task(() => + { + return BaseImpl.GetColumnPrefix(billAuditModel.DetailTable);// 明细表列前缀 + })); + billAuditModel.MasterPreFix = masterPreFixTask.Result; + billAuditModel.DetailPreFix = detailPreFixTask.Result; + billAuditModel.DetailOrderField = detailPreFixTask.Result + "lsidx_id";// 单据来源id + return billAuditModel; + })); + Task billAuditCommonModelTask = cachesDic.AddTask(this, "BillAuditCommonModel", new Task(() => + { + return new BillAuditCommonModel(); + })); + Task menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task(() => + { + return BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); //获取菜单其他配置 + })); + Task fileCountTask = cachesDic.AddTask(this, "FileCount", new Task(() => + { + return AttachImpl.GetFileCount(billAuditModelTask.Result.DirId + "", dynamicModel.BillDocumentId); + })); + //记录推送用户 + Task pushedOpersTask = cachesDic.AddTask(this, "PushedOpers", new Task(() => + { + return BillAuditImpl.GetPushedOpers(dynamicModel.BillDocumentId, dynamicModel.StepCode); + })); + Task billInfoDataTask = cachesDic.AddTask(this, "BillInfoData", new Task(() => + { + return BillAuditImpl.GetBillInfoData(dynamicModel.ModuleCode); + })); + #endregion + #region InitializeControl + Task readOnlyColumnsTask = cachesDic.AddTask(gridFlow, "ReadOnlyColumns", new Task(() => + { + return BaseAuditImpl.GetFlowRecordColumn(); + })); + string customColumKey = GridCustomColumnStruct.AuditPopupAttachGridView + billAuditModelTask.Result.FormKey; + cachesDic.AddTask(gridFlow, "DynamicModel", dynamicModelTask); + gridFlow.GetDataCaches(cachesDic, customColumKey); + Task gridViewDataSourceTask = cachesDic.AddTask(gridFlow, "GridViewDataSource", new Task(() => + { + return BaseAuditImpl.GetFlowRecordData(billAuditCommonModelTask.Result.SystemTabFlowStep, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); + })); + //BindTab + Task> detailTask = cachesDic.AddTask(gridFlow, "Details", new Task>(() => + { + List details = new List(); + 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 addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => + { + 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 addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => + { + 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 controlLocationTask = cachesDic.AddTask(this, "ControlLocation", new Task(() => + { + return BaseModuleImpl.GetControlLocation(billAuditModelTask.Result.FormKey, dynamicModel.ModuleCode); + })); + Task controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task(() => + { + 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 detailColumnsTask = cachesDic.AddTask(gridBillInfo, "DetailColumns", new Task(() => + { + return BillImpl.GetDetailColumns(dynamicModel.ModuleCode); + })); + string gridBillCustomColumKey = GridCustomColumnStruct.AuditPopupDetailGridView + billAuditModelTask.Result.FormKey; + cachesDic.AddTask(gridBillInfo, "DynamicModel", dynamicModelTask); + gridBillInfo.GetDataCaches(cachesDic, gridBillCustomColumKey); + Task baseGridRightMenusTask = cachesDic.AddTask(gridBillInfo, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus(accraditationModelTask.Result.BillGridMenuFlag + dynamicModel.ModuleCode, ModuleType.BillAuditDetail); + })); + Task baseGridRowColorsTask = cachesDic.AddTask(gridBillInfo, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + billAuditModelTask.Result.FormKey); + })); + //设置必填和修改字段 + Task currentFlowRowDataTask = cachesDic.AddTask(this, "CurrentFlowRowData", new Task(() => + { + 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 billFlowStepTask = cachesDic.AddTask(this, "BillFlowStep", new Task(() => + { + DataRow billFlowStep = BillAuditImpl.GetBillFlowStep(dynamicModel.ModuleCode, mainBillTypeValue, dynamicModel.StepCode); + if (billFlowStep != null) + { + Task flowTypeStepModelTask = cachesDic.AddTask(this, "FlowTypeStepModel", new Task(() => + { + FlowTypeStepModel flowTypeStepModel = new FlowTypeStepModel(billFlowStep); + //LoadRemindRecord + if (flowTypeStepModel != null && !string.IsNullOrEmpty(flowTypeStepModel.RemindSelect)) + { + Task remindinRecordTask = cachesDic.AddTask(gridRemind, "RemindinRecord", new Task(() => + { + DataTable dt = BaseAuditImpl.GetRemindinRecord(billAuditCommonModelTask.Result.FlowStepTable, billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); + if (dt != null && dt.Rows.Count > 0) + { + Task gridRemindReadOnlyColumnsTask = cachesDic.AddTask(gridRemind, "ReadOnlyColumns", new Task(() => + { + return BaseAuditImpl.GetRemindColumn(); + })); + cachesDic.AddTask(gridRemind, "DynamicModel", dynamicModelTask); + gridRemind.GetDataCaches(cachesDic); + } + return dt; + })); + } + return new FlowTypeStepModel(billFlowStep); + })); + string operUser = flowTypeStepModelTask.Result.OperUser; + Task operatorsTask = cachesDic.AddTask(this, "Operators", new Task(() => + { + 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 numberTask = cachesDic.AddTask(this, "Number", new Task(() => + { + return BaseImpl.GetResult(sql) + ""; + })); + } + return operators; + })); + Task billComfirmTask = cachesDic.AddTask(this, "BillComfirm", new Task(() => + { + return BillAuditImpl.GetBillComfirm(this.SysModel.ConfirmId) < 0; + })); + //代理权限 + Task agencyAuthorityTask = cachesDic.AddTask(this, "AgencyAuthority", new Task(() => + { + return BillAuditImpl.GetAgencyAuthority(dynamicModel.ModuleCode); + })); + } + return billFlowStep; + })); + } + } + return currentFlowRowData; + })); + //LoadSignRecord + if (billAuditCommonModelTask.Result != null) + { + Task signRecordTask = cachesDic.AddTask(gridSign, "SignRecord", new Task(() => + { + DataTable dt = BaseAuditImpl.GetSignRecord(billAuditCommonModelTask.Result.ComfrimTable, dynamicModel.BillDocumentId, dynamicModel.ModuleCode); + if (dt != null && dt.Rows.Count > 0) + { + Task gridSignReadOnlyColumnsTask = cachesDic.AddTask(gridSign, "ReadOnlyColumns", new Task(() => + { + return BaseAuditImpl.GetSignRecordCoulumn(); + })); + cachesDic.AddTask(gridSign, "DynamicModel", dynamicModelTask); + gridSign.GetDataCaches(cachesDic); + } + return dt; + })); + } + //InitCommonMenu + Task tableCommonTask = cachesDic.AddTask(this, "TableCommon", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.BillDetail); + })); + //InitOtherParms + Task checkSuggestionDataSourceTask = cachesDic.AddTask(this, "CheckSuggestionDataSource", new Task(() => + { + return BaseImpl.GetDataTableResult(accraditationModelTask.Result.SuggestionSql); + })); + #endregion + } + #endregion + + + + #region 初始化属性设置 + /// + /// 说明:初始化属性设置 + /// 创建人:龚宇超 + /// 创建日期:2018-01-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeSetting() + { + Dictionary 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 表格是否可以编辑设置 + /// + /// 说明:表格编辑时,判断是否是否编辑 + /// 创建人:王一帆 + /// 创建日期:2020-03-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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 流转表格设置行颜色 + /// + /// 说明:流转表格行颜色区分 + /// 创建人:龚宇超 + /// 创建日期:2018-01-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 初始化控件 + /// + /// 说明:初始化控件 + /// 创建人:龚宇超 + /// 创建日期:2018-01-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeControl() + { + Dictionary 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 + /// + /// 说明:录所有按钮的位置 + /// 创建人:王一帆 + /// 创建日期:2020-11-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 初始化常用菜单 + /// + /// 说明:设置初始化常用菜单 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitCommonMenu() + { + Dictionary 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 常用工具 + /// + /// 说明:常用工具点击 + /// 创建人:龚宇超 + /// 创建日期:2017-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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); + } + } + /// + /// 说明:执行前单独替换BilldocumentId + /// 创建人:王一帆 + /// 创建日期:2020-07-24 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The e. + 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 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 设置窗体大小 + /// + /// 说明:设置窗体大小 + /// 创建人:龚宇超 + /// 创建日期:2018-01-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 绑定选项卡 + /// + /// 说明:绑定选项卡 + /// 创建人:龚宇超 + /// 创建日期:2018-01-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void BindTab() + { + Dictionary 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 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); + } + + + + /// + /// 说明:获取选项卡数据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-15 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// List<GridDetailModel>. + private List GetTabDetails() + { + List details = new List(); + + 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 绑定审批单据 + /// + /// 说明:单据管理 + /// 创建人:龚宇超 + /// 创建日期:2018-01-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void BindBill() + { + Dictionary 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.isAuditMain = true; + 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; + // } + // } + //} + + this.AuthorityTable = PowerImpl.GetModuleAuthorityEnable(this.SysModel.ModuleCode); + + if (this.AuditModelObj.DetailModifyFields != "-1") + { + this.gridBillInfo.SetReadOnlyAllColumn(); + this.dbpFP.Enabled = false; + } + //设置必填和修改字段 + this.gridBillInfo.SetFieldStatus(this.AuditModelObj.DetailModifyFields, this.AuditModelObj.RequiredDetailFields, this.AuthorityTable); + + this.SetBillControl(this.AuditModelObj.BillModifyFields, this.AuditModelObj.RequiredFields); + this.InitPrint(); + + //加载分配 + this.dbpFP.Click += new System.EventHandler(this.OnBtnFPOldClick); + BarButtonItem itemFPBatch = new BarButtonItem(); + itemFPBatch.Caption = "批量分配"; + itemFPBatch.ItemClick += new ItemClickEventHandler(OnBtnFPNewClick); + //分配 + this.pmFP.AddItems(new BarItem[] { itemFPBatch }); + + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModelObj.PopupUnionCode); + } + + /// + /// 说明:数据绑定完后刷新数据 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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)); + this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); + + + 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(); + } + + + } + /// + /// 说明:设置Brp模版加载明细 + /// 创建人:王一帆 + /// 创建日期:2021-03-02 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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(); + } + + } + /// + /// 说明:数据绑定完后刷新数据 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + 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); + } + } + /// + /// 说明:刷新表格列(时间) + /// 创建人:王一帆 + /// 创建日期:2018-08-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// + /// + private void OnDataFileRefrshFile(object sender, EventArgs e) + { + AddDataColumns(); + UpdateDynamicColumns(); + OnGcMainDataSourceChanged(gridBillInfo.GridView, null);//手动刷新日期合计数据源 + } + private void AddDataColumns() + { + foreach (GridColumn gridColumn in gridBillInfo.GridView.Columns) + { + gridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; + } + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + if (DateColumnList.Count != dayCount) + { + foreach (GridColumn item in DateColumnList) + { + gridBillInfo.GridView.Columns.Remove(item); + } + gridBillInfo.GridView.Columns.Remove(SumGridColumn); + DateColumnList.Clear(); + for (int i = 0; i < dayCount; 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 = true; + gridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; + gridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; + gridBillInfo.GridView.Columns.Add(gridColumn); + DateColumnList.Add(gridColumn); + } + GridColumn sumGridColumn = new GridColumn(); + sumGridColumn.AppearanceCell.Options.UseTextOptions = true; + sumGridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center; + sumGridColumn.AppearanceHeader.Options.UseTextOptions = true; + sumGridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; + sumGridColumn.OptionsColumn.AllowEdit = false; + sumGridColumn.OptionsColumn.AllowMove = false; + sumGridColumn.OptionsColumn.AllowSize = false; + sumGridColumn.OptionsFilter.AllowFilter = false; + sumGridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False; + sumGridColumn.OptionsColumn.AllowSort = DefaultBoolean.False; + sumGridColumn.FieldName = $"workingsum"; + sumGridColumn.Caption = $"工时合计"; + sumGridColumn.Width = 70; + sumGridColumn.DisplayFormat.FormatType = FormatType.Numeric; + sumGridColumn.DisplayFormat.FormatString = "{0:#,##0.####}"; + sumGridColumn.Visible = true; + sumGridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; + sumGridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; + SumGridColumn = sumGridColumn; + gridBillInfo.GridView.Columns.Add(sumGridColumn); + } + } + + /// + /// 根据日期修改列状态 + /// + /// + private void UpdateDynamicColumns() + { + DateTime currentDate = DateTime.Now; + BaseUserControl dateUserControl = ControlObj.FindControl("bom_rdm_ksdt"); + if (dateUserControl is LabelDateEdit labelDateEdit) + { + currentDate = labelDateEdit.TextEdit.DateTime; + } + + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + DateTime endDate = currentDate.AddDays(dayCount); + 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(); + } + } + /// + /// 主表数据源改变时 + /// + /// + /// + 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(jhrowtiemjson); + JArray jArray = new JArray(); + jArray.Add(rowObject); + DataRow jhrowitem = JsonConvert.DeserializeObject(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; + } + } + /// + /// 构建带日期的数据源 + /// + /// + /// + /// + /// + private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate) + { + string rightPrimaryKey = "billdocument_id"; + string dateField = "showday"; + string amountField = "amount"; + string topPrimaryKey = BillModelObj.DetailUUIDKey; + int dayCount = 0; + + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + DateTime endDate = startDate.AddDays(dayCount); + + // ---------- 1. 预索引 dataDayPlan:billdocument_id -> List ---------- + var dayPlanMap = new Dictionary>(); + foreach (DataRow row in dataDayPlan.Rows) + { + string billId = row[rightPrimaryKey].ToString(); + if (!dayPlanMap.TryGetValue(billId, out var list)) + { + list = new List(); + dayPlanMap[billId] = list; + } + list.Add(row); + } + + // ---------- 2. 为主表添加日期列和合计列 ---------- + for (DateTime d = startDate; d <= endDate; d = d.AddDays(1)) + { + string colName = d.ToString("yyyy-MM-dd"); + if (!dataMain.Columns.Contains(colName)) + dataMain.Columns.Add(colName, typeof(decimal)); + } + if (!dataMain.Columns.Contains("workingsum")) + dataMain.Columns.Add("workingsum", typeof(decimal)); + + // ---------- 3. 预构建填充映射:主键 -> (日期列名, 金额) ---------- + var dataMap = new Dictionary>(); + foreach (DataRow mainRow in dataMain.Rows) + { + string key = mainRow[topPrimaryKey].ToString(); + var inner = new Dictionary(); + dataMap[key] = inner; + + if (dayPlanMap.TryGetValue(key, out var rows)) + { + foreach (DataRow dayRow in rows) + { + if (dayRow[dateField] == DBNull.Value) continue; + + DateTime d = Convert.ToDateTime(dayRow[dateField]); + if (d < startDate || d > endDate) continue; + + string col = d.ToString("yyyy-MM-dd"); + if (!dataMain.Columns.Contains(col)) continue; + + if (decimal.TryParse(dayRow[amountField]?.ToString(), out decimal amt)) + inner[col] = amt; + } + } + } + + // ---------- 4. 一次性填充并计算行合计 ---------- + foreach (DataRow mainRow in dataMain.Rows) + { + string key = mainRow[topPrimaryKey].ToString(); + decimal rowSum = 0m; + + if (dataMap.TryGetValue(key, out var inner)) + { + foreach (var kv in inner) + { + mainRow[kv.Key] = kv.Value; + rowSum += kv.Value; + } + } + + mainRow["workingsum"] = rowSum; // 行汇总 + } + + return dataMain; + } + #endregion + + #region 右键菜单执行后刷新 + /// + /// 说明:右键菜单执行后刷新单据数据 + /// 创建人:龚宇超 + /// 创建日期:2018-03-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + protected void OnGridViewRightCallBack(object sender, EventArgs e) + { + try + { + // 刷新主表 + this._drBillInfoMsg = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId); + this.ControlObj.SetAllControlValue(this._drBillInfoMsg); + + // 刷新明细表 + //this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId)); + this._dtSourceData = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); + 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); + } + } + /// + /// 说明:单据右键菜单执行后刷新Tab标签数据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-15 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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)); + + bool isDetailAttach = (model.IsReadOnly || model.IsChart); + string sqlValue = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, model.DetailSql) : GetSearchSql(model); + sqlValue = ReplaceHelper.ReplaceRowParam(dataRow, sqlValue); + //this.tab_basicInfo.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue)); + this.tab_basicInfo.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue)); + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + #endregion + + #region 初始化打印 + /// + /// 说明:创建打印 + /// 创建人:龚宇超 + /// 创建日期:2018-01-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 打印 + /// + /// 说明:打印事件 + /// 创建人:龚宇超 + /// 创建日期:2018-01-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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 绘制水印 + /// + /// 说明:绘制水印 + /// 创建人:龚宇超 + /// 创建日期:2018-01-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 审批单据管理 + /// + /// 说明:单据管理 + /// 创建人:龚宇超 + /// 创建日期:2018-01-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetBillControl(string billFields, string RequiredFields) + { + Dictionary 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 (string item in billFields.Split(',')) + { + BaseUserControl control = this.ControlObj.FindControl(item); + if (control == null) continue; + if (string.IsNullOrWhiteSpace(control.Model.PrivilegeOper)) + { + //没有人员权限,转成可编辑 + this.ControlObj.SetReadOnlyControl(item, false, false); + } + else + { + List targetPrivTypeIds = new List(); + foreach (string permission in control.Model.PrivilegeOper.Split(',')) + { + if (!string.IsNullOrWhiteSpace(permission)) targetPrivTypeIds.Add(int.Parse(permission)); + } + //获取权限对应的人员名称 + string userString = string.Join(",", AuthorityTable.AsEnumerable() + .Where(row => targetPrivTypeIds.Contains(row.Field("privTypeId"))) + .Select(row => row.Field("userList")) + .Where(value => value != null) + .ToList()); + //有权限的字段,转成可编辑 + if (userString.Split(',').Contains(ERPInfo.Instance.UserName)) this.ControlObj.SetReadOnlyControl(item, false, false); + + } + } + //foreach (DataRow dr in this._dtBillInfoFiled.Rows) + //{ + // string fieldName = dr["fieldName"] + ""; + // this.ControlObj.SetReadOnlyControl(fieldName, !billFields.Split(',').Contains(fieldName), true); + //} + } + + } + #endregion + + #region 设置按钮状态 + /// + /// 说明:设置按钮状态 + /// 创建人:龚宇超 + /// 创建日期:2018-01-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetButtonsStatus() + { + Dictionary 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 加载提醒记录 + /// + /// 说明:加载提醒记录 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void LoadRemindRecord() + { + Dictionary 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 加载会签记录 + /// + /// 说明:加载会签记录 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void LoadSignRecord() + { + Dictionary 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 加载其他属性 + /// + /// 说明:加载其他属性 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitOtherParms() + { + Dictionary 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 是否为确认审核功能 + /// + /// 说明:是否是确认审核 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 常用意见 + /// + /// 说明:常用意见下拉框事件 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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 表格双击事件 + /// + /// 说明:双击表格 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 表格选中双击共用函数 + /// + /// 说明:gridBillInfo点击事件共用函数 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// 1表示点击进入,2表示双击进入 + /// + 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); + if (tabPage.Tag is ModuleWebView) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + ModuleWebView webView = tabPage.Tag as ModuleWebView; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.Navigate(url); + } + else if (tabPage.Tag is FrmWebBrowser) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.LoadUrl(url); + } + else if (tabPage.Tag is FrmMiniBlink) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(dataRow, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.LoadUrl(url); + } + else if (tabPage.Tag is GridControlEx) + { + 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); + } + else if (tabPage.Tag is TabMultipledetails) + { + TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails; + tabMultipledetails.SetConditionValues(dataRow); + GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx); + GridDetailModel MainModel = grdExMain.Tag as GridDetailModel; + string searchMainSql = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, MainModel.DetailSql) : this.GetSearchSql(MainModel); + DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql); + grdExMain.LastSearchSql = searchMainSql; + grdExMain.SetGridViewDataSource(firstTable); + if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx) + { + GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx); + GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; + string searchAddSql = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, AdditionalModel.DetailSql) : this.GetSearchSql(AdditionalModel); + if (!MainModel.IsUnioDetail) + { + grdExAdditional.LastSearchSql = searchAddSql; + grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql)); + } + //右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件) + if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0) + { + grdExAdditional.LastSearchSql = ""; + grdExAdditional.SetGridViewDataSource(new DataTable()); + } + } + else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx) + { + ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx); + GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; + string searchAddSql = this.GetSearchSql(AdditionalModel); + DataTable table = MainImpl.GetDataTableResult(searchAddSql); + grdExAdditional.CreateChart(table); + } + + } + + } + } + #endregion + #region 获取查询条件 + /// + /// 说明:获取查询条件 + /// 创建人:王一帆 + /// 创建日期:2021-01-22 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The row item. + /// System.String. + 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 表格选中改变事件 + /// + /// 说明:gridBillInfo选中事件 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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); + } + } + + /// + /// 说明:gridBillInfo焦点行改变事件 + /// 创建人:曹屹峰 + /// 创建日期:2023-10-13 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 关闭 + /// + /// 说明:关闭 + /// 创建人:龚宇超 + /// 创建日期:2018-01-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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); + //string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", "p_BillAudit", "Q", "0", this.txtRemark.Text, "", "", true, -1); + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, 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 + { + if (!"9".Equals(result)) MessageUtil.Show(ResourceKeys.CloseFail + "\r\n" + msgText); + } + } + } + catch (Exception ex) + { + LogUtil.WriteError("关闭出错!", ex); + //MessageUtil.Show("关闭出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + #endregion + + #region 返回审核 + /// + /// 说明:返回审核 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row. + /// System.Int32. + 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 审核事件 + /// + /// 说明:提醒审核事件 + /// 创建人:龚宇超 + /// 创建日期:2020-08-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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); + //this.Close(); + this.DialogResult = DialogResult.OK; + 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) + { + //要删除的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(); + } + } + } + + } + 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); + //string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, this.txtRemark.Text, remindOpers, confirmOpers); + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, 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 + { + //上一次点开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(); + } + } + } + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + msgText); + } + } + + + } + } + } + catch (Exception ex) + { + LogUtil.WriteError("提醒审核事件出错!", ex); + //MessageUtil.Show("提醒审核事件出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + + /// + /// 说明:审核事件 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnAccradit_Click(object sender, EventArgs e) + { + try + { + //下方页签保存 + if (this.BillModelObj.ReviewSaveAdditional) + { + this.SaveAdditionalModules(); + } + 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); + this.DialogResult = DialogResult.OK; + //this.Close(); + 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) + { + //要删除的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(); + } + } + } + + } + 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); + //string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "F", this._flowTypeStepModel.RemindSelect, opinion, remindOpers, confirmOpers); + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, 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 + this.DialogResult = DialogResult.OK; + 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(); + } + } + } + + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(ResourceKeys.AuditFail + "\r\n" + msgText); + } + + } + } + + } + } + catch (Exception ex) + { + LogUtil.WriteError("审核事件出错!", ex); + MessageUtil.Show("审核事件出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + finally + { + WaitForm.HideForm(); + } + } + #endregion + + #region 分单 + /// + /// 说明:分单 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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 检查分单 + /// + /// 说明:检查分单 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// System.Boolean. + 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 单据来源 + /// + /// 说明:单据来源 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 分单创建单据 + /// + /// 说明:分单创建单据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); + 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 构造表头 + /// + /// 说明:构造表头 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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 构造明细 + /// + /// 说明:构造明细 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 单据编号. + 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 返退 + /// + /// 说明:提醒返回审核 + /// 创建人:王一帆 + /// 创建日期:2020-08-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + 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); + // string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + //this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, "", "", true, ret, 0, true); + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + 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 + { + //上一次点开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) + { + //要删除的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(); + } + } + } + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText)); + } + } + } + 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); + // string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + //this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, remindOpers, confirmOpers, true, ret); + + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + 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 + { + //上一次点开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) + { + //要删除的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(); + } + } + } + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText)); + } + } + } + } + catch (Exception ex) + { + LogUtil.WriteError("提醒返回审核出错!", ex); + //MessageUtil.Show("提醒返回审核出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + /// + /// 说明:返回审核 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnReturn_Click(object sender, EventArgs e) + { + try + { + + if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.AntiAuditUrl) && this.BillModelObj.NewVer == 1) + { + //string url = string.Format("/pages/app/app.html?stepcode=200&id=YQPS250610001&xtype=plugins.BaseAccraditation.AuditBackBox&username={0}&password={1}&dllcoid=", ERPInfo.Instance.UserName, "2383C0ADDCD699FB2CB45079ABB39E3CEF242D98"); + string url = ReplaceHelper.ReplaceUserInfo(SystemInfo.Instance.AntiAuditUrl); + url = url.Replace("{stepcode}", this.SysModel.StepCode).Replace("{primaryvalue}", this.SysModel.BillDocumentId).Replace("{remark}", txtRemark.Text).Replace("&isbase=1", ""); + string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~'); + string[] menuArgs = new string[] { "", "", url }; + string[] args = defaultArgs.Concat(menuArgs).ToArray(); + IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubBrower, args); + form.SubForm.WindowState = FormWindowState.Normal; + DialogResult result = form.SubForm.ShowDialog(); + if (result == DialogResult.OK) + { + this.DialogResult = DialogResult.OK; + 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) + { + //要删除的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(); + } + } + } + } + + return; + } + + + 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); + //string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + //this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, "", "", true, ret, 0, true); + + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + 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 + { + //上一次点开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) + { + //要删除的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(); + } + } + } + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText)); + } + } + } + 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); + // string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + //this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillAuditComObj.ProcedureName, "R", this._flowTypeStepModel.RemindSelect, this._auditAdvice, remindOpers, confirmOpers, true, ret); + + string result = this.AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out string msgText, + 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 + { + //上一次点开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) + { + //要删除的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(); + } + } + } + } + else + { + if (!"9".Equals(result)) MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, msgText)); + } + } + } + } + catch (Exception ex) + { + LogUtil.WriteError("返回审核出错!", ex); + MessageUtil.Show("返回审核出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + #endregion + + #region 记录本次推送人员 + /// + /// 说明:记录本次推送人员 + /// 创建人:龚宇超 + /// 创建日期:2018-01-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void GetPushOpers() + { + Dictionary 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 保存单据 + /// + /// 说明:保存单据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void btnSave_Click(object sender, EventArgs e) + { + try + { + SaveBillData(); + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + /// + /// 说明:保存单据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 保存确认标记 + 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); + } + + if (this.BillModelObj.SaveSuccessfullyRefresh && !save) return save;//保存成功才刷新 + + // 刷新主表 + 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); + 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 修改表头 + /// + /// 说明:获取修改表头 + /// 创建人:龚宇超 + /// 创建日期:2018-01-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// System.String. + 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 获取明细 + /// + /// 说明:获取明细 + /// 创建人:龚宇超 + /// 创建日期:2017-01-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// System.String. + 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 BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable)); + IEnumerable detailColumns = BillColumns.Columns.Cast(); + DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModelObj.DetailTable + "_temp")); + foreach (DataRow dataRow in detailTable.Rows) + { + StringBuilder fields = new StringBuilder(); + StringBuilder values = new StringBuilder(); + string detailSql = @"insert into " + BillModelObj.DetailTable + "_temp" + "({0}) values({1})"; + + fields.Append("sysstr,"); + values.Append("'" + guid + "',"); + foreach (DataColumn item in detailTable.Columns) + { + var selectColumn = detailColumns.Where(n => n.ColumnName.Equals(item.ColumnName, StringComparison.OrdinalIgnoreCase)); + if (selectColumn.Count() == 0) + { + continue; + } + fields.Append(item.ColumnName + ","); + string fieldValue = (dataRow[item] + "").Replace("'", "''"); + if (!BillTempColumns.Columns.Contains(item.ColumnName)) + { + string type = "varchar(50)"; + if (item.DataType == typeof(DateTime)) + { + type = "datetime"; + } + BaseImpl.ExecSqlValue(string.Format("alter table {0} add {1} {2}", BillModelObj.DetailTable + "_temp", item.ColumnName, type)); + } + if (!string.IsNullOrWhiteSpace(fieldValue)) + { + values.Append(item.DataType == typeof(DateTime) ? "N'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : "N'" + fieldValue + "',"); + } + else + { + if (item.DataType == typeof(Decimal) || + item.DataType == typeof(Double) || + item.DataType == typeof(Int16) || + item.DataType == typeof(Int32) || + item.DataType == typeof(Int64)) + values.Append("0,"); + else if (item.DataType == typeof(DateTime)) + values.Append("NULL,"); + else + values.Append("'',"); + } + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, dataRow, item, fieldValue); + } + detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(',')); + } + } + SaveErrorMessage = errorMessage; + return detailBuilder.ToString(); + } + #endregion + + #region 附件管理 + /// + /// 说明:附件管理 + /// 创建人:龚宇超 + /// 创建日期:2017-01-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// System.String. + 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 + + /// + /// 说明:初始化分割条位置 + /// 创建人:龚宇超 + /// 创建日期:2017-01-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + 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; + } + + + /// + /// 页签里数据修改后刷新明细 + /// + /// + /// + 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 = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfoMsg, this.BillModelObj.DetailSql)); + this._dtSourceData.OrderBy(this.BillModelObj.DetailOrderField); + if (this.BillModelObj.DetailTreeTable) + { + (this.gridBillInfo as TreeGridControlEx).SetGridViewDataSourceGenerateID(_dtSourceData); + } + else + { + this.gridBillInfo.SetGridViewDataSource(_dtSourceData); + } + } + + /// + /// 说明:检查可用条件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The cond. + /// The data row. + /// true if XXXX, false otherwise. + private bool ValidateCond(string cond, DataRow dataRow) + { + bool result = false; + cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else if (dataRow == null) + { + result = ReplaceHelper.EvalCond(cond); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); + } + return result; + } + /// + /// 说明:分配明细 + /// 创建人:龚宇超 + /// 创建日期:2020-01-15 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBtnFPOldClick(object sender, EventArgs e) + { + this.gridBillInfo.GridView.PostEditor(); + FPOld(); + } + private void OnBtnFPNewClick(object sender, EventArgs e) + { + this.gridBillInfo.GridView.PostEditor(); + FPNew(); + } + /// + /// 新版分配 + /// + private void FPNew(int rowHandle = 0) + { + try + { + this.gridBillInfo.GridView.FocusedRowHandle = rowHandle; + DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + #region 创建分配界面 + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelectBatch frmSelect = new FrmBaseSelectBatch(baseModel, this.ControlObj, this.gridBillInfo)) + { + frmSelect.Text = this.BillModelObj.TypeName; + frmSelect.InitControl(); + frmSelect.OnAfterFPCallback += OnAfterFPCallback; + #region 初始化第一条数据 + DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + return; + } + rowItem[guidField] = Guid.NewGuid().ToString(); + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) + { + int focusedRowHandle = this.gridBillInfo.GridView.FocusedRowHandle + 1; + this.gridBillInfo.GridView.FocusedRowHandle = focusedRowHandle; + if (this.gridBillInfo.GridView.FocusedRowHandle == focusedRowHandle) + { + FPNew(focusedRowHandle); + } + else + { + MessageUtil.Show("全部分配完毕"); + } + } + return; + } + } + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + frmSelect.InitData(rowItem); + frmSelect.OnBtnFPClick(null, null); + #endregion + //frmSelect.ShowDialog(); + #endregion + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 分配完成后回调 + /// + /// + /// + private void OnAfterFPCallback(object sender, EventArgs e) + { + WaitForm.ShowForm(); + try + { + // 临时禁用新增行(空白行) + if (this.BillModelObj.DefaultAddEmptyRow) this.gridBillInfo.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.None; + DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + return; + } + DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; + FrmBaseSelectBatch frmSelect = (FrmBaseSelectBatch)sender; + rowItem[guidField] = Guid.NewGuid().ToString(); + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) + { + this.gridBillInfo.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } + return; + } + } + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + frmSelect.InitData(rowItem); + bool success = frmSelect.FP(); + if (success) + { + if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + { + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + { + this.mRecordPrimaryField = frmSelect.RecordPrimaryField; + table.Columns.Add(this.mRecordPrimaryField, typeof(String)); + } + foreach (DataRow item in frmSelect.SelectedRows) + { + DataRow newRow = table.NewRow(); + newRow.ItemArray = rowItem.ItemArray; + newRow[guidField] = rowItem[guidField]; + DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + ""); + //自增长列分配按空值取 + if (IsIdentCol != null) + { + if (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) + { + newRow[IsIdentCol.ColumnName] = 0; + } + } + foreach (DataColumn col in item.Table.Columns) + { + if (table.Columns.Contains(col.ColumnName)) + { + //newRow[col.ColumnName] = item[col.ColumnName]; + newRow[col.ColumnName] = item[col.ColumnName]; + GridColumn column = this.gridBillInfo.GridView.Columns[col.ColumnName]; + if (column != null) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + } + } + } + newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; + newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; + table.Rows.Add(newRow); + } + NumberMc = frmSelect.AmountField; + table.Rows.Remove(rowItem); + // 重排顺序 + table.OrderBy(this.BillModelObj.DetailOrderField); + this.gridBillInfo.GridView.UpdateCurrentRow(); + this.gridBillInfo.GridView.ShowEditor(); + if (frmSelect.isNextOne) + { + int SourceRowIndex = this.gridBillInfo.GridView.GetFocusedDataSourceRowIndex(); + DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); + if (a.Length != 0) + { + this.gridBillInfo.GridView.FocusedRowHandle = SourceRowIndex; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } + } + } + } + else + { + if (this.gridBillInfo.GridView.FocusedRowHandle + 1 <= this.gridBillInfo.GridView.RowCount - 1) + { + this.gridBillInfo.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); + } + } + } + catch (Exception) + { + throw; + } + finally + { + // 重新开启新增行(空白行) + if (this.BillModelObj.DefaultAddEmptyRow) this.gridBillInfo.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; + WaitForm.HideForm(); + } + } + /// + /// 老版分配 + /// + private void FPOld() + { + try + { + DataRow rowItem = this.gridBillInfo.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + MessageUtil.Show("请先选择一条明细在进行分配!"); + return; + } + DataTable table = this.gridBillInfo.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + rowItem[guidField] = Guid.NewGuid().ToString(); ; + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + MessageUtil.Show("该行数据为已分配后的数据,无需分配!"); + return; + } + } + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModelObj.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelect frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gridBillInfo)) + { + //if (frmSelect.SelectRowItem == null) + //{ + // frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); + //} + frmSelect.Text = this.BillModelObj.TypeName; + frmSelect.SelectRowItem = rowItem; + bool isNextOne = false; + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + if (frmSelect.ShowDialog() == DialogResult.OK) + { + if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + { + //if (frmSelect.isNextOne) + //{ + // isNextOne = true; + //} + //else + //{ + // isNextOne = false; + //} + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + { + this.mRecordPrimaryField = frmSelect.RecordPrimaryField; + table.Columns.Add(this.mRecordPrimaryField, typeof(String)); + } + + foreach (DataRow item in frmSelect.SelectedRows) + { + DataRow newRow = table.NewRow(); + newRow.ItemArray = rowItem.ItemArray; + newRow[guidField] = rowItem[guidField]; + DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModelObj.DetailTable)) + ""); + //自增长列分配按空值取 + if (IsIdentCol != null) + { + if (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) + { + newRow[IsIdentCol.ColumnName] = 0; + } + } + foreach (DataColumn col in item.Table.Columns) + { + if (table.Columns.Contains(col.ColumnName)) + { + //newRow[col.ColumnName] = item[col.ColumnName]; + newRow[col.ColumnName] = item[col.ColumnName]; + GridColumn column = this.gridBillInfo.GridView.Columns[col.ColumnName]; + if (column != null) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + } + } + } + newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; + newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; + table.Rows.Add(newRow); + } + NumberMc = frmSelect.AmountField; + //double syAmount = frmSelect.GetSyAmount(); + //if (syAmount > 0) + //{ + // rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount(); + //} + //else + //{ + // table.Rows.Remove(rowItem); + //} + table.Rows.Remove(rowItem); + // 重排顺序 + table.OrderBy(this.BillModelObj.DetailOrderField); + this.gridBillInfo.GridView.UpdateCurrentRow(); + this.gridBillInfo.GridView.ShowEditor(); + } + } + if (frmSelect.isNextOne) + { + int SourceRowIndex = this.gridBillInfo.GridView.GetFocusedDataSourceRowIndex(); + DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); + if (a.Length != 0) + { + this.gridBillInfo.GridView.FocusedRowHandle = SourceRowIndex; + OnBtnFPOldClick(null, null); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex); + } + } + /// + /// 说明:计算列关联字段 + /// 创建人:龚宇超 + /// 创建日期:2017-12-18 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The field value. + protected virtual void SetUnionValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + DataTable table = this.gridBillInfo.gridControl.DataSourceTable(); + //DataRow rowItem = this.gridView.GetFocusedDataRow(); + string unionValues = model.UnionValues; + if (rowItem != null && model != null) + { + unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue)); + if (this.ControlObj != null) + { + unionValues = ControlObj.ReplaceParentControlValue(unionValues); + } + try + { + string[] fields = model.UnionFields.Trim(',').Split(','); + DataRow rowResult = BaseImpl.GetDataRowResult(unionValues); + if (rowResult != null) + { + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null; + rowItem[field] = value; + } + } + else + { + // 设置为空 + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + rowItem[field] = DBNull.Value; + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列关联字段--错误-->" + unionValues, ex); + } + } + } + /// + /// 说明:计算列计算公式 + /// 创建人:龚宇超 + /// 创建日期:2017-12-18 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The field value. + protected virtual void SetCalcValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + try + { + DataTable table = this.gridBillInfo.gridControl.DataSourceTable(); + if (rowItem != null && model != null) + { + List calcModels = this.gridBillInfo.ObjmControlList.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr)).OrderBy(y => y.CalcOrder).ToList(); + + foreach (GridColumnModel gridModel in calcModels) + { + // 计算顺序小于当前控件则不计算 + if (gridModel.CalcOrder < model.CalcOrder) continue; + + if (!gridModel.FieldName.Equals(model.FieldName, StringComparison.OrdinalIgnoreCase)) + { + bool isTruncate = false; + string calcExpr = gridModel.CalcExpr; + if (calcExpr.StartsWith("@truncate:")) + { + calcExpr = calcExpr.Substring(10); + isTruncate = true; + } + + try + { + if (this.ControlObj != null) + calcExpr = ControlObj.ReplaceParentControlValue(calcExpr); + + calcExpr = ReplaceHelper.ReplaceRowParam(rowItem, calcExpr); + //EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + "" + string result = EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + ""; + if (isTruncate) + { + result += result.Contains(".") ? "0000000000" : ".0000000000"; + rowItem[gridModel.FieldName] = result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1); + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1)); + } + else + { + try + { + double d = 0; + if (!string.IsNullOrEmpty(result) && + !"NaN".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"非数字".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"undefined".Equals(result, StringComparison.OrdinalIgnoreCase) && + result != "∞" && result != "-∞" && + !"正无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"负无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + double.TryParse(result, out d)) + { + if (string.IsNullOrEmpty(gridModel.DataFormat)) + { + result = Math.Round(Convert.ToDouble(d), model.Decimals, MidpointRounding.AwayFromZero) + ""; + } + else + { + //计算后先执行保存小数位数 + result = string.Format("{0:" + gridModel.DataFormat + "}", Convert.ToDecimal(result)); + } + if (model.FieldType == 7 && result.Contains('%')) + { + result = (double.Parse(result.Replace("%", "")) * 0.01).ToString(); + } + rowItem[gridModel.FieldName] = result; + // 判断计算列有无关联值 + GridColumnModel UnionModel = calcModels.FirstOrDefault(x => x.FieldName == gridModel.FieldName); + if (!string.IsNullOrEmpty(UnionModel.UnionFields)) + { + this.SetUnionValue(UnionModel, rowItem[gridModel.FieldName] + "", rowItem); + } + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result); + } + } + catch (Exception) + { + + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列计算公式--错误-->" + rowItem[gridModel.FieldName], ex); + } + } + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + // MessageUtil.Show(Message,ex.Message); + } + } + + + /// + /// 审核或反审 + /// + public string AuditMethod(out string nextSelectStepCode, + out string nextSelectStepOper, + out string msgText, + DynamicModel sysModel, + string stepCode, + string billDocumentId, + string message, + string storedName, + string accractFlag, + string remindSelect, + string remarkText = "", + string remindOpers = "", + string confirmOpers = "", + bool ret = false, + int returnd = 0, + int selectConfirmFlag = 0, + bool IsStepOver = false, + int comfirm = 0 + ) + { + string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, out msgText, sysModel, stepCode, billDocumentId, message, storedName, accractFlag, remindSelect, remarkText, remindOpers, confirmOpers, ret, returnd, selectConfirmFlag, IsStepOver, comfirm); + + if ("9".Equals(result)) + { + // 继续执行保存 + //if (string.IsNullOrWhiteSpace(msgText)) msgText = "失败"; + if (MessageUtil.Show(msgText, MessageBoxButtons.YesNo) == DialogResult.Yes) + result = AuditMethod(out nextSelectStepCode, out nextSelectStepOper, out msgText, sysModel, stepCode, billDocumentId, message, storedName, accractFlag, remindSelect, remarkText, remindOpers, confirmOpers, ret, returnd, selectConfirmFlag, IsStepOver, 1); + } + + return result; + } + + + /// + /// 保存所有附加模块 + /// + /// + public void SaveAdditionalModules() + { \ No newline at end of file