Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Discount discountSelected = discountsAvailable.GetDiscount
                                            (discountID);

            //save discount
            try
            {
                discountsAvailable.GetDiscount(txtDiscountID.Text).Percent = Convert.ToDecimal(txtPercentage.Text);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Prompt.ShowError(ex.Message);
            }

            if (chkValidate.Checked == true)
            {
                if (isDiscountValid(discountSelected))
                {
                    if (discountsApplied.Count <= DiscountAdapter.Instance.GetDiscountLimit() - 1)
                    {
                        discountSelected.ItemAppliedTo = cboItemsToApplyTo.Text;
                        //add discount to applied discounts
                        discountsApplied.Add
                            (discountSelected);
                        //remove discount to available discounts
                        discountsAvailable.Delete(discountSelected);
                    }
                    else
                    {
                        Prompt.ShowError("Maximum number of applicable discounts is reached.");
                    }
                }
                else
                {
                    Prompt.ShowError("This discount is not applicable.");
                }
            }
            else
            {
                //if validation is disabled
                discountSelected.ItemAppliedTo = cboItemsToApplyTo.Text;
                //add discount to applied discounts
                discountsApplied.Add
                    (discountSelected);
                //remove discount to available discounts
                discountsAvailable.Delete(discountSelected);
            }

            //repopulate
            populateDiscountsList();

            populateTotalDiscount();

            //clear edit fields
            txtDiscountID.Clear();
            txtDiscountDescription.Clear();
            txtPercentage.Clear();

            txtPercentage.ReadOnly = true;

            btnInsert.Enabled = false;

            //disable application
            disableDiscountApplication();
        }