Click here to Skip to main content
15,881,812 members
Articles / Database Development / SQL Server

DACBuilder – Data Access objects generation tool based on XML and XSL templates transformation

Rate me:
Please Sign up or sign in to vote.
5.00/5 (13 votes)
31 Mar 2006CPOL23 min read 75.8K   1.9K   68  
The DACBuilder application provides auto-generation features from multiple database systems in multiple programming languages.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace DACBuilder
{

	public delegate void SelectParametersEventHandler(object sender, SelectParametersEventArgs e);
	/// <summary>
	/// Summary description for frmParameters.
	/// </summary>
	public class frmParameters : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid dgParameters;
		private System.Windows.Forms.Label lblText;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.GroupBox grpBox;
		private System.Windows.Forms.Button btnCancel;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
		private System.Windows.Forms.DataGridTextBoxColumn colName;
		private System.Windows.Forms.DataGridTextBoxColumn colValue;
		private System.Windows.Forms.DataGridTextBoxColumn colSelect;

		private DataTable dtParameters;
		public event SelectParametersEventHandler SelectParameters;

		public frmParameters(DataTable dtParameters)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.dtParameters = dtParameters;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		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()
		{
			this.dgParameters = new System.Windows.Forms.DataGrid();
			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
			this.colName = new System.Windows.Forms.DataGridTextBoxColumn();
			this.colValue = new System.Windows.Forms.DataGridTextBoxColumn();
			this.colSelect = new System.Windows.Forms.DataGridTextBoxColumn();
			this.lblText = new System.Windows.Forms.Label();
			this.btnOK = new System.Windows.Forms.Button();
			this.grpBox = new System.Windows.Forms.GroupBox();
			this.btnCancel = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dgParameters)).BeginInit();
			this.SuspendLayout();
			// 
			// dgParameters
			// 
			this.dgParameters.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.dgParameters.DataMember = "";
			this.dgParameters.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgParameters.Location = new System.Drawing.Point(8, 32);
			this.dgParameters.Name = "dgParameters";
			this.dgParameters.Size = new System.Drawing.Size(348, 208);
			this.dgParameters.TabIndex = 0;
			this.dgParameters.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																									 this.dataGridTableStyle1});
			// 
			// dataGridTableStyle1
			// 
			this.dataGridTableStyle1.DataGrid = this.dgParameters;
			this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																												  this.colName,
																												  this.colValue,
																												  this.colSelect});
			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle1.MappingName = "";
			// 
			// colName
			// 
			this.colName.Format = "";
			this.colName.FormatInfo = null;
			this.colName.HeaderText = "name";
			this.colName.MappingName = "name";
			this.colName.ReadOnly = true;
			this.colName.Width = 75;
			// 
			// colValue
			// 
			this.colValue.Format = "";
			this.colValue.FormatInfo = null;
			this.colValue.HeaderText = "Value";
			this.colValue.MappingName = "value";
			this.colValue.Width = 75;
			// 
			// colSelect
			// 
			this.colSelect.Format = "";
			this.colSelect.FormatInfo = null;
			this.colSelect.HeaderText = "Is select";
			this.colSelect.MappingName = "select";
			this.colSelect.ReadOnly = true;
			this.colSelect.Width = 75;
			// 
			// lblText
			// 
			this.lblText.Location = new System.Drawing.Point(8, 8);
			this.lblText.Name = "lblText";
			this.lblText.Size = new System.Drawing.Size(264, 16);
			this.lblText.TabIndex = 1;
			this.lblText.Text = "Change appropriate values and press OK.";
			// 
			// btnOK
			// 
			this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnOK.Location = new System.Drawing.Point(188, 256);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 2;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// grpBox
			// 
			this.grpBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grpBox.Location = new System.Drawing.Point(8, 240);
			this.grpBox.Name = "grpBox";
			this.grpBox.Size = new System.Drawing.Size(348, 8);
			this.grpBox.TabIndex = 3;
			this.grpBox.TabStop = false;
			// 
			// btnCancel
			// 
			this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(276, 256);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// frmParameters
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(360, 286);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.grpBox);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.lblText);
			this.Controls.Add(this.dgParameters);
			this.Name = "frmParameters";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Parameters";
			this.Load += new System.EventHandler(this.frmParameters_Load);
			((System.ComponentModel.ISupportInitialize)(this.dgParameters)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmParameters_Load(object sender, System.EventArgs e)
		{
			dtParameters.DefaultView.AllowNew = false;
			dgParameters.DataSource = dtParameters.DefaultView;
		}

		private void OnSelectParameters()
		{
			SelectParametersEventArgs e = new SelectParametersEventArgs(this.dtParameters);
			if(SelectParameters != null)
			{
				SelectParameters(this, e);
			}
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			OnSelectParameters();
			this.DialogResult = DialogResult.OK;
			Close();
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			Close();
		}
	}

	public class SelectParametersEventArgs : EventArgs
	{
		private DataTable dtParameters;

		public SelectParametersEventArgs(DataTable dtParameters)
		{
			this.dtParameters = dtParameters;
		}

		public DataTable Parameters
		{
			get
			{
				return dtParameters;
			}
			set
			{
				dtParameters = value;
			}
		}
	}

}

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
Web Developer Telstra Internet
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions