You are on page 1of 3

PROG3 March 14, 2012 Creating Information System: MOF Sales System

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace ClothingSales { public partial class ClothingSalesForm : Form { //Constant and Summary Information private decimal totalAmountDecimal; private int numberTransactionsInteger; public ClothingSalesForm() { InitializeComponent(); } private void ClothingSalesForm_Load(object sender, EventArgs e) { }

private void summaryInformationToolStripMenuItem_Click (object sender, EventArgs e) { MessageBox.Show("Total Sales: " + totalAmountDecimal + "\nNumber of Transactions: " + numberTransactionsInteger, "Summary Transactions"); } private void calculateButton_Click(object sender, EventArgs e) { //calculate the sale, discount, and summary values. //declare variables. int quantityInteger; decimal priceDecimal; decimal extendedPriceDecimal, discountDecimal; decimal amountDueDecimal, textBox1Decimal; // Clear any error messages.

PROG3 March 14, 2012 Creating Information System: MOF Sales System
//Invalid price. errorProvider1.SetError(quantityTextBox, ""); errorProvider2.SetError(priceTextBox, String.Empty); try { //convert input values to numeric and assign to variables. quantityInteger = int.Parse(quantityTextBox.Text); textBox1Decimal = decimal.Parse(textBox1.Text); priceDecimal = decimal.Parse(priceTextBox.Text); try { priceDecimal = decimal.Parse(priceTextBox.Text); //calculate values. textBox1Decimal = decimal.Parse(textBox1.Text); extendedPriceDecimal = quantityInteger * priceDecimal; discountDecimal = decimal.Round((extendedPriceDecimal * textBox1Decimal), 2); amountDueDecimal = extendedPriceDecimal - discountDecimal; totalAmountDecimal += amountDueDecimal; numberTransactionsInteger++; //Format and Display answers. extendedPriceTextBox.Text = extendedPriceDecimal.ToString("C"); discountTextBox.Text = discountDecimal.ToString("N"); amountDueTextBox.Text = amountDueDecimal.ToString("C"); //Format and display summary information. totalAmountDecimal.ToString("C"); numberTransactionsInteger.ToString(); } catch (FormatException) { } else { errorProvider1.SetError(priceTextBox, "Price must be numeric."); priceTextBox.Focus(); priceTextBox.SelectAll(); } } catch (FormatException) { //invalid quantity. errorProvider2.SetError(quantityTextBox, "Quantity must be numeric."); quantityTextBox.Focus(); quantityTextBox.SelectAll(); //invalid quantity. errorProvider3.SetError(quantityTextBox, "It must be numeric."); quantityTextBox.Focus(); quantityTextBox.SelectAll(); } } private void clearToolStripMenuItem_Click(object sender, EventArgs e) { //Clear the text boxes. quantityTextBox.Clear(); priceTextBox.Clear(); discountTextBox.Clear(); extendedPriceTextBox.Clear(); amountDueTextBox.Clear(); quantityTextBox.Clear(); textBox1.Clear(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { //End the program. if (exitToolStripMenuItem.Selected) {

PROG3 March 14, 2012 Creating Information System: MOF Sales System
MessageBox.Show("Thank you for using the system! :)", "Sales System"); } this.Close(); } private void aboutToolStripMenuItem_Click_1(object sender, EventArgs e) { MessageBox.Show("Sales System \nWritten By: Pesebre", "About"); } } }

You might also like