Click here to Skip to main content
15,886,795 members
Articles / Programming Languages / C#

EasiReports

Rate me:
Please Sign up or sign in to vote.
4.87/5 (64 votes)
13 Feb 2006CPOL6 min read 480.2K   9.7K   219  
A library to add reports to your application.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;

using EasiReports.Report;
using EasiReports.Metadata;
using EasiReports.Algorithms;

namespace EasiReports
{
	/// <summary>
	/// Summary description for DlgDataControl.
	/// </summary>
	internal class CDlgAlgorithmsInsertVariableData : System.Windows.Forms.Form
	{

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private System.Windows.Forms.Label lblTable;
		private System.Windows.Forms.ComboBox cbTable;
		private System.Windows.Forms.Label lblField;
		private System.Windows.Forms.ComboBox cbField;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.TextBox textVariableName;
		private System.Windows.Forms.Label labelVariableName;

		private HelpProvider HelpProvider = new HelpProvider();

		private EasiReport         _Report     = null;
		private CMetadata       _Metadata   = null;
		private AlgorithmsMemoryAssembly     _Algorithms = null;
		private InsertVariable _InsertVariable         = null;

		public CDlgAlgorithmsInsertVariableData( EasiReport r, AlgorithmsMemoryAssembly algorithms, InsertVariable iv )
		{
			InitializeComponent();

			HelpProvider.HelpNamespace = Glob.HelpNamespace;
			HelpProvider.SetHelpNavigator( this, Glob.HelpNavigator );
			HelpProvider.SetHelpKeyword( this, "EasiReporter.Dialogs.InsertDataVariable.htm" );

			_Report = r;
			_Metadata = _Report.Metadata;
			_Algorithms = algorithms;
			_InsertVariable = iv;
		}

		/// <summary>Clean up any resources being used.</summary>
		/// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; <b>false</b> to release only unmanaged resources.</param>
		/// <remarks>Releases the unmanaged resources and optionally releases the managed resources.</remarks>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CDlgAlgorithmsInsertVariableData));
			this.lblTable = new System.Windows.Forms.Label();
			this.cbTable = new System.Windows.Forms.ComboBox();
			this.lblField = new System.Windows.Forms.Label();
			this.cbField = new System.Windows.Forms.ComboBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.labelVariableName = new System.Windows.Forms.Label();
			this.textVariableName = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// lblTable
			// 
			this.lblTable.Location = new System.Drawing.Point(16, 64);
			this.lblTable.Name = "lblTable";
			this.lblTable.Size = new System.Drawing.Size(80, 23);
			this.lblTable.TabIndex = 2;
			this.lblTable.Text = "Table";
			// 
			// cbTable
			// 
			this.cbTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbTable.Location = new System.Drawing.Point(112, 64);
			this.cbTable.Name = "cbTable";
			this.cbTable.Size = new System.Drawing.Size(192, 21);
			this.cbTable.TabIndex = 3;
			this.cbTable.SelectedIndexChanged += new System.EventHandler(this.cbTable_SelectedIndexChanged);
			// 
			// lblField
			// 
			this.lblField.Location = new System.Drawing.Point(16, 96);
			this.lblField.Name = "lblField";
			this.lblField.Size = new System.Drawing.Size(80, 23);
			this.lblField.TabIndex = 4;
			this.lblField.Text = "Field";
			// 
			// cbField
			// 
			this.cbField.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbField.Location = new System.Drawing.Point(112, 96);
			this.cbField.Name = "cbField";
			this.cbField.Size = new System.Drawing.Size(192, 21);
			this.cbField.TabIndex = 5;
			this.cbField.SelectedIndexChanged += new System.EventHandler(this.cbField_SelectedIndexChanged);
			// 
			// btnOK
			// 
			this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnOK.Location = new System.Drawing.Point(136, 136);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 6;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnCancel.Location = new System.Drawing.Point(224, 136);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 7;
			this.btnCancel.Text = "Cancel";
			// 
			// labelVariableName
			// 
			this.labelVariableName.Location = new System.Drawing.Point(16, 16);
			this.labelVariableName.Name = "labelVariableName";
			this.labelVariableName.Size = new System.Drawing.Size(80, 23);
			this.labelVariableName.TabIndex = 0;
			this.labelVariableName.Text = "Variable Name";
			// 
			// textVariableName
			// 
			this.textVariableName.Location = new System.Drawing.Point(112, 16);
			this.textVariableName.Name = "textVariableName";
			this.textVariableName.Size = new System.Drawing.Size(192, 20);
			this.textVariableName.TabIndex = 1;
			this.textVariableName.Text = "";
			// 
			// CDlgAlgorithmsInsertVariableData
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(322, 176);
			this.Controls.Add(this.textVariableName);
			this.Controls.Add(this.labelVariableName);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.cbField);
			this.Controls.Add(this.lblField);
			this.Controls.Add(this.cbTable);
			this.Controls.Add(this.lblTable);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "CDlgAlgorithmsInsertVariableData";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Insert Data Variable";
			this.Load += new System.EventHandler(this.CDlgAlgorithmsInsertVariableData_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void CDlgAlgorithmsInsertVariableData_Load(object sender, System.EventArgs e)
		{
//			FillCombo.FillTables( _Metadata, cbTable );
//			FillCombo.AddAlgorithms( _Report, cbTable );
//			cbTable.SelectedIndex = 0;

			FillCombo.AddTables( _Report, cbTable );
			FillCombo.AddClasses( _Report, AlgorithmsDirector.DataAlgorithmGroup, cbTable );
			FillCombo.Select( null, cbTable );
		}

		private void cbTable_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			cbField.Items.Clear();

			DataSelection selection = FillCombo.GetDataSelection( cbTable );

			FillCombo.AddFields( _Report, selection, AlgorithmsDirector.DataAlgorithmGroup, cbField );

			FillCombo.Select( null, cbField );
		}

		private void cbField_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			_InsertVariable.eInsertVariable = eInsertVariable.eData;

			_InsertVariable.sVariableName = textVariableName.Text;

//			_InsertVariable.sTable = cbTable.Text;
//			_InsertVariable.sField = cbField.Text;

			_InsertVariable.DataSelection = FillCombo.GetDataSelection( cbField );
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
I discovered C# and .NET 1.0 Beta 1 in late 2000 and loved them immediately.
I have been writing software professionally in C# ever since

In real life, I have spent 3 years travelling abroad,
I have held a UK Private Pilots Licence for 20 years,
and I am a PADI Divemaster.

I now live near idyllic Bournemouth in England.

I can work 'virtually' anywhere!

Comments and Discussions