Sub CreateTables
SQL1.ExecNonQuery("DROP TABLE IF EXISTS mbrsdata")
SQL1.ExecNonQuery("CREATE TABLE mbrsdata (mbr_prox TEXT, mbr_first_name TEXT, mbr_last_name TEXT, address_1 TEXT, city TEXT, state TEXT, zip_code TEXT, e_mail TEXT, home_phone TEXT, datej TEXT, description TEXT, assc_last_name TEXT, assc_first_name TEXT, birthd TEXT, duesp Text, mbr_number TEXT, assoc_prox Text, reldate text, ActCert Text)")
End Sub
Sub btnupdate_click
Dim su As StringUtils
Dim table As List
Dim table2 As List
Dim table3 As List
Dim items() As String
Dim items1() As String
Dim myzip As String
Dim Answ As Int
Dim m As Map
Dim i As Int
Dim j As Int
Dim k As Map
ProgressDialogShow2("Loading Members...", False)
If File.Exists(File.DirRootExternal,"mbrsnotes/*.*") = False Then
File.MakeDir(File.DirRootExternal,"mbrsnotes")
End If
If File.Exists(File.DirRootExternal,"download/appexport.zip") = True Then
If File.Exists(File.DirRootExternal,"mbrsphotos/*.*") = False Then
File.MakeDir(File.DirRootExternal,"mbrsphotos")
End If
Arc.UnZip(File.DirRootExternal, "download/AppExport.zip", File.DirRootExternal & "/mbrsphotos","")
File.Delete(File.DirRootExternal, "download/appexport.zip")
File.Copy(File.DirRootExternal, "mbrsphotos/NewMBRS.csv", File.dirDefaultExternal, "NewMBRS.csv")
File.Delete(File.DirRootExternal, "mbrshotos/NewMBRS.csv")
End If
If File.Exists(File.DirRootExternal,"download/NewMBRS.csv") = True Then
File.Copy(File.DirRootExternal,"download/NewMBRS.csv",File.DirDefaultExternal, "NewMBRS.csv")
File.Delete(File.DirRootExternal, "download/NewMBRS.csv")
'Else
' Msgbox("No new data file available","Membership")
End If
mbrdata = SQL1.ExecQuerySingleResult("Select count(*) from mbrsdata")
If mbrdata > 1 Then
'Answ = Msgbox2("Overwrite?", "Load new members? If select YES if no new data the old members will be loaded.", "Yes", "", "", Null)
'If Answ = DialogResponse.POSITIVE Then
Try
SQL1.ExecNonQuery("Delete from mbrsdata") ' clear the members table
Catch
End Try
table = su.LoadCSV(File.DirDefaultExternal, "NewMBRS.csv", ", ")
table2.Initialize
For i = 0 To table.Size - 1
items = table.Get(i)
'items1 = MbrsList.Get(i)
m.Initialize
m.Put("mbr_prox", items(0))
m.Put("mbr_first_name", items(1))
m.Put("mbr_last_name", items(2))
m.Put("address_1", items(3))
m.Put("city", items(4))
m.Put("state", items(5))
m.Put("zip_code", items(6))
m.Put("e_mail", items(7))
m.Put("home_phone", items(8))
m.Put("datej", items(9))
m.Put("description", items(10))
m.Put("assc_last_name", items(11))
m.Put("assc_first_name", items(12))
m.Put("birthd", items(13))
m.Put("duesp", items(14))
m.Put("mbr_prox", items(15))
m.Put("assoc_prox", items(16))
m.Put("reldate", items(17))
m.Put("ActCert", items(18))
table2.Add(m)
Next
DBUtils.InsertMaps(SQL1, "mbrsdata", table2)
Msgbox("Overwritten","")
'Else
' Return
'End If
Else
table = su.LoadCSV(File.DirDefaultExternal, "NewMBRS.csv", ", ")
table2.Initialize
For i = 1 To table.Size -1
items = table.Get(i)
'items1 = MbrsList.Get(i)
m.Initialize
k.Initialize
m.Put("mbr_prox", items(0))
m.Put("mbr_first_name", items(1))
m.Put("mbr_last_name", items(2))
m.Put("address_1", items(3))
m.Put("city", items(4))
m.Put("state", items(5))
m.Put("zip_code", items(6))
m.Put("e_mail", items(7))
m.Put("home_phone", items(8))
m.Put("datej", items(9))
m.Put("description", items(10))
m.Put("assc_last_name", items(11))
m.Put("assc_first_name", items(12))
m.Put("birthd", items(13))
m.Put("duesp", items(14))
m.Put("mbr_prox", items(15))
m.Put("assoc_prox", items(16))
m.Put("reldate", items(17))
m.Put("ActCert", items(18))
table2.Add(m)
Next
DBUtils.InsertMaps(SQL1, "mbrsdata", table2)
End If
members.Initialize
Dim cursor1 As Cursor
Dim Vmlname As String
Dim Vmfname As String
Dim vmnumber As String
Dim VList As String
cursor1 = SQL1.ExecQuery("Select mbr_prox, mbr_last_name, mbr_first_name from mbrsdata")
Dim Rcount As Int
For i = 0 To cursor1.RowCount -1
cursor1.Position = i
Vmlname = cursor1.GetString("mbr_last_name")
Vmfname = cursor1.GetString("mbr_first_name")
vmnumber = cursor1.GetString("mbr_prox")
VList = (vmnumber & ", " & Vmlname & ", " & Vmfname)
members.Add(VList)
Next
cursor1.Close
ProgressDialogHide
End Sub