Below is a list array.
Always start on level 1.
Positions have to be numbered, increments are 10. Starting with 10.
When there is a change from level 1 to 2, position must start with 10 again.
Same for change from level 2 to 3 and so on.
When go back from level 2 to 1, numbering has to start with increment 10 on the previous position from level 1
Is there a suggestion (I can renumber, when the level changed back it want remmeber the position)
Level|Position|ItemGroup|I
1 | |PCBFLX |401246900|
1 | |CASCER |402984000|
1 | |CASCER |402961200|
1 | |MPCAH |401617802|
2 | |CASCER |400094000|
2 | |CASCER |402961600|
2 | |CASCER |402961000|
2 | |CASCER |402965000|
2 | |CASCER |402965100|
2 | |CASCER |402976900|
2 | |CASCER |402965200|
2 | |DISDIO |400568400|
1 | |CASCER |402961200|
1 | |CASCER |402961200|
2 | |CASCER |402965200|
3 | |CASCER |402965200|
3 | |CASCER |402965200|
1 | |CASCER |402965200|
Result should be:
Level|Position|ItemGroup|I
1 | 10 |PCBFLX |401246900|' Start 10, first item in array lev1
1 | 20 |CASCER |402984000|' +10
1 | 30 |CASCER |402961200|' +10
1 | 40 |MPCAH |401617802|' +10
2 | 10 |CASCER |400094000|' Start 10, items belong to previous
2 | 20 |CASCER |402961600|' +10
2 | 30 |CASCER |402961000|' +10
2 | 40 |CASCER |402965000|' +10
2 | 50 |CASCER |402965100|' +10
2 | 60 |CASCER |402976900|' +10
2 | 70 |CASCER |402965200|' +10
2 | 80 |DISDIO |400568400|' +10
1 | 50 |CASCER |402961200|' See level 1, pos. 40 '+10
1 | 60 |CASCER |402961200|' +10
2 | 10 |CASCER |402965200|' Start 10,items belong to previous
2 | 20 |CASCER |402965200|' +10
3 | 10 |CASCER |402965200|' Start 10, items belong to previous
3 | 20 |CASCER |402965200|' +10
1 | 70 |CASCER |402965200|' See level 1, pos. 60 '+10
Loading
Erik BorghoutsPosted Sep 30, 2010, 5:51 AM
private void setPos()
{
recBom Bom;
int position = 0;
for (int level = 1; level < 10; level++)
{
for (int i = 0; i < arrBom.Count; i++)
{
Bom = arrBom[i];
if (Bom.Level > level) continue;
if (Bom.Level == level)
{
position += 10;
Bom.Position = position.ToString();
}
else
{
position = 0;
}
}
}
Sam HobbsPosted Sep 28, 2010, 6:51 AM
I would try doing it using iteration instead of recursion but most people would use recursion.
You need to understand collections, as a minimum. If you understood about arrays and other collections, then you would have done that much too. Without understanding arrays and other collections, you will have difficulty doing this even if someone provides some sample code.
Erik BorghoutsPosted Sep 28, 2010, 5:17 AM
I started with for next, but i was wondering for recursive functions.
private void setPos()
{
recBom Bom;
int position = 0;
for (int level = 1; level < 10; level++)
{
for (int i = 0; i < arrBom.Count; i++)
{
Bom = arrBom[i];
if (Bom.Level > level) continue;
if (Bom.Level < level) { position = 0; break; }
if (Bom.Level == level)
{
position += 10;
Bom.Position = position.ToString();
}
else
{
}
}
}
}
Sam HobbsPosted Sep 27, 2010, 6:47 PM