Using SeekByPrimaryKey


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
What does your code look like now? Also, why are you calling edit? As you as you make a change the BO will become dirty. So there is really no need to place the BO in edit mode.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
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();

}

}


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
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.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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();




Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
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 w00t

Edhy Rijo

Attachments
CheckedListView.png (125 views, 59.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
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. Tongue



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
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
There was other logic resetting CheckButton. Whistling 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! w00t Thanks for all the help!!



Have a great day! Smooooth

Bill
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Glad you got to the bottom of it! Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search