CloverExamplePOS.CloverExamplePOSForm.StoreItems_DiscountSelected C# (CSharp) Method

StoreItems_DiscountSelected() private method

private StoreItems_DiscountSelected ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void StoreItems_DiscountSelected(object sender, EventArgs e)
        {
            POSDiscount discount = ((StoreDiscount)((Control)sender).Parent).Discount;

            Store.CurrentOrder.Discount = discount;
            Store.NewDiscount = true;  //temporarily disables reapplication of a discount during UpdateDisplayOrderTotals() calls

            DisplayDiscount DisplayDiscount = new DisplayDiscount();
            DisplayDiscount.name = discount.Name;
            DisplayDiscount.amount = Decimal.Divide(discount.Value(Store.CurrentOrder.PreDiscountSubTotal), 100).ToString("C2");
            DisplayDiscount.percentage = (discount.PercentageOff * 100).ToString("###");

            // our example POS business rules say only 1 order discount
            while (DisplayOrder.discounts.elements.Count > 0)
            {
                DisplayDiscount RemovedDisplayDiscount = (DisplayDiscount)DisplayOrder.discounts.elements[0];
                DisplayOrder.discounts.Remove(RemovedDisplayDiscount);
                UpdateDisplayOrderTotals();
                cloverConnector.DiscountRemovedFromDisplayOrder(DisplayOrder, RemovedDisplayDiscount);
            }

            if (discount.Value(1000) != 0)
            {
                DisplayOrder.addDisplayDiscount(DisplayDiscount);
                UpdateDisplayOrderTotals();
                cloverConnector.DiscountAddedToDisplayOrder(DisplayOrder, DisplayDiscount);
            }
            Store.NewDiscount = false; //enables reapplication of a discount during UpdateDisplayOrderTotals() calls
        }
CloverExamplePOSForm