Пример #1
0
        private void lstAppliedDiscounts_SelectedIndexChanged(object sender, EventArgs e)
        {
            Discount discountSelected;

            if (lstDiscounts.SelectedItems.Count == 1)
            {
                discountID = lstDiscounts.SelectedItems[0].Text;

                discountSelected = discountsAvailable.GetDiscount(discountID);

                //if the discount is unapplied
                if (discountSelected != null)
                {
                    //enable application
                    btnInsert.Enabled         = true;
                    cboItemsToApplyTo.Enabled = true;

                    btnRemove.Enabled = false;

                    txtDiscountID.Text          = discountSelected.DiscountID;
                    txtPercentage.Text          = Convert.ToString(discountSelected.Percent);
                    txtDiscountDescription.Text = discountSelected.DiscountDescription;

                    //if discount is variable make percent editable
                    if (discountSelected.DiscountType == Discount_Type.Variable_Discount)
                    {
                        txtPercentage.ReadOnly = false;
                    }
                    else //if discount is fixed disable edit
                    {
                        txtPercentage.ReadOnly = true;
                    }
                }
                else
                {
                    txtPercentage.ReadOnly = true;
                    btnRemove.Enabled      = true;

                    //disable application
                    btnInsert.Enabled         = false;
                    cboItemsToApplyTo.Enabled = false;
                }
            }
            else
            {
                txtDiscountID.Clear();
                txtDiscountDescription.Clear();
                txtPercentage.Clear();

                //disable apply/unapply
                btnInsert.Enabled = false;
                btnRemove.Enabled = false;

                disableDiscountApplication();
            }
        }
Пример #2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            Discount discountSelected = discountsApplied.GetDiscount
                                            (lstDiscounts.SelectedItems[0].Text);

            //return discount to available discounts
            discountsAvailable.Add
                (discountSelected);
            discountsApplied.Delete(discountSelected);

            //unapply discount
            discountsAvailable.GetDiscount
                (discountSelected.DiscountID).ItemAppliedTo = "";
            discountsAvailable.GetDiscount
                (discountSelected.DiscountID).Amount = 0.00M;

            //repopulate
            populateDiscountsList();

            populateTotalDiscount();

            btnRemove.Enabled = false;
        }