public static void Copy()
        {
            DataSet DS = new DataSet();
            string ConnectionString = "Data Source=" + CalibrationSettings.Default.ConnectionDir + "Users.db;Version=3;New=False;Compress=True;";
            string LoadCommand = "SELECT * FROM users";
            DS.Clear();
            SQLiteConnection Connection = new SQLiteConnection(ConnectionString);
            //SQLiteCommand Query = new SQLiteCommand(LoadCommand, Connection);
            SQLiteDataAdapter DataAdaptor = new SQLiteDataAdapter(LoadCommand, Connection);
            DataAdaptor.Fill(DS);

            foreach (DataRow dRow in DS.Tables[0].Rows)
            {
                DataClasses.UserProfile CopyUser = new UserProfile();
                CopyUser.Gender = dRow[0].ToString();
                CopyUser.Name = dRow[2].ToString();
                CopyUser.Surname = dRow[3].ToString();
                CopyUser.Weight = Convert.ToInt32(dRow[5]);
                CopyUser.Password = dRow[6].ToString() + "000";
                if (dRow[1].ToString() == "255")
                    CopyUser.Name = "Richard";
                CopyUser.Name = new String(CopyUser.Name.Where(x => x != ' ' && x != '\r' && x != '\n').ToArray());
                CopyUser.EmailAddress = CopyUser.Name + dRow[1].ToString() + "@grucox.com";
                AccessorUsers.RegisterNewUser(CopyUser);
            }
        }
        //Button - Next
        private void btnNext_MouseUp(object sender, MouseEventArgs e)
        {
            if (CalibrationSettings.Default.SoundEnabled == true) GlobalFunctions.PlayClickSound();

            if (backgroundWorker_CheckUserEmail.IsBusy != true)
            {
                backgroundWorker_CheckUserEmail.RunWorkerAsync();    // Start the asynchronous operation.
            }

            FormMessageDialog = new frmMessageDialog("Validating User E-mail Address...", MessageBoxButtons.OK);
            FormMessageDialog.btnOK.Visible = false;
            FormMessageDialog.ShowDialog();

            switch (VerifyUserResponse)
            { 
                case "UserNotFound":
                    break;
                case "VerifyUserFailed":
                    break;
                case "UserFound":
                    GlobalVariables.WriteToRemoteServer = true;
                    SelectedUser = new DataClasses.UserProfile();
                    SelectedUser.EmailAddress = tbUserEmailAddress.Text;
                    string lblDialogText = "Please enter the Password for user: "******"";
                    ShowFormPassCodeCheck(lblDialogText, SelectedUser);
                    //((frmPassCodeCheck)Application.OpenForms["frmPassCodeCheck"]).SelectedUser.EmailAddress = tbUserEmailAddress.Text;
                    break;
                case "ConnectionToServerFailed":
                    if (SelectedUser != null)
                    {
                        GlobalVariables.WriteToRemoteServer = false;
                        string lblDialogText1 = "Please enter the Password for user: "******"";
                        ShowFormPassCodeCheck(lblDialogText1, SelectedUser);
                    }
                    break;
                case "SystemInOfflineMode":
                    if (SelectedUser != null)
                    {
                        GlobalVariables.WriteToRemoteServer = false;
                        string lblDialogText1 = "Please enter the Password for user: "******"";
                        ShowFormPassCodeCheck(lblDialogText1, SelectedUser);
                    }
                    break;
                default:
                    break;
            }
        }
        //System in Offline Mode
        private void SystemOfflineMode()
        {
            VerifyUserResponse = "SystemInOfflineMode";
            FormMessageDialog.UpdateTextSleep("System is configured to off-line mode", 2000);

            SelectedUser = DataClasses.AccessorUsers.GetUserByEmail(tbUserEmailAddress.Text);
            if (SelectedUser == null)
            {
                FormMessageDialog.UpdateTextSleepAndClose("User Profile not found on local server.\nPlease register a new profile.", 2000); 
            }
            else
                FormMessageDialog.Close();
        }
        //Switch to Offline Mode
        private void SwitchOfflineMode()
        {
            VerifyUserResponse = "ConnectionToServerFailed";
            FormMessageDialog.UpdateTextSleep("Connection to server could not be established", 2500);
            FormMessageDialog.UpdateTextSleep("Switching to off-line mode...\nSession Data will only be recorded to the local profile", 2500); 

            SelectedUser = DataClasses.AccessorUsers.GetUserByEmail(tbUserEmailAddress.Text);
            if (SelectedUser == null)
            {
                FormMessageDialog.UpdateTextSleepAndClose("User Profile not found on local server.\nPlease register a new profile", 2500); 
            }
            else
                FormMessageDialog.Close();

        }
        //Verify/Register local user - move to controller?
        private bool VerifyRegisterLocalUser(out string LocalRegisterResult)
        {
            LocalRegisterResult = "User Registration Failed";
            NewUser = new DataClasses.UserProfile();
            NewUser.Name = tbName.Text;
            NewUser.Surname = tbSurname.Text;
            NewUser.Weight = Convert.ToInt32(tbWeight.Text);
            NewUser.EmailAddress = tbEmail.Text;
            NewUser.Password = tbPassword.Text;

            DataClasses.UserProfile ExistingUser = DataClasses.AccessorUsers.GetUserByEmail(NewUser.EmailAddress);

            if (ExistingUser == null)
            {
                bool result = DataClasses.AccessorUsers.RegisterNewUser(NewUser);
                if (result == false)
                {
                    LocalRegisterResult = "LocalUserRegistrationFailed";
                    return false;
                }
                else
                {
                    LocalRegisterResult = "UserRegisteredToLocalDB";
                    return true;
                }
            }
            else
            {
                NewUser = ExistingUser;
                LocalRegisterResult = "UserAlreadyRegisteredToLocalDB";
                return false;
            }
        }
 partial void DeleteUserProfile(UserProfile instance);
 partial void UpdateUserProfile(UserProfile instance);
 partial void InsertUserProfile(UserProfile instance);
 private void textBoxFirstName_TextChanged(object sender, EventArgs e)
 {
     FilterResults();
     SelectedUser = null;
     tbUserID.Text = "";
 }
        private void DgvUserProfiles_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            tbUserID.Text = null;
            int currentRow = int.Parse(e.RowIndex.ToString());

            if (currentRow >= 0)
            {
                if (CalibrationSettings.Default.IsInternetConfigured == true)
                {
                    SelectedUser = new DataClasses.UserProfile();
                    string SelectedEmail = DgvUserProfiles["Email", currentRow].Value.ToString();
                    SelectedUser.EmailAddress = (from users in RegisteredRemoteUsers where users.Email == SelectedEmail select users).FirstOrDefault<DataClasses.User>().Email.ToString();
                    SelectedUser.id = (from users in RegisteredRemoteUsers where users.Email == SelectedEmail select users).LastOrDefault<DataClasses.User>().UserID;
                    tbUserID.Text = SelectedUser.EmailAddress.ToString();
                }
                else
                {
                    SelectedUser = DataClasses.AccessorUsers.GetUserByEmail(DgvUserProfiles[7, currentRow].Value.ToString());
                    tbUserID.Text = SelectedUser.EmailAddress.ToString();
                }
            }


        }