2

enter image description here

I need help on how can I compute for the Basic Pay which is the Rate/Day * No. of days worked.

How can I get the values of every position code so that I can multiply it to the No. of Days Worked.

For example when I enter position code A, the rate/day is 500. That should do 500 * 2 so that my basic pay would come out as 1000.

I need help please. Thanks in advance!!

1
  • 2
    if you get an answer that helps you to solve your problem, you should mark it as accepted. Here is explained how it works Commented Jun 25, 2021 at 9:02

1 Answer 1

1

On your NumericUpDown control, there's an event called ValueChanged, you can use that to compute the basic pay of the employee based on your ComboBox value.

You can use this code to automatically compute the basic bay of your employee base on the number of days worked

private void NumericUpDown1_ValueChanged(Object sender, EventArgs e)
{
    if(cmbPositionCode.SelectedItem == "Code A")
        txtBasicPay.Text = 500 * NumericUpDown1.Value;
    else if(cmbPositionCode.SelectedItem == "Code B")
        txtBasicPay.Text = 600 * NumericUpDown1.Value;
    ...
}

Edit:

So you want to use the compute button to compute the basic pay which is almost the same as above but you will put the code in the Click event of your Compute button

private void btnCompute_Click(Object sender, EventArgs e)
    {
        if(cmbPositionCode.SelectedItem == "Code A")
            txtBasicPay.Text = 500 * NumericUpDown1.Value;
        else if(cmbPositionCode.SelectedItem == "Code B")
            txtBasicPay.Text = 600 * NumericUpDown1.Value;
        ...
    }
Sign up to request clarification or add additional context in comments.

8 Comments

I did it like this decimal txtBasic; if(cmbPositionCode.SelectedItem == "A") txtBasic = 500 * numericUpDown1.Value; else if(cmbPositionCode.SelectedItem == "B") txtBasic = 400 * numericUpDown1.Value; else if (cmbPositionCode.SelectedItem == "C"); txtBasic = 300 * numericUpDown1.Value; How can I use my compute button into computing it and putting the answer in my textbox for Basic Pay txtBasic
@MikaelaNera I'll edit my post and provide the answer
@MikaelaNera oh I forgot to put the Text of the textbox on the code, I already fix it though.
Well you need to convert it to string
Great! You can upvote my answer at approved it if it helps you.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.