My code so far : using System; using System.Collections.Generic; using System.Co
ID: 3908567 • Letter: M
Question
My code so far :
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 Lab4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
ClearOilLube();
ClearFlushes();
ClearMisc();
ClearOther();
ClearFees();
}
private void ClearOilLube()
{
if (oilCheckBox.Checked == true)
{
oilCheckBox.Checked = false;
}
if (lubeCheckBox.Checked == true)
{
lubeCheckBox.Checked = false;
}
}
private void ClearFlushes()
{
if (radiatorCheckBox.Checked == true)
{
radiatorCheckBox.Checked = false;
}
if (tranCheckBox.Checked == true)
{
tranCheckBox.Checked = false;
}
}
private void ClearMisc()
{
if (inspectionCheckBox.Checked == true)
{
inspectionCheckBox.Checked = false;
}
if (replaceCheckBox.Checked == true)
{
replaceCheckBox.Checked = false;
}
if (tireCheckBox.Checked == true)
{
tireCheckBox.Checked = false;
}
}
private void ClearOther()
{
partsTextBox.Text = null;
laborTextBox.Text = null;
}
private void ClearFees()
{
serviceTextBox.Text = null;
partTextBox.Text = null;
taxTextBox.Text = null;
totalTextBox.Text = null;
}
private void calculateButton_Click(object sender, EventArgs e)
{
double oil = 0, lube = 0, radiator = 0, trans = 0, inspection = 0, muffler = 0, tire = 0;
if (oilCheckBox.Checked == true)
{
oil = 26;
}
if (lubeCheckBox.Checked == true)
{
lube = 18;
}
if (radiatorCheckBox.Checked == true)
{
radiator = 18;
}
if (tranCheckBox.Checked == true)
{
trans = 80;
}
if (inspectionCheckBox.Checked == true)
{
inspection = 15;
}
if (replaceCheckBox.Checked == true)
{
muffler = 100;
}
if (tireCheckBox.Checked == true)
{
tire = 20;
}
double parts = double.Parse(partsTextBox.Text);
double labor = double.Parse(laborTextBox.Text);
{
}
}
}
}
I need help with the charges for the clear button.
Joe's Automotive Joe's Automotive performs the following routine maintenance services .Oil change-$26.00 .Lube job-$18.00 Radiator flush-$30.00 Transmission flush-$80.00 Inspection-$15.00 .Muffler replacement $100.00 Tire rotation-$20.00 Joe also performs other nonroutine services and charges for parts and labor ($20 per hour) Create an application that displays the total for a customer's visit to Joe's. The form should resemble the one shown in Figure Figure Automotive form oil & Lube Flushes Oil Chenge (328 00) Radator Flush (330 00) Lube Job (518.00) Transrission Flush (S60 00) Misc Parts and Laber hopection ($15.00) Parts Replace Nurser ($100.00) Tre Rotaton ($20 00) Labor (S) Sumrery Sorvices & Labor Parts Tax (on parts) Total Fecs Calculate Total Clear ExitExplanation / Answer
Your code:
private void clearButton_Click(object sender, EventArgs e)
{
ClearOilLube();
ClearFlushes();
ClearMisc();
ClearOther();
ClearFees();
}
private void ClearOilLube()
{
if (oilCheckBox.Checked == true)
{
oilCheckBox.Checked = false;
}
if (lubeCheckBox.Checked == true)
{
lubeCheckBox.Checked = false;
}
}
private void ClearFlushes()
{
if (radiatorCheckBox.Checked == true)
{
radiatorCheckBox.Checked = false;
}
if (tranCheckBox.Checked == true)
{
tranCheckBox.Checked = false;
}
}
private void ClearMisc()
{
if (inspectionCheckBox.Checked == true)
{
inspectionCheckBox.Checked = false;
}
if (replaceCheckBox.Checked == true)
{
replaceCheckBox.Checked = false;
}
if (tireCheckBox.Checked == true)
{
tireCheckBox.Checked = false;
}
}
private void ClearOther()
{
partsTextBox.Text = null;
laborTextBox.Text = null;
}
private void ClearFees()
{
serviceTextBox.Text = null;
partTextBox.Text = null;
taxTextBox.Text = null;
totalTextBox.Text = null;
}
The above code of yours will clear all the text boxes and the checked boxes to the default value and make it ready for the re-entry or for another user.
This button does not have any connection with the charges you are calculated in the previous buttons.
It has to be called only after every calculation has done completely and that is not compulsorily necessary.
This will not have any charge as it is the common procedure in windows forms.
It makes UI more users friendly and easy to use.
If the above solution is helpful to you in any way please rate it Or if you have any concerns please comment it, I will help you through
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.