Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you specfiy Business Entity to use within the BO?
Message
From
08/04/2008 11:34:04
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
08/04/2008 11:07:29
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01308629
Message ID:
01309026
Views:
15
Hi Matt,

You are getting close.

>Maybe I'm getting there...I get having GetCustomerNameList() *AND* GetCustomerByNumber(int custNo) both as methods in the same BO.
>
>(Let me also point out that GetCustomerNameList() is design to return a list of *ONLY* customers that currently have an active job (it does this by calling GetEntityList on a stored proc))
>
>
>Therefore, is this a strategic approach:
>
>In my form, would I then create two separate objects, with each one being based on the Customer BO like this:
>
>//-- Declare Objects
> private Customer CustomerList; ( EntityList)
> private Customer CustomerDetails; (an Entity)
>
>//-- Instantiate
> this.CustomerList = (Customer)this.RegisterBizObj(new Customer());
> this.CustomerDetails = (Customer)this.RegisterBizObj(new Customer());
>
>//-- Populate
> this.CustomerList.GetCustomerNameList();
>
>
> //on the SelectionChanged() event of the Customer grid:
> this.CustomerDetails.GetCustomerByNumber(cust_no_from_grid);
>
>

I would not really advocate initializing two instances of the BO this way. I tried to return an EntityList and then also an individual record and according to Kevin you can do this. The problem I had was when I returned the individual record, it stepped on the list. Here is what I did in a similar situation. And since your list is not what you update (static) than you could do this pretty easy also.
private Customer oCustomer;
private DataSet dsCustomerList;

// Register the biz obj with the form
this.oCustomer = (Customer)this.RegisterBizObj(new Customer());
// Get the customer list dataset and bind it to the grid
this.dsCustomerList = this.oCustomer.GetdsCustomerList();
if (this.dsCustomerList.Tables[0].Rows.Count > 0)
{
     this.grdCustomer.DataSource = dsCustomerList;
     this.grdCustomer.DataBind();
    // You might want to set the initial index of the grid and then call the GetCustomerByNumber
    this.grdCustomer.SelectedIndex = 0;
    this.GetSpecificCustomer(cust_no_from_grid);
}

// when the index changes, call the 
private void grdCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
     this.GetSpecificCustomer(cust_no_from_grid);
}

// Make this a seperate method in the form so you can call it from multiple places 
private void GetSpecificCustomer(int custNo)
{
    this.oCustomer.GetCustomerByNumber(custNo);
}
By just getting a dataset, you won't step on the entity when you retrieve it. I am sure Kevin (and I wish he would) show us how to do this using an entity list and another entity without stepping on each other. I couldn't do it, and this worked great for me anyway. And when the data is static, who cares.

I hope that helps, but you are getting close.
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform