protected void calculateDiscount()
        {
            //Apply entered coupon

            Decimal total;

            if (string.IsNullOrEmpty(txtCouponCode.Text.Trim().ToString()))
            {
                showCouponCodeError();
            }
            else
            {
                string couponCode = "";
                couponCode = txtCouponCode.Text.Trim();
                Coupon coupon = CouponHelper.GetCouponByCode(couponCode);
                if (coupon != null)
                {
                    if (coupon.CouponDiscountTypeId > 0)
                    {
                        CouponDiscountType couponDiscountType = CouponDiscountTypeHelper.GetCouponTypeById(coupon.CouponDiscountTypeId);
                        if (couponDiscountType != null && couponDiscountType.Name == "Price Discount")
                        {
                            total = (decimal.Parse(hdnTotalPriceWithoutDisc.Value) - coupon.DiscountValue) < 0 ? 0 : (decimal.Parse(hdnTotalPriceWithoutDisc.Value) - coupon.DiscountValue);
                            lblTotalPrice.Text    = total.ToString("C");
                            hdnPriceDisc.Value    = ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - total).ToString();
                            lblDisCountPrice.Text = coupon.DiscountValue.ToString("C");
                            SessionWrapper.PaymentDetails.discountOffered = ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - total);
                            SessionWrapper.PaymentDetails.couponID        = coupon.CouponDiscountTypeId;
                        }
                        else if (couponDiscountType != null && couponDiscountType.Name == "Percentage Discount")
                        {
                            total = ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) * ((coupon.DiscountValue) / 100))) < 0 ? 0 : ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) * ((coupon.DiscountValue) / 100)));
                            lblTotalPrice.Text    = total.ToString("C");
                            hdnPriceDisc.Value    = ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - total).ToString();
                            lblDisCountPrice.Text = (((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) * ((coupon.DiscountValue) / 100)) < 0 ? 0 : ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) * ((coupon.DiscountValue) / 100))).ToString("C");
                            SessionWrapper.PaymentDetails.discountOffered = ((decimal.Parse(hdnTotalPriceWithoutDisc.Value)) - total);
                            SessionWrapper.PaymentDetails.couponID        = coupon.CouponDiscountTypeId;
                        }
                        lblDisCountPrice.Visible = true;
                        lblDiscountOffer.Visible = true;
                    }
                    hdnCouponID.Value            = coupon.CouponId.ToString();
                    lblErrorCouponCode.ForeColor = System.Drawing.Color.LimeGreen;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorMessage", "couponCodeError('Coupon code is valid.');", true);
                }
                else
                {
                    showPlanSummary();
                    lblDisCountPrice.Visible     = false;
                    lblDiscountOffer.Visible     = false;
                    lblErrorCouponCode.ForeColor = System.Drawing.Color.Red;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorMessage", "couponCodeError('Coupon code is invalid.');", true);
                }
            }
        }