summary refs log tree commit diff
path: root/invoice_total3/InvoiceTotal/frmInvoiceTotal.cs
diff options
context:
space:
mode:
Diffstat (limited to 'invoice_total3/InvoiceTotal/frmInvoiceTotal.cs')
-rw-r--r--invoice_total3/InvoiceTotal/frmInvoiceTotal.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/invoice_total3/InvoiceTotal/frmInvoiceTotal.cs b/invoice_total3/InvoiceTotal/frmInvoiceTotal.cs
new file mode 100644
index 0000000..94edf91
--- /dev/null
+++ b/invoice_total3/InvoiceTotal/frmInvoiceTotal.cs
@@ -0,0 +1,59 @@
+using System;

+using System.Collections.Generic;

+using System.ComponentModel;

+using System.Data;

+using System.Drawing;

+using System.Linq;

+using System.Text;

+using System.Threading.Tasks;

+using System.Windows.Forms;

+

+namespace InvoiceTotal

+{

+	public partial class frmInvoiceTotal : Form

+	{

+		public frmInvoiceTotal()

+		{

+			InitializeComponent();

+		}

+

+		private void btnCalculate_Click(object sender, EventArgs e)

+		{

+			try {

+				if (txtSubtotal.Text == "") {

+					MessageBox.Show("Please enter a subtotal",

+						"Entry Error");

+					return;

+				}

+				decimal subtotal = Decimal.Parse(txtSubtotal.Text);

+				if (subtotal <= 0 || subtotal >= 10000) {

+					MessageBox.Show("The subtotal must be in the "

+						+ "range of 1 to 9999", "Entry Error");

+					return;

+				}

+				decimal discountPercent = .25m;

+				decimal discountAmount = subtotal * discountPercent;

+				decimal invoiceTotal = subtotal - discountAmount;

+

+				discountAmount = Math.Round(discountAmount, 2);

+				invoiceTotal = Math.Round(invoiceTotal, 2);

+

+				txtDiscountPercent.Text = discountPercent.ToString("p1");

+				txtDiscountAmount.Text = discountAmount.ToString();

+				txtTotal.Text = invoiceTotal.ToString();

+				txtSubtotal.Focus();

+			}

+			catch {

+				MessageBox.Show(

+					"Please enter a valid subtotal for the "

+					+ "subtotal field.", "Entry Error");

+			}

+

+		}

+

+		private void btnExit_Click(object sender, EventArgs e)

+		{

+			this.Close();

+		}

+	}

+}
\ No newline at end of file