Пример #1
0
        //Common function to process login. To be called by other functions
        //processing shop login
        private void processLogin()
        {
            //RMEOVE      JSDLKSDJHLSJDLJDKSJDLS
            var applicationForm = new ShopEntryForm();
            applicationForm.Show();
            this.Close();
            //REMOVE     KSLFNSLDHLSKDJSLDJLSDKJSLDK

            string query = "SELECT " + LOGIN_USERNAME_FIELD + " FROM " +
                           LOGIN_TABLE + " WHERE " + LOGIN_USERNAME_FIELD + "=" +
                           BaseConnection.STRING_SEPARATOR +
                           MySqlHelper.EscapeString(userNameText.Text) +
                           BaseConnection.STRING_SEPARATOR +
                           " AND " + LOGIN_PASSWORD_FIELD + "=MD5(" +
                           BaseConnection.STRING_SEPARATOR +
                           MySqlHelper.EscapeString(passwordText.Text) +
                           BaseConnection.STRING_SEPARATOR + ")";

            MySqlDataReader queryOutcome =
                singletonConnection.queryResult(query);
            if (queryOutcome != null)
            {
                processLoginQuery(queryOutcome);
            }
            else
            {
                errorSignal.ForeColor = Color.Red;
                errorSignal.Text = LOGIN_CONNECTION_FAILED;
            }
        }
Пример #2
0
        //Function process login query based on outcome provided
        private void processLoginQuery(MySqlDataReader queryOutcome)
        {
            int rowCount = 0;
            string username = "";
            while (queryOutcome.Read())
            {
                username = (string) queryOutcome[LOGIN_USERNAME_FIELD];
                rowCount++;
            }

            //Only one username/password combination should exist
            if (rowCount == 1)
            {
                singletonConnection.setBaseUser(username);
                var applicationForm = new ShopEntryForm();
                applicationForm.Show();
                this.Close();
            }
            else
            {
                errorSignal.ForeColor = Color.Red;
                errorSignal.Text = LOGIN_COMBINATION_FAILED;
            }
        }