嗨,我是新来的,也是新的C#。 我想制作一个包含登录的简单桌面应用程序(简单并已完成) 但我很困惑如何根据需要在数据库中检查的帐户类型制作不同的主窗口(我有用户和一个超级用户)
答案 0 :(得分:2)
要么为用户创建一个两个分隔的窗口,为超级用户创建一个窗口OR(如果这两个窗口之间没有太多差异),您只需根据users表决定什么东西显示如此简单:
if (this.UserType == 1) { //u assign UserType variable based on users table row
var superForm = new SuperForm(); //in case of use 2 seperated forms
superForm.Show();
}
或者假设例如超级用户窗口只有另一个按钮 仍然像这样简单:
public MainForm(int userType) { // u pass userType when creating the form after the login
if (userType == 1) {
this.superButton.Visible = true; //by default superButton would be hidden
}
}
对于mysql结构,您只需在UserType
中创建一个UsersTable
字段,例如超级用户的值 1 , 0 对于其他用户。