Message based system with datagrids

  • Thread starter Thread starter msnews.microsoft.com
  • Start date Start date
M

msnews.microsoft.com

I am new to C# (coming from java) and I am confused about how to properly
work with datagrids.

The application I am working on is a message based system where properties
aren't changed in direct response to edits on the front end.

For example, setting the status of an order from active to pause would
result in a EditOrderStatusMessage being sent from the FE to the BE
requesting the desired status change. Only after we the message from the BE
is received with the new status should the property on the FE changed and
all the controls notified.

But I have NO CLUE how I would go about doing something like this with a
datagrid. Since I have bound the grid to the status, when I change the
status in the grid, I also change the status in the object, which then
results in the controls being notified ... but they shouldn't be notified
till the BE says so.

Since I am obviously not the first person to hit this, I was wondering how
others might have solved this problem.
 
In the Setter for the "status" property make a call to the BE and when the
call returns only then should you set the value in the object

public OrderStatus Status
{
set
{
BE.SetStatus(value);
_status = value;
}

get
{
return _status;
}
}
 
Hi,

You can do it this way:

1) Create a custom DataGridColumnStyle containing buttons. Each button would
read "Pause Order" or something similar.
2) At the same time, create a read-only column of combo boxes indicating
actual order status.
3) When one of the buttons is clicked, send a message to BE but don't do any
status updates to the datasource bound to the grid
4) When you receive the response from the BE, update the corresponding order
status in the bound datasource. The grid should now reflect the new status.
 
The question seems very simple, how might I go about creating a business
object in C# with bound controls for an async message based system.

On of the nice aspects of a business object and localizing all the logic for
validation / updates in a single object is that it lightens the load for the
UI deveoper not to have to worry about such issues.

So, for example, lets say that an Order that isn't an odd lot can't be
submitted to the BE. Ideally I would want to bind the Size property to a
sizeTextBox and an IsValid property to the submitButton. This way, if any
rules are broken (and the size is not % 100) the send button won't enable.

This provides real nice encapsulation. But on the flip side, setting the
Size in the object will ALSO notify all the bound controls of the new size.
That is undesirable. Becasue, for example, if there was an order blotter, I
wouldn't want it to update also.

The problem becomes more difficult when you think about the following
situation ... an order with a size of 100,000. I open the order entry screen
and change the size to 50,000. Then, while I am editing the object, the
order size (lets say from a different trader) is changed to 200,000. If I
had the order blotter open, I should see that change (and prob be notified
in the order entry screen that the size chagned, but that is a different
story.)

So while I agree that the buiness object approach is a great way to go, I am
having difficulty resolving issues like the one mentioned above.

So ... was wondering if anyone else has worked on such problems ...
 
Back
Top