d8ac361255
SVN-Revision: r1148
154 lines
5.8 KiB
C#
154 lines
5.8 KiB
C#
/******************************
|
|
* 说明:表格报表模版
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-11-20
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Business;
|
|
using System.Threading.Tasks;
|
|
using System.Collections;
|
|
|
|
namespace Lskj.Report
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 报表动态链接库参数
|
|
/// </summary>
|
|
public DynamicReportModel Model;
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";
|
|
|
|
this.mControl.ModuleGridDetailObj.ModuleGridObj.VisibleOperPanel = false;
|
|
|
|
if (!dataCaches.GetValue(this, "Details", out List<GridDetailModel> details))
|
|
{
|
|
details = GetReportDetails();
|
|
}
|
|
|
|
this.mControl.Details = details;
|
|
this.mControl.InitControls(Model);
|
|
this.FormClosing += new FormClosingEventHandler(OnClose);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseReport);
|
|
//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();
|
|
}
|
|
|
|
private void OnClose(object sender, FormClosingEventArgs e)
|
|
{
|
|
this.mControl.CloseModule();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取报表明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>List<GridDetailModel>.</returns>
|
|
private List<GridDetailModel> GetReportDetails()
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
|
|
DataTable table = ReportImpl.GetReportDetailPages(Model.ModuleCode);
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
|
|
return details;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
|
|
{
|
|
//全局数据
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task<DynamicModel>(() =>
|
|
{
|
|
return Model;//动态链接库对象
|
|
}));
|
|
Task<DataRow> systemDllRowTask = cachesDic.AddTask(this, "SystemDllRow", new Task<DataRow>(() =>
|
|
{
|
|
return MainImpl.GetSystemdllTab(Model.ModuleCode);//获取单个模块信息
|
|
}));
|
|
Task<ModuleModel> sysModelTask = cachesDic.AddTask(this, "SysModel", new Task<ModuleModel>(() =>
|
|
{
|
|
ModuleModel sysModel = new ModuleModel(systemDllRowTask.Result);
|
|
return sysModel;//系统模块实体对象
|
|
}));
|
|
Task<List<GridDetailModel>> detailTask = cachesDic.AddTask(this, "Details", new Task<List<GridDetailModel>>(() =>
|
|
{
|
|
DataTable detailPages = ReportImpl.GetReportDetailPages(Model.ModuleCode);//
|
|
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
|
foreach (DataRow item in detailPages.Rows)
|
|
{
|
|
GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.BaseDetailGridView);
|
|
details.Add(gridDetailModel);
|
|
Task<DataTable> addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task<DataTable>(() =>
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");//获取报表明细列
|
|
gridDetailModel.GridColumns = gridColumns;
|
|
return gridColumns;
|
|
}));
|
|
}
|
|
return details;
|
|
}));
|
|
Task<int> formTypeTask |