B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public xui As XUI
Public ko As SQL
Public DBFileName = "data.db" As String
Public DBFileDir As String
Public DBTableName = "siswa" As String
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private txtnama, txtuser, txtpass, txtno As B4XView
Dim B64 As Base64
Dim epass As String
Private Button1 As B4XView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("hal_daftar")
End Sub
private Sub Button1_Click
'cek data
If txtnama.Text ="" Then
Msgbox("Masukkan Nama","info")
Return
End If
If txtuser.Text ="" Then
Msgbox("Masukkan Username","info")
Return
End If
If txtpass.Text ="" Then
Msgbox("Password","info")
Return
End If
If txtno.Text ="" Then
Msgbox("Masukkan No.Handphone","info")
Return
End If
'checks if the data already exist in the database
Public co As ResultSet
co = ko.ExecQuery2("SELECT * FROM " & DBTableName & " WHERE nama = ? AND user = ? AND password = ? AND notelepon = ?", Array As String(txtnama.Text, txtuser.Text, txtpass.Text, txtno.Text))
If co.NextRow = True Then
'if yes display a MessageBox
xui.MsgboxAsync("Username dan Password sudah digunakan","info")
Else
Private mapRow As Map
'defines the Map with the column names as key and the values
mapRow.Initialize
mapRow.Put("Nama Lengkap", txtnama.Text)
mapRow.Put("Username", txtuser.Text)
mapRow.Put("Password", txtpass.Text)
mapRow.Put("No.Telepon", txtno.Text)
'memanggil enkripsi
encript
Activity.Finish
StartActivity(act_login)
End If
End Sub
Sub encript
epass = B64.EncodeStoS(txtpass.Text, "UTF8")
End Sub