Exemplo n.º 1
0
        private void AddReceiptLine(ReceiptLine l)
        {
            bool AddedYet = false;

            Debug.Assert(RefundButton.IsChecked != null);

            // If the 'ReceiptLine' already exists on the receipt, increment its 'amount' value.
            foreach (ReceiptLine lcur in ReceiptLines)
            {
                if (lcur.SKU == l.SKU &&
                    lcur.Barcode == l.Barcode &&
                    lcur.Description == l.Description &&
                    lcur.UnitPrice == l.UnitPrice &&
                    lcur.VAT == l.VAT)
                {
                    if ((bool)RefundButton.IsChecked)
                    {
                        lcur.Amount--;
                    }
                    else
                    {
                        lcur.Amount++;
                    }
                    lcur.TotalPrice = lcur.UnitPrice * lcur.Amount;
                    AddedYet        = true;
                }
            }

            // Otherwise, add a new line to the receipt.
            if (!AddedYet)
            {
                if ((bool)RefundButton.IsChecked)
                {
                    l.Amount = -1;
                }
                else
                {
                    l.Amount = 1;
                }
                l.TotalPrice = l.UnitPrice * l.Amount;
                ReceiptLines.Add(l);
            }
            ReceiptDataGrid.Items.Refresh();

            // Shrink the 'Description' column width to its minimal size,
            // providing room for the other columns to grow if needed.
            ReceiptDataGrid.Columns[2].Width = DataGridLength.Auto;
            ReceiptDataGrid.UpdateLayout();

            // Expand the 'Description' column width again to fill any empty space that remains.
            ReceiptDataGrid.Columns[2].Width = new DataGridLength(1.0, DataGridLengthUnitType.Star);
            ReceiptDataGrid.UpdateLayout();
        }
Exemplo n.º 2
0
        void ClearReceipt()
        {
            ReceiptLines.Clear();
            ReceiptDataGrid.Items.Refresh();

            // Shrink the 'Description' column width to its minimal size,
            // providing room for the other columns to grow if needed.
            ReceiptDataGrid.Columns[2].Width = DataGridLength.Auto;
            ReceiptDataGrid.UpdateLayout();

            // Expand the 'Description' column width again to fill any empty space that remains.
            ReceiptDataGrid.Columns[2].Width = new DataGridLength(1.0, DataGridLengthUnitType.Star);
            ReceiptDataGrid.UpdateLayout();
        }