Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
100
Task/Simple-database/Run-BASIC/simple-database.basic
Normal file
100
Task/Simple-database/Run-BASIC/simple-database.basic
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
sqliteconnect #sql, "f:\client.db" ' Connect to the DB
|
||||
|
||||
' -------------------------------
|
||||
' show user options
|
||||
' -------------------------------
|
||||
[sho]
|
||||
cls ' clear screen
|
||||
button #acd, "Add a new entry", [add]
|
||||
button #acd, "Print the latest entry", [last]
|
||||
button #acd, "Print the latest entry for each category", [lastCat]
|
||||
button #acd, "Print all entries sorted by a date", [date]
|
||||
button #ex, "Exit", [exit]
|
||||
wait
|
||||
|
||||
' ------------------------------------
|
||||
' add a new entry (user input screen)
|
||||
' ------------------------------------
|
||||
[add]
|
||||
cls ' clear the screen
|
||||
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat>"
|
||||
html "<TR align=center BGCOLOR=tan><TD colspan=2>Client Maintenance</TD></TR><TR>"
|
||||
html "<TD bgcolor=tan align=right>Client Num</TD><TD>"
|
||||
textbox #clientNum,clientNum$,5
|
||||
|
||||
html "</TD></TR><TR><TD bgcolor=tan align=right>Name</TD><TD>"
|
||||
textbox #name,name$,30
|
||||
|
||||
html "</TD></TR><TR><TD bgcolor=tan align=right>Client Date</TD><TD>"
|
||||
textbox #clientDate,clientDate$,19
|
||||
|
||||
html "</TD></TR><TR><TD bgcolor=tan align=right>Category</TD><TD>"
|
||||
textbox #category,category$,10
|
||||
|
||||
html "</TD></TR><TR><TR bgcolor=tan><TD colspan=2 ALIGN=CENTER>"
|
||||
button #acd, "Add", [addIt]
|
||||
button #ex, "Exit", [sho]
|
||||
html "</TD></TR></TABLE>"
|
||||
wait
|
||||
|
||||
' ---------------------------------------------
|
||||
' Get data from the screen
|
||||
' ---------------------------------------------
|
||||
[addIt]
|
||||
clientNum = #clientNum contents$()
|
||||
name$ = trim$(#name contents$())
|
||||
clientDate$ = trim$(#clientDate contents$())
|
||||
category$ = trim$(#category contents$())
|
||||
dbVals$ = clientNum;",'";name$;"','";clientDate$;"','";category$;"'"
|
||||
sql$ = "INSERT into client VALUES ("; dbVals$ ; ")"
|
||||
#sql execute(sql$)
|
||||
goto [sho]
|
||||
|
||||
' ------------------------------------
|
||||
' Select last entry
|
||||
' ------------------------------------
|
||||
[last]
|
||||
sql$ = "SELECT *,client.rowid as rowid FROM client ORDER BY rowid desc LIMIT 1"
|
||||
what$ = "---- Last Entry ----"
|
||||
goto [shoQuery]
|
||||
|
||||
' ------------------------------------
|
||||
' Select by category (Last date only)
|
||||
' ------------------------------------
|
||||
[lastCat]
|
||||
sql$ = "SELECT * FROM client
|
||||
WHERE client.clientDate = (SELECT max(c.clientDate)
|
||||
FROM client as c WHERE c.category = client.category)
|
||||
ORDER BY category"
|
||||
what$ = "---- Last Category Sequence ----"
|
||||
goto [shoQuery]
|
||||
|
||||
' ------------------------------------
|
||||
' Select by date
|
||||
' ------------------------------------
|
||||
[date]
|
||||
sql$ = "SELECT * FROM client ORDER BY clientDate"
|
||||
what$ = "---- By Date ----"
|
||||
|
||||
[shoQuery]
|
||||
cls
|
||||
print what$
|
||||
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>"
|
||||
html "<TR align=center bgcolor=wheat><TD>Client<br>Num</TD><TD>Name</TD><TD>Client<br>Date</TD><TD>Category</TD></TR>" ' heading
|
||||
#sql execute(sql$)
|
||||
WHILE #sql hasanswer()
|
||||
#row = #sql #nextrow()
|
||||
clientNum = #row clientNum()
|
||||
name$ = #row name$()
|
||||
clientDate$ = #row clientDate$()
|
||||
category$ = #row category$()
|
||||
|
||||
html "<TR><TD align=right>";clientNum;"</TD><TD>";name$;"</TD><TD>";clientDate$;"</TD><TD>";category$;"</TD></TR>"
|
||||
WEND
|
||||
html "</TABLE>"
|
||||
button #c, "Continue", [sho]
|
||||
wait
|
||||
|
||||
' ------ the end -------
|
||||
[exit]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue