我不确定我是否做得对,但是当我在运行时单击CalculateBttn_Click 按钮时,我试图让CalculateGrossPay 方法运行。但是,无论出于何种原因,我都会遇到不断变化的随机语法错误。我不会改变任何东西来实现这一点。我应该制定一个单独的方法来计算总工资。
private void CalculateBttn_Click(object sender, EventArgs e)
{ CalculateGrossPay(decimal hours, decimal rate);
}
private decimal CalculateGrossPay(decimal hours, decimal rate)
{
decimal result=0.00m;
decimal standardHours= 0.00m;
decimal overtimeHours=0.00m;
if (hours > 40)
{
overtimeHours = (hours - 40) * ( (rate) * 1.5m);
standardHours = 40 * rate;
DisplayOutPut.Text = name+ NameTextBox.Text + "";
DisplayOutPut.Text = "Gross Pay:" + result;
}
else
{
standardHours = hours * rate;
DisplayOutPut.Text = "Hours:" + HoursTextBox.Text;
DisplayOutPut.Text = "Rate:" + RateTextBox.Text;
}
result = standardHours + overtimeHours;
return result;
}