예제 #1
0
        public Action MoveDownCommand()
        {
            if (_moveDownCommand == null)
            {
                _moveDownCommand = delegate()
                {
                    // reindex all the items by moving the selected index up
                    SelectedRange[] range   = Lines.GetSelectedRows();
                    int             fromRow = (int)range[0].FromRow;

                    if (fromRow == Lines.GetLength() - 1)
                    {
                        return;
                    }

                    QuoteDetail line      = (QuoteDetail)Lines.GetItem(fromRow);
                    QuoteDetail lineAfter = (QuoteDetail)Lines.GetItem(fromRow + 1);
                    // swap the indexes from the item before
                    int?lineItemNumber = line.LineItemNumber;
                    line.RaisePropertyChanged("LineItemNumber");
                    lineAfter.RaisePropertyChanged("LineItemNumber");
                    line.LineItemNumber      = lineAfter.LineItemNumber;
                    lineAfter.LineItemNumber = lineItemNumber;
                    range[0].FromRow++;
                    Lines.RaiseOnSelectedRowsChanged(range);

                    Lines.SortBy(new SortCol("lineitemnumber", true));
                    Lines.Refresh();
                };
            }
            return(_moveDownCommand);
        }