private void buttonLogin_Click(object sender, EventArgs e) { string name = textBoxUsername.Text; string pass = textBoxPassword.Text; String ID = textBox1.Text; bool login = false; login = _queryUser.queryAstronautaLogin(ID, pass); if (login) { Business.Astronauta u = _queryUser.login(ID, name, pass); _dataBase.User = u; MessageBox.Show("Login efetuado com sucesso"); this.Dispose(); } else { if (_queryUser.queryNASAadminLogin(ID, pass)) { Register r = new Register(_queryUser); r.Show(); } else { MessageBox.Show("Login incorrecto"); } } }
public EscolheMissao(Business.DataBaseUser dataBase, DataBase.QueryUser queryUser) { InitializeComponent(); _dataBase = dataBase; _queryUser = queryUser; // estruturas auxiliares para calculo da decisão tabelaSmartNorm = new Dictionary <string, float>(); Business.Astronauta user = _dataBase.User; }
/*Cria um User com os dados da Base de Dados*/ public Business.Astronauta login(string ID, string nome, string password) { Business.Astronauta u = new Business.Astronauta(); SqlDataReader myReader = null; string select = "SELECT [nome] AS NOME, [password] AS PASSWORD, [ID] AS ID" + " FROM [LI4].[dbo].[Astronauta] " + " WHERE nome = '" + nome + "' " + "AND password = '******'" + "AND ID = '" + ID + "'"; SqlCommand myCommand = new SqlCommand(select, _myConnection); myReader = myCommand.ExecuteReader(); while (myReader.Read()) { u.Username = (string)myReader["USERNAME"]; u.Password = (string)myReader["PASSWORD"]; u.Id = (string)myReader["ID"]; } return(u); }