How do I save on a SQLite database the contents of two listview and reading invoke the same content and put it back in the two listview source?
B4X:
Sub add_Click
mp1.Load(File.DirAssets,"click.wav")
mp1.Play
If txttavolo.Text="" Then
mp1.Load(File.DirAssets,"alert.wav")
mp1.Play
Msgbox("Per favore inserisci il prodotto","ATTENZIONE")
Else
Dim NewID As Int
Try
NewID = SQL1.ExecQuerySingleResult("SELECT max(id) FROM listview ") + 1
Catch
NewID = 1
End Try
Dim qry As String
Dim MyFields() As Object
MyFields=Array As Object(lswordine,lswordine2,txtzona.Text,txtoperatore.Text,txteuro.Text,txttotaleeuro.Text,txtnote.Text,NewID) 'rest of edittext boxes
qry = "INSERT INTO listview VALUES (?,?,?,?,?,?,?,?)" 'Account for all fields
SQL1.ExecNonQuery2(qry,MyFields)
lswordine.Clear
lswordine2.Clear
txtzona.Text=""
txteuro.Text=""
txttotaleeuro.Text=""
txtnote.Text=""
Msgbox("prodotti aggiunti nel database","ESEGUITO")
End If
read_Click
End Sub
Sub read_Click
If File.Exists(File.DirInternal,"listview.db") = True Then
mp1.Load(File.DirAssets,"click.wav")
mp1.Play
pnlbase.Visible=False
pnlsetup.Visible=False
pnlaiuto.Visible=False
pnltecnico.Visible=False
pnlresoconto.Visible=False
pnldata.Visible=False
pnloperatore.Visible=False
pnlsetup2.Visible=False
pnlblocco.Visible=False
pnllist.Visible=True
lvdb.Clear
cursor1 = SQL1.ExecQuery("SELECT * FROM listview")
Log(cursor1.RowCount)
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
lvdb.AddSingleLine(cursor1.GetString("id")& " : " & cursor1.GetString(txtprodotto.Text))
Next
cursor1.Close
Else
Msgbox("Nessun database presente, Prego riavvia il programma","AVVISO !!")
End If
End Sub
Last edited: