Click here to Skip to main content
15,896,726 members
Articles / Web Development / ASP.NET

Three Tier Code Generator For ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.78/5 (34 votes)
8 Jul 200512 min read 426.3K   22.2K   251  
Generates three tier code for ASP.NET.
'**==========================================================================================
'**
'** FILE  : AddAdmin.aspx.vb
'** Author: Stevan Rodrigues
'**
'**==========================================================================================
'**
'** (c) The contents of this file , and of any file or document derived from it , are copyright 
'** to Webchamps . Unlicensed alteration, change or copying in any form, 
'** whether written, by photocopy, by print or by any other methods of reproduction is 
'** strictly prohibited.
'**
'**==========================================================================================
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports WebChamps.Components.Web
Imports  Company.ThreeTierDemoVB.Components.Business

'*********************************************************************
'
' Company.ThreeTierDemoVB.Admin Namespace
'
'*********************************************************************
Namespace Company.ThreeTierDemoVB.Admin
	Public Class AddAdmin
	Inherits WebChamps.Components.Web.SitePage
		Protected PageMessage As System.Web.UI.WebControls.Label
		Protected ErrorMessage As System.Web.UI.WebControls.Label

		Protected FirstNameField As System.Web.UI.WebControls.TextBox
		Protected LastNameField As System.Web.UI.WebControls.TextBox
		Protected UsernameField As System.Web.UI.WebControls.TextBox
		Protected PasswordField As System.Web.UI.WebControls.TextBox
		Protected AddRecord As System.Web.UI.WebControls.Button

		#Region " Web Form Designer Generated Code "

			'This call is required by the Web Form Designer.
			<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

				AddHandler Me.Load, New System.EventHandler(AddressOf Me.Page_Load)
				AddHandler Me.AddRecord.Click, New System.EventHandler(AddressOf Me.AddRecord_Click)
			End Sub

			Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
				'CODEGEN: This method call is required by the Web Form Designer
				'Do not modify it using the code editor.
				InitializeComponent()
			End Sub

		#End Region

		'*********************************************************************
		'
		' Page_Load event
		'
 		'Add code to this event.
		'
		'*********************************************************************
		Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
			' Insert code to process code when the page is loaded for first time or without a post back.
			If  Not IsPostBack Then
			End If 
		End Sub

		'*********************************************************************
		'
		' AddRecord_Click event
		'
 		'The Company.ThreeTierDemoVB.Components.Data.AdminDB.AddAdmin_Tb is used to add record to the table.
		'
		'*********************************************************************
		Private Sub AddRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
			'Define objects 
			Dim ParamAdmin As Company.ThreeTierDemoVB.Components.Business.Admin
			Dim ReturnValue As Int32
			Dim AdminId As Int32
			AdminId = 0

			'Create the Admin instance.
			ParamAdmin = New Company.ThreeTierDemoVB.Components.Business.Admin()
			ParamAdmin.AdminId = AdminId
			ParamAdmin.FirstName = FirstNameField.Text
			ParamAdmin.LastName = LastNameField.Text
			ParamAdmin.Username = UsernameField.Text
			ParamAdmin.Password = PasswordField.Text
			'Assign the return value.
			ReturnValue = ParamAdmin.Add(User.Identity.Name)
			If ReturnValue = 0 Then
				Response.Redirect("Default.aspx")
			ElseIf ReturnValue = -1 Then
				ErrorMessage.Text = "Custom error!"
			ElseIf ReturnValue = 1 Then
				ErrorMessage.Text = "Database error!"
			Else 
				PageMessage.Text = "Record already exists!"
			End If 
		End Sub

	End Class
End Namespace

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
Software Developer (Senior)
Australia Australia
Stevan is a Microsoft Certified Solutions Developer in .Net Architecture (MCSD.Net Early Achiever – one among the first 2500 worldwide), Microsoft Certified Application Developer in .Net – MCAD.Net (Charter Member - one among the first 5000 developers worldwide).

Comments and Discussions