i made the DB , now i need to build the application
-
hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz
-
hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz
-
thanks i'll try it but if anyone have more ...
-
man that wasn't what i need sory man i want a tutorial to make the classes then to make the BLL then how to make objects to use in the windows application -interface thanks
-
hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz
You want to know how to write the entire application ? Do you know VB.NET at all ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
You want to know how to write the entire application ? Do you know VB.NET at all ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
sure man i know vb.net and i wrote applications before but they weren't very good from the point of view seperation on layers and i read that i should seperate Data layer - sql : i know it very well data access layer bussniess logic layer presentation - vb.net : i know it very well so i need to know how to pass from data layer to DAL to BLL then in the application if i use classe for each table or something like that... how to make instances ... before i craete a dataset for each class and if i call the select methode of the classe, where i wrote the call of the stored procedure, i put the rows in this dataset ... so i feel that this isn't what they mean by DAL or BLL thanks
-
sure man i know vb.net and i wrote applications before but they weren't very good from the point of view seperation on layers and i read that i should seperate Data layer - sql : i know it very well data access layer bussniess logic layer presentation - vb.net : i know it very well so i need to know how to pass from data layer to DAL to BLL then in the application if i use classe for each table or something like that... how to make instances ... before i craete a dataset for each class and if i call the select methode of the classe, where i wrote the call of the stored procedure, i put the rows in this dataset ... so i feel that this isn't what they mean by DAL or BLL thanks
OK, now we've narrowed down the question. The DAL should contain only code for accessing the database. It should expose methods that don't reveal anything about where the data comes from, such as List SearchForEntityObjects(string search). The business layer contains all the classes that create objects and enforce rules about how the app behaves. The Presentation layer should really only present UI and call business layer objects to do the behind the scenes work. If it us to do with UI, it belongs in the presentation layer. If it's to do with data access, it belongs in the DAL. The rest goes in the middle tier. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
OK, now we've narrowed down the question. The DAL should contain only code for accessing the database. It should expose methods that don't reveal anything about where the data comes from, such as List SearchForEntityObjects(string search). The business layer contains all the classes that create objects and enforce rules about how the app behaves. The Presentation layer should really only present UI and call business layer objects to do the behind the scenes work. If it us to do with UI, it belongs in the presentation layer. If it's to do with data access, it belongs in the DAL. The rest goes in the middle tier. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
ok man thanks for help so the question is ... how to make them ... i have 6-7 tables ... i know alittle UML ... so i can know the classes to made but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,... these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ? if that is right ... what's the BLL ... thanks 4 the help man
-
ok man thanks for help so the question is ... how to make them ... i have 6-7 tables ... i know alittle UML ... so i can know the classes to made but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,... these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ? if that is right ... what's the BLL ... thanks 4 the help man
Lord Hasan wrote:
know alittle UML
You're ahead of me, I know none...
Lord Hasan wrote:
but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,...
I'd create a datalayer class for each object that calls it, so if you have a Person class, have a PersonDataLayer class. This class will return and accept Person objects, and each method exposed will map to a stored proc.
Lord Hasan wrote:
these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ?
You can return datasets, or you can return entity objects. Returning entity objects is prettier, but on complex systems, in the absence of friend classes, can make keeping things OO a little difficult. Either way will work fine.
Lord Hasan wrote:
if that is right ... what's the BLL ...
Business rules. Entity classes. For example, if you have a Person class, and a Person has a Role property, the database would return the Role, and set the Role in the DB. The BLL would decide when the Role changed, and what it changed to. The Person class would be in the business layer. The data access would be calls from the person class to the persondatalayer class. The way that a Person looked on the screen, would be the presentation layer. If you clicked on a button that said 'set rol to Admin', the presentation layer would create an instance of the Person class, and call a method to set the Role, which would then call the data layer, so your code has moved through the three layers, each has it's area of responsibility.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Lord Hasan wrote:
know alittle UML
You're ahead of me, I know none...
Lord Hasan wrote:
but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,...
I'd create a datalayer class for each object that calls it, so if you have a Person class, have a PersonDataLayer class. This class will return and accept Person objects, and each method exposed will map to a stored proc.
Lord Hasan wrote:
these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ?
You can return datasets, or you can return entity objects. Returning entity objects is prettier, but on complex systems, in the absence of friend classes, can make keeping things OO a little difficult. Either way will work fine.
Lord Hasan wrote:
if that is right ... what's the BLL ...
Business rules. Entity classes. For example, if you have a Person class, and a Person has a Role property, the database would return the Role, and set the Role in the DB. The BLL would decide when the Role changed, and what it changed to. The Person class would be in the business layer. The data access would be calls from the person class to the persondatalayer class. The way that a Person looked on the screen, would be the presentation layer. If you clicked on a button that said 'set rol to Admin', the presentation layer would create an instance of the Person class, and call a method to set the Role, which would then call the data layer, so your code has moved through the three layers, each has it's area of responsibility.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
so i create classes then for each class i made a datalayerclasse then in the application i make instances frome the classes not from their datalayer calsses example class persone id as integer name as string age as integer ap as appartment public function get_person(i as integer) as persone dim p as personedatalayer return p.getdataperson(i) end function and class personedatalayer public function get_getdataperson(i as integer) as persone dim ds as new dataset con.open() .... calling stored procedure con.close() return ds.tables(0).row(0) end function is this right ? if it's right so how to return a set of persons ?
-
so i create classes then for each class i made a datalayerclasse then in the application i make instances frome the classes not from their datalayer calsses example class persone id as integer name as string age as integer ap as appartment public function get_person(i as integer) as persone dim p as personedatalayer return p.getdataperson(i) end function and class personedatalayer public function get_getdataperson(i as integer) as persone dim ds as new dataset con.open() .... calling stored procedure con.close() return ds.tables(0).row(0) end function is this right ? if it's right so how to return a set of persons ?
Lord Hasan wrote:
return ds.tables(0).row(0)
That's not going to work. You need to create a new Persone instance and populate it, either with properties or a constructor.
Lord Hasan wrote:
dim p as personedatalayer
You also need to call 'new'. I'd just make the methods static ( shared ). A 'get person' method would also be shared. You don't need to create a person to create a person, that makes no sense.
Lord Hasan wrote:
so how to return a set of persons ?
Well, your code can do one of two things. 1 - populate a persone instance in the datalayer from the datarow 2 - return the datarow and have your object populate itself from that. I lean towards 2, as 1 tends to break encapsulation, in my experience. There are other ways to go about it, but broadly, that's what will have to happen.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Lord Hasan wrote:
return ds.tables(0).row(0)
That's not going to work. You need to create a new Persone instance and populate it, either with properties or a constructor.
Lord Hasan wrote:
dim p as personedatalayer
You also need to call 'new'. I'd just make the methods static ( shared ). A 'get person' method would also be shared. You don't need to create a person to create a person, that makes no sense.
Lord Hasan wrote:
so how to return a set of persons ?
Well, your code can do one of two things. 1 - populate a persone instance in the datalayer from the datarow 2 - return the datarow and have your object populate itself from that. I lean towards 2, as 1 tends to break encapsulation, in my experience. There are other ways to go about it, but broadly, that's what will have to happen.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC
-
hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC
sory that wasn't work in the buton the array should be static and this is a problem
-
hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC
Lord Hasan wrote:
.Numero = MyDataSet.Tables(0).Rows(i)(0) .ArrivageDate = MyDataSet.Tables(0).Rows(i)(1)
You should grab columns by name, not by index.
Lord Hasan wrote:
but now i feel that the class dossier isn't important it just call the dossierdatalayer class so what's its importance
Well, it depends. This is really a struct right now, but over time, most business layer classes will have methods that do mmore than just call data access methods. They will also contain business rules, such as deciding what state an object is in ( which the data layer will then save ).
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Lord Hasan wrote:
.Numero = MyDataSet.Tables(0).Rows(i)(0) .ArrivageDate = MyDataSet.Tables(0).Rows(i)(1)
You should grab columns by name, not by index.
Lord Hasan wrote:
but now i feel that the class dossier isn't important it just call the dossierdatalayer class so what's its importance
Well, it depends. This is really a struct right now, but over time, most business layer classes will have methods that do mmore than just call data access methods. They will also contain business rules, such as deciding what state an object is in ( which the data layer will then save ).
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
so what i did is the correct structure of an n-tier application Data layer DAL BLL Presentation layer so thanks for the help ... u r gr8 man
-
so what i did is the correct structure of an n-tier application Data layer DAL BLL Presentation layer so thanks for the help ... u r gr8 man
hello again man we have now a new problem with this structure i'm doing that but the application became so slow !! espacilly by filling listviews and combos WHY we don't use ADO.NET things, like data sets and bind them in a listview !!! i'm comfused !!!
" I love deadlines. I like the whooshing sound they make as they fly by. "