StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
»
Using SeekByPrimaryKey
Using SeekByPrimaryKey
Post Reply
Like
0
Using SeekByPrimaryKey
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Bill Cunnien
Bill Cunnien
posted 16 Years Ago
ANSWER
HOT
Topic Details
Share Topic
Group: Forum Members
Posts: 785,
Visits: 3.6K
I am attempting to edit/save (aka update) selected BO's represented on a grid. Here is the code that I am using to accomplish this seemingly easy task:
waitWindow1.Message = "Updating the following parts . . . \r";
waitWindow1.ShowWaitWindow();
int[] mRows = gridView1.GetSelectedRows();
for (int i = 0; i < gridView1.SelectedRowsCount; i++)
{
int mPartIndex = (int)gridView1.GetRowCellValue(mRows[i], "partindex");
if (partsBO1.SeekToPrimaryKey(mPartIndex))
{
waitWindow1.Message += partsBO1.partnum + "\r";
partsBO1.Edit();
if (chkProdAppend.Checked) { partsBO1.prodnotes += txtNewNote.Text; }
if (chkProdReplace.Checked) { partsBO1.prodnotes = txtNewNote.Text; }
if (chkShipAppend.Checked) { partsBO1.shipnotes += txtNewNote.Text; }
if (chkShipReplace.Checked) { partsBO1.shipnotes = txtNewNote.Text; }
partsBO1.Save();
}
}
waitWindow1.HideWaitWindow();
The result of this code is that only the first and last record are updated. All other selected parts in between are ignored. Each part number shows up in the WaitWindow as I cycle through the selected records; however, only the first and last records are actually persisted to the database.
Any ideas?
Thanks,
Bill
Reply
Like
0
Replies
Bill Cunnien
Bill Cunnien
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 785,
Visits: 3.6K
Here's the code...I did take out the Edit(). I am now testing without it. I'll let you know if that changes anything.
for (int i = 0; i < listPartNum.SelectedItems.Count; i++)
{
int mPartIndex = (int)listPartNum.SelectedItems[i].Tag;
if (partsBO1.SeekToPrimaryKey(mPartIndex))
{
waitWindow1.Message += partsBO1.partnum + "\r";
if (chkProdAppend.Checked) { partsBO1.prodnotes += txtNewNote.Text; }
if (chkProdReplace.Checked) { partsBO1.prodnotes = txtNewNote.Text; }
if (chkShipAppend.Checked) { partsBO1.shipnotes += txtNewNote.Text; }
if (chkShipReplace.Checked) { partsBO1.shipnotes = txtNewNote.Text; }
partsBO1.Save();
}
}
Reply
Like
0
Bill Cunnien
Bill Cunnien
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 785,
Visits: 3.6K
If I select the first four in the list...only the first one is persisted.
If I pick the second through the fourth...only the second one (first in my selected items) is persisted.
I have got to take off. I'll try to check in later today to see if I can try working on this again.
Reply
Like
0
Trent Taylor
Trent Taylor
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
First, I would use a foreach. I would do something more like this:
foreach(ListViewItem i in listPartNum.SelectedItems)
{
//-- Find the item
if(!partsBO1.SeekToPrimaryKey((int)i.Tag)) { continue; }
//-- Update the record
if (chkProdAppend.Checked) { partsBO1.prodnotes += txtNewNote.Text; }
if (chkProdReplace.Checked) { partsBO1.prodnotes = txtNewNote.Text; }
if (chkShipAppend.Checked) { partsBO1.shipnotes += txtNewNote.Text; }
if (chkShipReplace.Checked) { partsBO1.shipnotes = txtNewNote.Text; }
}
//-- Save outside of the loop
partsBO1.Save();
Reply
Like
0
Edhy Rijo
E
Edhy Rijo
posted 16 Years Ago
ANSWER
Post Details
Share Post
E
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
Hi Bill,
Adding to Trent's reply, I have a this suggestion:
1- I use the ListView extensively, and in your case, I would use the ListView.Checked property instead of MultiSelect, with this you will have better control on what records are currently checked since the list view has a collection for it, and it will be easier for the End User to just click the box or double click the record to check it. (See attached screenshoot)
If Me.lstTransactionItems.CheckedItems.Count > 0 Then
For Each listItem As ListViewItem In Me.lstTransactionItems.Items
If listItem.Checked Then
If Me.BizTransactionItemsForListView.SeekToPrimaryKey(listItem.Tag) Then
Me.BizTransactionItemsForListView.DeleteCurrentRow(True)
End If
End If
Next
Me.lstTransactionItems.Requery()
End If
As you can see, in my case I am deleting the current row, but you'll get the idea, and of course my code is in VB
Edhy Rijo
Attachments
CheckedListView.png
(
144 views,
59.00 KB
)
Reply
Like
0
Bill Cunnien
Bill Cunnien
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 785,
Visits: 3.6K
Hi Edhy,
I did try using the checked property; however, the user loses the range select (click, shift-click) option. The user would prefer to do that than click 30+ checkboxes.
Trent, I tried that code, but I am getting the same results. Only the first record is getting persisted; however, all selected items are being seeked because the part number shows up in the wait window perfectly.
I am tackling this again today. After a really nice weekend, hopefully, I'll be able to conquer this pesky little issue.
Thanks!!
Ling
Reply
Like
0
Trent Taylor
Trent Taylor
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
Then there has to be something either set within your BO or some other logic moving the CurrentRowIndex because I have done this repeatedly. You are welcome to supply a sample, but I know that this will work as it is a common piece of logic.
Reply
Like
0
Bill Cunnien
Bill Cunnien
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: Forum Members
Posts: 785,
Visits: 3.6K
There was other logic resetting CheckButton.
I discovered that and replaced the CheckButtons with a RadioGroup (a little cleaner). I was able to remove all of my extra fancy code to manage the checkbuttons and now the form works as expected. It is clean and fast!
Thanks for all the help!!
Have a great day!
Bill
Reply
Like
0
Trent Taylor
Trent Taylor
posted 16 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
Glad you got to the bottom of it!
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
Using SeekByPrimaryKey
Bill Cunnien
-
16 Years Ago
Hi Bill,
Not sure if this is your case, but it looks like...
Edhy Rijo
-
16 Years Ago
Edhy...thanks. Here is what I introduced to my code just before the...
Bill Cunnien
-
16 Years Ago
Now...here's some more data for us to ponder...
The...
Bill Cunnien
-
16 Years Ago
OK, there can be a number of things going on here. First, you are...
Trent L. Taylor
-
16 Years Ago
[quote]3. The planets are beginning to align for a total...
Bill Cunnien
-
16 Years Ago
Ok. The ListView displays the data from a query within its own...
Bill Cunnien
-
16 Years Ago
AutoNavigateToSelectedRecord
Setting this to true did the...
Bill Cunnien
-
16 Years Ago
You will have to set the MultiSelect property to true in code. It is...
Trent L. Taylor
-
16 Years Ago
Yepper...that was the ticket.
So far, we have replaced that...
Bill Cunnien
-
16 Years Ago
What does your code look like now? Also, why are you calling edit?...
Trent L. Taylor
-
16 Years Ago
Here's the code...I did take out the Edit(). I am now testing without...
Bill Cunnien
-
16 Years Ago
If I select the first four in the list...only the first one is...
Bill Cunnien
-
16 Years Ago
First, I would use a foreach. I would do something more like this:...
Trent L. Taylor
-
16 Years Ago
Hi Bill,
Adding to Trent's reply, I have a this suggestion:...
Edhy Rijo
-
16 Years Ago
Hi Edhy,
I did try using the checked property; however, the...
Bill Cunnien
-
16 Years Ago
Then there has to be something either set within your BO or some other...
Trent L. Taylor
-
16 Years Ago
There was other logic resetting CheckButton. :Whistling: I...
Bill Cunnien
-
16 Years Ago
Glad you got to the bottom of it! :)
Trent L. Taylor
-
16 Years Ago
Post Reply
Like
0
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search