Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        resultado.text = " ";
        // Retrieve next word from database
        description = "something went wrong with the database";

        db = GetComponent <dbAccess>();

        if (!System.IO.File.Exists(Application.persistentDataPath + "/" + "InGame.db"))
        {
            db.OpenDB("InGame.db");
        }
        else
        {
            db.OpenDB("InGame.db");
        }

        //reader = db.BasicQuery("drop table if exists users");
        reader = db.BasicQuery("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'users';");


        string[] col     = { "kp", "nombre", "pw" };
        string[] colType = { "integer primary key autoincrement", "text", "text" };

        if (!db.CreateTable("users", col, colType))
        {
            Debug.Log("Error creating table");
        }

        db.CloseDB();
    }
Ejemplo n.º 2
0
//	void OnGUI() {
//		GUI.Window (0, new Rect (Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2 - 70), LoginWindow, "Login");
//		if (login){
//			loginUser ();
//		}
//		if (createUser){
//			createNewUser ();
//		}
//	}

    void createTable(dbAccess db, string tableName, ArrayList columnNames, ArrayList columnValues)
    {
        db.OpenDB(DatabaseName);
        try{
            db.CreateTable(tableName, columnNames, columnValues);
            Debug.Log("Created DB table");
        } catch (Exception e) {
            Debug.Log(TableName + " already exists.");
        }
    }
	// Use this for initialization
	void Start () 
	{
		if( m_ColumnLabels.Length != m_ValuesType.Length )
			return ;
		m_DB = new dbAccess() ;
		m_DB.OpenDB( m_DataBaseFileName ) ;
		Debug.Log( "m_DB.OpenDB done" ) ;
		
		try
		{
			m_DB.CreateTable( m_DataBaseTable1Name , m_ColumnLabels , m_ValuesType ) ;
			Debug.Log( "m_DB.CreateTable done" ) ;
		}
		catch
		{
			
		}
		
		RefreshData() ;
		Debug.Log( "m_DataBaseContent" + m_DataBaseContent.Count ) ;		

	}
Ejemplo n.º 4
0
    void DoMyWindow(int windowID)
    {
        // Q. Are you a player or a therapist?
        // A. Patient or Therapist
        if (windowID == 1)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label(chooseOne, centeredStyle);
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.BeginVertical();
            if (GUILayout.Button(player, GUILayout.Width(player.width), GUILayout.Height(player.height)))
            {
                window_ID = 2;
            }

            if (GUILayout.Button(therapist, GUILayout.Height(player.height), GUILayout.Width(player.width)))
            {
                window_ID = 3;
            }
            GUILayout.EndVertical();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        // patient login
        // Q. First Name, Last Name
        // A. ...
        if (windowID == 2)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.Label(playerLogin, centeredStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label(UserName);
            PatientUsername = GUILayout.TextField(PatientUsername, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(PassWord);
            PatientPassword = GUILayout.PasswordField(PatientPassword, "*"[0], 25, "box", GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(cancel, GUILayout.Width(cancel.width), GUILayout.Height(cancel.height)))
            {
                PatientUsername = "";
                PatientPassword = "";
                window_ID       = 1;
            }

            if (GUILayout.Button(signIn))
            {
                // check if patient is in database; if so, successful login
                if (db.isRecordExists(tableName, "username", PatientUsername, "password", PatientPassword))
                {
                    currentID = db.GetIDWithUserPass(tableName, "PatientID", "username", PatientUsername, "password", PatientPassword);
                    string patientTableName = tablePrefix + currentID;

                    db.InsertRow(patientTableName, newsessionCol, newsessionEntries);
                    List <int> sessID_list = new List <int>();
                    sessID_list = db.GetIDValues(patientTableName, "SessionID");
                    int newSessionNum = sessID_list[sessID_list.Count - 1];
                    registeredPatient = new Patient();
                    registeredPatient.beginSession(currentID, newSessionNum);

                    db.CloseDB();
                    PatientUsername = "";
                    PatientPassword = "";
                    Application.LoadLevel("Visualizer");
                }

                PatientUsername = "";
                PatientPassword = "";
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        // therapist login
        // Q. username, password
        // A. ...
        if (windowID == 3)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.Label("THERAPIST LOGIN", centeredStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label(UserName);
            TherapistUsername = GUILayout.TextField(TherapistUsername, "box", GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(PassWord);
            TherapistPassword = GUILayout.PasswordField(TherapistPassword, "*"[0], 25, "box", GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(cancel, GUILayout.Width(cancel.width), GUILayout.Height(cancel.height)))
            {
                TherapistUsername = "";
                TherapistPassword = "";
                window_ID         = 1;
            }
            if (GUILayout.Button(signIn, GUILayout.Width(signIn.width), GUILayout.Height(signIn.height)))
            {
                // check if therapist is in database
                // if so, successful login
                Application.LoadLevel("TherapistScreen");
                Debug.Log("do stuff");
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        // new user sign up
        // Q. Add a player or a therapist
        // A. Player or Therapist or Cancel
        if (windowID == 4)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label(AddAPlayerOrTherapist, centeredStyle);
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.BeginVertical();
            if (GUILayout.Button(player, GUILayout.Width(player.width), GUILayout.Height(player.height)))
            {
                window_ID = 5;
            }
            if (GUILayout.Button(therapist, GUILayout.Width(therapist.width), GUILayout.Height(therapist.height)))
            {
                window_ID = 6;
            }
            if (GUILayout.Button(cancel, GUILayout.Width(cancel.width), GUILayout.Height(cancel.height)))
            {
                window_ID = 1;
            }

            GUILayout.EndVertical();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        // new patient sign up
        // Q. First Name, Last Name, Therapist (***implement dropdown***)
        // A. ...
        if (windowID == 5)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.Label(enterInfo, centeredStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label(FirstName);
            newPatientFirstName = GUILayout.TextField(newPatientFirstName, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(LastName);
            newPatientLastName = GUILayout.TextField(newPatientLastName, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(therapist);
            newPatientTherapist = GUILayout.TextField(newPatientTherapist, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(UserName);
            newPatientUsername = GUILayout.TextField(newPatientUsername, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(PassWord);
            newPatientPassword = GUILayout.PasswordField(newPatientPassword, "*"[0], 25, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(add, GUILayout.Width(add.width), GUILayout.Height(add.height)))
            {
                // add patient to list
                if (newPatientLastName != "" && newPatientFirstName != "" && newPatientTherapist != "" &&
                    newPatientUsername != "" && newPatientPassword != "")
                {
                    newpatientEntries.Add(newPatientLastName);
                    newpatientEntries.Add(newPatientFirstName);
                    newpatientEntries.Add(newPatientTherapist);
                    newpatientEntries.Add(newPatientUsername);
                    newpatientEntries.Add(newPatientPassword);
                    db.InsertRow(tableName, newpatientCol, newpatientEntries);

                    string newPatientTableName = tablePrefix + db.GetID(
                        tableName, "PatientID", "LastName", newPatientLastName, "FirstName", newPatientFirstName);
                    db.CreateTable(newPatientTableName, newtableCol, newtableVal);
                    newPatientLastName  = "";
                    newPatientFirstName = "";
                    newPatientTherapist = "";
                    newPatientUsername  = "";
                    newPatientPassword  = "";
                    newpatientEntries.Clear();
                }
                window_ID = 1;
            }
            if (GUILayout.Button(cancel, GUILayout.Width(cancel.width), GUILayout.Height(cancel.height)))
            {
                newPatientLastName  = "";
                newPatientFirstName = "";
                // newPatientPilotHand = "";
                newPatientTherapist = "";
                newPatientUsername  = "";
                newPatientPassword  = "";
                newpatientEntries.Clear();
                window_ID = 1;
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }

        // new therapist sign up
        // Q. First Name, Last Name, username, password
        // A. ...
        if (windowID == 6)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
            GUILayout.Space(10);

            GUILayout.Label(enterInfo, centeredStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label(FirstName);
            newTherapistFirstName = GUILayout.TextField(newTherapistFirstName, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(LastName);
            newTherapistLastName = GUILayout.TextField(newTherapistLastName, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            // GUILayout.Space (40);
            GUILayout.Label(UserName);
            newTherapistUsername = GUILayout.TextField(newTherapistUsername, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            // GUILayout.Space (40);
            GUILayout.Label(PassWord);
            newTherapistPassword = GUILayout.PasswordField(newTherapistPassword, "*"[0], 25, GUILayout.Width(200), GUILayout.Height(30));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(add, GUILayout.Width(add.width), GUILayout.Height(add.height)))
            {
                // add therapist to list
                window_ID = 1;
            }
            if (GUILayout.Button(cancel, GUILayout.Width(cancel.width), GUILayout.Height(cancel.height)))
            {
                window_ID = 2;
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            GUILayout.EndVertical();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
        }
    }