Project Tracker Winform UI bug?

Project Tracker Winform UI bug?

Old forum URL: forums.lhotka.net/forums/t/282.aspx


Huw posted on Tuesday, June 06, 2006

I'm fairly new to c# and business objects and have recently downloaded the demo app and have been having a play. 

I have come across a bug in the winform ui that i can't for the life of me work out why.

I'd be grateful if anybody could give me an explanation as to why and some pointers on how to fix this.

Here's the problem:  after clicking on the "Apply" button in "Resource Edit" to save a new resource and then choosing the "assign" button, the datagridview does not update itself. If, however, I click in another field on the form e.g. Last name and make a change when i move out of this field the datagridview does indeed update itself.   I hope this sufficiently explains the odd behaviour i'm seeing.  If you need more info please just ask.  In the meantime if anybody has any ideas on this i'd really appreciate some advice.

Many thank!!

RockfordLhotka replied on Tuesday, June 06, 2006

Are you running version 2.0 or 2.0.1? There's a known issue with the Apply button code from the book, and 2.0.1 (hopefully) addressed that issue.

http://www.lhotka.net/Articles.aspx?id=6432c872-92ce-4bb8-bc26-b610b71956c8

Huw replied on Tuesday, June 06, 2006

Hi Rocky,

Thanks for the reply.

I'm running the code as downloaded from the APRESS website.  However, i have made the changes to the code as detailed in the errata and it's still not working for me.

OK, i've also just downloaded the latest 2.0.1 version from the website and i'm getting the same problem here too.  I guess it works with you?  So what am i missing?  Basically after making a change and hitting the Apply button i immediately try to assign or unassign and it won't refresh for me.

Thanks,

Huw

kids_pro replied on Tuesday, June 06, 2006

Hi Rocky,

I have similiar problem when I tried to add new project.

Step:
1. Add New Project
2. Enter project detail, assign few resource to the project
3. Click on the Apply button


If I add new project without resource it works fine.
I am using CSLA.NET 2.0.1

Please advice.
Kid

RockfordLhotka replied on Tuesday, June 06, 2006

Hi kids,

That's a totally different and unrelated problem. Your problem is that the DTC isn't enabled on your computer - or perhaps it is enabled, but you are running WinXP SP2 and haven't followed Microsoft's KB article to defeat all the new security that they put in place to block the DTC from being useful...

kids_pro replied on Tuesday, June 06, 2006

WOW, Rocky you spray the magic now it works.
Many thanks,
Kids

kids_pro replied on Tuesday, June 06, 2006

RockfordLhotka:

Hi kids,

That's a totally different and unrelated problem. Your problem is that the DTC isn't enabled on your computer - or perhaps it is enabled, but you are running WinXP SP2 and haven't followed Microsoft's KB article to defeat all the new security that they put in place to block the DTC from being useful...



Rocky, will this problem occur if I decided to use MySQL instead of SQL Server.

RockfordLhotka replied on Tuesday, June 06, 2006

The problem will occur if you tell the data portal to use anything other than Manual transactions on your DataPortal_XYZ methods. Both COM+ (Enterprise Services) and TransactionScope will use the DTC. Manual transactions typically won't use the DTC, as you are usually using ADO.NET or stored procedure transactions (or none at all).
 
Rocky


From: kids_pro [mailto:cslanet@lhotka.net]
Sent: Tuesday, June 06, 2006 11:18 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Project Tracker Winform UI bug?

RockfordLhotka:

Hi kids,

That's a totally different and unrelated problem. Your problem is that the DTC isn't enabled on your computer - or perhaps it is enabled, but you are running WinXP SP2 and haven't followed Microsoft's KB article to defeat all the new security that they put in place to block the DTC from being useful...



Rocky, will this problem occur if I decided to use MySQL instead of SQL Server.




ajj3085 replied on Wednesday, June 07, 2006

Rocky,

Transaction scope won't use DTC unless you open more than one connection within the scope.  I have DTC disabled completely on my computer to catch places where I forget to open a more persistant connection in my DAL.

At least, this is the behavior with Sql 2k5.  Sql 2k may always use DTC; I'm not sure on that.

Andy

RockfordLhotka replied on Wednesday, June 07, 2006

True, the DTC only kicks in with TransactionScope if you open a second db connection or use any database other than SQL2k5. But the question was about MySQL - and if TransactionScope works with MySQL (which I doubt very much will happen any time soon), it will likely use the DTC.
 
But your clarification is valuable, because my reply was certainly vague on this point.
 
Thx, Rocky


From: ajj3085 [mailto:cslanet@lhotka.net]
 
 Rocky,

Transaction scope won't use DTC unless you open more than one connection within the scope.  I have DTC disabled completely on my computer to catch places where I forget to open a more persistant connection in my DAL.

At least, this is the behavior with Sql 2k5.  Sql 2k may always use DTC; I'm not sure on that.

Andy

ajj3085 replied on Wednesday, June 07, 2006

Ahh,

I missed the part where the question was on MySql.

It is disappointing that the only db that doesn't use DTC is Sql Server 2k5. At the very least you'd think MS would figure out TransactoinScope without DTC and Sql Server 2k.

Andy

RockfordLhotka replied on Tuesday, June 06, 2006

Yes, I see the problem. It is interesting, and I don't know how I didn't run into this when writing Chapter 9 in the first place.

It turns out that after you re-enable the data binding events in the finally block the data isn't refreshed from the underlying data source - at least not automatically. So the controls are bound to the correct data, but that data isn't refreshed. You can solve this by adding the following line in the finally block after turning the event handling back on:

this.ResourceBindingSource.ResetCurrentItem();

It appears to be sufficient to trigger a reset on the top level binding source - but that may be due to the nature of the PTWin UI layout, so your mileage may vary... In other words, I imagine it could be the case that you need to reset all binding source objects - though that seems unlikely since you'd have to do a reset on every row for data in a grid (I would think).

RockfordLhotka replied on Tuesday, June 06, 2006

OK, to reply to my own reply, there may be a better method: ResetBindings

this.ResourceBindingSource.ResetBindings(false);

this.AssignmentsBindingSource.ResetBindings(false);

From the description of this method it appears to be the better one to use in general terms, because it triggers a refresh of any bound controls - presumably including grids, etc.

Huw replied on Wednesday, June 07, 2006

Cool, thank you very much.

Nice to know i was thinking along kinda the same lines.  I tried to implement this code prior to raising this topic here but i was putting it in the wrong place!!  I originally tried putting it in immediately after rebinding the datasources.  Oh well back to the books i guess to read up more about databinding.

Once again thank you very much for your quick response to this problem and for all your help!!!

Copyright (c) Marimer LLC