首先在programm.cs里设置登录窗体显示
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FrmReg fr = new FrmReg();
if (fr.ShowDialog()== DialogResult.OK)
{
Application.Run(new FrmMain());
}
}
}
代码中的FrmReg为登录窗体,,登录验证成功后 显示 FrmMain.cs窗体
在登录窗体FrmReg.cs的登录按钮中写上以下代码:
JC.BLL.Login.Add(GetModel());
MessageBox.Show("注册成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
//以下开始显示主窗体 并关闭登录窗体
this.DialogResult = DialogResult.OK;
this.Close();