ASDV-C-Sharp/MP4/JoesAutomotive_CalebFontenot/Form1.cs

116 lines
3.7 KiB
C#
Raw Permalink Normal View History

2022-11-16 17:48:22 -06:00
using System.CodeDom;
2022-11-15 14:22:17 -06:00
namespace JoesAutomotive_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
2022-11-16 17:48:22 -06:00
private decimal OilLubeChanges(decimal total)
{
// Check if the appropiate check boxes are checked, and if they are, add their sums to total.
if (oilChangeCheckBox.Checked)
{
total += 26.00m;
}
if (lubeJobCheckBox.Checked)
{
total += 16.00m;
}
return total;
}
private decimal FlushCharges(decimal total)
{
// Check if the appropiate check boxes are checked, and if they are, add their sums to total.
if (radiatorFlushCheckBox.Checked)
{
total += 30.00m;
}
if (transmissionFlushCheckBox.Checked)
{
total += 80.00m;
}
return total;
}
private decimal MiscCharges(decimal total)
{
// Check if the appropiate check boxes are checked, and if they are, add their sums to total.
if (inspectionCheckBox.Checked)
{
total += 30.00m;
}
if (replaceMufflerCheckBox.Checked)
{
total += 80.00m;
}
if (tireRotationCheckBox.Checked)
{
total += 20.00m;
}
return total;
}
2022-11-17 17:00:33 -06:00
private decimal TotalCharges()
2022-11-16 17:48:22 -06:00
{
2022-11-17 17:00:33 -06:00
decimal total = 0m;
total = OilLubeChanges(total);
total = FlushCharges(total);
total = MiscCharges(total);
total += OtherCharges();
2022-11-16 17:48:22 -06:00
return total;
}
2022-11-17 17:00:33 -06:00
private decimal TaxCharges()
2022-11-16 17:48:22 -06:00
{
2022-11-17 21:59:26 -06:00
decimal.TryParse(partsInputTextBox.Text, out decimal total);
2022-11-16 17:48:22 -06:00
decimal tax = total * 0.06m;
return tax;
}
2022-11-17 17:00:33 -06:00
private decimal OtherCharges()
{
decimal partsCost, laborCost;
decimal.TryParse(partsInputTextBox.Text, out partsCost);
decimal.TryParse(laborInputTextBox.Text, out laborCost);
return partsCost + laborCost;
}
private void calculateButton_Click(object sender, EventArgs e)
2022-11-16 17:48:22 -06:00
{
decimal total = TotalCharges();
decimal tax = TaxCharges();
2022-11-17 17:00:33 -06:00
decimal outputOtherCharges = OtherCharges();
2022-11-16 17:48:22 -06:00
// Set textboxes
2022-11-17 17:00:33 -06:00
servicesAndLaborTextBox.Text = total.ToString("c");
2022-11-17 21:59:26 -06:00
totalFeesTextBox.Text = (total + tax).ToString("c");
2022-11-16 17:48:22 -06:00
taxTextBox.Text = tax.ToString("c");
2022-11-17 21:59:26 -06:00
partsTextBox.Text = partsInputTextBox.Text;
}
private void exitButton_Click(object sender, EventArgs e)
{
Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
// Clear EVERYTHING
servicesAndLaborTextBox.Text = "";
partsTextBox.Text = "";
partsInputTextBox.Text = "";
taxTextBox.Text = "";
totalFeesTextBox.Text = "";
laborInputTextBox.Text = "";
// Now for the checkboxes.
oilChangeCheckBox.Checked = false;
lubeJobCheckBox.Checked = false;
radiatorFlushCheckBox.Checked = false;
transmissionFlushCheckBox.Checked = false;
inspectionCheckBox.Checked = false;
replaceMufflerCheckBox.Checked = false;
tireRotationCheckBox.Checked = false;
2022-11-16 17:48:22 -06:00
}
}
2022-11-17 17:00:33 -06:00
}