⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runrepoertviewctl.cs

📁 树形逻辑报表程序源码,能根居元数据定义拖拉开发新的报表.
💻 CS
📖 第 1 页 / 共 4 页
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;

namespace TreeReportApp
{
	/// <summary>
	/// TreeRepoertViewCtl 的摘要:
	/// 自定义报表查看控件,把tree报表的管理、根据配置运行等,全部公共功能打包在此类中。
	/// 1、界面分三部分:报表选择及操作面板、搜索条件控件组、报表查看器
	///         由属性IsDisplayOperatePanel控制“报表选择及操作面板”的显示与否
	///         由属性IsDisplaySearchCtlGroup控制“搜索条件控件组”的显示与否
	/// 2、报表选择及操作面板内有:当前报表名、候选报表列表按钮、任意条件按钮、运行生成报表按钮、
	///   用户设置、报表输出等控件。
	///         这些控件的可见性都设为“public”,外部程序可以根据需要设置“隐藏/显示”它们。
	/// 
	/// 3、设置当前要查看的报表:调用initRepoert(string report_id, string select_descript),
	///         调用setRepoert指明并填写当前要查看的报表,检查报表信息是否存在,有否权限,
	///         并做好前执行前的准备,取得报表的信息,初始化报表管理及配置信息的数据实体类,
	///         但不运行生成报表。
	/// 4、要想从外部程序对报表的源数据进行筛选,就把把表达式赋给属性WhereExpForReportData
	/// 
	/// 4、运行报表:调用RunReport(),此方法检查当前设置是否正确,根据外部程序设定的WhereExpForReportData(内部变量名outsideexp),
	///        及常用条件搜索控件输入生成的表达式searchexp,任意条件生成对话框生成的表达式dlggenexp,用与关系形成有效的
	///        条件表达式,对数据源进行筛选,重设数据源,并运行生成报表。
	/// 
	/// </summary>
	public class TreeRepoertViewCtl : System.Windows.Forms.UserControl
	{
		//当前报表ID及报表对象
		public string currentreportid="";
		public DataDynamics.ActiveReports.ActiveReport currentreport;

		//当前报表的管理、可配置、用户配置、搜索条件配置等集中信息对象
		private RunReportInfo reportconfiginfo; 

		//此条件表达式用于筛选报表管理信息表中的报表,符合条件的报表名显示在报表列表中,供用户选。
		//whereForReports=""且idlist为空时,表示列选所有的报表。
		private string whereForReports="";

		//此条件表达式用于筛选报表管理信息表中的报表,符合条件的报表名显示在报表列表中,供用户选。
		private string originalSQL="";

		//预设候选报表列表项,程序可以调用addItemToReportList(),向此数组中添加的报表名,显示在报表列表中,供用户选。
		//whereForReports=""且idlist为空时,表示列选所有的报表。
		private ArrayList idlist = new ArrayList();
		private ArrayList desclist = new ArrayList();
		
		//在动态生成常用查询界面组时,需要保存各控件信息的变量数组
		private ArrayList controlsarray = new ArrayList();
		private ArrayList ctltypesarray = new ArrayList();
		private ArrayList datatypesarray = new ArrayList();

		//生成报表时,筛选源数据所用的条件
		//private string searchexp="";//常用搜索条件生成的条件表达式
		private string dlggenexp="";//条件生成对话框生成的条件表达式
		public string outsideexp="";//外部程序设置的条件表达式

		//界面上,搜索条件组框(groupbox)的宽度,当尺寸变化时,用以比较宽度与原来相比,是否已变化
		private int groupcontitionwidth = 0;

		private bool IsInited = false;
		private bool IsRunned = false;

		/*
		//表示各操作控件的状态
		private bool IsCanRun = true;
		private bool IsCanSelect = true;
		private bool IsCanGenExp = true;
		private bool IsCanSetup = true;
		private bool IsCanExport = true;
		*/

		public System.Windows.Forms.Panel panel_operatereport;
		private System.Windows.Forms.GroupBox groupBox_searchcontition;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ImageList imageList_ctl;
		public System.Windows.Forms.Button button_reportrun;
		public System.Windows.Forms.Button button_reportexport;
		public System.Windows.Forms.Button button_reportsetup;
		public System.Windows.Forms.Button button_reportcontition;
		public DataDynamics.ActiveReports.Viewer.Viewer reportviewer;
		public System.Windows.Forms.Button button_brows;
		private System.Windows.Forms.Label label_report;
		public System.Windows.Forms.Button button_stop;
		private System.ComponentModel.IContainer components;
	
		public TreeRepoertViewCtl()
		{
			// 该调用是 Windows.Forms 窗体设计器所必需的。
			InitializeComponent();

			reportconfiginfo = new RunReportInfo();
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region 组件设计器生成的代码
		/// <summary> 
		/// 设计器支持所需的方法 - 不要使用代码编辑器 
		/// 修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TreeRepoertViewCtl));
			this.panel_operatereport = new System.Windows.Forms.Panel();
			this.label_report = new System.Windows.Forms.Label();
			this.imageList_ctl = new System.Windows.Forms.ImageList(this.components);
			this.button_brows = new System.Windows.Forms.Button();
			this.button_reportrun = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.button_reportexport = new System.Windows.Forms.Button();
			this.button_reportsetup = new System.Windows.Forms.Button();
			this.button_reportcontition = new System.Windows.Forms.Button();
			this.button_stop = new System.Windows.Forms.Button();
			this.groupBox_searchcontition = new System.Windows.Forms.GroupBox();
			this.reportviewer = new DataDynamics.ActiveReports.Viewer.Viewer();
			this.panel_operatereport.SuspendLayout();
			this.SuspendLayout();
			// 
			// panel_operatereport
			// 
			this.panel_operatereport.Controls.Add(this.label_report);
			this.panel_operatereport.Controls.Add(this.button_brows);
			this.panel_operatereport.Controls.Add(this.button_reportrun);
			this.panel_operatereport.Controls.Add(this.label1);
			this.panel_operatereport.Controls.Add(this.button_reportexport);
			this.panel_operatereport.Controls.Add(this.button_reportsetup);
			this.panel_operatereport.Controls.Add(this.button_reportcontition);
			this.panel_operatereport.Controls.Add(this.button_stop);
			this.panel_operatereport.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel_operatereport.Location = new System.Drawing.Point(0, 0);
			this.panel_operatereport.Name = "panel_operatereport";
			this.panel_operatereport.Size = new System.Drawing.Size(712, 28);
			this.panel_operatereport.TabIndex = 0;
			// 
			// label_report
			// 
			this.label_report.BackColor = System.Drawing.Color.Ivory;
			this.label_report.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label_report.ForeColor = System.Drawing.Color.Black;
			this.label_report.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.label_report.ImageIndex = 0;
			this.label_report.ImageList = this.imageList_ctl;
			this.label_report.Location = new System.Drawing.Point(56, 4);
			this.label_report.Name = "label_report";
			this.label_report.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.label_report.Size = new System.Drawing.Size(296, 20);
			this.label_report.TabIndex = 4;
			this.label_report.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// imageList_ctl
			// 
			this.imageList_ctl.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList_ctl.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList_ctl.ImageStream")));
			this.imageList_ctl.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// button_brows
			// 
			this.button_brows.BackColor = System.Drawing.Color.Orange;
			this.button_brows.ForeColor = System.Drawing.Color.SandyBrown;
			this.button_brows.ImageIndex = 9;
			this.button_brows.ImageList = this.imageList_ctl;
			this.button_brows.Location = new System.Drawing.Point(353, 3);
			this.button_brows.Name = "button_brows";
			this.button_brows.Size = new System.Drawing.Size(24, 23);
			this.button_brows.TabIndex = 5;
			this.button_brows.TabStop = false;
			this.button_brows.Click += new System.EventHandler(this.button_brows_Click);
			// 
			// button_reportrun
			// 
			this.button_reportrun.Enabled = false;
			this.button_reportrun.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_reportrun.ImageIndex = 4;
			this.button_reportrun.ImageList = this.imageList_ctl;
			this.button_reportrun.Location = new System.Drawing.Point(447, 4);
			this.button_reportrun.Name = "button_reportrun";
			this.button_reportrun.Size = new System.Drawing.Size(54, 20);
			this.button_reportrun.TabIndex = 3;
			this.button_reportrun.Text = "生成";
			this.button_reportrun.TextAlign = System.Drawing.ContentAlignment.TopRight;
			this.button_reportrun.Click += new System.EventHandler(this.button_reportrun_Click);
			// 
			// label1
			// 
			this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.label1.ImageIndex = 10;
			this.label1.ImageList = this.imageList_ctl;
			this.label1.Location = new System.Drawing.Point(4, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(59, 14);
			this.label1.TabIndex = 1;
			this.label1.Text = " 报表:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// button_reportexport
			// 
			this.button_reportexport.Enabled = false;
			this.button_reportexport.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_reportexport.ImageIndex = 6;
			this.button_reportexport.ImageList = this.imageList_ctl;
			this.button_reportexport.Location = new System.Drawing.Point(653, 4);
			this.button_reportexport.Name = "button_reportexport";
			this.button_reportexport.Size = new System.Drawing.Size(54, 20);
			this.button_reportexport.TabIndex = 3;
			this.button_reportexport.Text = "输出";
			this.button_reportexport.TextAlign = System.Drawing.ContentAlignment.TopRight;
			this.button_reportexport.Click += new System.EventHandler(this.button_reportexport_Click);
			// 
			// button_reportsetup
			// 
			this.button_reportsetup.Enabled = false;
			this.button_reportsetup.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_reportsetup.ImageIndex = 7;
			this.button_reportsetup.ImageList = this.imageList_ctl;
			this.button_reportsetup.Location = new System.Drawing.Point(594, 4);
			this.button_reportsetup.Name = "button_reportsetup";
			this.button_reportsetup.Size = new System.Drawing.Size(54, 20);
			this.button_reportsetup.TabIndex = 3;
			this.button_reportsetup.Text = "设置";
			this.button_reportsetup.TextAlign = System.Drawing.ContentAlignment.TopRight;
			this.button_reportsetup.Click += new System.EventHandler(this.button_reportsetup_Click);
			// 
			// button_reportcontition
			// 
			this.button_reportcontition.Enabled = false;
			this.button_reportcontition.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_reportcontition.ImageIndex = 8;
			this.button_reportcontition.ImageList = this.imageList_ctl;
			this.button_reportcontition.Location = new System.Drawing.Point(389, 4);
			this.button_reportcontition.Name = "button_reportcontition";
			this.button_reportcontition.Size = new System.Drawing.Size(54, 20);
			this.button_reportcontition.TabIndex = 3;
			this.button_reportcontition.Text = " 条件";
			this.button_reportcontition.TextAlign = System.Drawing.ContentAlignment.TopRight;
			this.button_reportcontition.Click += new System.EventHandler(this.button_reportcontition_Click);
			// 
			// button_stop
			// 
			this.button_stop.Enabled = false;
			this.button_stop.Image = ((System.Drawing.Image)(resources.GetObject("button_stop.Image")));
			this.button_stop.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_stop.Location = new System.Drawing.Point(506, 4);
			this.button_stop.Name = "button_stop";
			this.button_stop.Size = new System.Drawing.Size(54, 20);
			this.button_stop.TabIndex = 3;
			this.button_stop.Text = "停止";
			this.button_stop.TextAlign = System.Drawing.ContentAlignment.TopRight;
			this.button_stop.Click += new System.EventHandler(this.button_stop_Click);
			// 
			// groupBox_searchcontition
			// 
			this.groupBox_searchcontition.Dock = System.Windows.Forms.DockStyle.Top;
			this.groupBox_searchcontition.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.groupBox_searchcontition.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.groupBox_searchcontition.ForeColor = System.Drawing.Color.Black;
			this.groupBox_searchcontition.Location = new System.Drawing.Point(0, 28);
			this.groupBox_searchcontition.Name = "groupBox_searchcontition";
			this.groupBox_searchcontition.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.groupBox_searchcontition.Size = new System.Drawing.Size(712, 43);
			this.groupBox_searchcontition.TabIndex = 1;
			this.groupBox_searchcontition.TabStop = false;
			this.groupBox_searchcontition.Text = "输入查询条件";
			this.groupBox_searchcontition.Resize += new System.EventHandler(this.groupBox_searchcontition_Resize);
			// 
			// reportviewer
			// 
			this.reportviewer.BackColor = System.Drawing.SystemColors.Control;
			this.reportviewer.Dock = System.Windows.Forms.DockStyle.Fill;
			this.reportviewer.Location = new System.Drawing.Point(0, 71);
			this.reportviewer.Name = "reportviewer";
			this.reportviewer.ReportViewer.CurrentPage = 0;
			this.reportviewer.ReportViewer.MultiplePageCols = 3;
			this.reportviewer.ReportViewer.MultiplePageRows = 2;
			this.reportviewer.Size = new System.Drawing.Size(712, 321);
			this.reportviewer.TabIndex = 2;
			this.reportviewer.TableOfContents.Text = "Table Of Contents";
			this.reportviewer.TableOfContents.Width = 200;
			this.reportviewer.Toolbar.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			// 
			// TreeRepoertViewCtl
			// 
			this.Controls.Add(this.reportviewer);
			this.Controls.Add(this.groupBox_searchcontition);
			this.Controls.Add(this.panel_operatereport);
			this.Name = "TreeRepoertViewCtl";
			this.Size = new System.Drawing.Size(712, 392);
			this.panel_operatereport.ResumeLayout(false);
			this.ResumeLayout(false);

		}

		
		#endregion


		#region Tree报表操作控件界面属性

		/// <summary>
		/// IsDisplayOperatePanel - 控制“报表选择及操作面板”的显示与否
		/// </summary>
		public bool IsDisplayOperatePanel
		{
			get
			{
				return panel_operatereport.Visible;
			}

			set
			{
				panel_operatereport.Visible = value;
			}
		}

		/// <summary>
		/// WhereExpForReportData - 外部程序设置筛选报表数据的条件表达式(不含where单词)
		/// </summary>
		public string WhereExpForReportData
		{
			get
			{
				return outsideexp;
			}
			set
			{
				outsideexp = value;
			}
		}


		/// <summary>
		/// IsDisplaySearchCtlGroup - 控制“搜索条件控件组”的显示与否
		/// </summary>
		public bool IsDisplaySearchCtlGroup
 		{
			get
			{
				return groupBox_searchcontition.Visible;
			}

			set
			{
				groupBox_searchcontition.Visible = value;
			}
		}

		/// <summary>
		/// IsCanRunReport - 操作按钮的可见性
		/// </summary>
		public bool IsCanRunReport
		{
			get
			{
				return button_reportrun.Visible;
			}
			set
			{
				button_reportrun.Visible = value;
			}
		}

		/// <summary>
		/// IsCanSelectReport - 操作按钮的可见性
		/// </summary>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -