using System; using System.Windows.Forms; namespace Chapter6 { public partial class frmCalculate : Form { public static decimal decDiscountAmt, decTotalPrice, decTotalAmnt = 0; public static int intTotalQuantity = 0; public frmCalculate() { InitializeComponent(); } private void lblDisQuantity_Click(object sender, EventArgs e) { // throw new System.NotImplementedException(); } private decimal Calculate(int quantity, decimal price, decimal discount) { return (quantity * price) * (1 - (discount - 100)); } private void btnCalc_Click(object sender, EventArgs e) { int intQuantity = 0; decimal decPrice = 0; decimal decDiscount = 0; try { intQuantity = int.Parse(txtQuantity.Text); try { decPrice = int.Parse(txtPrice.Text); try { decDiscount = int.Parse(txtDiscount.Text); lblOut.Text = Calculate(intQuantity, decPrice, decDiscount).ToString("C"); } catch (Exception exception) { //discount error } } catch (Exception exception) { //price error } } catch (Exception exception) { //quantity Error } } private void toolStripMenuItem1_Click(object sender, EventArgs e) { // throw new System.NotImplementedException(); } private void mnuEditCalculate_Click(object sender, EventArgs e) { if (mnuEditCalculate.Checked) { mnuEdit.Checked = false; } else { mnuEditCalculate.Checked = true; } } private void mnuEditSSummary_Click(object sender, EventArgs e) { if (mnuEditSSummary.Checked) { mnuEditSSummary.Checked = false; } else { mnuEditSSummary.Checked = true; frmSummary frm = new frmSummary(); frm.Show(); frm.Focus(); } } } }