private void BtnCheckOut_Click(object sender, RoutedEventArgs e) { if (adpurchasedflag == 1 && adpurchasedcourse == 0) { MessageBox.Show("Thank you for shopping with us\n Your total for Anima Designer Product with key code storage is : " + "\n" + cashout); } else if (adpurchasedcourse == 1 && adpurchasedflag == 0) { MessageBox.Show("Thank you for shopping with us\n Your total for Anima course and Anima Designer Product is : " + cashout); } else if (adpurchasedflag == 1 && adpurchasedcourse == 1) { try { cashout = (TotalAfterDiscount + 1100); MessageBox.Show("Thank you for shopping with us\n Your total for Anima course, key code storage, and Anima Designer Product is : " + cashout); } catch (Exception) { MessageBox.Show("Not a valid input"); } } else { MessageBox.Show("Thank you for shopping with us\nYour total for Anima Designer is : " + TotalAfterDiscount.ToString()); } //clear boxes ClearForm(); }
private void Txt_Amt_Sold_LostFocus(object sender, RoutedEventArgs e) { //Discounts are available, depending on the quantity selected.Here is a list //of quantity discounts: //course will have same discounts //10 - 19 20% discount //20 - 49 30% discount //50 - 99 40% discount //100 or more 50% discount // Declare the Variables // PackagePrice is the price of 1 package before the discount. // AmountSold quantity of the products customer has selected. // TotalPrice is the price of the total. // DiscountRate is the weight of discount depending on the total amount sold. // TotalAfterDiscount is the TotalPrice with discoun string DiscountLabel; if (Txt_Amt_Sold.Text != "") { AmountSold = int.Parse(Txt_Amt_Sold.Text); } //Declare the variables for the calculation TotalPrice = AmountSold * PackagePrice; TotalAfterDiscount = TotalPrice; DiscountLabel = ""; //If user inputs an ammount less then 10 there is no discount. if (AmountSold < 10) { DiscountLabel = ""; TotalAfterDiscount = TotalPrice; Discount_Amount.Text = "$" + 0.ToString(); } //if user inputs amount between 10-19 they recieve discount of 20% else if (AmountSold >= 10 && AmountSold <= 19) { DiscountLabel = "20%"; TotalAfterDiscount = TotalPrice * (1 - 0.2); Discount_Amount.Text = "$" + (TotalPrice * 0.2).ToString(); } //if user inputs amount between 20-49 they recieve discount of 30% else if (AmountSold >= 20 && AmountSold <= 49) { DiscountLabel = "30%"; TotalAfterDiscount = TotalPrice * (1 - 0.3); Discount_Amount.Text = "$" + (TotalPrice * 0.3).ToString(); } //if user inputs amount between 50-100 they recieve a discount of 40% else if (AmountSold >= 50 && AmountSold <= 99) { DiscountLabel = "40%"; TotalAfterDiscount = TotalPrice * (1 - 0.4); Discount_Amount.Text = "$" + (TotalPrice * 0.4).ToString(); } //if user inputs amount greater then a 100 they recieve discount of 50% else if (AmountSold >= 100) { DiscountLabel = "50%"; TotalAfterDiscount = TotalPrice * (1 - 0.5); Discount_Amount.Text = "$" + (TotalPrice * 0.5).ToString(); } //converts the discount from a decimal into a string and inputs it into the specific text boxes Ttl_Before_Discount.Text = "$" + TotalPrice.ToString(); Total_Amount.Text = "$" + TotalAfterDiscount.ToString(); Discount_Percent.Text = DiscountLabel; }