//This function checks if the username is already taken. If yes, the function returns false. If no: true
        public bool verifyUsername(string name)
        {
            bool valid = false;

            //Creating a connection and sending the username to the database repository for testing
            DBRepository dbrUserTest = new DBRepository ();
            valid = dbrUserTest.TestUsername(name);

            return valid;
        }
Ejemplo n.º 2
0
        //This function loads the text fields with user information
        //UNDER CONSTRUCTION !! GLOBAL VARIABLE FOR DETERMINING USER ID IS NECESSARY
        void LoadAccount_Click(object sender, EventArgs e)
        {
            DBRepository dbr = new DBRepository ();
            var result = dbr.GetAccount();
            Toast.MakeText (this, result, ToastLength.Short).Show ();

            EditText ID = FindViewById<EditText> (Resource.Id.txtGetId);
            //ID.SetText = dbr.GetAccount(UGHHHHH)
            EditText user = FindViewById<EditText> (Resource.Id.txtGetUsername);
            EditText pass = FindViewById<EditText> (Resource.Id.txtGetPassword);
            EditText access = FindViewById<EditText> (Resource.Id.txtGetAccess);
        }
Ejemplo n.º 3
0
        //This function updates the text fields in the layout to relect user information by id number
        void DisplayTable(int id)
        {
            DBRepository dbr = new DBRepository ();
            var user = dbr.GetUserById (id);

            //Setting text fields to information
            Id.Text = (user.ID).ToString();
            Username.Text = user.UserName;
            Password.Text = user.Pass;
            ProfileName.Text = user.ProfileName;
            Access.Text = (user.Access).ToString ();
            FName.Text = user.FirstName;
            LName.Text = user.LastName;
            Email.Text = user.Email;
        }
        //This handler tests and saves information for a new user
        void Register_Click(object sender, EventArgs e)
        {
            //Saving input into strings(access level is assigned in other event handlers)
            string User = FindViewById<EditText>(Resource.Id.txtUsername).Text.ToString();
            string Password = FindViewById<EditText>(Resource.Id.txtPassword).Text.ToString();
            string RePassword = FindViewById<EditText>(Resource.Id.txtRePassword).Text.ToString();
            string Fname = FindViewById<EditText>(Resource.Id.txtFName).Text.ToString();
            string Lname = FindViewById<EditText>(Resource.Id.txtLName).Text.ToString();
            string Email = FindViewById<EditText>(Resource.Id.txtEmail).Text.ToString();
            string ProfileName = FindViewById<EditText>(Resource.Id.txtPName).Text.ToString();

            //Testing username and password/repassword
            bool validUser, validPass;
            validUser = verifyUsername(User);
            validPass = verifyPassword(Password, RePassword);

            if (!validUser)
                {
                string userError = "This username is already selected!";
                Toast.MakeText (this, userError, ToastLength.Short).Show ();
                }
            else if (!validPass)
                {
                string passwordError = "The passwords do not match.";
                Toast.MakeText (this, passwordError, ToastLength.Short).Show ();
                }
            else
                {
                    DBRepository dbr = new DBRepository ();
                    var result = dbr.CreateDB (User, Password, ProfileName, accessLevel, Fname, Lname, Email);
                    Toast.MakeText (this, result, ToastLength.Short).Show ();
                    StartActivity (typeof(RegisterConfirmActivity));
                }
        }
Ejemplo n.º 5
0
 //This function displays all users as a message
 void GetAll_Click(object sender, EventArgs e)
 {
     DBRepository dbr = new DBRepository ();
     string result = dbr.GetAccount ();
     Toast.MakeText (this, result, ToastLength.Short).Show ();
 }