﻿B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=9.01
@EndOfDesignText@
#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.
	Private SQL As JdbcSQL
	Private DBLocation As String = "IP" 'Can use IP address or domain name
	Private DBUsername As String = "USER MYSQL"
	Private DBPassword As String = "LOGIN"
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 ListView1 As ListView
	'Private Button1 As Button
	Private btnvoltar As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	SetActionBarColor(Colors.RGB(197,128,128))
	Activity.LoadLayout("frm2")
	ListView1.TwoLinesLayout.Label.TextColor = Colors.Black
	Activity.Title=".::Extrato::."
	btnvoltar.Color=Colors.RGB(197,128,128)
	btnvoltar.TextColor=Colors.White
	btnvoltar.Text="Voltar"
	'cordalista
	CONECTAR

End Sub

Sub SetActionBarColor(Color As Int)
	Dim jo As JavaObject
	jo.InitializeContext
	Dim cd As ColorDrawable
	cd.Initialize(Color, 0)
	jo.RunMethodJO("getActionBar", Null).RunMethod("setBackgroundDrawable", Array(cd))
   
	jo.RunMethodJO("getActionBar", Null).Runmethod("setIcon",Array(cd))
End Sub


Sub CONECTAR
	SQL.InitializeAsync("MySQL", "com.mysql.jdbc.Driver", $"jdbc:mysql://${DBLocation}/sysjoins_bddizimos?useSSL=false"$, DBUsername, DBPassword)
	'

'	ListView1.la
'	cordalista

	Wait For MySQL_Ready (Success As Boolean)
	If Success = False Then
		
		Log("Check unfiltered logs for JDBC errors.")
		
	Else
	'	Activity.LoadLayout("frm2")
		Dim RS As JdbcResultSet = SQL.ExecQuery("SELECT * FROM tbldizimos")
		Do While RS.NextRow
			If RS.GetString2(2)="Entrada"  Then

				ListView1.AddTwoLinesAndBitmap(RS.GetString2(1) & RS.GetString2(3),"R$ " &  RS.GetString2(4), LoadBitmap(File.DirAssets, "salvar.png"))
				
			Else 

				ListView1.AddTwoLinesAndBitmap(RS.GetString2(1) & RS.GetString2(3),"R$ " & RS.GetString2(4), LoadBitmap(File.DirAssets, "menos.png"))
			'ListView1.AddTwoLines(RS.GetString2(2)&RS.GetString2(3),RS.GetString2(4)&"-"&RS.GetString2(5))
			End If
			'Log(RS.GetString2(2)&RS.GetString2(3)&RS.GetString2(4))
		Loop

		RS.Close
		SQL.Close
	End If
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub ListView1_ItemClick (Position As Int, Value As Object)
	
End Sub

Sub Button1_Click
	SQL.InitializeAsync("MySQL", "com.mysql.jdbc.Driver", $"jdbc:mysql://${DBLocation}/sysjoins_bddizimos?useSSL=false"$, DBUsername, DBPassword)

	'Dim Table_Name As String = "tbldizimos"
'Wait For MySQL_Ready (Success As Boolean)
'	If Success = False Then
'SQL.BeginTransaction
'Try
	'	SQL.ExecNonQuery2( $"INSERT INTO ${Table_Name} VALUES (3,'Descricao','Data','Tipo','Valoe','Observacao')"$, Array As Object( "tbldizimos"))
	'SQL.InitializeAsync("MySQL", "com.mysql.jdbc.Driver", $"jdbc:mysql://${DBLocation}/sysjoins_bddizimos?useSSL=false"$, DBUsername, DBPassword)
SQL.ExecNonQuery2("INSERT INTO tbldizimos VALUES (3, 'Geraldo', '/08/1980','Entradas','76.99','')", Array As Object("some text", 2))
'SQL.TransactionSuccessful
'Catch
'Log(LastException.Message)
'End Try

'	Else
		
'		End If
End Sub

Sub btnvoltar_Click
	StartActivity(mdlprincipal)
End Sub