B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=12.2
@EndOfDesignText@
Sub Class_Globals
	Private Root As B4XView 'ignore
	Private xui As XUI 'ignore
	Private et_mil As EditText
	Private et_quinientos As EditText
	Private et_docientos As EditText
	Private et_cien As EditText
	Private et_cincuenta As EditText
	Private et_veinte As EditText
	Private et_m_veinte As EditText
	Private et_m_diez As EditText
	Private et_m_cinco As EditText
	Private et_m_dos As EditText
	Private et_m_peso As EditText
	Private et_m_centavo As EditText
	Private b_calcular As Button
	Private b_guardar As Button
	Private l_total As Label
	Dim sum_billetes As Int
	Dim sum_monedas As Float
	Dim total As Float
	Dim c As Cursor
	Dim d As Cursor
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
	Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
	Root = Root1
	'load the layout to Root
	Root.LoadLayout("tabulador")
End Sub

Sub B4XPage_Appear
	d = Starter.skmt.ExecQuery("SELECT VEINTE, DIEZ, CINCO, DOS, PESO, CENTAVO, TOTAL FROM TABULADOR_MONEDAS")
	c = Starter.skmt.ExecQuery("SELECT MIL, QUINIENTOS, DOCIENTOS, CIEN, CINCUENTA, VEINTE FROM TABULADOR_BILLETES")
	c.Position = 0
	d.Position = 0
	If c.RowCount > 0 And d.RowCount > 0 Then
		Log("TABULADR CON RESUKTADO")
		et_mil.Text = c.GetString("MIL")
		et_quinientos.Text = c.GetString("QUINIENTOS")
		et_docientos.Text = c.GetString("DOCIENTOS")
		et_cien.Text = c.GetString("CIEN")
		et_cincuenta.Text = c.GetString("CINCUENTA")
		et_veinte.Text = c.GetString("VEINTE")
		et_m_veinte.Text = d.GetString("VEINTE")
		et_m_diez.Text = d.GetString("DIEZ")
		et_m_cinco.Text = d.GetString("CINCO")
		et_m_dos.Text = d.GetString("DOS")
		et_m_peso.Text = d.GetString("PESO")
		et_m_centavo.Text = d.GetString("CENTAVO")	
		l_total.Text = d.GetString("TOTAL")
	else If c.RowCount = 0 And d.RowCount = 0 Then
		Log("TABULADR SIN RESUKTADO")
		et_mil.Text = ""
		et_quinientos.Text = ""
		et_docientos.Text = ""
		et_cien.Text = ""
		et_cincuenta.Text = ""
		et_veinte.Text = ""
		et_m_veinte.Text = ""
		et_m_diez.Text = ""
		et_m_cinco.Text = ""
		et_m_dos.Text = ""
		et_m_peso.Text = ""
		et_m_centavo.Text = ""
		l_total.Text = ""
	End If
	c.Close
	d.Close
End Sub

Private Sub b_guardar_Click
	b_calcular_Click
	Starter.skmt.ExecNonQuery("DELETE FROM TABULADOR_MONEDAS")
	Starter.skmt.ExecNonQuery("DELETE FROM TABULADOR_BILLETES")
	Starter.skmt.ExecNonQuery2("INSERT INTO TABULADOR_BILLETES (MIL, QUINIENTOS, DOCIENTOS, CIEN, CINCUENTA, VEINTE) VALUES (?,?,?,?,?,?)", Array As Object(et_mil.Text,et_quinientos.Text,et_docientos.Text,et_cien.Text,et_cincuenta.Text,et_veinte.Text))
	Starter.skmt.ExecNonQuery2("INSERT INTO TABULADOR_MONEDAS (VEINTE, DIEZ, CINCO, DOS, PESO, CENTAVO, TOTAL) VALUES (?,?,?,?,?,?,?)", Array As Object(et_m_veinte.Text,et_m_diez.Text,et_m_cinco.Text,et_m_dos.Text,et_m_peso.Text,et_m_centavo.Text,l_total.Text))
	B4XPages.ShowPage("Principal")
End Sub

Private Sub b_calcular_Click
	If et_mil.Text = "" Then
		et_mil.Text = 0
	End If
	If et_quinientos.Text = "" Then
		et_quinientos.Text = 0
	End If
	If et_docientos.Text = "" Then
		et_docientos.Text = 0
	End If
	If et_cien.Text = "" Then
		et_cien.Text = 0
	End If
	If et_cincuenta.Text = "" Then
		et_cincuenta.Text = 0
	End If
	If et_veinte.Text = "" Then
		et_veinte.Text = 0
	End If
	If et_m_veinte.Text = "" Then
		et_m_veinte.Text = 0
	End If
	If et_m_diez.Text = "" Then
		et_m_diez.Text = 0
	End If
	If et_m_cinco.Text = "" Then
		et_m_cinco.Text = 0
	End If
	If et_m_dos.Text = "" Then
		et_m_dos.Text = 0
	End If
	If et_m_peso.Text = "" Then
		et_m_peso.Text = 0
	End If
	If et_m_centavo.Text = "" Then
		et_m_centavo.Text = 0
	End If
	sum_billetes = (et_mil.Text * 1000) + (et_quinientos.Text * 500) + (et_docientos.Text * 200) + ( et_cien.Text * 100 ) + ( et_cincuenta.Text * 50 ) + ( et_veinte.Text * 20 )
	sum_monedas = (et_m_veinte.Text * 20) + ( et_m_diez.Text * 10 ) + ( et_m_cinco.Text * 5 ) + ( et_m_dos.Text * 2 ) + ( et_m_peso.Text * 1 ) + ( et_m_centavo.Text * 0.50 )
	total = sum_billetes + sum_monedas
	l_total.Text = Round2(total, 2)
End Sub