Jump to content
Sign in to follow this  
JLogan3o13

<solved> Trying to display columns from Array in GUI

Recommended Posts

JLogan3o13

I have a script that creates and manages a small scheduling SQLite database for cancer patients at one of my customers. I was thinking of wrapping a GUI around it, to make it a bit more user friendly. For now the interface is very minimalist (first screenshot). I would like to display the first and last name, culled from the appropriate columns, in the box on the left (second screenshot). The SQLite query is no problem; I'm just wondering as to a method of pulling this data into a form. The relevant portion of the SQLite code is below; any suggestions would be appreciated.

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <File.au3>
#include <Array.au3>
Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()

If Not FileExists(@DesktopDir & "\abc.db") Then
_create()
EndIf

$hDb = _SQLite_Open(@DesktopDir & '\abc.db')

Func _create()

$hDb = _SQLite_Open(@DesktopDir & '\abc.db')
  _SQLite_Exec(-1, "Create table Patients(ID, First_Name, Last_Name, Phone_Number, Next_Appointment)")
_addUser()

EndFunc

Func _addUser()

  $pID = InputBox("Patient Care Database", "Please enter a unique ID for the Patient")
  $fName = InputBox("Patient Care Database", "Please enter the Patient's First Name")
  $lName = InputBox("Patient Care Database", "Please enter the Patient's Last Name")
  $phoneNum = InputBox("Patient Care Database", "Please enter the Patient's Contact Number")
  $nextAppt = InputBox("Patient Care Database", "Please enter the date of the Patient's Next Appointment")

  _SQLite_Exec(-1, 'INSERT INTO Patients VALUES (' & _
     '"' & $pID & '", "' & $fName & '", "' & $lName & '", "' & $phoneNum & '", "' & $nextAppt & '")' )

  $msg = MsgBox(4, "Patient Care Database", "Would you like to add another Patient?")
     If $msg = 6 Then
        _addUser()
     EndIf

EndFunc

Func _query()

  Local $hQuery, $aRow, $sMsg

  $query = InputBox("Patient Care Database", "Please enter the Patient's ID or Last Name")

  Local $aQuery = _SQLite_Query(-1, "SELECT Next_Appointment FROM Patients WHERE ID='" & $query & "' OR Last_Name='" & $query & "'", $hQuery)

   While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    $sMsg &= $aRow[0]
   WEnd

  MsgBox(0, "Patient Care Database", $sMsg)

EndFunc

$iRval = _SQLite_GetTable2d(-1, "Select Last_Name, First_Name from Patients;", $aResult, $iRows, $iColumns)

If $iRval = $SQLITE_OK Then
  _ArrayDisplay($aResult, "Patient Care Database", -1)
EndIf

_SQLite_Close()
_SQLite_Shutdown()

Edit: Disregard my laziness, should have read deeper into the help file. It seems I can use GUICtrlListView to do something like this.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×