static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //显示登录窗体 FrmUserLogin frmUserLogin = new FrmUserLogin(); DialogResult dialogResult = frmUserLogin.ShowDialog(); //判断是否登录成功 if (dialogResult == DialogResult.OK) { Application.Run(new FrmMain()); } else { Application.Exit(); } }
//切换账号 private void BtnChangeAccount_Click(object sender, EventArgs e) { if (userLogin == null) { userLogin = new FrmUserLogin(); userLogin.Text = "【账号切换】"; } else { userLogin.Activate();//激活只能在最小化的时候起作用 userLogin.WindowState = FormWindowState.Normal; } DialogResult dialogResult = userLogin.ShowDialog(); if (dialogResult == DialogResult.OK) { this.lblCurrentUser.Text = Program.admins.AdminName + "]"; } }