protected void btnRemove_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(lblOfferAmount.Text)) { string message = string.Empty; calculateOrderAmount = new CalculateOrderAmount(Convert.ToDouble(lblOfferAmount.Text), 0.00); discountCommand = new DiscountCommand(calculateOrderAmount); cashBackCommand = new CashBackCommand(calculateOrderAmount); if (rblOffers.SelectedIndex == 0) { command = cashBackCommand; message = "Cash back offer is not applied"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); } else if (rblOffers.SelectedIndex == 1) { command = discountCommand; lblOfferAmount.Visible = false; lblTotalAmount.Text = command.UnExecute().ToString(); } btnApply.Enabled = true; btnRemove.Enabled = false; } }
protected void btnApply_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(lblTotalAmount.Text)) { string message = string.Empty; calculateOrderAmount = new CalculateOrderAmount(Convert.ToDouble(lblTotalAmount.Text), Convert.ToDouble(rblOffers.SelectedValue)); discountCommand = new DiscountCommand(calculateOrderAmount); cashBackCommand = new CashBackCommand(calculateOrderAmount); //Cash back offer selected if (rblOffers.SelectedIndex == 0) { command = cashBackCommand; message = "Cash back of Rs." + command.Execute().ToString() + " will be added to your account!!!"; #region Show a message System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); #endregion } //Discount Offer Selected else if (rblOffers.SelectedIndex == 1) { command = discountCommand; lblTotalAmount.Text = command.Execute().ToString(); #region Enable/Disable Controls lblOfferAmount.Text = lblTotalAmount.Text; lblOfferAmount.Visible = true; lblOfferAmount.Font.Strikeout = true; lblOfferAmount.ForeColor = System.Drawing.Color.Red; #endregion } btnApply.Enabled = false; btnRemove.Enabled = true; } }