ASDV-C-Sharp/MP4/JoesAutomotive_CalebFontenot/Form1.cs
2022-11-17 17:00:33 -06:00

91 lines
2.8 KiB
C#
Executable File

using System.CodeDom;
namespace JoesAutomotive_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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;
}
private decimal TotalCharges()
{
decimal total = 0m;
total = OilLubeChanges(total);
total = FlushCharges(total);
total = MiscCharges(total);
total += OtherCharges();
return total;
}
private decimal TaxCharges()
{
decimal total = 0m;
total = MiscCharges(total);
decimal tax = total * 0.06m;
return tax;
}
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)
{
decimal total = TotalCharges();
decimal tax = TaxCharges();
decimal outputOtherCharges = OtherCharges();
// Set textboxes
servicesAndLaborTextBox.Text = total.ToString("c");
totalFeesTextBox.Text = (total + tax + outputOtherCharges).ToString("c");
taxTextBox.Text = tax.ToString("c");
}
}
}