Click here to Skip to main content
15,896,482 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  : ProcAddUsers_Tb.sql
** Author:Stevan Rodrigues
**
**==========================================================================================
**
** (c) The contents of this file , and of any file or document derived from it , are copyright 
** to Site Builders . Unlicensed alteration, change or copying in any form, 
** whether written, by photocopy, by print or by any other methods of reproduction is 
** strictly prohibited.
**
**==========================================================================================
**
** PURPOSE OF FILE :
**
** DETAILED DESCRIPTION OF FUNCTIONALITY
** LIST OF PARAMETERS USED
	@UserId int output,
	@FirstName VARCHAR(75),
	@LastName VARCHAR(75),
	@Email VARCHAR(100),
	@Comments VARCHAR(500),
	@AddedDate datetime,
	@UpdatedDate datetime, 
	@EditUsername varchar(25) 
**
** LIST OF RETURN VALUES AND THEIR DEFINITIONS
** 0	:   Successful
**=========================================================================================*/
if exists( select * from sysobjects where id = object_id(N'[dbo].[ProcAddUsers_Tb]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop proc [dbo].[ProcAddUsers_Tb]
go
create procedure ProcAddUsers_Tb
	@UserId int output,
	@FirstName VARCHAR(75),
	@LastName VARCHAR(75),
	@Email VARCHAR(100),
	@Comments VARCHAR(500),
	@AddedDate datetime,
	@UpdatedDate datetime, 
	@EditUsername varchar(25) 
as
	set nocount on
	Declare @ErrorNumber int,
		@RowCount int,
		@CountRec int,
		@EditAdminId int,
		@TableName varchar(50),
		@PrimaryId int,
		@Action varchar(15),
		@ActionDate datetime

	select @CountRec = COUNT(*) FROM Users_Tb
	where Email = @Email
	if @CountRec = 0
	begin
		insert into Users_Tb(
			FirstName, 
			LastName, 
			Email, 
			Comments, 
			AddedDate,
			UpdatedDate
		)
		values (
			@FirstName, 
			@LastName, 
			@Email, 
			@Comments, 
			@AddedDate,
			@UpdatedDate
		)

		-- error checking
		select @ErrorNumber = @@error, 
		@RowCount = @@rowcount
		if ( @ErrorNumber <> 0 )
		begin
			/*exec ErrorHandler @ErrorNumber, 'Users_Tb', 'adding'*/
			set nocount off
			return 1
		end

		select @UserId = @@IDENTITY
		select @EditAdminId = AdminId from Admin_Tb
			where Username = @EditUsername
		select @TableName = 'Users_Tb'
		select @PrimaryId = @UserId
		select @Action = 'Add'
		select @ActionDate = @AddedDate 
		exec ProcAddRecordAction_Tb @EditAdminId, @TableName, @PrimaryId, @Action, @ActionDate
	end
	else
	begin
		select  @UserId =  0 
		 return 2 
	end
	set nocount off
	return 0
go

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