Question: I have the following code that will calculate the two text boxes txtHourlyRate.Text * txtHoursWeek. What I need to add to this is a else
I have the following code that will calculate the two text boxes txtHourlyRate.Text * txtHoursWeek. What I need to add to this is a else if for one of the following options below (I only need one):
txtSalary.Text = txtHourlyRate.Text * 40 - this is only to occur if the rbEmployee is selected
or
txtSalary.Text = txtHourlyRate.Text * 40 - this is to occur if only the txtHourlyRate.Text has a hourly rate entered.
The code below is for a contractor who will need to enter both details to calculate their salary.
If the rbEmployee is selected then the employee will only have to enter hourly rate (txtHoursWeek.Text will be hidden) as it will automatically calculate their salary by multiplying it by 40.
Here is my current code:
private void txtHourlyRate_TextChanged(object sender, EventArgs e) { if (txtHourlyRate.Text != " " && txtHoursWeek.Text != " ") { txtSalary.Text = ((Convert.ToDecimal(txtHourlyRate.Text)) * (Convert.ToInt32(txtHoursWeek.Text))).ToString();
}
Any help would be appreciated. Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
