我已经创建了一个类并且已经编写了类的单选按钮,并希望将它链接到GUI按钮上的代码是否可能?使用的GUI是Windows表单应用程序
班级代码
public void OnlineSalesman(double OnlinePercentage, double OnlineSales)
{
double Commission = OnlinePercentage * OnlineSales;
double Total = Commission + OnlineSales;
Message = Commission.ToString();
Message1 = Total.ToString();
}
public void PhoneSalesman(double PhonePercentage, double PhoneSales)
{
double Comission = PhonePercentage * PhoneSales;
double Total = Comission + PhoneSales;
Message = Comission.ToString();
Message1 = Total.ToString();
}
public void DoorSalesman(double DoorPercentage, double DoorSales)
{
double Comission = DoorPercentage * DoorSales;
double Total = Comission + DoorSales;
Message = Comission.ToString();
Message1 = Total.ToString();
}
我希望将类单选按钮代码添加到
中的GUI按钮的代码private void btnSave_Click(object sender, EventArgs e)
{
double sales = 0;
if (txtID.Text == "")
{
MessageBox.Show("Please enter ID");
txtID.Focus();
}
else if (txtSales.Text == "")
{
MessageBox.Show("Please enter Sales");
txtSales.Focus();
}
else if (txtName.Text == "")
{
MessageBox.Show("Please Enter Name ");
}
else if (double.TryParse(txtSales.Text, out sales) == false)
{
MessageBox.Show("Numeric Value only");
txtSales.Focus();
}
else
{
if (the codes i want to link from the class)
}
}