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

📄 designreportsearchcfg.cs

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

namespace TreeReportApp
{
	/// <summary>
	/// TreeReportSearchCfg 的摘要说明。
	/// </summary>
	public class TreeReportSearchCfg : System.Windows.Forms.Form
	{
		//private TreeReportDesignFrm designfrm;
		
		private DataDynamics.ActiveReports.ActiveReport designreport;
		private ReportManageInfo manageinfo;

		private System.Data.OleDb.OleDbDataAdapter adapter;
		private System.Data.DataSet dataset;
		private System.Data.DataTable datatable;

		private System.Data.OleDb.OleDbDataAdapter adapter_fields;
		private System.Data.DataSet dataset_fields;
		private System.Data.DataTable datatable_fields;

		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.ListView listView_searchfield;
		private System.Windows.Forms.ListView listView_datafield;
		private System.Windows.Forms.Button button_addsearch;
		private System.Windows.Forms.Button button_delsearch;
		private System.Windows.Forms.Button button_ok;
		private System.Windows.Forms.ImageList imageList_view;
		private System.Windows.Forms.Button button_attribte;
		private System.ComponentModel.IContainer components;

		public TreeReportSearchCfg()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}


		/// <summary>
		/// initReportSearchCfg -- 检查此报表是否是存在于数据库中,是正式报表?
		/// </summary>
		public bool initReportSearchCfg(ActiveReport design_report,ReportManageInfo manage_info)
		{
			designreport = design_report;
			manageinfo = manage_info;

			if (manageinfo._ReportID==null || manageinfo._ReportID.Length == 0)
				return false;

			System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
			//连接据库,这段程序用一个公共连接类代替
			conn.ConnectionString = TreeConnection.connstr;
			conn.Open();

			System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("select count(*) from ReportsManage where ReportID='" +manageinfo._ReportID + "'",conn);
			int cnt = Convert.ToInt32(cmd.ExecuteScalar().ToString());

			conn.Close();

			if (cnt==0)//库中还没有此报表的任何信息,不能进行搜索条件配置
				return false;
			else
				return true;
		}

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

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TreeReportSearchCfg));
			this.panel1 = new System.Windows.Forms.Panel();
			this.button_attribte = new System.Windows.Forms.Button();
			this.imageList_view = new System.Windows.Forms.ImageList(this.components);
			this.button_ok = new System.Windows.Forms.Button();
			this.listView_searchfield = new System.Windows.Forms.ListView();
			this.listView_datafield = new System.Windows.Forms.ListView();
			this.button_addsearch = new System.Windows.Forms.Button();
			this.button_delsearch = new System.Windows.Forms.Button();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.button_attribte);
			this.panel1.Controls.Add(this.button_ok);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 309);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(650, 40);
			this.panel1.TabIndex = 1;
			// 
			// button_attribte
			// 
			this.button_attribte.BackColor = System.Drawing.SystemColors.Info;
			this.button_attribte.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_attribte.ImageIndex = 3;
			this.button_attribte.ImageList = this.imageList_view;
			this.button_attribte.Location = new System.Drawing.Point(528, 8);
			this.button_attribte.Name = "button_attribte";
			this.button_attribte.Size = new System.Drawing.Size(104, 24);
			this.button_attribte.TabIndex = 1;
			this.button_attribte.Text = "条件控件属性";
			this.button_attribte.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.button_attribte.Click += new System.EventHandler(this.button_attribte_Click);
			// 
			// imageList_view
			// 
			this.imageList_view.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList_view.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList_view.ImageStream")));
			this.imageList_view.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// button_ok
			// 
			this.button_ok.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.button_ok.ImageIndex = 2;
			this.button_ok.ImageList = this.imageList_view;
			this.button_ok.Location = new System.Drawing.Point(184, 8);
			this.button_ok.Name = "button_ok";
			this.button_ok.TabIndex = 0;
			this.button_ok.Text = "  确 认";
			this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
			// 
			// listView_searchfield
			// 
			this.listView_searchfield.BackColor = System.Drawing.SystemColors.Info;
			this.listView_searchfield.Dock = System.Windows.Forms.DockStyle.Right;
			this.listView_searchfield.Location = new System.Drawing.Point(250, 0);
			this.listView_searchfield.MultiSelect = false;
			this.listView_searchfield.Name = "listView_searchfield";
			this.listView_searchfield.Size = new System.Drawing.Size(400, 309);
			this.listView_searchfield.SmallImageList = this.imageList_view;
			this.listView_searchfield.TabIndex = 2;
			this.listView_searchfield.View = System.Windows.Forms.View.Details;
			this.listView_searchfield.DoubleClick += new System.EventHandler(this.listView_searchfield_DoubleClick);
			// 
			// listView_datafield
			// 
			this.listView_datafield.Dock = System.Windows.Forms.DockStyle.Left;
			this.listView_datafield.Location = new System.Drawing.Point(0, 0);
			this.listView_datafield.MultiSelect = false;
			this.listView_datafield.Name = "listView_datafield";
			this.listView_datafield.Size = new System.Drawing.Size(184, 309);
			this.listView_datafield.SmallImageList = this.imageList_view;
			this.listView_datafield.TabIndex = 3;
			this.listView_datafield.View = System.Windows.Forms.View.Details;
			this.listView_datafield.DoubleClick += new System.EventHandler(this.listView_datafield_DoubleClick);
			// 
			// button_addsearch
			// 
			this.button_addsearch.Location = new System.Drawing.Point(193, 72);
			this.button_addsearch.Name = "button_addsearch";
			this.button_addsearch.Size = new System.Drawing.Size(48, 23);
			this.button_addsearch.TabIndex = 4;
			this.button_addsearch.Text = "-->>";
			this.button_addsearch.Click += new System.EventHandler(this.button_addsearch_Click);
			// 
			// button_delsearch
			// 
			this.button_delsearch.Location = new System.Drawing.Point(193, 200);
			this.button_delsearch.Name = "button_delsearch";
			this.button_delsearch.Size = new System.Drawing.Size(48, 23);
			this.button_delsearch.TabIndex = 5;
			this.button_delsearch.Text = "<<--";
			this.button_delsearch.Click += new System.EventHandler(this.button_delsearch_Click);
			// 
			// TreeReportSearchCfg
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(650, 349);
			this.ControlBox = false;
			this.Controls.Add(this.button_delsearch);
			this.Controls.Add(this.button_addsearch);
			this.Controls.Add(this.listView_datafield);
			this.Controls.Add(this.listView_searchfield);
			this.Controls.Add(this.panel1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "TreeReportSearchCfg";
			this.ShowInTaskbar = false;
			this.Text = "配置在报表执行界面上出现的可输入条件域";
			this.Load += new System.EventHandler(this.TreeReportSearchCfg_Load);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void TreeReportSearchCfg_Load(object sender, System.EventArgs e)
		{
			listView_datafield.Columns.Add("可用数据域(双击选择)",200,HorizontalAlignment.Left);
			listView_searchfield.Columns.Add("设置条件的数据域(双击改属性)",200,HorizontalAlignment.Left);
			listView_searchfield.Columns.Add("类型",38,HorizontalAlignment.Left);
			listView_searchfield.Columns.Add("控件",80,HorizontalAlignment.Left);
			listView_searchfield.Columns.Add("宽度",45,HorizontalAlignment.Left);
			listView_searchfield.Columns.Add("F/T",30,HorizontalAlignment.Left);

			System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
			//连接据库,这段程序用一个公共连接类代替
			conn.ConnectionString = TreeConnection.connstr;
			conn.Open();

			try
			{
				System.Data.OleDb.OleDbCommand cmd;
				//System.Data.OleDb.OleDbParameter para;
				//从库中取searchfield数据
				adapter = new System.Data.OleDb.OleDbDataAdapter();//"select ReportID,DataField from ReportSearchField where ReportID='" + manageinfo._ReportID +"'",conn);

				//cmd = new System.Data.OleDb.OleDbCommand("select ReportID,DataField from ReportSearchField where ReportID='" + manageinfo._ReportID +"'",conn);
				cmd = new System.Data.OleDb.OleDbCommand("select * from ReportSearchField where ReportID='" + manageinfo._ReportID +"'",conn);
				adapter.SelectCommand = cmd;

				System.Data.OleDb.OleDbCommandBuilder cmdbuilder = new System.Data.OleDb.OleDbCommandBuilder(adapter);
				
				
				/*/---------------------------------
				cmd = new System.Data.OleDb.OleDbCommand( "INSERT INTO ReportSearchField(ReportID,DataField) VALUES('"+manageinfo._ReportID+"',?)",conn);
				cmd.Parameters.Add("@DataField",System.Data.OleDb.OleDbType.VarChar,50,"DataField");
				adapter.InsertCommand = cmd;

				cmd = new System.Data.OleDb.OleDbCommand( "UPDATE ReportSearchField SET DataField=? WHERE ReportID='"+manageinfo._ReportID + "' and DataField=?",conn);
				cmd.Parameters.Add("@DataField",System.Data.OleDb.OleDbType.VarChar,50,"DataField");
				para = cmd.Parameters.Add("@oldDataField",System.Data.OleDb.OleDbType.VarChar,50,"DataField");
				para.SourceVersion = DataRowVersion.Original;

⌨️ 快捷键说明

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