Created
August 21, 2023 18:40
-
-
Save BrianMRO/c76e28cb7d4fdc9f8ab32cc8a5f74fe8 to your computer and use it in GitHub Desktop.
CMMS-Lite - Josh's Row Up/Down
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region RowUp | |
public PXAction<WOOrder> rowUp; | |
[PXButton(ImageKey = "ArrowUp", Tooltip = "Move Row Up")] | |
[PXUIField(DisplayName = " ", MapEnableRights = PXCacheRights.Update)] | |
protected IEnumerable RowUp(PXAdapter adapter) | |
{ | |
SwapRows(Transactions.Current, true); | |
return adapter.Get(); | |
} | |
#endregion | |
#region RowDown | |
public PXAction<WOOrder> rowDown; | |
[PXButton(ImageKey = "ArrowDown", Tooltip = "Move Row Down")] | |
[PXUIField(DisplayName = " ", MapEnableRights = PXCacheRights.Update)] | |
protected IEnumerable RowDown(PXAdapter adapter) | |
{ | |
SwapRows(Transactions.Current, false); | |
return adapter.Get(); | |
} | |
#endregion | |
#region SwapRows | |
private void SwapRows(WOLine line1, bool up) | |
{ | |
WOLine toSwap = Transactions.Select().FirstOrDefault(x => x.Record.OrderNbr == (up == true ? line1.OrderNbr - 1 : line1.OrderNbr + 1)); | |
if (toSwap != null) | |
{ | |
int? newLine1 = toSwap.OrderNbr; | |
int? newToSwap = line1.OrderNbr; | |
toSwap.OrderNbr = newToSwap; | |
Transactions.Update(toSwap); | |
line1.OrderNbr = newLine1; | |
Transactions.Update(line1); | |
} | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment