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

📄 runrepoertviewctl.cs

📁 树形逻辑报表程序源码,能根居元数据定义拖拉开发新的报表.
💻 CS
📖 第 1 页 / 共 4 页
字号:
		public bool IsCanSelectReport
		{
			get
			{
				return button_brows.Visible;
			}
			set
			{
				button_brows.Visible = value;
			}
		}

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

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


		#endregion


		#region Tree报表操作功能函数
				
		/// <summary>
		/// addItemToReportList - 设置报表候选列表的项,如果没有任何设置,默认为库中所有报表
		/// </summary>
		public bool addItemToReportList(string report_id, string report_descript)
		{
			if(report_id.Length==0)
				return false;

			if (report_descript.Length==0)
				report_descript = report_id;

			idlist.Add(report_id);
			desclist.Add(report_descript);

			return true;
		}

		/// <summary>
		/// initRepoert - 指明当前要查看的报表,查报表是否存在,有否权限,并做好前执行前的准备
		/// </summary>
		public bool initRepoert(string report_id, string select_descript)
		{
			IsRunned = false;
			button_reportexport.Enabled = IsRunned;

			IsInited = setRepoert(report_id,select_descript);
			if (IsInited)
			{
				button_reportcontition.Enabled = true;
				button_reportrun.Enabled = true;
				button_reportsetup.Enabled = true;
				//button_stop.Enabled = true;
				//button_reportexport.Enabled = true;
			}
			else
			{
				button_reportcontition.Enabled = false;
				button_reportrun.Enabled = false;
				button_reportsetup.Enabled = false;
				button_stop.Enabled = false;
				button_reportexport.Enabled = false;
			}

			return IsInited;
		}

		
		/// <summary>
		/// setRepoert - 指明当前要查看的报表,查报表是否存在,有否权限,并做好前执行前的准备
		/// </summary>
		private bool setRepoert(string report_id, string select_descript)
		{
			try
			{
				if (report_id.Length==0)
					return false;

				if(reportconfiginfo.IsExistReportInfo(report_id)==0)
					return false;//报表不存在

				//读取报表的配置信息,放在reportconfiginfo的成员infodataset(一个数据集)中
				if (!reportconfiginfo.readReportInfoFromDB(report_id))
					return false;

				//取模板文件的路径及文件名
				string layoutfile = reportconfiginfo.getManageInfo().Rows[0]["ReportPath"].ToString();

				DataDynamics.ActiveReports.ActiveReport activereport = new DataDynamics.ActiveReports.ActiveReport();
				//载入模板文件(布局文件)
				activereport.LoadLayout(layoutfile);

				//如果从数据字典成功取得SQL,重设置数据源,否则使用布局文件中的数据源,但要重设连接串
				if (reportconfiginfo.readDataSourceSQLFromReportInfo()==true)
				{
					//重设置数据源
					DataDynamics.ActiveReports.DataSources.OleDBDataSource datasource = new DataDynamics.ActiveReports.DataSources.OleDBDataSource();
					datasource.ConnectionString = TreeConnection.connstr; 
					if (reportconfiginfo.IsNotSqlStrInDict)
						datasource.SQL = "SELECT * FROM " + reportconfiginfo.datasourceSQL; 
					else
						datasource.SQL = reportconfiginfo.datasourceSQL; 
					 
					activereport.DataSource = datasource;
					originalSQL = datasource.SQL;
				}
				else
				{
					//重设置数据源中的连接串
					DataDynamics.ActiveReports.DataSources.OleDBDataSource datasource = (DataDynamics.ActiveReports.DataSources.OleDBDataSource)activereport.DataSource;
					datasource.ConnectionString = TreeConnection.connstr;     
					originalSQL = datasource.SQL;
				}

				reportviewer.Document = activereport.Document;

				currentreportid = report_id;
				currentreport = activereport;

		  //清除原有的表达式 
				//searchexp="";//常用搜索条件生成的条件表达式
				dlggenexp="";//条件生成对话框生成的条件表达式
				outsideexp="";//外部程序设置的条件表达式

			
				//设置界面上的当前报表名称
				if (select_descript.Length>0)
					label_report.Text = "   "+select_descript;
				else
					label_report.Text = "   "+report_id;

				//生成常用条件搜索界面
				initSearchFields();
			}
			catch
			{
				return false;
			}

			return true;
		}

		/// <summary>
		/// countlablesize - 检查字符串的长,字母及数字算一个单位,其它是两个单位
		/// </summary>
		private int countlablesize(string lblstr)
		{
			int ln =0;
			for(int i=0; i<lblstr.Length; i++)
			{
				if ((lblstr[i]>='a' && lblstr[i]<='z')||(lblstr[i]>='A' && lblstr[i]<='Z')||(lblstr[i]>='0' && lblstr[i]<='9'))
					ln +=1;
				else
					ln +=2;
			}
			return ln;	
		}

		
		/// <summary>
		/// CheckAndWrapToNextRow() - 检查是否要换行显示?并采取换行与否的行动
		/// </summary>
		private Point CheckAndWrapToNextRow( Point current_pos,int lable_width, int currentctl_width,string isFromTo, GroupBox group_box)
		{
			if (groupBox_searchcontition.Width <300)
				return current_pos;

			int xpos;
			if (isFromTo.Equals("Y"))
				xpos = current_pos.X + lable_width + 2*currentctl_width + 8;
			else
				xpos = current_pos.X + lable_width + currentctl_width;

			if (xpos > (group_box.Width-10))
			{
				group_box.Height += 25;
				current_pos.X = 16;
				current_pos.Y += 25;
			}

			return current_pos;
		}


		/// <summary>
		/// getContitionExp - 取得有效的条件表达式
		/// </summary>
		public string getContitionExp()
		{
			string expstr = "";
			if (outsideexp.Trim().Length>0)
				expstr = " (" + outsideexp +") ";

			if (dlggenexp.Trim().Length>0)
			{
				if(expstr.Length>0)
					expstr += " AND ";

				expstr += " (" + dlggenexp +") ";
			}

			string fieldexp;
			string searchexp ="";
			for(int i=0; i<controlsarray.Count; i++)
			{
				if("CheckBox".Equals(""+ctltypesarray[i]))
				{
					CheckBox fieldcontrol = (CheckBox)controlsarray[i];
					fieldexp = fieldcontrol.Tag.ToString();
					
					if (fieldcontrol.Checked == true)
						fieldexp = fieldexp.Replace("@boolean@","true");
					else
						fieldexp = fieldexp.Replace("@boolean@","false");
				}
				else if("DateTimePicker".Equals(""+ctltypesarray[i]))
				{
					DateTimePicker fieldcontrol = (DateTimePicker)controlsarray[i];
					fieldexp = fieldcontrol.Tag.ToString();
					
					//if (fieldcontrol.Value == null)
					//	fieldexp = "";
					//else
					fieldexp = fieldexp.Replace("@text@",fieldcontrol.Value.ToString());//此句与多种语言有关,今后的多语版本中要修改
				}
				else if("ComboBox".Equals(""+ctltypesarray[i]))
				{
					ComboBox fieldcontrol = (ComboBox)controlsarray[i];
					fieldexp = fieldcontrol.Tag.ToString();
					
					if (fieldcontrol.SelectedIndex<=0)
						fieldexp = "";
					else
					{
						if ("B".Equals(""+datatypesarray[i]) && !fieldcontrol.Text.ToUpper().Equals("TRUE")  && !fieldcontrol.Text.ToUpper().Equals("FALSE"))
						{
							fieldexp = "";
							fieldcontrol.SelectedIndex=0;
						}
						else if ("N".Equals(""+datatypesarray[i]))
						{
							try
							{
								Decimal.Parse(fieldcontrol.Text);
								fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
							}
							catch
							{
								fieldexp = "";
								fieldcontrol.SelectedIndex=0;
							}
						}
						else if ("D".Equals(""+datatypesarray[i]))
						{
							try
							{
								DateTime.Parse(fieldcontrol.Text);
								fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
							}
							catch
							{
								fieldexp = "";
								fieldcontrol.SelectedIndex=0;
							}
						}
						else
							fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
					}
				}
				else
				{
					System.Windows.Forms.Control fieldcontrol = (System.Windows.Forms.Control) controlsarray[i];
					fieldexp = fieldcontrol.Tag.ToString();
					
					if (("" + fieldcontrol.Text).Length == 0)
						fieldexp = "";
					else 
					{
						if ("B".Equals(""+datatypesarray[i]) && !fieldcontrol.Text.ToUpper().Equals("TRUE")  && !fieldcontrol.Text.ToUpper().Equals("FALSE"))
						{
							fieldexp = "";
							fieldcontrol.Text = "";
						}
						else if ("N".Equals(""+datatypesarray[i]))
						{
							try
							{
								Decimal.Parse(fieldcontrol.Text);
								fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
							}
							catch
							{
								fieldexp = "";
								fieldcontrol.Text = "";
							}
						}
						else if ("D".Equals(""+datatypesarray[i]))
						{
							try
							{
								DateTime.Parse(fieldcontrol.Text);
								fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
							}
							catch
							{
								fieldexp = "";
								fieldcontrol.Text = "";
							}
						}
						else
							fieldexp = fieldexp.Replace("@text@",fieldcontrol.Text);
					}
				}

				if (fieldexp.Length>0)
				{
					if(searchexp.Length>0)
						searchexp += " AND ";
 
					searchexp += " "+fieldexp +" ";
				}
			}

			if (searchexp.Trim().Length>0)
			{
				if(expstr.Length>0)
					expstr += " AND ";

				expstr += " " + searchexp +" ";
			}

			return expstr;
		}

		/// <summary>
		/// runRepoert - 指明当前要查看的报表,查报表是否存在,有否权限,并做好前执行前的准备
		/// </summary>
		private bool runRepoert()
		{
			if(!IsInited)
			{
				IsRunned = false;

⌨️ 快捷键说明

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