Click here to Skip to main content
15,884,099 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 425.2K   22.2K   251  
Generates three tier code for ASP.NET.
'**==========================================================================================
'**
'** FILE  : User.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 Company.ThreeTierDemoVB.Components.Interface
Imports WebChamps.Components.Parent
'*********************************************************************
'
' Company.ThreeTierDemoVB.Components.Business Namespace
'
'*********************************************************************
Namespace Company.ThreeTierDemoVB.Components.Business
	'*********************************************************************
	'
	' Class: User
	'
 	'Description: Business object to maintain 	records
 	' of Users_Tb within database.
	'
	'*********************************************************************
	Public Class User
		Inherits BusinessObject
		Implements IUser
		Private _UserId As Int32
		Private _FirstName As string
		Private _LastName As string
		Private _Email As string
		Private _Comments As string

		Public Sub New()
		End Sub

		Public Sub New(ByVal ParamUserId As Int32)
		Dim MsDataReader As System.Data.SqlClient.SqlDataReader
			_UserId = ParamUserId
			MsDataReader = Company.ThreeTierDemoVB.Components.Data.User.SelectUser(ParamUserId)
			If MsDataReader.Read() Then
				_FirstName = System.Convert.ToString(MsDataReader("FirstName"))
				_LastName = System.Convert.ToString(MsDataReader("LastName"))
				_Email = System.Convert.ToString(MsDataReader("Email"))
				_Comments = System.Convert.ToString(MsDataReader("Comments"))
			End If 
			MsDataReader.Close()
		End Sub

		Public Property UserId() As Int32 Implements IUser.UserId
			Get
				Return _UserId
			End Get
			Set(ByVal Value As Int32)
				_UserId = Value
			End Set
		End Property

		Public Property FirstName() As string Implements IUser.FirstName
			Get
				Return _FirstName
			End Get
			Set(ByVal Value As string)
				_FirstName = Value
			End Set
		End Property

		Public Property LastName() As string Implements IUser.LastName
			Get
				Return _LastName
			End Get
			Set(ByVal Value As string)
				_LastName = Value
			End Set
		End Property

		Public Property Email() As string Implements IUser.Email
			Get
				Return _Email
			End Get
			Set(ByVal Value As string)
				_Email = Value
			End Set
		End Property

		Public Property Comments() As string Implements IUser.Comments
			Get
				Return _Comments
			End Get
			Set(ByVal Value As string)
				_Comments = Value
			End Set
		End Property

		Public Function Add(ByVal Username As String) As Int32
			Try
				Return Company.ThreeTierDemoVB.Components.Data.User.AddUser(Me, Username)
			Catch ex As WebChamps.Components.Web.AppException
				Return -1
			Catch ex As System.Exception
				Throw New WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemoVB.Components.Business.User.Add", ex)

			Finally
				'Some action
			End Try

		End Function

		Public Function Update(ByVal Username As String) As Int32
			Try
				Return Company.ThreeTierDemoVB.Components.Data.User.UpdateUser(Me, Username)
			Catch ex As WebChamps.Components.Web.AppException
				Return -1
			Catch ex As System.Exception
				Throw New WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemoVB.Components.Business.User.Update", ex)

			Finally
				'Some action
			End Try

		End Function

		Public Function Delete(ByVal Username As String) As Int32
			Try
				Return Company.ThreeTierDemoVB.Components.Data.User.DeleteUser(_UserId, Username)
			Catch ex As WebChamps.Components.Web.AppException
				Return -1
			Catch ex As System.Exception
				Throw New WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemoVB.Components.Business.User.Delete", ex)

			Finally
				'Some action
			End Try

		End Function

		Public Function ShowAll() As System.Data.DataSet
			Try
				Return Company.ThreeTierDemoVB.Components.Data.User.ShowUser()
			Catch ex As WebChamps.Components.Web.AppException
				Return Nothing
			Catch ex As System.Exception
				Throw New WebChamps.Components.Web.AppException("An error occurred while executing the Company.ThreeTierDemoVB.Components.Business.User.ShowAll", ex)

			Finally
				'Some action
			End Try

		End Function

	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