'Class module
Sub Class_Globals
Private page1 As Page
Dim pane As Panel
Private tx As TextField
Dim tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8 As TextField
Dim sw1,sw2,sw3,sw4 As Switch
Dim lb1,lb2,lb3, lb4 As Label
Dim sw1,sw2,sw3 As Switch
Dim bt As Button
Private hd As HUD
Dim a,b,c As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize( pg As Page, NameView As String)
page1 = pg
Dim l,t,w,h As Int
l = page1.RootPanel.Width*0/100
t = page1.RootPanel.Height*0/100
w = page1.RootPanel.Width*40/100
h = page1.RootPanel.Height*100/100
pane.Initialize("pane")
pane.Tag = NameView
pane.Color = Colors.ARGB(80,255,255,255)
pane.SetAlphaAnimated(500,1)
page1.RootPanel.AddView(pane,l,t,w,h)
Dim bmao As Bitmap
bmao.Initialize(File.DirAssets,"background001.png")
Dim rec1,rec2 As Rect
rec1.Initialize(0,0,pane.Width,pane.Height)
rec2.Initialize(0,0,pane.Width,pane.Height)
Dim cv As Canvas
cv.Initialize(pane)
cv.DrawBitmap(bmao,rec1)
cv.DrawLine(pane.Width-5,0,pane.Width-5,pane.Height,Colors.ARGB(200,0,0,0),5)
cv.DrawLine(pane.Width-4,0,pane.Width-4,pane.Height,Colors.ARGB(180,255,255,255),1)
cv.Refresh
initializeform
End Sub
Sub initializeform
Dim l,t,w,h As Int
l = pane.Width*10/100
t = pane.Width*10/100
w = pane.Width*80/100
h = 42
tx1.Initialize("tx")
tx1.HintText = "Nome"
tx1.Tag = tx1.HintText
pane.AddView(tx1,l,t,w,h)
t = t + 62dip
tx2.Initialize("tx")
tx2.HintText = "Cognome"
tx2.Tag = tx2.HintText
pane.AddView(tx2,l,t,w,h)
t = t + 62dip
tx3.Initialize("tx")
tx3.HintText = "Cellulare"
tx3.KeyboardType = tx3.TYPE_NUMBER_PAD
tx3.Tag = tx3.HintText
pane.AddView(tx3,l,t,w,h)
t = t + 62dip
tx4.Initialize("tx")
tx4.HintText = "Email"
tx4.Tag = tx4.HintText
tx4.KeyboardType = tx4.TYPE_EMAIL_ADDRESS
If Mod_Global.register = True Then
tx4.Enabled = False
tx4.Color = Colors.ARGB(200,255,255,255)
End If
pane.AddView(tx4,l,t,w,h)
t = t + 62dip
tx5.Initialize("tx")
tx5.HintText = "Città"
tx5.Tag = tx5.HintText
pane.AddView(tx5,l,t,w,h)
t = t + 62dip
tx6.Initialize("tx")
tx6.HintText = "Password"
tx6.Tag = tx6.HintText
tx6.PasswordMode = True
pane.AddView(tx6,l,t,w,h)
t = t + 62dip
tx7.Initialize("tx")
tx7.HintText = "Nick"
tx7.Tag = tx7.HintText
pane.AddView(tx7,l,t,w,h)
' switch phone, mail, city
t = t + 82dip
Dim sw1 As Switch
sw1.Initialize("sw1")
sw1.Value = True
pane.AddView(sw1,l,t,w,h)
Dim lb1 As Label
lb1.Initialize("lb1")
lb1.Font = Font.CreateNew2(lb1.Font.Name,18dip)
lb1.Text = "Telefono visibile"
lb1.TextColor = Colors.ARGB(255,222,222,222)
pane.AddView(lb1,l+65dip,t-5dip,w,h)
t = t + 62dip
Dim sw2 As Switch
sw2.Initialize("sw1")
sw2.Value = True
pane.AddView(sw2,l,t,w,h)
Dim lb2 As Label
lb2.Initialize("lb1")
lb2.Font = Font.CreateNew2(lb2.Font.Name,18dip)
lb2.Text = "Mail visibile"
lb2.TextColor = Colors.ARGB(255,222,222,222)
pane.AddView(lb2,l+65dip,t-5dip,w,h)
t = t + 62dip
Dim sw3 As Switch
sw3.Initialize("sw1")
sw3.Value = True
pane.AddView(sw3,l,t,w,h)
Dim lb3 As Label
lb3.Initialize("lb1")
lb3.Font = Font.CreateNew2(lb2.Font.Name,18dip)
lb3.Text = "Città visibile"
lb3.TextColor = Colors.ARGB(255,222,222,222)
pane.AddView(lb3,l+65dip,t-5dip,w,h)
t = t + 62dip
Dim sw4 As Switch
sw4.Initialize("sw1")
sw4.Value = False
pane.AddView(sw4,l,t,w,h)
Dim lb4 As Label
lb4.Initialize("lb1")
lb4.Font = Font.CreateNew2(lb2.Font.Name,18dip)
lb4.Text = "Localizzato"
lb4.TextColor = Colors.ARGB(255,222,222,222)
pane.AddView(lb4,l+65dip,t-5dip,w,h)
' button logout
t = t + 62dip
Dim bt As Button
bt.InitializeCustom("bt",Colors.ARGB(255,255,255,255),Colors.ARGB(255,0,0,200))
bt.Tag = "logout"
bt.Text = bt.Tag
bt.SetBorder(2,Colors.Red,8)
bt.Color = Colors.ARGB(255,255,0,0)
pane.AddView(bt,l,t,w,h)
' button save e close
h = 48
w = pane.Width/2
l = 0
t = pane.Height - h 't + 52dip
Dim bt As Button
bt.InitializeCustom("bt",Colors.ARGB(255,255,255,255),Colors.ARGB(255,0,0,200))
bt.Tag = "Save"
bt.Text = bt.Tag
bt.Color = Colors.ARGB(0,0,0,255)
pane.AddView(bt,l,t,w,h)
w = pane.Width/2
l = (pane.Width/2)
t = pane.Height - h 't + 52dip
Dim bt As Button
bt.InitializeCustom("bt",Colors.ARGB(255,255,255,255),Colors.ARGB(255,0,0,200))
bt.Tag = "Close"
bt.Text = bt.Tag
bt.Color = Colors.ARGB(0,255,0,0)
pane.AddView(bt,l,t,w,h)
If setField = True Then
End If
End Sub
Public Sub setField As Boolean
For i = 0 To pane.NumberOfViews-1
If pane.GetView(i) Is TextField Then
Dim txtemp As TextField = pane.GetView(i)
Select txtemp.Tag
Case "Nome"
txtemp.Text = Mod_Global.name
Case "Cognome"
txtemp.Text = Mod_Global.lastname
Case "Cellulare"
txtemp.Text = Mod_Global.numberphone
Case "Email"
txtemp.Text = Mod_Global.emailaddress
Case "Città"
txtemp.Text = Mod_Global.city
Case "Password"
txtemp.Text = Mod_Global.password
Case "Nick"
txtemp.Text = Mod_Global.nik
End Select
End If
Next
Return True
End Sub
Sub bt_Click
Dim bt As Button = Sender
' close panel
If bt.Tag = "Close" Then
For i = 0 To page1.RootPanel.NumberOfViews-1
If page1.RootPanel.GetView(i) Is Panel Then
If page1.RootPanel.GetView(i).Tag = "pane" Then
page1.RootPanel.RemoveViewAt(i)
End If
End If
Next
End If
' save
If bt.Tag = "Save" Then
If verifydata = True Then
saverecord
End If
End If
' logout
If bt.Tag = "logout" Then
Msgbox2("logout", "Logout","Sicuro di voler eliminare dati login", Array("Si","No"))
End If
End Sub
Sub logout_Click(value As String)
If value = "Si" Then
If Mod_Global.ClearSetting = True Then
Mod_Global.register = False
tx1.Text = ""
tx2.Text = ""
tx3.Text = ""
tx4.Text = ""
tx5.Text = ""
tx6.Text = ""
tx7.Text = ""
Mod_Global.name = ""
Mod_Global.lastname = ""
Mod_Global.numberphone = ""
Mod_Global.emailaddress = ""
Mod_Global.city = ""
Mod_Global.password = ""
Mod_Global.nik = ""
End If
End If
End Sub
Sub setMap(left As Int, top As Int, wight As Int, height As Int)
top = top + 52dip
height = 240dip
Dim cm As ClassMap
cm.Initialize(pane,left,top,wight,height,tx5.Text)
End Sub
Sub verifydata As Boolean
If tx1.Text = "" OR tx1.Text.Length = 0 Then
Msgbox("Il campo nome non può essere vuoto","Alert")
Return False
End If
If tx2.Text = "" OR tx2.Text.Length = 0 Then
Msgbox("Il campo cognome non può essere vuoto","Alert")
Return False
End If
If tx3.Text = "" OR tx3.Text.Length = 0 Then
Msgbox("Il campo telefono non può essere vuoto","Alert")
Return False
End If
If tx4.Text = "" OR tx4.Text.Length = 0 Then
Msgbox("Il campo email non può essere vuoto","Alert")
Return False
End If
If tx5.Text = "" OR tx5.Text.Length = 0 Then
Msgbox("Il campo città non può essere vuoto","Alert")
Return False
End If
If tx6.Text = "" OR tx6.Text.Length = 0 Then
Msgbox("Il campo password non può essere vuoto","Alert")
Return False
End If
If tx7.Text = "" OR tx7.Text.Length = 0 Then
Msgbox("Il campo Nik non può essere vuoto","Alert")
Return False
End If
Return True
End Sub
Sub saverecord
Mod_Global.name = tx1
Mod_Global.lastname = tx2
Mod_Global.numberphone = tx3
Mod_Global.emailaddress = tx4
Mod_Global.city = tx5
Mod_Global.password = tx6
Mod_Global.nik = tx7
Mod_Global.idphone = Mod_Global.GetDeviceId
Dim linkpage As String = "http://xxx.eu/xxx/xxx.php"
Dim s As String
a=0
b=0
c=0
If sw1 = True Then
a=1
End If
If sw2 = True Then
b=1
End If
If sw3 = True Then
c=1
End If
If Mod_Global.register = False Then
s = "INSERT INTO user (name, lastname, phone, email, city, password, nik, idphone,hidephone,hidemail,hidecity) VALUES ('" & tx1.Text & "', '" & tx2.Text & "', '" & tx3.Text & "', '" & tx4.Text & "', '" & tx5.Text & "', '" & tx6.Text & "', '" & tx7.Text & "', '" & Mod_Global.GetDeviceId & "'" & a & "','" & b & "','" & c & "')"
Else
s = "UPDATE user SET name='" & tx1.Text & "', " & _
"lastname='" & tx2.Text & "', " & _
"phone='" & tx3.Text & "', " & _
"email='" & tx4.Text & "', " & _
"city='" & tx5.Text & "', " & _
"password='" & tx6.Text & "', " & _
"nik='" & tx7.Text & "' " & _
"hidephone='" & a & "' " & _
"hidemail='" & b & "' " & _
"hidecity='" & c & "' " & _
"WHERE idphone='" & Mod_Global.GetDeviceId & "'"
End If
Dim job1cli As HttpJob
job1cli.Initialize("0",Me)
job1cli.Download2(linkpage,Array As String("q",s,"command","FreeQuery","debug","no"))
End Sub
Sub JobDone(Job As HttpJob)
Log(Job.GetString)
If Job.Success = True Then
If Job.JobName = "0" Then
Msgbox("Dati salvati","Login")
Mod_Global.name = tx1.Text
Mod_Global.lastname = tx2.Text
Mod_Global.numberphone = tx3.Text
Mod_Global.emailaddress = tx4.Text
Mod_Global.city = tx5.Text
Mod_Global.password = tx6.Text
Mod_Global.nik = tx7.Text
Mod_Global.idphone = Mod_Global.GetDeviceId
Mod_Global.hidephone = a
Mod_Global.hidemail = b
Mod_Global.hidecity = b
Mod_Global.WriteSetting
End If
Else
Log("Error: " & Job.ErrorMessage)
hd.ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub