Example #1
0
    public void finishSession()
    {
        ID = 0;

        db = new dbAccess();
        db.OpenDB(dbName);

        // If not accidental login
        if(sessionTime > 0)
        {
            TimeSpan duration = TimeSpan.FromSeconds((int)sessionTime);
            db.UpdateSpecific(patientTable, "SessionLength", sessionTime.ToString(), "SessionID", sessionNum);
            db.UpdateSpecific(patientTable, "NumOfPlays", numPlays.ToString(), "SessionID", sessionNum);
        }
        // If accidental login, delete the row made for this session
        else
        {
            db.DeleteRow(patientTable, "SessionID", sessionNum);
        }

        db.CloseDB();
    }
Example #2
0
    public void finishSession()
    {
        ID = 0;

        db = new dbAccess();
        db.OpenDB(dbName);

        // If not accidental login
        if (sessionTime > 0)
        {
            TimeSpan duration = TimeSpan.FromSeconds((int)sessionTime);
            db.UpdateSpecific(patientTable, "SessionLength", sessionTime.ToString(), "SessionID", sessionNum);
            db.UpdateSpecific(patientTable, "NumOfPlays", numPlays.ToString(), "SessionID", sessionNum);
        }
        // If accidental login, delete the row made for this session
        else
        {
            db.DeleteRow(patientTable, "SessionID", sessionNum);
        }

        db.CloseDB();
    }
Example #3
0
    void DoMyWindow(int windowID)
    {
        if (windowID == 1)
        {
            // Open Main Window

            // Draw any controls inside the window here
            GUI.Label(new Rect(7, 10, 100, 30), "ID");
            GUI.Label(new Rect(130, 10, 100, 30), "Name");

            // show tabular patient listing
            GUILayout.BeginArea(new Rect(0, 40, Screen.width / 2 - 100, Screen.height * 2 / 3 - 40));

            // DISPLAY PATIENTS AND SELECT BUTTONS
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(Screen.height * 2 / 3 - 40));

            if (db.GetRowCount(tableName) > 0)
            {
                List <int> ID_list = new List <int>();
                ID_list = db.GetIDValues(tableName, "PatientID");
                for (int i = 0; i < ID_list.Count; i++)
                {
                    List <string> rowList = new List <string>();
                    rowList = db.GetRowValues(tableName, "PatientID", ID_list[i]);
                    GUILayout.BeginHorizontal("box");
                    GUILayout.Space(20);
                    GUILayout.Label(rowList[0], GUILayout.Width(50));                           // ID
                    GUILayout.FlexibleSpace();
                    string name = rowList[1] + ", " + rowList[2];
                    GUILayout.Label(name, GUILayout.Width(150));                                // Last, First
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Select", GUILayout.Width(150)))
                    {
                        selectedID = int.Parse(rowList[0]);
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }

        /*else if (windowID == 2)
         * {
         *      selectedID = -1;
         *
         *      // Open Add Patient Window
         *      GUILayout.BeginArea(new Rect(50, Screen.height/4, Screen.width/3, Screen.height/3));
         *      GUILayout.BeginVertical();
         *
         *      GUILayout.Label("New patient information: ");
         *      GUILayout.Space(10);
         *
         *      GUILayout.BeginHorizontal("box");
         *      GUILayout.Label("Last Name");
         *      newPatientLastName = GUILayout.TextField(newPatientLastName);
         *      GUILayout.EndHorizontal();
         *
         *      GUILayout.BeginHorizontal("box");
         *      GUILayout.Label("First Name");
         *      newPatientFirstName = GUILayout.TextField(newPatientFirstName);
         *      GUILayout.EndHorizontal();
         *
         *      GUILayout.BeginHorizontal("box");
         *      if(GUILayout.Button("Add"))
         *      {
         *              if(newPatientLastName != "" && newPatientFirstName != "")
         *              {
         *                      newpatientEntries.Add(newPatientLastName);
         *                      newpatientEntries.Add(newPatientFirstName);
         *                      db.InsertRow(tableName, newpatientCol, newpatientEntries);
         *
         *                      string newPatientTableName = tablePrefix + db.GetID(
         *                              tableName, "PatientID", "LastName", newPatientLastName, "FirstName", newPatientFirstName);
         *                      db.CreateTable(newPatientTableName, newtableCol, newtableVal);
         *
         *                      newPatientLastName = "";
         *                      newPatientFirstName = "";
         *                      newpatientEntries.Clear();
         *
         *                      window_ID = 1;
         *              }
         *      }
         *      if(GUILayout.Button("Cancel"))
         *      {
         *              window_ID = 1;
         *      }
         *      GUILayout.EndHorizontal();
         *      GUILayout.EndVertical();
         *      GUILayout.EndArea();
         * }*/
        else if (windowID == 3)
        {
            selectedID = -1;

            // Open Delete Patient Window
            GUILayout.BeginArea(new Rect(50, Screen.height / 4, Screen.width / 3, Screen.height / 3));
            GUILayout.BeginVertical("box");

            GUILayout.Label("Enter patient information: ");
            GUILayout.Space(10);
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("ID");
            deletePatientID = GUILayout.TextField(deletePatientID);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal("box");

            if (GUILayout.Button("Delete"))
            {
                /* TO BE ADDED LATER
                 * prompt user if he is sure he would like to delete this patient
                 */
                if (deletePatientID != "")
                {
                    /* TO BE ADDED LATER
                     * if ID not found, show message: "Patient ID not found!"
                     */
                    int deleteID;                       // if string can be converted to int, then delete
                    if (int.TryParse(deletePatientID, out deleteID))
                    {
                        int delID = deleteID;                           // to avoid NullReferenceException
                        db.DeleteRow(tableName, "PatientID", delID);
                        string tabletoDelete = tablePrefix + delID.ToString();
                        db.DeleteTable(tabletoDelete);
                    }
                    deletePatientID = "";

                    window_ID = 1;
                }
            }

            if (GUILayout.Button("Cancel"))
            {
                deletePatientID = "";
                window_ID       = 1;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
    }