/****************************** * 说明:标准基础档案 * 创建人:龚宇超 * 创建日期:2017-08-21 * 修改人: * 修改日期: * 修改备注: * 版本: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 Lskj.Main.Model; using Lskj.Business; using System.Collections; using System.Threading.Tasks; namespace Lskj.PubModule { public partial class FrmMain : BaseForm { public DynamicModuleModel Model; public FrmMain() { InitializeComponent(); } /// /// 说明:窗体加载时 /// 创建人:龚宇超 /// 创建日期:2017-09-01 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The instance containing the event data. protected override void OnLoad(EventArgs e) { WaitForm.ShowForm(); try { this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + ""; this.mControl.LeftCond = Model.LeftCond; this.mControl.InitControls(Model); SetFormSize(); this.FormClosing += new FormClosingEventHandler(OnClose); } catch (Exception ex) { LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule); //MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); this.mControl.Visible = true; } WaitForm.HideForm(); } /// /// 获取数据源缓存 /// /// public void GetDataCaches(Dictionary cachesDic) { //全局数据 Task dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task(() => { return Model;//动态链接库对象 })); Task systemDllRowTask = cachesDic.AddTask(this, "SystemDllRow", new Task(() => { return MainImpl.GetSystemdllTab(Model.ModuleCode);//获取单个模块信息 })); Task sysModelTask = cachesDic.AddTask(this, "SysModel", new Task(() => { ModuleModel sysModel = new ModuleModel(systemDllRowTask.Result); return sysModel;//系统模块实体对象 })); Task> detailTask = cachesDic.AddTask(this, "Details", new Task>(() => { DataTable detailPages = BaseModuleImpl.GetBaseDetailPages(Model.ModuleCode);//根据传入的模块编号获得基础档案底部标签的数据 List details = new List();//表格明细对象的集合 foreach (DataRow item in detailPages.Rows) { GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.BaseDetailGridView); details.Add(gridDetailModel); Task addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => { DataTable gridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");//获取报表明细列 gridDetailModel.GridColumns = gridColumns; return gridColumns; })); } return details; })); Task formTypeTask = cachesDic.AddTask(this, "FormType", new Task(() => { return BaseImpl.GetBaseType(Model.ModuleCode); })); Task privilegeTask = cachesDic.AddTask(this, "Privilege", new Task(() => { return Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";// 权限(1.有操作权限.0.无权限.2.只读权限.3.右键配置权限全部开放) })); //添加数据到mControl cachesDic.AddTask(mControl, "DynamicModel", dynamicModelTask); cachesDic.AddTask(mControl, "SystemDllRow", systemDllRowTask); cachesDic.AddTask(mControl, "SysModel", sysModelTask); cachesDic.AddTask(mControl, "Details", detailTask); //获取mControl控件的数据 mControl.GetDataCaches(cachesDic); } /// /// 关闭模块时发生 /// /// /// private void OnClose(object sender, FormClosingEventArgs e) { this.mControl.CloseModule(); string guid = this.Tag + ""; if (string.IsNullOrWhiteSpace(guid)) return; DllModule m = Manager.ModuleForms[guid]; m.IsClose = true; if (SystemInfo.Instance.EfficientVerification) { bool SaveResults = this.mControl.ModuleGridDetailObj.VerificationInterface(); if (!SaveResults) { DialogResult result = MessageUtil.Show(("数据未保存,是否确定关闭?"), MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { m.IsClose = true; e.Cancel = false; } else { m.IsClose = false; e.Cancel = true; } } } } #region 设置窗口大小 /// /// 说明:设置弹出窗体大小 /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void SetFormSize() { if (this.FormBorderStyle == FormBorderStyle.Sizable) { string height = Util.IniHelper.Read("ModuleGrid_Height_" + Model.ModuleCode); string width = Util.IniHelper.Read("ModuleGrid_Width_" + Model.ModuleCode); this.Height = string.IsNullOrEmpty(height) ? this.Height : Convert.ToInt32(height); this.Width = string.IsNullOrEmpty(width) ? this.Width : Convert.ToInt32(width); this.Width = this.Width > Screen.PrimaryScreen.WorkingArea.Width ? Screen.PrimaryScreen.WorkingArea.Width : this.Width; this.Height = this.Height > Screen.PrimaryScreen.WorkingArea.Height ? Screen.PrimaryScreen.WorkingArea.Height : this.Height; this.Left = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2; this.Top = (Screen.PrimaryScreen.WorkingArea.Height - t