B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=7.77
@EndOfDesignText@
#Region  Service Attributes 
	#StartAtBoot: False
	#ExcludeFromLibrary: True
#End Region

Sub Process_Globals
	Public SQL1 As SQL
	
	Public SQLDataBasePath As String
	Public SQLDateBaseName As String
	
	Public SQLTabelName As String
	
	Public HtmlCSS As String
End Sub

Sub Service_Create
	'initialize the variables
	SQLDataBasePath = File.DirRootExternal
	SQLDateBaseName = "Stock.db"
	
	File.Delete(SQLDataBasePath, SQLDateBaseName) ' only for testing, removes the database
		
	'check if the database already exists
	If File.Exists(SQLDataBasePath, SQLDateBaseName) = True Then
		'if yes, initialize it
		SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, True)
	Else
		'if no, initialize it
		SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, True)
		'and create it
		SQLInit
	End If

	HtmlCSS = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
		& " th { font-weight: bold;	background-color: #acf;	border-bottom: 1px solid #cef; }" _ 
		& "td,th {	padding: 4px 5px; }" _
		& ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
		& "a { text-decoration:none; color: #000;}"

	' with a different text size
'	HtmlCSS = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
'	& " th { font-size: 18px; font-weight: bold;	background-color: #acf;	border-bottom: 1px solid #cef; }" _ 
'	& "td,th {	padding: 4px 5px; }" _
'	& ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
'	& "a { font-size: 18 px; text-decoration:none; color: #000;}"

End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
	Return True
End Sub

Sub Service_Destroy

End Sub

'create the stocdatabase
Sub SQLInit
	Private query As String
	
	query = "CREATE TABLE Stock (Number INTEGER, ProductID INTEGER, Date INTEGER)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (5, 1, 1092941466000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (10, 2, 1265583600000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (15, 4, 1328655600000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (2, 5, 1297119600000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (20, 3, 1391814000000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (15, 6, " & DateTime.Now & ")"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (8, 7, 1391814000000)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (13, 9, " & DateTime.Now & ")"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (4, 10, " & DateTime.Now & ")"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Stock VALUES (2, 11, 1328655600000)"
	SQL1.ExecNonQuery(query)
	
	query = "CREATE TABLE Products (Name TEXT, Price REAL, SupplierID INTEGER)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Brake', 350.123, 1)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Brake', 175.657, 3)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Brake', 225, 4)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Brake', 270, 5)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Brake', 250, 6)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 150, 2)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 250, 1)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 175, 4)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 175, 3)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 175, 5)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Products VALUES ('Exhaust pipe', 175, 6)"
	SQL1.ExecNonQuery(query)
		
	query = "CREATE TABLE Suppliers (Name TEXT, Address TEXT, City TEXT)"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('Renault','Rue de la Gare 30', 'Paris')"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('Ford', 'Main street 11', 'Detroit')"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('VW', 'Hauptstrasse 3', 'Wolfsburg')"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('Opel', 'Bahnhofsplatz 1', 'Rüsselsheim')"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('PSA', 'Avenue de la Grande Armée 75', 'Paris')"
	SQL1.ExecNonQuery(query)
	query = "INSERT INTO Suppliers VALUES ('Fiat', 'Corso Giulio Cesare 360', 'Torino')"
	SQL1.ExecNonQuery(query)
End Sub
