protected void CouponButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(CouponTextBox.Text)) { MessageUserControl.ShowInfo("Please enter a valid coupon."); } else { CouponController sysmgr = new CouponController(); Coupon coupon = sysmgr.ValidateCoupon(CouponTextBox.Text); if (coupon == null) { MessageUserControl.ShowInfo("Please enter a valid coupon."); } else { MessageUserControl.TryRun(() => { decimal couponDiscount = decimal.Parse(coupon.CouponDiscount.ToString()); decimal discount = couponDiscount / 100; CouponIDLabel.Text = coupon.CouponID.ToString(); Label3.Visible = true; decimal discountValue = decimal.Parse(SubTotalLabel.Text) * discount; DiscountLabel.Text = discountValue.ToString(); decimal total = decimal.Parse(TotalLabel.Text); total -= discountValue; TotalLabel.Text = total.ToString(); }, "Coupon", "Coupon successfully applied."); MainView.ActiveViewIndex = 2; } } }