about summary refs log tree commit diff
path: root/invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs
diff options
context:
space:
mode:
author1970-01-01 00:00:00 +0000
committer1970-01-01 00:00:00 +0000
commit11cbd7dc38b57c4ec23b045178508c7eac13ab21 (patch)
treed0f83a7cbaa9f76559ae56841dcc49fe7f4fac19 /invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs
parenttxt to html (diff)
downloadsql-11cbd7dc38b57c4ec23b045178508c7eac13ab21.tar
sql-11cbd7dc38b57c4ec23b045178508c7eac13ab21.tar.gz
sql-11cbd7dc38b57c4ec23b045178508c7eac13ab21.tar.bz2
sql-11cbd7dc38b57c4ec23b045178508c7eac13ab21.tar.xz
sql-11cbd7dc38b57c4ec23b045178508c7eac13ab21.zip
2 vers of invoice total
Diffstat (limited to 'invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs')
-rw-r--r--invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs82
1 files changed, 82 insertions, 0 deletions
diff --git a/invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs b/invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs
new file mode 100644
index 0000000..10c8136
--- /dev/null
+++ b/invoice_total_discount/InvoiceTotal/frmInvoiceTotal.cs
@@ -0,0 +1,82 @@
+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();

+		}

+

+		int numInvoices = 0;

+		decimal smallestInvoice = Decimal.MaxValue;

+		decimal largestInvoice = 0m;

+		decimal avgInvoice = 0m;

+		decimal invoicesTotal = 0m;

+

+		private void btnCalculate_Click(object sender, EventArgs e)

+		{

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

+			decimal discountPercent = .25m;

+			decimal discountAmount = Math.Round(subtotal * discountPercent, 2);

+			decimal invoiceTotal = Math.Round(subtotal - discountAmount, 2);

+

+			numInvoices++;

+			invoicesTotal += invoiceTotal;

+			avgInvoice = invoicesTotal / numInvoices;

+

+			if (invoiceTotal < smallestInvoice)

+				smallestInvoice = invoiceTotal;

+			if (invoiceTotal > largestInvoice)

+				largestInvoice = invoiceTotal;

+

+			txtSubtotal.Text = subtotal.ToString("c");

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

+			txtDiscountAmount.Text = discountAmount.ToString("c");

+			txtTotal.Text = invoiceTotal.ToString("c");

+			txtNumInvoices.Text = numInvoices.ToString();

+			txtSmallestInvoice.Text = smallestInvoice.ToString("c");

+			txtLargestInvoice.Text = largestInvoice.ToString("c");

+			txtAvgInvoice.Text = avgInvoice.ToString("c");

+			txtInvoicesTotal.Text = invoicesTotal.ToString("c");

+

+			txtEnterSubtotal.Focus();

+		}

+

+		private void btnExit_Click(object sender, EventArgs e)

+		{

+			this.Close();

+		}

+

+		private void btnClear_Click(object sender, EventArgs e)

+		{

+			numInvoices = 0;

+			smallestInvoice = Decimal.MaxValue;

+			largestInvoice = 0m;

+			avgInvoice = 0m;

+			invoicesTotal = 0m;

+

+			txtEnterSubtotal.Text = "";

+			txtSubtotal.Text = "";

+			txtDiscountPercent.Text = "";

+			txtDiscountAmount.Text = "";

+			txtTotal.Text = "";

+			txtNumInvoices.Text = "";

+			txtInvoicesTotal.Text = "";

+			txtSmallestInvoice.Text = "";

+			txtLargestInvoice.Text = "";

+			txtAvgInvoice.Text = "";

+

+			txtEnterSubtotal.Focus();

+		}

+	}

+}