public partial class Login : Form
{
foreach (DataRow rowtab in obtainData.dataSetWithDB.Tables[0].Rows) //Looping through each row 1 by 1
{
tblLogin loginDetails = StoreloginDetailsToPassAroundForms(rowtab);
if (txtDisplay.TextLength == 4 && rowtab["managerAccount"].ToString() == "No" && getInfoFromSelectedCell(DataGridLoginID) == rowtab["userName"].ToString() && txtDisplay.Text == rowtab["userPIN"].ToString())
{
MainMenu nextForm = new MainMenu(false, loginDetails); //The issue is with the 'loginDetails' parametre that I am passing to the MainMenu form constructor, how do I solve this?
nextForm.Show();
}
}
private tblLogin StoreloginDetailsToPassAroundForms(DataRow row)
{
tblLogin loginDetails = new tblLogin();
loginDetails.ManagerAccount = row["managerAccount"].ToString();
loginDetails.UserName = row["userName"].ToString();
loginDetails.StaffName = row["staffName"].ToString();
loginDetails.UserID = Convert.ToInt32(row["userID"]);
return loginDetails;
}
}
public partial class MainMenu : Form
{
public MainMenu(bool WaiterAccount, tblLogin loginDetails)
{
InitializeComponent();
if (WaiterAccount == false)
{
btnMenuMang.Hide();
btnEmployeeMang.Hide();
btnSystemMang.Hide();
}
txtName.Text = loginDetails.StaffName;
}
}
请查看注释。
这是我得到的错误:
错误1可访问性不一致:参数类型' PSObyEssaKhan.tblLogin'比方法更难以获取' PSObyEssaKhan.MainMenu.MainMenu(bool,PSObyEssaKhan.tblLogin)' F:\ C#2016- PROTOTYPE \ V21登录结束\ PSObyEssaKhan \ PSObyEssaKhan \ MainMenu.cs 14 16 PSObyEssaKhan
我该如何解决这个问题?
答案 0 :(得分:1)
将您的tblLogin类设为公共
示例:
public class tblLogin
然后你不会得到这个例外