B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=6.8
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	
End Sub

Sub Globals
	Private edtName, edtAddress, edtCity As EditText
	Private Cursor1 As Cursor
	Private btnAdd, btnUpdate As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("EditSupplier")
	Activity.Title = "Product " & Suppliers.EditMode
	
	Init
	Select Suppliers.EditMode
	Case "Add"
		InitNewItem
		btnUpdate.Visible = False
	Case "Edit"
		InitEditItem
	End Select
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
'	Cursor1.Close
End Sub

Sub btnAdd_Click
	Private Query As String
	
	Query = "INSERT INTO Suppliers VALUES ('" & edtName.Text & "', '" & edtAddress.Text & "', '" & edtCity.Text & "')"
	Starter.SQL1.ExecNonQuery(Query)
	btnUpdate.Visible = True
End Sub

Sub btnUpdate_Click
	Private Query As String
	
	Query = "UPDATE Suppliers SET Name = '" & edtName.Text & "', Address = '" & edtAddress.Text & "', City = '" & edtCity.Text & "'"
	Query = Query & " WHERE rowid = " & Suppliers.SelectedRowID
	
	Starter.SQL1.ExecNonQuery(Query)
End Sub

Sub Init

End Sub

Sub InitNewItem
	edtName.Text = ""
	edtAddress.Text = ""
	edtCity.Text = ""
End Sub

Sub InitEditItem
	Private Query As String
	
	Query = "SELECT Name, Address, City FROM Suppliers WHERE Suppliers.rowid = " & Suppliers.SelectedRowID
	Cursor1 = Starter.SQL1.ExecQuery(Query)	
	Cursor1.Position = 0
	edtName.Text = Cursor1.GetString2(0)
	edtAddress.Text = Cursor1.GetString2(1)
	edtCity.Text = Cursor1.GetString2(2)
End Sub

Sub btnFirst_Click
	Suppliers.SelectedRowID = Suppliers.RowIDList.Get(0)
End Sub

Sub btnPrevious_Click
	
End Sub

Sub btnNext_Click
	
End Sub

Sub btnLast_Click
	
End Sub
