By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,080 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,080 IT Pros & Developers. It's quick & easy.

Architecture Question

P: n/a
Hi I have a question about architecting solutions..

I have a part of a project which requires me to track person details (name, addresses, etc...
Should I be creating Person objects, Address objects etc as Business layer classes and then have an data access layer which actually save / updates / delete to and from the DB..

If so, and bearing in mind the 'easiest' way to pass data between the layers would be with a dataset - should my BL classes take dataset results from the DAL and convert into class objects ?

E.g

BL Person - Persist method calls DAL Person - persist method (which actually saves the data to the underlying DB)
In the BL Person should the persist method first convert its own object into a dataset and send that to the DAL persist method..

Also..

BL Persons (collection) GetBypostcode method - calls DAL GetPersonsByPostcode method - should the DAL method return a dataset and then the BL method converts that into a collection of Person objects for use by the UI layer..

Any thought, comments or experience would be appreciated..

... Ke

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
here's w i use
(keep in mind i use the data access application block for .NET, its all for
sqlserver and the collection class is a work in progress)
take your time, have a look at it (yust paste the things in vs and mind
linebreaks)

extra note the classes all work together (an fk is a class of that type) if
you have recursive relations you need to change some things.
/* SP INSERT */

/*** Drop Stored Procedure Insert tblPrijsType*/
If exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spInserttblPrijsType]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1) drop procedure [dbo].[spInserttblPrijsType]
GO

/* Stored Procedure Insert tblPrijsType*/
CREATE PROCEDURE spInserttblPrijsType
@ID bigint output,
-- FK tblEenheidType.ETID
@ptETID int,
@ptCode varchar(50),
@ptOms varchar(200),
@ptFactor float,
@ptIDat datetime,
@ptUDat datetime,
@ptVDat datetime,
@ptIUsr int,
@ptUUsr int,
@ptVUsr int
As Insert INTO tblPrijsType
(ptETID,
ptCode,
ptOms,
ptFactor,
ptIDat,
ptUDat,
ptVDat,
ptIUsr,
ptUUsr,
ptVUsr
)
VALUES
(
@ptETID,
@ptCode,
@ptOms,
@ptFactor,
@ptIDat,
@ptUDat,
@ptVDat,
@ptIUsr,
@ptUUsr,
@ptVUsr
)
SET @ID = SCOPE_IDENTITY()
GO

/* SP UPDATE */

/*** Drop Stored Procedure Update tblPrijsType*/
If exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spUpdatetblPrijsType]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1) drop procedure [dbo].[spUpdatetblPrijsType]
GO

/* Stored Procedure Update tblPrijsType*/
CREATE PROCEDURE spUpdatetblPrijsType
@PTID int,
-- FK tblEenheidType.ETID
@ptETID int,
@ptCode varchar(50),
@ptOms varchar(200),
@ptFactor float,
@ptUDat datetime,
@ptUUsr int
As UPDATE tblPrijsType SET
ptETID = @ptETID,
ptCode = @ptCode,
ptOms = @ptOms,
ptFactor = @ptFactor,
ptUDat = @ptUDat,
ptUUsr = @ptUUsr
WHERE PTID = @PTID

GO

/* SP SELECT ON ID
Returns extra output parameter exist 1 if true -1 if false */

/*** Drop Stored Procedure Select tblPrijsType*/
If exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spSelidtblPrijsType]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1) drop procedure [dbo].[spSelidtblPrijsType]
GO

/* Stored Procedure select on id tblPrijsType*/
CREATE PROCEDURE spSelidtblPrijsType
@PTID int,
@exists int OUTPUT,
-- FK tblEenheidType.ETID
@ptETID int OUTPUT,
@ptCode varchar(50) OUTPUT,
@ptOms varchar(200) OUTPUT,
@ptFactor float OUTPUT,
@ptIDat datetime OUTPUT,
@ptUDat datetime OUTPUT,
@ptVDat datetime OUTPUT,
@ptIUsr int OUTPUT,
@ptUUsr int OUTPUT,
@ptVUsr int OUTPUT
As SELECT
@exists = PTID,
@ptETID = ptETID,
@ptCode = ptCode,
@ptOms = ptOms,
@ptFactor = ptFactor,
@ptIDat = ptIDat,
@ptUDat = ptUDat,
@ptVDat = ptVDat,
@ptIUsr = ptIUsr,
@ptUUsr = ptUUsr,
@ptVUsr = ptVUsr
FROM tblPrijsType
WHERE PTID = @PTID
if @exists is NULL
begin
select @exists = -1
end
else
begin
select @exists = 1
end

RETURN
GO

/* SP UPDATEV */

/*** Drop Stored Procedure UpdateV tblPrijsType*/
If exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spUpdateVtblPrijsType]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1) drop procedure [dbo].[spUpdateVtblPrijsType]
GO

/* Stored Procedure UpdateV tblPrijsType*/
CREATE PROCEDURE spUpdateVtblPrijsType
@PTID int,
@ptVDat datetime,
@ptVUsr int
As UPDATE tblPrijsType SET
ptVDat = @ptVDat,
ptVUsr = @ptVUsr
WHERE PTID = @PTID

GO

/* SP FilterColl */

/*** Drop Stored Procedure Filter tblPrijsType*/
If exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[spFilterColltblPrijsType]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1) drop procedure [dbo].[spFilterColltblPrijsType]
GO

/* Stored Procedure FilterColl tblPrijsType*/
CREATE PROCEDURE spFilterColltblPrijsType

-- FK tblEenheidType.ETID
@ptETID int,
@blnptETID bit,
@ptCode varchar(50),
@blnptCode bit,
@ptOms varchar(200),
@blnptOms bit,
@ptFactor float,
@blnptFactor bit,
@ptIDat datetime,
@blnptIDat bit,
@ptUDat datetime,
@blnptUDat bit,
@ptVDat datetime,
@blnptVDat bit,
@ptIUsr int,
@blnptIUsr bit,
@ptUUsr int,
@blnptUUsr bit,
@ptVUsr int,
@blnptVUsr bit
As SELECT *
FROM tblPrijsType
WHERE (ptETID = @ptETID OR @blnptETID = 0)
AND
(ptCode like @ptCode OR @blnptCode = 0)
AND
(ptOms like @ptOms OR @blnptOms = 0)
AND
(ptFactor = @ptFactor OR @blnptFactor = 0)
AND
(ptIDat = @ptIDat OR @blnptIDat = 0)
AND
(ptUDat = @ptUDat OR @blnptUDat = 0)
AND
(ptVDat = @ptVDat OR @blnptVDat = 0)
AND
(ptIUsr = @ptIUsr OR @blnptIUsr = 0)
AND
(ptUUsr = @ptUUsr OR @blnptUUsr = 0)
AND
(ptVUsr = @ptVUsr OR @blnptVUsr = 0)

RETURN
GO

'******************* classes *******************
'******************* With class relations *******************

'class clstblPrijsType
'Do not change this class change clsPrijsType
<Serializable()> Public Class clstblPrijsType

Private intPTID AS Integer
Private clPTETID AS clstblEenheidType
Private strptCode AS String
Private strptOms AS String
Private dblptFactor AS Double
Private datptIDat AS DateTime
Private datptUDat AS DateTime
Private datptVDat AS DateTime
Private intptIUsr AS Integer
Private intptUUsr AS Integer
Private intptVUsr AS Integer
Public sub new (OPTIONAL Byval id as Integer = 0)
intPTID = id
clPTETID = New clstblEenheidType
strptCode = ""
strptOms = ""
dblptFactor = 0
datptIDat = "24/01/1930"
datptUDat = "24/01/1930"
datptVDat = "24/01/1930"
intptIUsr = 0
intptUUsr = 0
intptVUsr = 0
End Sub

Public READONLY Property ClassName() as String
Get
Return "clstblPrijsType"
End Get
End Property

Public Property ID() as Integer
Get
Return intPTID
End Get
Set(ByVal Value As Integer)
intPTID = Value
End Set
End Property

Public Property cPTETID() as clstblEenheidType
Get
Return clPTETID
End Get
Set(ByVal Value As clstblEenheidType)
clPTETID = Value
End Set
End Property

Public Property ptCode() as String
Get
Return strptCode
End Get
Set(ByVal Value As String)
strptCode = Value
End Set
End Property

Public Property ptOms() as String
Get
Return strptOms
End Get
Set(ByVal Value As String)
strptOms = Value
End Set
End Property

Public Property ptFactor() as Double
Get
Return dblptFactor
End Get
Set(ByVal Value As Double)
dblptFactor = Value
End Set
End Property

Public Property ptIDat() as DateTime
Get
Return datptIDat
End Get
Set(ByVal Value As DateTime)
datptIDat = Value
End Set
End Property

Public Property ptUDat() as DateTime
Get
Return datptUDat
End Get
Set(ByVal Value As DateTime)
datptUDat = Value
End Set
End Property

Public Property ptVDat() as DateTime
Get
Return datptVDat
End Get
Set(ByVal Value As DateTime)
datptVDat = Value
End Set
End Property

Public Property ptIUsr() as Integer
Get
Return intptIUsr
End Get
Set(ByVal Value As Integer)
intptIUsr = Value
End Set
End Property

Public Property ptUUsr() as Integer
Get
Return intptUUsr
End Get
Set(ByVal Value As Integer)
intptUUsr = Value
End Set
End Property

Public Property ptVUsr() as Integer
Get
Return intptVUsr
End Get
Set(ByVal Value As Integer)
intptVUsr = Value
End Set
End Property


'Call insert sp
Public Function SaveNew() as Boolean
Dim arParms() as system.Data.SqlClient.SqlParameter = new
system.Data.SqlClient.SqlParameter(10) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@ID", SqlDbType.bigint)
arParms(0).Direction = ParameterDirection.Output
arParms(1) = new system.Data.SqlClient.sqlParameter("@ptETID",
SqlDbType.int)
arParms(1).Value = clPTETID.ID
arParms(2) = new system.Data.SqlClient.sqlParameter("@ptCode",
SqlDbType.varchar, 50)
arParms(2).Value = strptCode
arParms(3) = new system.Data.SqlClient.sqlParameter("@ptOms",
SqlDbType.varchar, 200)
arParms(3).Value = strptOms
arParms(4) = new system.Data.SqlClient.sqlParameter("@ptFactor",
SqlDbType.float)
arParms(4).Value = dblptFactor
arParms(5) = new system.Data.SqlClient.sqlParameter("@ptIDat",
SqlDbType.datetime)
arParms(5).Value = datptIDat
arParms(6) = new system.Data.SqlClient.sqlParameter("@ptUDat",
SqlDbType.datetime)
arParms(6).Value = datptUDat
arParms(7) = new system.Data.SqlClient.sqlParameter("@ptVDat",
SqlDbType.datetime)
arParms(7).Value = datptVDat
arParms(8) = new system.Data.SqlClient.sqlParameter("@ptIUsr",
SqlDbType.int)
arParms(8).Value = intptIUsr
arParms(9) = new system.Data.SqlClient.sqlParameter("@ptUUsr",
SqlDbType.int)
arParms(9).Value = intptUUsr
arParms(10) = new system.Data.SqlClient.sqlParameter("@ptVUsr",
SqlDbType.int)
arParms(10).Value = intptVUsr
Try
SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.StoredProcedure,
"spInserttblPrijsType", arParms)
intPTID = arParms(0).value
Return True
Catch ex as exception
MessageBox.Show("Error in clstblPrijsType.savenew " & ex.message,"error in
insert", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function

'Call update sp
Public Function SaveUpdate() as Boolean
'Id can't be 0
If Not intPTID = 0 then
Dim arParms() as system.Data.SqlClient.SqlParameter = new
system.Data.SqlClient.SqlParameter(6) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@PTID", SqlDbType.int)
arParms(0).Value = intPTID
arParms(1) = new system.Data.SqlClient.sqlParameter("@ptETID",
SqlDbType.int)
arParms(1).Value = clPTETID.ID
arParms(2) = new system.Data.SqlClient.sqlParameter("@ptCode",
SqlDbType.varchar, 50)
arParms(2).Value = strptCode
arParms(3) = new system.Data.SqlClient.sqlParameter("@ptOms",
SqlDbType.varchar, 200)
arParms(3).Value = strptOms
arParms(4) = new system.Data.SqlClient.sqlParameter("@ptFactor",
SqlDbType.float)
arParms(4).Value = dblptFactor
arParms(5) = new system.Data.SqlClient.sqlParameter("@ptUDat",
SqlDbType.datetime)
arParms(5).Value = datptUDat
arParms(6) = new system.Data.SqlClient.sqlParameter("@ptUUsr",
SqlDbType.int)
arParms(6).Value = intptUUsr
Try
SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.StoredProcedure,
"spUpdatetblPrijsType", arParms)
Return True
Catch ex as exception
MessageBox.Show("Error in clstblPrijsType.saveUpdate " & ex.message,"error
in update", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End If
End Function

'Call updateV sp
Public Function SaveUpdateV() as Boolean
'Id can't be 0
If Not intPTID = 0 then
Dim arParms() as system.Data.SqlClient.SqlParameter = new
system.Data.SqlClient.SqlParameter(2) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@PTID", SqlDbType.int)
arParms(0).Value = intPTID
arParms(1) = new system.Data.SqlClient.sqlParameter("@ptVDat",
SqlDbType.datetime)
arParms(1).Value = datptVDat
arParms(2) = new system.Data.SqlClient.sqlParameter("@ptVUsr",
SqlDbType.int)
arParms(2).Value = intptVUsr
Try
SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.StoredProcedure,
"spUpdateVtblPrijsType", arParms)
Return True
Catch ex as exception
MessageBox.Show("Error in clstblPrijsType.saveUpdate " & ex.message,"error
in updateV", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End If
End Function

'call spSelIDtblPrijsType
Public Function Opzoeken(Optional zoekID as Integer = 0) as Boolean
'Id can't be 0
If Not zoekID = 0 then
intPTID = zoekID
ElseIf intPTID = 0 Then
Return False
Exit function
End If
Dim arParms() as system.Data.SqlClient.SqlParameter = new
system.Data.SqlClient.SqlParameter(11) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@PTID", SqlDbType.int)
arParms(0).Value = intPTID
arParms(1) = new system.Data.SqlClient.sqlParameter("@exists",
SqlDbType.Int)
arParms(1).Direction = ParameterDirection.Output
arParms(2) = new system.Data.SqlClient.sqlParameter("@ptETID",
SqlDbType.int)
arParms(2).Direction = ParameterDirection.Output
arParms(3) = new system.Data.SqlClient.sqlParameter("@ptCode",
SqlDbType.varchar, 50)
arParms(3).Direction = ParameterDirection.Output
arParms(4) = new system.Data.SqlClient.sqlParameter("@ptOms",
SqlDbType.varchar, 200)
arParms(4).Direction = ParameterDirection.Output
arParms(5) = new system.Data.SqlClient.sqlParameter("@ptFactor",
SqlDbType.float)
arParms(5).Direction = ParameterDirection.Output
arParms(6) = new system.Data.SqlClient.sqlParameter("@ptIDat",
SqlDbType.datetime)
arParms(6).Direction = ParameterDirection.Output
arParms(7) = new system.Data.SqlClient.sqlParameter("@ptUDat",
SqlDbType.datetime)
arParms(7).Direction = ParameterDirection.Output
arParms(8) = new system.Data.SqlClient.sqlParameter("@ptVDat",
SqlDbType.datetime)
arParms(8).Direction = ParameterDirection.Output
arParms(9) = new system.Data.SqlClient.sqlParameter("@ptIUsr",
SqlDbType.int)
arParms(9).Direction = ParameterDirection.Output
arParms(10) = new system.Data.SqlClient.sqlParameter("@ptUUsr",
SqlDbType.int)
arParms(10).Direction = ParameterDirection.Output
arParms(11) = new system.Data.SqlClient.sqlParameter("@ptVUsr",
SqlDbType.int)
arParms(11).Direction = ParameterDirection.Output
Try
SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.StoredProcedure,
"spSelIDtblPrijsType", arParms)

if arparms(1).value = 1 Then
clPTETID.ID = CInt(arParms(2).value)
clPTETID.Opzoeken()
strptCode = CStr(arParms(3).value)
strptOms = CStr(arParms(4).value)
dblptFactor = CDbl(arParms(5).value)
datptIDat = CDate(arParms(6).value)
datptUDat = CDate(arParms(7).value)
datptVDat = CDate(arParms(8).value)
intptIUsr = CInt(arParms(9).value)
intptUUsr = CInt(arParms(10).value)
intptVUsr = CInt(arParms(11).value)

Return True
Else
Return False
End If
Return True

Catch ex as exception
MessageBox.Show("Error in clstblPrijsType.Opzoeken " & ex.message,"error in
opzoek", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function

'call spSelIDNoClasstblPrijsType
Public Function OpzoekenNoClass(Optional zoekID as Integer = 0) as Boolean
'Id can't be 0
If Not zoekID = 0 then
intPTID = zoekID
ElseIf intPTID = 0 Then
Return False
Exit function
End If
Dim arParms() as system.Data.SqlClient.SqlParameter = new
system.Data.SqlClient.SqlParameter(11) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@PTID", SqlDbType.int)
arParms(0).Value = intPTID
arParms(1) = new system.Data.SqlClient.sqlParameter("@exists",
SqlDbType.Int)
arParms(1).Direction = ParameterDirection.Output
arParms(2) = new system.Data.SqlClient.sqlParameter("@ptETID",
SqlDbType.int)
arParms(2).Direction = ParameterDirection.Output
arParms(3) = new system.Data.SqlClient.sqlParameter("@ptCode",
SqlDbType.varchar, 50)
arParms(3).Direction = ParameterDirection.Output
arParms(4) = new system.Data.SqlClient.sqlParameter("@ptOms",
SqlDbType.varchar, 200)
arParms(4).Direction = ParameterDirection.Output
arParms(5) = new system.Data.SqlClient.sqlParameter("@ptFactor",
SqlDbType.float)
arParms(5).Direction = ParameterDirection.Output
arParms(6) = new system.Data.SqlClient.sqlParameter("@ptIDat",
SqlDbType.datetime)
arParms(6).Direction = ParameterDirection.Output
arParms(7) = new system.Data.SqlClient.sqlParameter("@ptUDat",
SqlDbType.datetime)
arParms(7).Direction = ParameterDirection.Output
arParms(8) = new system.Data.SqlClient.sqlParameter("@ptVDat",
SqlDbType.datetime)
arParms(8).Direction = ParameterDirection.Output
arParms(9) = new system.Data.SqlClient.sqlParameter("@ptIUsr",
SqlDbType.int)
arParms(9).Direction = ParameterDirection.Output
arParms(10) = new system.Data.SqlClient.sqlParameter("@ptUUsr",
SqlDbType.int)
arParms(10).Direction = ParameterDirection.Output
arParms(11) = new system.Data.SqlClient.sqlParameter("@ptVUsr",
SqlDbType.int)
arParms(11).Direction = ParameterDirection.Output
Try
SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.StoredProcedure,
"spSelIDtblPrijsType", arParms)

if arparms(1).value = 1 Then
clPTETID.ID = CInt(arParms(2).value)
strptCode = CStr(arParms(3).value)
strptOms = CStr(arParms(4).value)
dblptFactor = CDbl(arParms(5).value)
datptIDat = CDate(arParms(6).value)
datptUDat = CDate(arParms(7).value)
datptVDat = CDate(arParms(8).value)
intptIUsr = CInt(arParms(9).value)
intptUUsr = CInt(arParms(10).value)
intptVUsr = CInt(arParms(11).value)

Return True
Else
Return False
End If
Return True

Catch ex as exception
MessageBox.Show("Error in clstblPrijsType.Opzoeken " & ex.message,"error in
opzoek", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function

Public sub Wis()
intPTID= 0
clPTETID = New clstblEenheidType
strptCode = ""
strptOms = ""
dblptFactor = 0
datptIDat = "24/01/1930"
datptUDat = "24/01/1930"
datptVDat = "24/01/1930"
intptIUsr = 0
intptUUsr = 0
intptVUsr = 0
End Sub

Public Function DeleteRec() as Boolean
Try
Dim strSql as string
strSql = "DELETE FROM tblPrijsType WHERE PTID = " & intPTID.ToString

SqlHelper.ExecuteNonQuery(gstrCnn, CommandType.Text, strSql)
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class


'class clsPrijsType
'Put your own stuff here
<Serializable()> Public Class clsPrijsType
Inherits clstblPrijsType
Public sub new (OPTIONAL Byval id as Integer = 0)
'call to parent constructor
MyBase.New(id)
End Sub
Public Overloads READONLY Property ClassName() as String
Get
Return "clsPrijsType"
End Get
End Property
End Class

'class clsColltblPrijsType

<Serializable()> Public Class clsColltblPrijsType
Inherits System.collections.collectionBase
Public READONLY Property ClassName() as String
Get
Return "clsColltblPrijsType"
End Get
End Property

Public Function FilterPrijsType(Optional ByVal intptETID AS Integer = 0,
Optional Byval blnintptETID AS Boolean = False, Optional ByVal strptCode AS
String = "", Optional Byval blnstrptCode AS Boolean = False, Optional ByVal
strptOms AS String = "", Optional Byval blnstrptOms AS Boolean = False,
Optional ByVal dblptFactor AS Double = 0, Optional Byval blndblptFactor AS
Boolean = False, Optional ByVal datptIDat AS String = "24/01/1930", Optional
Byval blndatptIDat AS Boolean = False, Optional ByVal datptUDat AS String =
"24/01/1930", Optional Byval blndatptUDat AS Boolean = False, Optional ByVal
datptVDat AS String = "24/01/1930", Optional Byval blndatptVDat AS Boolean =
False, Optional ByVal intptIUsr AS Integer = 0, Optional Byval blnintptIUsr
AS Boolean = False, Optional ByVal intptUUsr AS Integer = 0, Optional Byval
blnintptUUsr AS Boolean = False, Optional ByVal intptVUsr AS Integer = 0,
Optional Byval blnintptVUsr AS Boolean = False) as DataSet

Dim arParms() as SqlParameter = New SqlParameter(19) {}

arParms(0) = new system.Data.SqlClient.sqlParameter("@ptETID",
SqlDbType.int)
arParms(0).Value = intptETID
arParms(1) = new system.Data.SqlClient.sqlParameter("@blnptETID",
SqlDbType.bit)
arParms(1).Value = blnintptETID

arParms(2) = new system.Data.SqlClient.sqlParameter("@ptCode",
SqlDbType.varchar, 50)
arParms(2).Value = strptCode
arParms(3) = new system.Data.SqlClient.sqlParameter("@blnptCode",
SqlDbType.bit)
arParms(3).Value = blnstrptCode

arParms(4) = new system.Data.SqlClient.sqlParameter("@ptOms",
SqlDbType.varchar, 200)
arParms(4).Value = strptOms
arParms(5) = new system.Data.SqlClient.sqlParameter("@blnptOms",
SqlDbType.bit)
arParms(5).Value = blnstrptOms

arParms(6) = new system.Data.SqlClient.sqlParameter("@ptFactor",
SqlDbType.float)
arParms(6).Value = dblptFactor
arParms(7) = new system.Data.SqlClient.sqlParameter("@blnptFactor",
SqlDbType.bit)
arParms(7).Value = blndblptFactor

arParms(8) = new system.Data.SqlClient.sqlParameter("@ptIDat",
SqlDbType.datetime)
arParms(8).Value = datptIDat
arParms(9) = new system.Data.SqlClient.sqlParameter("@blnptIDat",
SqlDbType.bit)
arParms(9).Value = blndatptIDat

arParms(10) = new system.Data.SqlClient.sqlParameter("@ptUDat",
SqlDbType.datetime)
arParms(10).Value = datptUDat
arParms(11) = new system.Data.SqlClient.sqlParameter("@blnptUDat",
SqlDbType.bit)
arParms(11).Value = blndatptUDat

arParms(12) = new system.Data.SqlClient.sqlParameter("@ptVDat",
SqlDbType.datetime)
arParms(12).Value = datptVDat
arParms(13) = new system.Data.SqlClient.sqlParameter("@blnptVDat",
SqlDbType.bit)
arParms(13).Value = blndatptVDat

arParms(14) = new system.Data.SqlClient.sqlParameter("@ptIUsr",
SqlDbType.int)
arParms(14).Value = intptIUsr
arParms(15) = new system.Data.SqlClient.sqlParameter("@blnptIUsr",
SqlDbType.bit)
arParms(15).Value = blnintptIUsr

arParms(16) = new system.Data.SqlClient.sqlParameter("@ptUUsr",
SqlDbType.int)
arParms(16).Value = intptUUsr
arParms(17) = new system.Data.SqlClient.sqlParameter("@blnptUUsr",
SqlDbType.bit)
arParms(17).Value = blnintptUUsr

arParms(18) = new system.Data.SqlClient.sqlParameter("@ptVUsr",
SqlDbType.int)
arParms(18).Value = intptVUsr
arParms(19) = new system.Data.SqlClient.sqlParameter("@blnptVUsr",
SqlDbType.bit)
arParms(19).Value = blnintptVUsr

Return SqlHelper.ExecuteDataset(gstrCnn, CommandType.StoredProcedure,
"spFilterColltblPrijsType", arParms)

End Function
Default Public Property Item(Byval index as Integer) as clsPrijsType
Get
Return Ctype(list(index), clsPrijsType)
End Get
Set(ByVal Value As clsPrijsType)
list(index) = Value
End Set
End Property

Public Function VulCollectie(Byval dsData As Dataset) As clsColltblPrijsType
Dim zelf as New clsColltblPrijsType
Dim dr as DataRow
Dim el as New clsPrijsType

For each dr in dsData.Tables(0).rows
el = new clsPrijsType
el.ID = CInt(dr(0))
el.cptETID.ID = CInt(dr(1))
el.ptCode = CStr(dr(2))
el.ptOms = CStr(dr(3))
el.ptFactor = CDbl(dr(4))
el.ptIDat = CDate(dr(5))
el.ptUDat = CDate(dr(6))
el.ptVDat = CDate(dr(7))
el.ptIUsr = CInt(dr(8))
el.ptUUsr = CInt(dr(9))
el.ptVUsr = CInt(dr(10))
zelf.List.Add(el)
Next
Return zelf
End Function

Public Sub Insert(ByVal index as Integer, Byval value As clsPrijsType)
list.Insert(index, value)
End Sub

Public Function Insert(Byval value As clsPrijsType) As Integer
Return list.Add(value)
End Function

Public Sub Remove(Byval value As clsPrijsType)
list.Remove(value)
End Sub

Public Function Contains(Byval value As clsPrijsType) As Boolean
Return list.Contains(value)
End Function

Public Function IndexOf(Byval value As clsPrijsType) As Integer
Return list.IndexOf(value)
End Function
End Class



"Ken H" <an*******@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hi I have a question about architecting solutions...

I have a part of a project which requires me to track person details (name, addresses, etc...) Should I be creating Person objects, Address objects etc as Business layer classes and then have an data access layer which actually save / updates /
delete to and from the DB...
If so, and bearing in mind the 'easiest' way to pass data between the layers would be with a dataset - should my BL classes take dataset results
from the DAL and convert into class objects ??
E.g.

BL Person - Persist method calls DAL Person - persist method (which actually saves the data to the underlying DB). In the BL Person should the persist method first convert its own object into a dataset and send that to the DAL persist method...
Also...

BL Persons (collection) GetBypostcode method - calls DAL GetPersonsByPostcode method - should the DAL method return a dataset and
then the BL method converts that into a collection of Person objects for use
by the UI layer...

Any thought, comments or experience would be appreciated...
.. Ken

Nov 20 '05 #2

P: n/a

"Ken H" <an*******@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hi I have a question about architecting solutions...

I have a part of a project which requires me to track person details (name, addresses, etc...) Should I be creating Person objects, Address objects etc as Business layer classes and then have an data access layer which actually save / updates /
delete to and from the DB...
If so, and bearing in mind the 'easiest' way to pass data between the layers would be with a dataset - should my BL classes take dataset results
from the DAL and convert into class objects ??
E.g.

BL Person - Persist method calls DAL Person - persist method (which actually saves the data to the underlying DB). In the BL Person should the persist method first convert its own object into a dataset and send that to the DAL persist method...
Also...

BL Persons (collection) GetBypostcode method - calls DAL GetPersonsByPostcode method - should the DAL method return a dataset and
then the BL method converts that into a collection of Person objects for use
by the UI layer...

Any thought, comments or experience would be appreciated...
.. Ken


Ken,

This is a massive subject. However, I had similar questions to you and I got
a copy of Rockford Lhotka's book, Visual Basic .NET Business Objects
(Apress). Now, he develops his own architecture, CSLA, throughout the book.
I haven't implemented this in entirety, as I found it was one thing building
it all the tough part was explaining the concepts to colleagues. What I did
do was take parts I considered useful adn this has worked fabulously for me
and my projects.

I recommend this book most definately as it is an excellent starting point
for those with OO architecture experience wanting to get savvy with the same
concepts in .NET.

HTH

AT
Nov 20 '05 #3

P: n/a
AntiTrust

Thanks for the comments - the issue i have is that in VB6 it all seemed to make sense now with .Net people are going on about linking datasets to UI components (grids etc) so are we moving to 2 tier (or 3 tier with UI, DAL and DataStore) or do we still need a Bus Layer. If the latter then how to make best use of ability of datasets to move data between layers...

or.

Should I just stick with my normal method calls between layers and ignore the advantages of datasets (i.e. having to change both layers for adding a new attribute to an object..

... Ke

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.