Пример #1
0
        private void bConnect_Click(object sender, EventArgs e)
        {
            byte[] login    = Encoding.ASCII.GetBytes(tbLogin.Text);
            byte[] password = Encoding.ASCII.GetBytes(tbPassword.Text);

            string connectionResponse = _databaseConnection.CheckConnection(login, password);

            consoletest.Items.Add(connectionResponse);

            if (connectionResponse == "Good Password")
            {
                string comm =
                    $"SELECT * FROM users WHERE USERNAME = '******' AND USERPASS = '******'";
                string acctype = _databaseConnection.SQLGetParam(comm, "usertype");
                consoletest.Items.Add(acctype);


                string getiduser = $"SELECT * FROM users WHERE USERNAME = '******'";

                string iduser = _databaseConnection.SQLGetParam(getiduser, "userid");
                _loggedUserConnection = new UserConnection(login, password, int.Parse(acctype), int.Parse(iduser));
                _loggedUserConnection.GetMessages(_databaseConnection);
                lstTitre = _loggedUserConnection.GetTitres(lstTitre);
            }
            else
            {
                consoletest.Items.Add("Could not log in");
            }
        }