Untitled
unknown
csharp
a year ago
10 kB
0
Indexable
Never
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MS806_Assignment1 { public partial class Form1 : Form { //declaration of variables int FullFarePassengers; int StudentFarePassengers; int ChildFarePassengers; int TotalNumberofPassengers; decimal DriverDailyReceipts; decimal FullFareReceipts; decimal StudentFareRceipts; decimal ChildFareReceipts; decimal FullFarePercentage; decimal StudentFarePercentage; decimal ChildFarePercentage; int TotalDailyDriversSummary; int TotalPassengerSummary; decimal TotalCompanyReceiptSummary; decimal TotalFullFareReceiptsSummary; decimal TotalStudentFareReceiptsSummary; decimal TotalChildFareReceiptsSummary; decimal TotalFullFarePercentageSummary; decimal TotalStudentFarePercentageSummary; decimal TotalChildFarePercentageSummary; //constant values used const decimal FullFare = 9.50m; const decimal StudentFare = 6.75m; const decimal ChildFare = 4.75m; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { UserData_panel1.Visible = true; FirstMATPictureBox.Visible = true; Action_panel3.Visible = false; Customerinfo_groupBox1.Visible = false; DriverSummary_GroupBox5.Visible = false; CompanySummary_GroupBox3.Visible = false; SecondMATpictureBox.Visible = false; } private void button1_Click(object sender, EventArgs e) { this.Text = "Data Entry for Driver: " + UserName_TextBox1.Text + " Bus ID: " + BusID_TextBox2.Text; //to display the action going to take place if clicked Clear1_toolTip.SetToolTip(Clear1_button, "Click Here to Clear Form for New Data Entry"); Exit1_toolTip.SetToolTip(Exit1_button, "Click Here to Exit Application"); Customerinfo_groupBox1.Visible = true; Action_panel3.Visible = true; SecondMATpictureBox.Visible = true; UserData_panel1.Visible = false; FirstMATPictureBox.Visible = false; DriverSummary_GroupBox5.Visible = false; CompanySummary_GroupBox3.Visible = false; } private void Process1_button_Click(object sender, EventArgs e) { this.Text = "Driver Summary:" + UserName_TextBox1.Text + "BusID:" + BusID_TextBox2.Text; //incase inappropriate input is given try { FullFarePassengers = int.Parse(FullFarePassengers1_TextBox.Text); } catch { MessageBox.Show("Enter the numerical value for Full Fares", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { StudentFarePassengers = int.Parse(StudentFarePassengers1_TextBox.Text); } catch { MessageBox.Show("Enter the numerical value for Student Fares", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ChildFarePassengers = int.Parse(ChildFarePassengers1_TextBox.Text); } catch { MessageBox.Show("Enter the numerical value for Child Fares", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DriverSummary_GroupBox5.Visible = true; SecondMATpictureBox.Visible = true; Customerinfo_groupBox1.Visible = true; Action_panel3.Visible = true; CompanySummary_GroupBox3.Visible = false; Customerinfo_groupBox1.Enabled = false; //Calculations int TotalDriver = 1; TotalNumberofPassengers = FullFarePassengers + StudentFarePassengers + ChildFarePassengers; DriverDailyReceipts = (FullFarePassengers * FullFare) + (StudentFarePassengers * StudentFare) + (ChildFarePassengers * ChildFare); FullFareReceipts = FullFarePassengers * FullFare; StudentFareRceipts = StudentFarePassengers * StudentFare; ChildFareReceipts = ChildFarePassengers * ChildFare; //divibe by zero exception if (DriverDailyReceipts != 0) { FullFarePercentage = FullFareReceipts / DriverDailyReceipts * 100; StudentFarePercentage = StudentFareRceipts / DriverDailyReceipts * 100; ChildFarePercentage = ChildFareReceipts / DriverDailyReceipts * 100; } else { FullFarePercentage = 0; StudentFarePercentage = 0; ChildFarePercentage = 0; } TotalNumberofPassengers1_TextBox.Text = TotalNumberofPassengers.ToString(); TotalDriverReceipts1_TextBox.Text = DriverDailyReceipts.ToString("C"); FullFareReceipts1_TextBox.Text = FullFareReceipts.ToString("C"); FullFarePercentage1_TextBox.Text = FullFarePercentage.ToString("0.00") + "%"; StudentFareReceipts1_TextBox.Text = StudentFareRceipts.ToString("C"); StudentFarePercentage1_TextBox.Text = StudentFarePercentage.ToString("0.00") + "%"; ChildFareReceipts1_TextBox.Text = ChildFareReceipts.ToString("C"); ChildFarePercentage1_TextBox.Text = ChildFarePercentage.ToString("0.00") + "%"; TotalDailyDriversSummary = TotalDailyDriversSummary + TotalDriver; TotalPassengerSummary = TotalPassengerSummary + TotalNumberofPassengers; TotalCompanyReceiptSummary = TotalCompanyReceiptSummary + DriverDailyReceipts; TotalFullFareReceiptsSummary = TotalFullFareReceiptsSummary + FullFareReceipts; TotalStudentFareReceiptsSummary = TotalStudentFareReceiptsSummary+StudentFareRceipts; TotalChildFareReceiptsSummary = TotalChildFareReceiptsSummary + ChildFareReceipts; if(TotalDailyDriversSummary !=0) { TotalFullFarePercentageSummary = TotalFullFareReceiptsSummary / TotalDailyDriversSummary * 100; TotalStudentFarePercentageSummary = TotalStudentFareReceiptsSummary/TotalDailyDriversSummary * 100; TotalChildFarePercentageSummary = TotalChildFarePercentageSummary/TotalDailyDriversSummary * 100; } else { TotalFullFarePercentageSummary = 0; TotalStudentFarePercentageSummary = 0; TotalChildFarePercentageSummary = 0; } } private void Clear1_button_Click(object sender, EventArgs e) { this.Text = "Welcome to MAT Driver Portal"; UserData_panel1.Visible = true; FirstMATPictureBox.Visible = true; Customerinfo_groupBox1.Visible = false; Action_panel3.Visible = false; SecondMATpictureBox.Visible = false; DriverSummary_GroupBox5.Visible = false; Customerinfo_groupBox1.Enabled = true; UserName_TextBox1.Text = ""; BusID_TextBox2.Text = ""; FullFarePassengers1_TextBox.Text = ""; StudentFarePassengers1_TextBox.Text = ""; ChildFarePassengers1_TextBox.Text = ""; TotalNumberofPassengers1_TextBox.Text = ""; TotalDriverReceipts1_TextBox.Text = ""; FullFareReceipts1_TextBox.Text = ""; FullFarePercentage1_TextBox.Text = ""; StudentFareReceipts1_TextBox.Text = ""; StudentFarePercentage1_TextBox.Text = ""; ChildFareReceipts1_TextBox.Text = ""; ChildFarePercentage1_TextBox.Text = ""; TotalNumberofDrivers1_TextBox.Text = ""; TotalNumberofPassengers2_TextBox.Text = ""; TotalCompanyReceipts1_TextBox.Text = ""; FullFareReceipts2_TextBox.Text = ""; FullFarePercentage2_TextBox.Text = ""; StudentFareReceipts2_TextBox.Text = ""; StudentFarePercentage2_TextBox.Text = ""; ChildFareReceipts2_TextBox.Text = ""; ChildFarePercentage2_TextBox.Text = ""; } private void Exit1_button_Click(object sender, EventArgs e) { this.Close(); } private void Summary1_button_Click(object sender, EventArgs e) { this.Text = "MAT Summary Data"; CompanySummary_GroupBox3.Visible = true; SecondMATpictureBox.Visible = true; DriverSummary_GroupBox5.Visible = false; Action_panel3.Visible = true; Customerinfo_groupBox1.Visible = false; //Calculations TotalNumberofDrivers1_TextBox.Text = TotalDailyDriversSummary.ToString(); TotalNumberofPassengers2_TextBox.Text = TotalPassengerSummary.ToString(); TotalCompanyReceipts1_TextBox.Text = TotalCompanyReceiptSummary.ToString(); FullFareReceipts2_TextBox.Text = TotalFullFareReceiptsSummary.ToString("C"); FullFarePercentage2_TextBox.Text = TotalFullFarePercentageSummary.ToString("0.00") + "%"; StudentFareReceipts2_TextBox.Text = TotalStudentFareReceiptsSummary.ToString("C"); StudentFarePercentage2_TextBox.Text = TotalStudentFarePercentageSummary.ToString("0.00") + "%"; ChildFareReceipts2_TextBox.Text = TotalChildFareReceiptsSummary.ToString("c"); ChildFarePercentage2_TextBox.Text = TotalChildFarePercentageSummary.ToString("0.00") + "%"; } } }