By Terry Bottorff - 1/28/2008
I fill my business object by 'Select * from cowboys order by cow_lastname, cow_firstname' and then it comes in alphabetically. But when I add a new cowboy how do I keep the data in Alpha order? The form is a SF maintenance form but the navigation keys no longer work after I add a new cowboy. ???? TIA.
|
By Greg McGuffey - 1/28/2008
Check out the Sort property on the BO.
|
By Trent L. Taylor - 1/28/2008
I would tend to agree with Greg, it sounds like you have a Sort on your BO. Check that and if that doesn't resolve your issue let us know.
|
By Terry Bottorff - 1/28/2008
OK I will and let you know.
|
By Trent L. Taylor - 1/28/2008
Or a filter....this is can be a culprit as well. Check the Sort and the Filter just in case
|
By Ivan George Borges - 1/28/2008
Hey Terry.I know it is a cowboy's table, but "cow_lastname" and "cow_firstname" sounded really funny for me... I'm Brazilian, it is not my fault to be silly like this...
|
By Terry Bottorff - 1/28/2008
We have a lot of cowboys from Brazil in Cheyenne Frontier Days, the largest out door rodeo, and they are very good.
|
By Terry Bottorff - 1/28/2008
I looked for the sort property and could not find it on either the BO in the project or the instance on the form. What am I missing? TIA
|
By Trent L. Taylor - 1/28/2008
It is a property on the BO:MyBo.Sort MyBo.Filter If you have either of these set and add a new record, you generally get the behavior you are experiencing. I would imagine that some type of filter or set is set.
|
By Terry Bottorff - 1/28/2008
I'm sorry, I am either not looking in the correct place or I am just missing the boat some how. I can not find either the sort or filter property in the property window on either the BO in the project or the instanciated BO on the form. I have sorted the properties and looked at them that way and still can not find them. What am I missing????? TIA.
|
By Terry Bottorff - 1/28/2008
After I reread the help on sorting I found out that it is set programmatically and not by the property box. I tried setting it right after I called my fillallcowboys() but now I get a couple of the records and not the others. When I go to get out of the form it asks me to save data when all I have tried to do is move around in the table. ??? TIA.
|
By StrataFrame Team - 1/29/2008
When I go to get out of the form it asks me to save data when all I have tried to do is move around in the table. Either you have the business object in Edit or Add mode or the business object is somehow getting dirty (some property set is firing) and making the business object dirty. To figure out what's causing it, add a handler to the business object's IsDirtyChanged event and put a break point in the handler. When the break point is hit, check the call stack and you should be able to figure out what caused the business object to think that it's dirty.
|
By Terry Bottorff - 1/29/2008
OK I will do it. Thanks. I will let you know what I find.
|
By StrataFrame Team - 1/29/2008
Excellent. If the issue it not apparent when you look at the stack trace, then just post it here and we might be able to help you with the sleuthing.
|
By Terry Bottorff - 1/29/2008
I was not sure exactly what to put in the IsDirtyChanged event so I just put a local buff = 1 after I dim it as an integer with a break point. The follow are the call stacks that showed as it was finally loading the form and after I hit a navigation buttorn.
****
Lighting5.exe!Lighting5.CustomerEdit.CustomersBO_IsDirtyChanged(Object sender = {LightingBO.CustomersBO}, System.EventArgs e = {System.EventArgs}) Line 5Basic
Lighting5.exe!Lighting5.CustomerEdit.CustomersBO_ParentFormLoading() Line 10 + 0x15 bytesBasic
****
I hope this is what you wanted. Since I am new to .NET and Strataframe I am doing both the best I can at this time. Let me know if you want more. Is there a way to copy the entire Stack Call? TIA.
|
By StrataFrame Team - 1/30/2008
Yep, it looks like the last thing from your code that was called before the IsDirtyChanged was fired is the ParentFormLoading event. Do you have any code within your ParentFormLoading that might be setting a value within one of the business objects?
|
By Terry Bottorff - 1/30/2008
Yes I have the following code.
****
Me.CustomersBO.fillallcustomers()
****
This is what I use to fill the BO. "Select * from cowboys"
?? TIA
|
By StrataFrame Team - 1/30/2008
OK, something deep down seems to be modifying the record within the business object... you'll need to turn off "Just My Code" in order to see all of the stack trace (including the .NET methods and SF methods). VS Menu -> Tools -> Options -> Debugging -> General -> Uncheck "Enable Just My Code" -> OK Now, when you hit the breakpoint in the IsDirtyChanged handler, you should have a lot more in your Call Stack window that might give us a clue to the problem.
|
By Terry Bottorff - 1/30/2008
OK I just started over with a new project and added a few fields at a time and I think I have it working but I have some questions about a datetimepicker. I wanted to use it as a time stamp as to when a record was created so on a maintenance form I would need it enabled on new but on edit I would not. Is that feesible?
And that is what seems to be creating the grief even on the new project. If I enter it say on an edit and don't pick a date it seems to leave the record Dirty? Is that correct or is it something else? I have not checked the help yet but since I am here is there a way to default the datetimepicker to the current date?
TIA again and again.
|
By StrataFrame Team - 1/31/2008
If you want to independently control the enabled state of that control, then you will want to set the IgnoreUIReadOnlyState to True on the control... this will cause the business object to leave it alone when it's enabling/disabling the controls when the object is edited/added/saved. You would then need to control when that control is enabled. I'm not sure what's causing it to think that the record is dirty, but if you disable the control when you're not wanting to edit the record, then it shouldn't copy any data back to the control.If it's still causing you issues after you set the enabled state manually, then let me know.
|
By Terry Bottorff - 1/31/2008
I really don't want to control it so I will play with it some more and see if I can isolate that it is this control giving me the wierd results. Is there a way to default the datetimepicker to the current date? TIA.
|
By StrataFrame Team - 1/31/2008
Since the control is bound to the field on the business object, it is going to pull its value from the business object, so the best way to default it to the current date will be to set the field on the business object in the SetDefaultValues method to todays date. DateTime.Now will work, or if you don't want the time, then DateTime.Now.Date.
|
By Terry Bottorff - 1/31/2008
OK, Thanks that is what I needed. I will try that and report back. I still believe this timedate field is what is screwing up the dirty record. I will keep at it...
|
By Terry Bottorff - 1/31/2008
This gets more bizarre by the minute. I put the code in the setdefaultvalues event and that works but now when I create a new person I get a negative number for the PK which I know I should (I just show the PK as read only), I can fill in the first name and last name and when I put the first character of the address field it automatically fills in the form with information (even the first and last name) from the last person I added and truncates parts of the name. Now I am really dorked up in terms of what to do and how could that happen??????? TIA......
|
By StrataFrame Team - 1/31/2008
Looks like there is some sort of handler on the address field which is causing it to Navigate the record. If all of the data is changing to a different record, then the business object is definitly navigating. Put a handler on the business object's Navigating event and put a break point on that handler... when the handler fires, post the stack trace (along with all the extra stuff that shows when you turn off the "Just My Code" stuff mentioned above.
|
By Terry Bottorff - 2/3/2008
Every Field after the First and Last name fields causes the other fields to fill with the info from the last person added. How can that possibly be? I have not tried your suggestion yet but I was just seeing if it was only one field that caused the form to autofill and found out it was not. This is more of frustration note more then anything else at this moment. I will try your suggestion and get back. TIA.
|
By Terry Bottorff - 2/4/2008
I tried your suggestion about putting a break point in the navigating event of the BO. It is not fired because the break point does not fire. I have inserted a picture of what the form looks like and when I took this snap shot it was right after I entered the 1 in the address 1 text box. Any suggestions would be appreciated. TIA.
|
By Trent L. Taylor - 2/5/2008
I can practically guarantee that you have an event that is being handled causing either the row to be set back to the previous row or causing some type of validation issue. If you place a breakpoint in the Set of the BO property, you may then be able to see at what point the values are being set or updated....also, the Navigated and Navigating events will definitely be firing...so if they are not firing then you may have your breakpoint in the wrong place. Be sure to put your breakpoint in the Navigating of your BO (you may want to add some code in there so you can set your breakpoint).
|
By Terry Bottorff - 2/5/2008
I put the following two lines in the navigating event of the BO with a break point on the second line. The break point never fired.dimension xcnt as integer xcnt = 1 I will try the Set event and see what happens. TIA.....
|
By Trent L. Taylor - 2/5/2008
I think that there is something fishy going on with your form (as I think that you already knew ). If you create a new form, drop on the BO and a few of these fields, do you have the same behavior? You need to determine if the issue is within the form or the BO itself...this would be one way to find out.
|
By Terry Bottorff - 2/5/2008
I created a new form and dropped a BO on it. Now as soon as I start typing in the Company field exactly the same thing happens as the picture show I get the form filled in???? I don't have a clue. Why does it not happen on the first and last names???? Could it be the SQL back end that is doing it? TIA.
|
By Trent L. Taylor - 2/5/2008
Terry,You have something going on with the BO. Can you send me your project?
|
By Terry Bottorff - 2/5/2008
I certainly can but I am not sure how to do it. Do I zip the solution subdirectory? And what do I do about the SQL database? TIA.
|
By Trent L. Taylor - 2/5/2008
Yeah, zip up the solution and all of the sub folders and as for the SQL database, just do a backup and include that in a zip as well then I can restore your backup to my test server.
|
By Terry Bottorff - 2/5/2008
Alright here it is. Please let me know if I did it correctly. TIA.
|
By Trent L. Taylor - 2/6/2008
Ahhhh...yeah, that will get you every time You have a sort on the CustomersEditBO set to "cust_lastname, cust_firstname" ....so, when you create a new record, modify the name fields, etc. the record pointer is moving on you. First, in this instance, I would order the records when they are retrieved with an ORDER BY command. If you want to use the sort this way, you have to take it into account so when you create a new record, or are modifying a record, you need to remove the sort and then add it back once the editing is complete...that should get you going though.
|
By Terry Bottorff - 2/6/2008
Can you maybe explain a bit more why the sort is making the record pointer move when I add a record? I think I tried putting the the order by clause in the Select but when I added a record then the records were no longer in alpha order by name. After a record is added or edited how do you repopulate the BO so that the maintenance form will show them in Alpha order? First thanks for all of your attention and help. I am glad you found out what was wrong but for some reason I don't have my mind around how it works yet. Again Thank You.
|
By Trent L. Taylor - 2/6/2008
Sure, it is actually quite simple. As you may have already learned, the BO has several exposed properties within the BO: CurrentDataTable, CurrentView, CUrrentRow, and CurrentRowIndex. All of the BOs logic surrounds the CurrentView which is a DataView (CurentDataTable.DefaultView is the same reference). The sort on a DataView is dynamic, so as soon as you add a new record (or modify a field within the sort), the view will "reshuffle" to match the updated values.Example: DataView Index | cust_FirstName | cust_LastName | 0 | Joe | Smith | 1 | Trent | Taylor |
If I add a new record and have a sort of (cust_LastName, cust_FirstName), the instant that the new row is added to the DataTable (which in turn is added to the view), the sort is effective and resorts the list: DataView Index | cust_FirstName | cust_LastName | 0 | (empty) | (empty) | 1 | Joe | Smith | 2 | Trent | Taylor |
However, the CurrentRowIndex of the BO is still set to 0 since the BO has not actually navigated....so if you were to call a BO.Refresh() all of the fields would reflect the newly added record...but instead, you are only seeing changes to the fields that are changing which made it look like it was updating two records at once. The Sort is a great feature and we use it often, but when you use Sort and Filter, you need to take into account new and modified records otherwise you will have strange behavior...I have chansed my tail more than once for this reason.
|
By Terry Bottorff - 2/6/2008
OK the mud is starting to thin a bit. The BO is Dynamic and since the sort is on cust_lastname and cust_firstname it makes sense that as soon as those are added then the BO reshuffles and the form is filled with other data. According to what you have said it seems I have the following options.If I use the Sort event: It sounds like I could turn the sort off when adding and editing and as soon as they are over turn it back on. At that time I guess I would refresh the BO. I understand this concept but I do not understand how\where I would do these. I am sure I would turn it off beforesave and beforeedit if these events exists I will look and see and probably turn it on in aftersave.
If I don't use the Sort but use the Order by in the Select: I would some way have to refresh the BO after saving the new record or saving the edit. Again where/how?
I will start looking at events of the BO and see what a come up. Again Thanks you so much.
|
By Trent L. Taylor - 2/6/2008
It sounds like I could turn the sort off when adding and editing and as soon as they are over turn it back on. At that time I guess I would refresh the BO. I understand this concept but I do not understand how\where I would do these. I am sure I would turn it off beforesave and beforeedit if these events exists I will look and see and probably turn it on in aftersave. Yes, but you will constantly be fighting this...my recommendation would be to use the ORDER BY within the query in this particular scenario. Where you place this depends on what you are trying to accomplish, but BeforeAddNew would be one place to turn it off and AfterSave you could turn it back on. I would some way have to refresh the BO after saving the new record or saving the edit. Again where/how? In the AfterSave event you could resort the BO: MyBO.Sort = "cust_LastName" MyBo.CopyDataFrom(MyBo, ClearnAndFillFromDefaultView) MyBo.SOrt = ""
|
By Terry Bottorff - 2/7/2008
My Gad I got it to work the way I want with that little bit of code you gave me and where to put it. 40 posts to get to 3 lines of code. Your Help is Awsome. Thanks, I'm sure I will be back.....
|
By Trent L. Taylor - 2/7/2008
Glad you got it going
|