From a59db8a29dee6b71483320de50714dfa2554f6f3 Mon Sep 17 00:00:00 2001
From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com>
Date: Fri, 2 Feb 2024 10:31:09 -0500
Subject: [PATCH] Finished Midterm!
---
MidtermProject/Form1.Designer.cs | 40 ----
MidtermProject/Form1.cs | 22 --
MidtermProject/Midterm.Designer.cs | 346 +++++++++++++++++++++++++++
MidtermProject/Midterm.cs | 269 +++++++++++++++++++++
MidtermProject/Midterm.resx | 120 ++++++++++
MidtermProject/MidtermProject.csproj | 9 +-
MidtermProject/Program.cs | 2 +-
7 files changed, 742 insertions(+), 66 deletions(-)
delete mode 100644 MidtermProject/Form1.Designer.cs
delete mode 100644 MidtermProject/Form1.cs
create mode 100644 MidtermProject/Midterm.Designer.cs
create mode 100644 MidtermProject/Midterm.cs
create mode 100644 MidtermProject/Midterm.resx
diff --git a/MidtermProject/Form1.Designer.cs b/MidtermProject/Form1.Designer.cs
deleted file mode 100644
index 82fa7fb..0000000
--- a/MidtermProject/Form1.Designer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-namespace MidtermProject
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
-
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/MidtermProject/Form1.cs b/MidtermProject/Form1.cs
deleted file mode 100644
index 8135d50..0000000
--- a/MidtermProject/Form1.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-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 MidtermProject
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
-
-
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/MidtermProject/Midterm.Designer.cs b/MidtermProject/Midterm.Designer.cs
new file mode 100644
index 0000000..e74b28d
--- /dev/null
+++ b/MidtermProject/Midterm.Designer.cs
@@ -0,0 +1,346 @@
+namespace MidtermProject
+{
+ partial class Midterm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.lblDisTitle = new System.Windows.Forms.Label();
+ this.lblDisBlue = new System.Windows.Forms.Label();
+ this.lblDisYellow = new System.Windows.Forms.Label();
+ this.lblDisTotal = new System.Windows.Forms.Label();
+ this.lblTotal = new System.Windows.Forms.Label();
+ this.txtYellow = new System.Windows.Forms.TextBox();
+ this.txtBlue = new System.Windows.Forms.TextBox();
+ this.grpSummary = new System.Windows.Forms.GroupBox();
+ this.lblSumGrandTotal = new System.Windows.Forms.Label();
+ this.lblTransactions = new System.Windows.Forms.Label();
+ this.lblAvg = new System.Windows.Forms.Label();
+ this.lblSumYellow = new System.Windows.Forms.Label();
+ this.lblSumBlue = new System.Windows.Forms.Label();
+ this.lblDisTotalSales = new System.Windows.Forms.Label();
+ this.lblDisTotalTransactions = new System.Windows.Forms.Label();
+ this.lblDisAvg = new System.Windows.Forms.Label();
+ this.lblDisSummaryYellow = new System.Windows.Forms.Label();
+ this.lblDisSummaryBlue = new System.Windows.Forms.Label();
+ this.chkSummary = new System.Windows.Forms.CheckBox();
+ this.chkTax = new System.Windows.Forms.CheckBox();
+ this.btnCalc = new System.Windows.Forms.Button();
+ this.btnReset = new System.Windows.Forms.Button();
+ this.btnNext = new System.Windows.Forms.Button();
+ this.btnExit = new System.Windows.Forms.Button();
+ this.grpSummary.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // lblDisTitle
+ //
+ this.lblDisTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblDisTitle.Location = new System.Drawing.Point(141, 20);
+ this.lblDisTitle.Name = "lblDisTitle";
+ this.lblDisTitle.Size = new System.Drawing.Size(335, 40);
+ this.lblDisTitle.TabIndex = 0;
+ this.lblDisTitle.Text = "TSCT Skating Association";
+ this.lblDisTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // lblDisBlue
+ //
+ this.lblDisBlue.Location = new System.Drawing.Point(60, 103);
+ this.lblDisBlue.Name = "lblDisBlue";
+ this.lblDisBlue.Size = new System.Drawing.Size(164, 27);
+ this.lblDisBlue.TabIndex = 1;
+ this.lblDisBlue.Text = "&Blue Skateboards:";
+ this.lblDisBlue.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblDisYellow
+ //
+ this.lblDisYellow.Location = new System.Drawing.Point(60, 143);
+ this.lblDisYellow.Name = "lblDisYellow";
+ this.lblDisYellow.Size = new System.Drawing.Size(164, 27);
+ this.lblDisYellow.TabIndex = 2;
+ this.lblDisYellow.Text = "&Yellow Skateboards:";
+ this.lblDisYellow.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblDisTotal
+ //
+ this.lblDisTotal.Location = new System.Drawing.Point(60, 216);
+ this.lblDisTotal.Name = "lblDisTotal";
+ this.lblDisTotal.Size = new System.Drawing.Size(164, 27);
+ this.lblDisTotal.TabIndex = 3;
+ this.lblDisTotal.Text = "&Total Amount:";
+ this.lblDisTotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblTotal
+ //
+ this.lblTotal.BackColor = System.Drawing.SystemColors.Info;
+ this.lblTotal.Location = new System.Drawing.Point(230, 216);
+ this.lblTotal.Name = "lblTotal";
+ this.lblTotal.Size = new System.Drawing.Size(164, 27);
+ this.lblTotal.TabIndex = 4;
+ this.lblTotal.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // txtYellow
+ //
+ this.txtYellow.Location = new System.Drawing.Point(230, 147);
+ this.txtYellow.Name = "txtYellow";
+ this.txtYellow.Size = new System.Drawing.Size(162, 20);
+ this.txtYellow.TabIndex = 2;
+ this.txtYellow.TextChanged += new System.EventHandler(this.txtYellow_TextChanged);
+ //
+ // txtBlue
+ //
+ this.txtBlue.Location = new System.Drawing.Point(230, 107);
+ this.txtBlue.Name = "txtBlue";
+ this.txtBlue.Size = new System.Drawing.Size(162, 20);
+ this.txtBlue.TabIndex = 0;
+ this.txtBlue.TextChanged += new System.EventHandler(this.txtBlue_TextChanged);
+ //
+ // grpSummary
+ //
+ this.grpSummary.Controls.Add(this.lblSumGrandTotal);
+ this.grpSummary.Controls.Add(this.lblTransactions);
+ this.grpSummary.Controls.Add(this.lblAvg);
+ this.grpSummary.Controls.Add(this.lblSumYellow);
+ this.grpSummary.Controls.Add(this.lblSumBlue);
+ this.grpSummary.Controls.Add(this.lblDisTotalSales);
+ this.grpSummary.Controls.Add(this.lblDisTotalTransactions);
+ this.grpSummary.Controls.Add(this.lblDisAvg);
+ this.grpSummary.Controls.Add(this.lblDisSummaryYellow);
+ this.grpSummary.Controls.Add(this.lblDisSummaryBlue);
+ this.grpSummary.Location = new System.Drawing.Point(544, 262);
+ this.grpSummary.Name = "grpSummary";
+ this.grpSummary.Size = new System.Drawing.Size(232, 154);
+ this.grpSummary.TabIndex = 7;
+ this.grpSummary.TabStop = false;
+ this.grpSummary.Text = "Summary Information";
+ //
+ // lblSumGrandTotal
+ //
+ this.lblSumGrandTotal.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.lblSumGrandTotal.Location = new System.Drawing.Point(116, 131);
+ this.lblSumGrandTotal.Name = "lblSumGrandTotal";
+ this.lblSumGrandTotal.Size = new System.Drawing.Size(110, 20);
+ this.lblSumGrandTotal.TabIndex = 23;
+ //
+ // lblTransactions
+ //
+ this.lblTransactions.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.lblTransactions.Location = new System.Drawing.Point(116, 104);
+ this.lblTransactions.Name = "lblTransactions";
+ this.lblTransactions.Size = new System.Drawing.Size(100, 20);
+ this.lblTransactions.TabIndex = 22;
+ //
+ // lblAvg
+ //
+ this.lblAvg.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.lblAvg.Location = new System.Drawing.Point(116, 77);
+ this.lblAvg.Name = "lblAvg";
+ this.lblAvg.Size = new System.Drawing.Size(110, 20);
+ this.lblAvg.TabIndex = 21;
+ //
+ // lblSumYellow
+ //
+ this.lblSumYellow.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.lblSumYellow.Location = new System.Drawing.Point(116, 50);
+ this.lblSumYellow.Name = "lblSumYellow";
+ this.lblSumYellow.Size = new System.Drawing.Size(100, 20);
+ this.lblSumYellow.TabIndex = 20;
+ //
+ // lblSumBlue
+ //
+ this.lblSumBlue.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.lblSumBlue.Location = new System.Drawing.Point(116, 23);
+ this.lblSumBlue.Name = "lblSumBlue";
+ this.lblSumBlue.Size = new System.Drawing.Size(100, 20);
+ this.lblSumBlue.TabIndex = 19;
+ //
+ // lblDisTotalSales
+ //
+ this.lblDisTotalSales.Location = new System.Drawing.Point(6, 124);
+ this.lblDisTotalSales.Name = "lblDisTotalSales";
+ this.lblDisTotalSales.Size = new System.Drawing.Size(104, 27);
+ this.lblDisTotalSales.TabIndex = 18;
+ this.lblDisTotalSales.Text = "Total Sales:";
+ this.lblDisTotalSales.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblDisTotalTransactions
+ //
+ this.lblDisTotalTransactions.Location = new System.Drawing.Point(6, 97);
+ this.lblDisTotalTransactions.Name = "lblDisTotalTransactions";
+ this.lblDisTotalTransactions.Size = new System.Drawing.Size(104, 27);
+ this.lblDisTotalTransactions.TabIndex = 17;
+ this.lblDisTotalTransactions.Text = "Total Transactions:";
+ this.lblDisTotalTransactions.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblDisAvg
+ //
+ this.lblDisAvg.Location = new System.Drawing.Point(6, 70);
+ this.lblDisAvg.Name = "lblDisAvg";
+ this.lblDisAvg.Size = new System.Drawing.Size(104, 27);
+ this.lblDisAvg.TabIndex = 16;
+ this.lblDisAvg.Text = "Average Sale";
+ this.lblDisAvg.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ this.lblDisAvg.Click += new System.EventHandler(this.lblDisAvg_Click);
+ //
+ // lblDisSummaryYellow
+ //
+ this.lblDisSummaryYellow.Location = new System.Drawing.Point(6, 43);
+ this.lblDisSummaryYellow.Name = "lblDisSummaryYellow";
+ this.lblDisSummaryYellow.Size = new System.Drawing.Size(104, 27);
+ this.lblDisSummaryYellow.TabIndex = 15;
+ this.lblDisSummaryYellow.Text = "Yellow Skateboards:";
+ this.lblDisSummaryYellow.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // lblDisSummaryBlue
+ //
+ this.lblDisSummaryBlue.Location = new System.Drawing.Point(6, 16);
+ this.lblDisSummaryBlue.Name = "lblDisSummaryBlue";
+ this.lblDisSummaryBlue.Size = new System.Drawing.Size(104, 27);
+ this.lblDisSummaryBlue.TabIndex = 14;
+ this.lblDisSummaryBlue.Text = "Blue Skateboards:";
+ this.lblDisSummaryBlue.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // chkSummary
+ //
+ this.chkSummary.Location = new System.Drawing.Point(544, 232);
+ this.chkSummary.Name = "chkSummary";
+ this.chkSummary.Size = new System.Drawing.Size(104, 24);
+ this.chkSummary.TabIndex = 100;
+ this.chkSummary.Text = "&Show Summary";
+ this.chkSummary.UseVisualStyleBackColor = true;
+ this.chkSummary.CheckedChanged += new System.EventHandler(this.chkSummary_CheckedChanged);
+ //
+ // chkTax
+ //
+ this.chkTax.Location = new System.Drawing.Point(230, 189);
+ this.chkTax.Name = "chkTax";
+ this.chkTax.Size = new System.Drawing.Size(164, 24);
+ this.chkTax.TabIndex = 3;
+ this.chkTax.Text = "In State &Tax (4%)";
+ this.chkTax.UseVisualStyleBackColor = true;
+ this.chkTax.CheckedChanged += new System.EventHandler(this.chkTax_CheckedChanged);
+ //
+ // btnCalc
+ //
+ this.btnCalc.Location = new System.Drawing.Point(165, 324);
+ this.btnCalc.Name = "btnCalc";
+ this.btnCalc.Size = new System.Drawing.Size(93, 23);
+ this.btnCalc.TabIndex = 4;
+ this.btnCalc.Text = "&Calculate";
+ this.btnCalc.UseVisualStyleBackColor = true;
+ this.btnCalc.Click += new System.EventHandler(this.btnCalc_Click);
+ //
+ // btnReset
+ //
+ this.btnReset.Location = new System.Drawing.Point(283, 324);
+ this.btnReset.Name = "btnReset";
+ this.btnReset.Size = new System.Drawing.Size(93, 23);
+ this.btnReset.TabIndex = 100;
+ this.btnReset.Text = "Reset";
+ this.btnReset.UseVisualStyleBackColor = true;
+ this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
+ //
+ // btnNext
+ //
+ this.btnNext.Location = new System.Drawing.Point(165, 366);
+ this.btnNext.Name = "btnNext";
+ this.btnNext.Size = new System.Drawing.Size(93, 23);
+ this.btnNext.TabIndex = 5;
+ this.btnNext.Text = "Clear / Next";
+ this.btnNext.UseVisualStyleBackColor = true;
+ this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
+ //
+ // btnExit
+ //
+ this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnExit.Location = new System.Drawing.Point(283, 366);
+ this.btnExit.Name = "btnExit";
+ this.btnExit.Size = new System.Drawing.Size(93, 23);
+ this.btnExit.TabIndex = 100;
+ this.btnExit.Text = "&Exit";
+ this.btnExit.UseVisualStyleBackColor = true;
+ this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
+ //
+ // Midterm
+ //
+ this.AcceptButton = this.btnCalc;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.btnExit;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.btnExit);
+ this.Controls.Add(this.btnNext);
+ this.Controls.Add(this.btnReset);
+ this.Controls.Add(this.btnCalc);
+ this.Controls.Add(this.chkTax);
+ this.Controls.Add(this.chkSummary);
+ this.Controls.Add(this.grpSummary);
+ this.Controls.Add(this.txtBlue);
+ this.Controls.Add(this.txtYellow);
+ this.Controls.Add(this.lblTotal);
+ this.Controls.Add(this.lblDisTotal);
+ this.Controls.Add(this.lblDisYellow);
+ this.Controls.Add(this.lblDisBlue);
+ this.Controls.Add(this.lblDisTitle);
+ this.Name = "Midterm";
+ this.Text = "Form1";
+ this.grpSummary.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ }
+
+ private System.Windows.Forms.Label lblSumBlue;
+ private System.Windows.Forms.Label lblSumYellow;
+ private System.Windows.Forms.Label lblAvg;
+ private System.Windows.Forms.Label lblTransactions;
+ private System.Windows.Forms.Label lblSumGrandTotal;
+
+ private System.Windows.Forms.CheckBox chkTax;
+ private System.Windows.Forms.Button btnCalc;
+ private System.Windows.Forms.Button btnReset;
+ private System.Windows.Forms.Button btnNext;
+ private System.Windows.Forms.Button btnExit;
+ private System.Windows.Forms.Label lblDisTotal;
+ private System.Windows.Forms.Label lblDisSummaryBlue;
+ private System.Windows.Forms.Label lblDisSummaryYellow;
+ private System.Windows.Forms.Label lblDisAvg;
+ private System.Windows.Forms.Label lblDisTotalSales;
+
+ private System.Windows.Forms.TextBox txtYellow;
+ private System.Windows.Forms.TextBox txtBlue;
+ private System.Windows.Forms.GroupBox grpSummary;
+ private System.Windows.Forms.CheckBox chkSummary;
+
+ private System.Windows.Forms.Label lblDisTitle;
+ private System.Windows.Forms.Label lblDisBlue;
+ private System.Windows.Forms.Label lblDisYellow;
+
+ private System.Windows.Forms.Label lblTotal;
+ private System.Windows.Forms.Label lblDisTotalTransactions;
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/MidtermProject/Midterm.cs b/MidtermProject/Midterm.cs
new file mode 100644
index 0000000..e2d0fc5
--- /dev/null
+++ b/MidtermProject/Midterm.cs
@@ -0,0 +1,269 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Windows.Forms;
+
+namespace MidtermProject
+{
+ public partial class Midterm : Form
+ {
+ // Tax Rates
+ private const decimal STANDARD_TAX_RATE = 0.06m;
+ private const decimal INSTATE_TAX_RATE = 0.04m;
+
+ // Prices
+ private const decimal BLUE_COST = 24.99m;
+ private const decimal YELLOW_COST = 15.97m;
+
+
+ // Running totals
+ private int transactions;
+ private int yellowSold;
+ private int blueSold;
+ private decimal totalSum;
+
+ // Integer Limit Checks
+ private double dubBlue = 0;
+ private double dubYellow = 0;
+
+ private int track;
+
+ private decimal tax = STANDARD_TAX_RATE;
+
+ private readonly ErrorProvider ep1 = new ErrorProvider();
+
+
+ public Midterm()
+ {
+ InitializeComponent();
+ LoadForm();
+ }
+
+ private void LoadForm()
+ {
+ lblSumBlue.Text = "0";
+ lblSumYellow.Text = "0";
+ lblAvg.Text = "0";
+ lblTransactions.Text = "0";
+ lblSumGrandTotal.Text = "0";
+ grpSummary.Visible = false;
+ btnNext.Enabled = false;
+ btnCalc.Enabled = false;
+ btnReset.Enabled = false;
+ }
+
+ private void lblDisAvg_Click(object sender, EventArgs e)
+ {
+ // throw new System.NotImplementedException();
+ }
+
+ private void chkSummary_CheckedChanged(object sender, EventArgs e)
+ {
+ if (chkSummary.Checked)
+ grpSummary.Visible = true;
+ else
+ grpSummary.Visible = false;
+ }
+
+ private void chkTax_CheckedChanged(object sender, EventArgs e)
+ {
+ if (chkTax.Checked)
+ tax = INSTATE_TAX_RATE;
+ else
+ tax = STANDARD_TAX_RATE;
+ }
+
+ private decimal Calculate(int qBlue, int qYellow)
+ {
+ decimal cost;
+ transactions++;
+
+ yellowSold += qYellow;
+ blueSold += qBlue;
+ dubYellow += qYellow;
+ dubBlue += qBlue;
+
+ cost = qBlue * BLUE_COST * (1 + tax) + qYellow * YELLOW_COST * (1 + tax);
+ totalSum += cost;
+ return cost;
+ }
+
+ private void btnCalc_Click(object sender, EventArgs e)
+ {
+ Int32 qBlue = 0;
+ Int32 qYellow = 0;
+
+
+ try
+ {
+
+
+ try
+ {
+ qBlue = int.Parse(txtBlue.Text);
+ }
+ catch (Exception exception)
+ {
+ ep1.SetError(txtBlue, "Invalid Value");
+ throw new Exception();
+ }
+
+ try
+ {
+ qYellow = int.Parse(txtYellow.Text);
+ }
+ catch (Exception exception)
+ {
+ ep1.SetError(txtYellow, "Invalid Value");
+ throw new Exception();
+ }
+
+ // Check to make sure sales dont surpass integer limits
+
+ try
+ {
+
+ if (blueSold + qBlue != dubBlue + qBlue)
+ {
+ throw new Exception();
+ }
+
+ }
+ catch (Exception exception)
+ {
+ ep1.SetError(txtBlue, "We Can't Sell That Many");
+ throw;
+
+ }
+
+ try
+ {
+
+ if (yellowSold + qYellow != dubYellow + qYellow)
+ {
+ throw new Exception();
+ }
+
+ }
+ catch (Exception exception)
+ {
+ ep1.SetError(txtYellow, "We Can't Sell That Many");
+ throw;
+
+ }
+
+ if (txtBlue.Text.Length > 0 || txtYellow.Text.Length > 0)
+ try
+ {
+ lblTotal.Text = Calculate(qBlue, qYellow).ToString("C");
+ }
+ catch (Exception exception)
+ {
+ ep1.SetError(btnCalc, "Calculation Error");
+ }
+ else
+ MessageBox.Show("Whoops!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+
+
+ track++;
+ }
+ catch (Exception exception)
+ {
+ // Dont Run Calculations
+ }
+
+ UpdateForm();
+ }
+
+ private void UpdateForm()
+ {
+ lblSumBlue.Text = blueSold.ToString("N0");
+ lblSumYellow.Text = yellowSold.ToString("N0");
+ if (transactions > 0)
+ {
+ lblAvg.Text = (totalSum / transactions).ToString("C");
+ btnReset.Enabled = true;
+ }
+ else
+ {
+ lblAvg.Text = "0";
+ btnReset.Enabled = false;
+ }
+
+ lblTransactions.Text = transactions.ToString("N0");
+ lblSumGrandTotal.Text = totalSum.ToString("C");
+
+ if (track > 0)
+ btnNext.Enabled = true;
+ else
+ btnNext.Enabled = false;
+
+ if (txtBlue.Text.Length > 0 && txtYellow.Text.Length > 0)
+ {
+ btnCalc.Enabled = true;
+ }
+ else
+ {
+ btnCalc.Enabled = false;
+ }
+
+ }
+
+ private void btnExit_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void txtBlue_TextChanged(object sender, EventArgs e)
+ {
+ UpdateForm();
+ ep1.Clear();
+ }
+
+ private void btnNext_Click(object sender, EventArgs e)
+ {
+ track = 0;
+
+ txtBlue.Text = "";
+ txtYellow.Text = "";
+ lblTotal.Text = "";
+ chkTax.Checked = false;
+
+ txtBlue.Focus();
+
+ UpdateForm();
+ }
+
+ private void txtYellow_TextChanged(object sender, EventArgs e)
+ {
+ UpdateForm();
+ ep1.Clear();
+ }
+
+ private void btnReset_Click(object sender, EventArgs e)
+ {
+ DialogResult btnDialog;
+ string strResponse;
+
+ strResponse = "Do you really want to reset all statistics?";
+
+ btnDialog = MessageBox.Show(strResponse, "Midterm", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button2);
+
+ if (btnDialog == DialogResult.Yes)
+ {
+ transactions = 0;
+ yellowSold = 0;
+ blueSold = 0;
+ totalSum = 0;
+ track = 0;
+
+ txtBlue.Text = "";
+ txtYellow.Text = "";
+ lblTotal.Text = "";
+
+ }
+
+ UpdateForm();
+ }
+ }
+}
\ No newline at end of file
diff --git a/MidtermProject/Midterm.resx b/MidtermProject/Midterm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/MidtermProject/Midterm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/MidtermProject/MidtermProject.csproj b/MidtermProject/MidtermProject.csproj
index 7e2f0bb..962df1c 100644
--- a/MidtermProject/MidtermProject.csproj
+++ b/MidtermProject/MidtermProject.csproj
@@ -46,14 +46,17 @@
-
+
Form
-
- Form1.cs
+
+ Midterm.cs
+
+ Midterm.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/MidtermProject/Program.cs b/MidtermProject/Program.cs
index f2cfa1f..33df7c2 100644
--- a/MidtermProject/Program.cs
+++ b/MidtermProject/Program.cs
@@ -16,7 +16,7 @@ namespace MidtermProject
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new Form1());
+ Application.Run(new Midterm());
}
}
}
\ No newline at end of file