Created
November 6, 2016 23:24
-
-
Save drmcarvalho/07a7bf283e54f911e6030aace4fa8c66 to your computer and use it in GitHub Desktop.
Tela de login.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Forms; | |
namespace ExemploLogin | |
{ | |
public partial class frmLogin : Form | |
{ | |
private bool _loginOk = false; | |
public frmLogin() | |
{ | |
InitializeComponent(); | |
} | |
private void frmLogin_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
if (_loginOk) | |
{ | |
DialogResult = DialogResult.OK; | |
} | |
} | |
private void _btnLogin_Click(object sender, EventArgs e) | |
{ | |
_loginOk = Login(_txtUser.Text, _txtPass.Text); | |
if (_loginOk) | |
{ | |
Close(); | |
} | |
else | |
{ | |
MessageBox.Show("Usuario ou senha não confere."); | |
} | |
} | |
bool Login(string user, string pass) | |
{ | |
return _txtUser.Text.Equals("admin") && _txtPass.Text.Equals("123"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Forms; | |
namespace ExemploLogin | |
{ | |
static class Program | |
{ | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
static void Main() | |
{ | |
frmLogin login = new frmLogin(); | |
if (login.ShowDialog() == DialogResult.OK) | |
{ | |
Application.Run(new MainFormEx()); | |
} | |
else | |
{ | |
Application.Exit(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment