Using GetEnumerable


Author
Message
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
I have the following method:


private void cmdApplyAll_Click(object sender, EventArgs e)
{
   
MessageFunctionType mMft = MessageForm.ShowMessage("Aspire Confirmation", "Are you sure that you want to apply the change to all selected parts?", 1001", MessageFunction.YesNo, MessagingIcon.Question, MessagingSounds.Question);
   
if (mMft == MessageFunctionType.Yes)
    {
        waitWindow1.DisplayTitle =
true;
        waitWindow1.Title =
"Updating Parts";
        waitWindow1.Message =
"Updating the following parts . . . \r";
        waitWindow1.ShowWaitWindow();
       
foreach (PartsBO mBO in partsBO1.GetEnumerable())
        {
            waitWindow1.Message += mBO.partnum +
"\r";
            
mBO.Edit();
           
if (chkProdAppend.Checked) { mBO.prodnotes += txtNewNote.Text; }
           
if (chkProdReplace.Checked) { mBO.prodnotes = txtNewNote.Text; }
           
if (chkShipAppend.Checked) { mBO.shipnotes += txtNewNote.Text; }
           
if (chkShipReplace.Checked) { mBO.shipnotes = txtNewNote.Text; }
            mBO.Save();
        }

        waitWindow1.HideWaitWindow();

    }
}

The code ends up in an infinite loop after the second trip through the partsBO1 BOs.  It keeps repeating the second record.  What am I doing wrong?

Thanks!
Bill

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,

I believe the problem is the mBO.Edit() and mBO.Save() enumerating the same BO.  I think you can update all the records you need and do a single partsBO1.Save() at the end of the loop.

Edhy Rijo

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
Thanks, Edhy!  That was it...I really appreciate the code review. 

Have a great day!
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
Good answer, Edhy. Smile
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
You are welcome guys! Smile

Edhy Rijo

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