private void btLogin_Click(object sender, EventArgs e) { if (btLogin.Text == "Login") { var user = Firebird.ReturnUser(txtUser.Text, txtPassword.Text); if (user.UserName == null) { var lista = Firebird.ReturnListUsers(); bool UserExists = false; foreach (var item in lista) { if (item.UserName == txtUser.Text) { UserExists = true; break; } } string s = string.Empty; if (!UserExists) { s = "Usuário não encontrado"; } else { s = "Senha incorreta"; } MessageBox.Show(s, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CurrentUser = user; cbCanAdd.Checked = user.CanAdd == 1; cbCanAlter.Checked = user.CanAlter == 1; cbCanDelete.Checked = user.CanDelete == 1; txtUser.Enabled = false; txtPassword.Enabled = false; btLogin.Text = "Desconectar"; lbUser.Text = user.UserName; if (CurrentUser.IsAdmin == 1) { label1.Text = "Admin: "; } else { label1.Text = "Usuário: "; } Firebird.SaveLastUser(CurrentUser); return; } if (btLogin.Text == "Desconectar") { CurrentUser = null; txtUser.Enabled = true; txtPassword.Enabled = true; txtUser.Text = string.Empty; txtPassword.Text = string.Empty; btLogin.Text = "Login"; lbUser.Text = "--"; } }