Sub Write_Session_Master_Record(ShowMessages As Boolean) As Boolean
'Update the SR based on the content of the SK_SMR
Dim SuccessFlag As Boolean
Dim SessionMasterMap As Map
Dim Result As String
Dim MyQuery As String
SessionMasterMap.Initialize
SuccessFlag = False
'We do not write the SessionNumber as this is an AutoIncrement Primary Index
SessionMasterMap.Put("SchemaVersion", Main.SK_SMR.SchemaVersion)
SessionMasterMap.Put("SessionClosed", Main.SK_SMR.SessionClosed)
SessionMasterMap.Put("Date", Main.SK_SMR.Date)
SessionMasterMap.Put("Time", Main.SK_SMR.Time)
SessionMasterMap.Put("SinglesDoubles", Main.SK_SMR.SinglesDoubles)
SessionMasterMap.Put("SinglesDoublesDescription", Main.SK_SMR.SinglesDoublesDescription)
SessionMasterMap.Put("CourtType", Main.SK_SMR.CourtType)
SessionMasterMap.Put("CourtTypeDescription", Main.SK_SMR.CourtTypeDescription)
SessionMasterMap.Put("MatchType", Main.SK_SMR.MatchType)
SessionMasterMap.Put("MatchTypeDescription", Main.SK_SMR.MatchTypeDescription)
SessionMasterMap.Put("PlayerServesFirst", Main.SK_SMR.PlayerServesFirst)
SessionMasterMap.Put("PlayerName", Main.SK_SMR.PlayerName )
SessionMasterMap.Put("PPartnerName", Main.SK_SMR.PPartnerName )
SessionMasterMap.Put("OpponentName", Main.SK_SMR.OpponentName )
SessionMasterMap.Put("OPartnerName", Main.SK_SMR.OPartnerName )
SessionMasterMap.Put("CustomShotsEnabled", Main.SK_SMR.CustomShotsEnabled)
'SessionMasterMap.Put("Custom1ButtonName", Main.SK_SMR.Custom1ButtonName)
'SessionMasterMap.Put("Custom2ButtonName", Main.SK_SMR.Custom2ButtonName)
SessionMasterMap.Put("Custom1ButtonName", "Custom 1")
SessionMasterMap.Put("Custom2ButtonName", "Custom 2")
SessionMasterMap.Put("CollectPointDetail", Main.SK_SMR.CollectPointDetail)
SessionMasterMap.Put("CollectStrokeDetail", Main.SK_SMR.CollectStrokeDetail)
SessionMasterMap.Put("CollectErrorDetail", Main.SK_SMR.CollectErrorDetail)
SessionMasterMap.Put("CollectPlayerDetail", Main.SK_SMR.CollectPlayerDetail)
'SessionMasterMap.Put("Comment", Main.SK_SMR.Comment )
SessionMasterMap.Put("Comment", "This is the comment" )
SessionMasterMap.Put("Flags", Main.SK_SMR.Flags )
'DBUtils.InsertMaps requires a list of maps, even for a single entry.
Dim MapList As List
MapList.Initialize
MapList.Add(SessionMasterMap)
'Write the data to the DB
'Main.DB.BeginTransaction
Dim MyDB As SQL
MyDB.Initialize(Main.Settings.DB_Dir, Main.Settings.DB_Name,False)
Try
DBUtils.InsertMaps(MyDB, "SK_SESSION_MASTER", MapList)
'Main.DB.TransactionSuccessful
'Now get the new session number that we just created
MyQuery = "SELECT MAX(SessionNumber) FROM SK_SESSION_MASTER"
Result = Main.DB.ExecQuerySingleResult(MyQuery)
If Result <> Null Then
SessionNumber = Result
If ShowMessages = True Then ToastMessageShow("Created new session number " & SessionNumber, False)
SuccessFlag = True
End If
Catch
Log(LastException.Message)
If ShowMessages = True Then ToastMessageShow("Error creating new session",True)
End Try
'Main.DB.EndTransaction
Return SuccessFlag
End Sub