使用GroupBox
第一步:创建一个Windows窗体应用程序项目GroupBoxDemo。其窗体设计如下
第二步:计算按钮代码如下
private void button1_Click(object sender, EventArgs e)
{
double ordinarySalary = Convert.ToDouble(textBox8.Text); //工作日时薪
double holidaySalary = Convert.ToDouble(textBox8.Text); //节假日时薪
//每天工作时间
double monday = Convert.ToDouble(textBox1.Text);
double tuesday= Convert.ToDouble(textBox2.Text);
double wednesday= Convert.ToDouble(textBox3.Text);
double thursday= Convert.ToDouble(textBox4.Text);
double friday= Convert.ToDouble(textBox5.Text);
double saturday= Convert.ToDouble(textBox6.Text);
double sunday= Convert.ToDouble(textBox7.Text);
//工作日为周一到周五,节假日为周六和周日
double weekday = monday +tuesday+wednesday+thursday+friday;
double holiday = saturday+sunday;
//计算薪水并显示
double allSalary = ordibarySalary*weekday +holidaySalary*holiday;
textBox10.Text = allSalary.ToString();
}
|