BO as parameter


Author
Message
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
You are welcome, Tiong.

I am really happy you got it working. Cool

Tiong Diu King
Tiong Diu King
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: Forum Members
Posts: 28, Visits: 70
Hi Ivan,



I wanna thanks for your help again and again. Your sample is work great...
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Download the sample from the following link and have a look at the Base BO concept. This way you won't have to repeat this kind of code.

http://forum.strataframe.net/FindPost27794.aspx

Tiong Diu King
Tiong Diu King
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: Forum Members
Posts: 28, Visits: 70
Hi Edhy,



your method is doing the code at BO. I don't want the code doing at BO because if i have 50 BO then i need do it 50 times. I want only 2 function there are

1) pass BO's name and primary key then function return me code

2) pass BO's name and code then function return me primary key



Please advice...







Hi Ivan,



I did declare the BO as As MicroFour.StrataFrame.Business.BusinessLayer but it doesn't work.

when i create new instance of the BO with the parameter BO but there is the error code

etc: Dim loBO As BO_Library.BO



Please advice...
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Tiong.

Also, regarding having your BO as a function parameter, follow this link to get an idea:

http://forum.strataframe.net/FindPost28016.aspx

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Tiong,



There are many ways to do this depending on what you really want. If you want to use this function from several places then you don't have to fill the BO you can run an scalar method to get that particular field value for lcCode. Take a look at the help file, there are sample code almost all over, also the forum have a ton of experiences with many code samples too.



Keep in mind that your BO class is also the place to add functions and methods that apply to the BO or anything you want and that will also make it easier for you to access those functions and methods. So let's say you need to get the cCode field from the Employee BO, you would create a method in the BO class to return that field, something like this:



Public Function get_code_from_key(ByVal PKValue As Integer) As String

Using cmd As New SqlCommand()

'-- Build the command

cmd.CommandType = CommandType.Text

cmd.CommandText = "SELECT Employee.Code FROM Employee WHERE EmployeePK = @EmployeePKValue"



'-- Create and set the parameters

cmd.Parameters.AddWithValue("@EmployeePKValue", PKValue).SqlDbType = SqlDbType.Int



'-- Execute the query and return the value

Return CType(Me.ExecuteScalar(cmd), String)

End Using

End Function





By adding above function to the BO, you can now call it from any instance of the BO being use like this:



Dim loBo as New BO_Library.EmployeeBO

Dim lcCode as String = loBO.get_code_from_key(Your PK Value)





Still that is not foolproof, there are several things to be enhanced, like checking for DBNull, etc., but I leave that as a homework for you BigGrin Hint: there are plenty of samples on this in the forums.

Edhy Rijo

Tiong Diu King
Tiong Diu King
StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)StrataFrame Beginner (30 reputation)
Group: Forum Members
Posts: 28, Visits: 70
Hi all,



public sub get_code_from_key()

Dim loBO = New BO_Library.employee

loBO.FillByPrimaryKey(4)

Dim lcCode As String = loBO.CurrentRow(1)

End sub



Above sub module is work. How do i convert into function and parameter BO's name is passing?





public function get_code_from_key(byval BO as ???, byval key as integer)

Dim loBO = New BO_Library.BO

loBO.FillByPrimaryKey(key)

Dim lcCode As String = loBO.CurrentRow(1)

Return lcCode

End function





** My collection of BO is under assembly BO_Library





Please help...
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search