点击登录按钮时;
1 if (this.txtLoginName.Text.Trim()=="admin" && this.txtLoginPwd.Text.Trim()=="123456") 2 { 3 this.DialogResult = DialogResult.OK; 4 this.Close(); 5 } 6 else 7 { 8 MessageBox.Show("用户名或密码错误", "信息提示"); 9 }
1 static class Program 2 { 3 /// <summary> 4 /// 应用程序的主入口点。 5 /// </summary> 6 [STAThread] 7 static void Main() 8 { 9 Application.EnableVisualStyles(); 10 Application.SetCompatibleTextRenderingDefault(false); 11 LoginFrm lf = new LoginFrm(); 12 lf.ShowDialog(); 13 if (lf.DialogResult == DialogResult.OK) 14 { 15 Application.Run(new MainFrm()); 16 } 17 else return; 18 } 19 }