加班时间加工时的工资计算问题

时间:2015-05-09 17:42:12

标签: c# asp.net

我花了太多时间在理论上很简单。我的工资计算器仅在小时超过40小时时显示一个值。如果我输的少于40,那么输出是0.00英镑?一些指导意见将不胜感激:

hoursWorked = double.Parse(txtHoursWorked.Text); // change string to int

switch (rblJobRole.SelectedIndex)// set employees basic hourly rate
{
    case 0: //engineer
        basicHourRate = 10;
        break;
    case 1: //Senior Engineer
        basicHourRate = 12;
        break;
    case 2: //Technical Engineer
        basicHourRate = 25;
        break;
    case 3: //Supervisor
        basicHourRate = 30;
        break;
}

if (ckBEng.Checked) // if they have a certificate
{
    certAmount = (basicHourRate * 10) / 100; // calculate 10% of hourly rate
    basicHourRate = basicHourRate + certAmount; // add to hourly rate
    basicWage = basicHourRate * hoursWorked; // basic wage set to include bonus.
}

if (hoursWorked > 40) // if employee worked more than 40hrs
{
    overHrs = hoursWorked - regHrs; // calcualte over hours
    basicWage = regHrs * basicHourRate; // calculate basic wage @ 40hrs only
    overTimeRate = overHrs * (basicHourRate * 1.5); // calculate 50% bonus on 40+ hrs
    basicWage = basicWage + overTimeRate; // calculate total wage
}

lblTotalWage.Text = basicWage.ToString("c"); // int to string to display Total Wage on a label
lblDescWage.Text = "You have earned:  ";

1 个答案:

答案 0 :(得分:3)

如果他们没有证书(ckBEng.Checkedfalse),并且他们不能使用&gt; 40小时(hoursWorked <= 40),他们不拿钱: - )

if (ckBEng.Checked)
{
}

这里需要else

或者你搬家

basicWage = basicHourRate * hoursWorked;

if

之外