Reputation: 33
I have my basic pay that is computed from the Basic Pay (The position code with a value ex. Code: A, Rate/day: 500) multiplied by the No of days worked.
if (cmbPositionCode.SelectedItem == "A")
txtBasic.Text = (500 * nudDays.Value).ToString();
else if (cmbPositionCode.SelectedItem == "B")
txtBasic.Text = (400 * nudDays.Value).ToString();
else
txtBasic.Text = (300 * nudDays.Value).ToString();
And now, I need to compute for the SSS Contribution that is if the basic pay is within the given range (ex. 10,000 & above, SSS Rate is 7%).
SSS Contribution = Basic Pay * SSS Rate
I tried this but I was not really sure on how to do it
double sscontri;
sscontri = Convert.ToDouble(txtBasic);
if (txtBasic >= 10000)
sscontri = txtBasic * 0.07;
txtSSS.Text = sscontri.ToString();
I'm getting an error of Operator '>=' cannot be applied to operands of type and Operator '*' cannot be applied to operands of type
I need help on how to remove this errors. Is my txtBasic inside the if wrong? TIA!
Upvotes: 0
Views: 60
Reputation: 802
I'm getting an error of Operator '>=' cannot be applied to operands of type and Operator '' cannot be applied to operands of type*
Because you can't compare txtBasic
which is a control to 10000
which is int. If you want to compare the txtBasic text
, you should convert it first to an int:
int basic = int.Parse(txtBasic.Text);
if (basic >= 10000)
sscontri = txtBasic * 0.07;
txtSSS.Text = sscontri.ToString();
Upvotes: 1