473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Business Logic Layer - Design

Hi, I need some advise on creating a general Business Logic Layer for
my applications.

The approach I use today is to create a class with the same name as
the table, create a property for each field in the table, write
constructors, to create a new row, and a constructor to open an
existing row, write update, delete functions, write a static get
method, to get a list of all the rows in the table..

I have created a Code generator to write the class based on the
database table.

Do anyone of you have any advises/links to resources which describes
how this layer should be designed?

Thanks..

To illustrate my model I can give an example:

Table: Customer
Field: CustomerID int
Field: GivenName Char(50)
Field: LastName Char(50)

Class:
Imports System
Imports System.Configuration
Imports MS.DataAccessLayer
Namespace MyCompany.BusinessLogicLayer
Public Class Customer

Private _customerid As System.Int32
Private _givenname As System.String
Private _lastname As System.String

Public Property CustomerID() As System.Int32
Get
Return _customerid
End Get
Set(Byval Value As System.Int32)
_customerid = Value
End Set
End Property

Public Property GivenName() As System.String
Get
Return _givenname
End Get
Set(Byval Value As System.String)
_givenname = Value
End Set
End Property

Public Property LastName() As System.String
Get
Return _lastname
End Get
Set(Byval Value As System.String)
_lastname = Value
End Set
End Property
Public Sub New()

End Sub

Public Sub New(ByVal CustomerID As System.Int32)
Dim _ds as dataset =
sqlhelper.ExecuteDataset(ConfigurationSettings.App Settings("connectionstring"),
_
"Customer_Select_BY_CustomerID", _
CustomerID)
Dim _row as DataRow = _ds.tables(0).Rows(0)

_CustomerID = _row("CustomerID")
_GivenName = _row("GivenName")
_LastName = _row("LastName")

End Sub
Public Sub Update()

if _CustomerID = 0 then
CustomerID = sqlhelper.ExecuteScalar(ConfigurationSettings.AppS ettings("connectionstring"),
_
"Customer_Insert", _
_GivenName, _
_LastName)
else
sqlhelper.ExecuteNonQuery(ConfigurationSettings.Ap pSettings("connectionstring"),
_
"Customer_Update", _
_CustomerID, _
_GivenName, _
_LastName)
End if

End Sub
Public Sub Delete()
sqlhelper.ExecuteNonQuery(ConfigurationSettings.Ap pSettings("connectionstring"),
_
"Customer_Delete", _
_CustomerID)

End Sub
Public Shared Function Get_All_Of_Customer() as CustomerCollection

Dim _ds as dataset =
sqlhelper.ExecuteDataset(ConfigurationSettings.App Settings("connectionstring"),
_
"Customer_Select_All")

Dim _col as new CustomerCollection

For each _row as datarow in _ds.tables(0).Rows
Dim _Customer as new Customer(_row("CustomerID"))
_col.Add(_Customer)
Next _row

Return _col
End Function
End Class
Public Class CustomerCollection
Inherits ArrayList
End Class
End Namespace
Nov 21 '05 #1
0 1182

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
1
by: abc my vclass | last post by:
How to design and build reports which data source from business logic layer ? Is there any documents or tutorials explain the steps to design and build reports if my projects' data source from...
7
by: Rob R. Ainscough | last post by:
I understand and implement the concept (as best I can), BUT what I would like to know -- how is it possible to completely remove the UI from business logic? "UI references business logic, but...
16
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
4
by: pratham | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
1
by: Nemisis | last post by:
hi guys, Currently converting an old classic asp system to a OOP asp.net application. We are building the new application using a 3 tier arcitecture and i was wondering about the following. ...
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
2
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
2
by: oliharvey | last post by:
Hi - (not really a C# question -...apologies) I seem to have gravitated towards a particlar design pattern - and would welcome your opinions as to it's sanity - thanks... The basic idea is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.