Click here to Skip to main content
15,891,204 members
Articles / Programming Languages / C#

DBLayer Wizard V 1.0

,
Rate me:
Please Sign up or sign in to vote.
3.42/5 (22 votes)
8 Nov 20052 min read 75.3K   1.5K   51  
DBLayer Wizard is a code generator that generates Data Layer classes in C# using ADO.NET and SQL Server 2000.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace SampleApp
{
	/// <summary>
	/// Summary description for ExecSP.
	/// </summary>
	public class ExecSP : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.DataGrid DG;
		private System.Windows.Forms.Button btnSampleA;
		private System.Windows.Forms.Button btnSampleB;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.DateTimePicker dtStart;
		private System.Windows.Forms.DateTimePicker dtEnd;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ExecSP()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <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.btnSampleA = new System.Windows.Forms.Button();
			this.btnSampleB = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.DG = new System.Windows.Forms.DataGrid();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.dtStart = new System.Windows.Forms.DateTimePicker();
			this.dtEnd = new System.Windows.Forms.DateTimePicker();
			((System.ComponentModel.ISupportInitialize)(this.DG)).BeginInit();
			this.SuspendLayout();
			// 
			// btnSampleA
			// 
			this.btnSampleA.Location = new System.Drawing.Point(16, 16);
			this.btnSampleA.Name = "btnSampleA";
			this.btnSampleA.Size = new System.Drawing.Size(120, 32);
			this.btnSampleA.TabIndex = 3;
			this.btnSampleA.Text = "Ten Most Expensive Products";
			this.btnSampleA.Click += new System.EventHandler(this.btnSampleA_Click);
			// 
			// btnSampleB
			// 
			this.btnSampleB.Location = new System.Drawing.Point(160, 16);
			this.btnSampleB.Name = "btnSampleB";
			this.btnSampleB.Size = new System.Drawing.Size(120, 32);
			this.btnSampleB.TabIndex = 3;
			this.btnSampleB.Text = "Employee Sales by Country";
			this.btnSampleB.Click += new System.EventHandler(this.btnSampleB_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(360, 16);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(112, 32);
			this.button3.TabIndex = 3;
			this.button3.Text = "SalesByCategory";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// DG
			// 
			this.DG.AlternatingBackColor = System.Drawing.Color.LightGray;
			this.DG.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.DG.BackColor = System.Drawing.Color.Gainsboro;
			this.DG.BackgroundColor = System.Drawing.Color.Silver;
			this.DG.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.DG.CaptionBackColor = System.Drawing.Color.LightSteelBlue;
			this.DG.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
			this.DG.CaptionForeColor = System.Drawing.Color.MidnightBlue;
			this.DG.CaptionText = "SQL Result";
			this.DG.DataMember = "";
			this.DG.FlatMode = true;
			this.DG.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
			this.DG.ForeColor = System.Drawing.Color.Black;
			this.DG.GridLineColor = System.Drawing.Color.DimGray;
			this.DG.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
			this.DG.HeaderBackColor = System.Drawing.Color.MidnightBlue;
			this.DG.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);
			this.DG.HeaderForeColor = System.Drawing.Color.White;
			this.DG.LinkColor = System.Drawing.Color.MidnightBlue;
			this.DG.Location = new System.Drawing.Point(8, 112);
			this.DG.Name = "DG";
			this.DG.ParentRowsBackColor = System.Drawing.Color.DarkGray;
			this.DG.ParentRowsForeColor = System.Drawing.Color.Black;
			this.DG.SelectionBackColor = System.Drawing.Color.CadetBlue;
			this.DG.SelectionForeColor = System.Drawing.Color.White;
			this.DG.Size = new System.Drawing.Size(512, 200);
			this.DG.TabIndex = 4;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(160, 56);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(48, 16);
			this.label1.TabIndex = 5;
			this.label1.Text = "Start";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(160, 80);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 5;
			this.label2.Text = "End";
			// 
			// dtStart
			// 
			this.dtStart.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dtStart.Location = new System.Drawing.Point(208, 56);
			this.dtStart.Name = "dtStart";
			this.dtStart.Size = new System.Drawing.Size(104, 20);
			this.dtStart.TabIndex = 6;
			this.dtStart.Value = new System.DateTime(1996, 7, 10, 0, 0, 0, 0);
			// 
			// dtEnd
			// 
			this.dtEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dtEnd.Location = new System.Drawing.Point(208, 80);
			this.dtEnd.Name = "dtEnd";
			this.dtEnd.Size = new System.Drawing.Size(104, 20);
			this.dtEnd.TabIndex = 6;
			this.dtEnd.Value = new System.DateTime(1997, 1, 20, 0, 0, 0, 0);
			// 
			// ExecSP
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(528, 318);
			this.Controls.Add(this.dtStart);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.DG);
			this.Controls.Add(this.btnSampleA);
			this.Controls.Add(this.btnSampleB);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.dtEnd);
			this.Name = "ExecSP";
			this.Text = "ExecSP";
			((System.ComponentModel.ISupportInitialize)(this.DG)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void btnSampleA_Click(object sender, System.EventArgs e)
		{
			DG.DataSource=null;
			DataSet ds=DBLayer.DBSP.Ten_Most_Expensive_Products();
			DG.DataSource=ds;
		}

		private void btnSampleB_Click(object sender, System.EventArgs e)
		{
			DG.DataSource=null;
			DataSet ds=DBLayer.DBSP.Employee_Sales_by_Country(dtStart.Value.Date,dtEnd.Value.Date);
			DG.DataSource=ds;
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			DG.DataSource=null;
			DataSet ds=DBLayer.DBSP.SalesByCategory("Beverages","1997");
			DG.DataSource=ds;
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Austria Austria
Egyption ,B.Sc in computer science Department from faculty of computer science and information system Egypt-Helwan Univeristy ,
my master in progress in intelligent systems in Vienna Technology university ,
Microsoft Certified Professional science 2003 experience with
Turbo Pascal ,C++,VC++,C#,VB.NET,J# ,asp,ASP.Net,COM+ & XML , sql server 2000,action script 2

Written By
Web Developer
Egypt Egypt
I have B.Sc in Computer Science , Microsoft Certified Solution Developer and experienced with C/C++,MFC,C#,VB.NET,ASP.NET,XML,SQL Server 2000 & Crystal Reports.I like challenge and enjoy working with new technologies.

Comments and Discussions