VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsMapItem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Const m_cNAME As String = "clsMapItem"
Private Const m_cItemSubSep As String = "<MI ]>"

Private m_oTableHelperMapItems As New clsFOTAADOTableHelper

Public m_nMapItemID As Long
Public m_nMapID As Long
Public m_sName As String
Public m_sDescription As String
Public m_sHistory As String
Public m_sPicture As String
Public m_nX As Long
Public m_nY As Long
Public m_nWidth As Long
Public m_nHeight As Long

Public Function Load(oDB As ADODB.Connection, nMapItemID As Long)

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".Load"
    Call WriteProcStart(sRoutineName)

    
    Call m_oTableHelperMapItems.LoadRecords("WHERE nMapItemID = " & nMapItemID)

    m_nMapItemID = m_oTableHelperMapItems.GetValue("nMapItemID")
    m_nMapID = m_oTableHelperMapItems.GetValue("nMapID")
    m_sName = Trim(m_oTableHelperMapItems.GetValue("sName"))
    m_sDescription = m_oTableHelperMapItems.GetValue("sDescription")
    m_sHistory = m_oTableHelperMapItems.GetValue("sHistory")
    m_sPicture = m_oTableHelperMapItems.GetValue("sPicture")
    m_nX = m_oTableHelperMapItems.GetValue("nX")
    m_nY = m_oTableHelperMapItems.GetValue("nY")
    m_nWidth = m_oTableHelperMapItems.GetValue("nWidth")
    m_nHeight = m_oTableHelperMapItems.GetValue("nHeight")


    Call WriteProcStop(sRoutineName)
    'Exit the sub... on an error we will jump over this function
    Exit Function
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount

End Function

Public Sub Save(dbDND As ADODB.Connection)

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".Save"
    Call WriteProcStart(sRoutineName) ' "OBJECT")


    m_oTableHelperMapItems.SetValue("nMapID") = m_nMapID
    m_oTableHelperMapItems.SetValue("sName") = m_sName
    m_oTableHelperMapItems.SetValue("sDescription") = m_sDescription
    m_oTableHelperMapItems.SetValue("sHistory") = m_sHistory
    m_oTableHelperMapItems.SetValue("sPicture") = m_sPicture
    m_oTableHelperMapItems.SetValue("nX") = m_nX
    m_oTableHelperMapItems.SetValue("nY") = m_nY
    m_oTableHelperMapItems.SetValue("nWidth") = m_nWidth
    m_oTableHelperMapItems.SetValue("nHeight") = m_nHeight
    
    m_nMapItemID = m_oTableHelperMapItems.Save()


    Call WriteProcStop(sRoutineName)
    'Exit the sub... on an error we will jump over this function
    Exit Sub
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount

End Sub

Public Sub Delete(dbDND As ADODB.Connection)

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".Delete"
    Call WriteProcStart(sRoutineName)
    
    
    If m_oTableHelperMapItems.IsRecordLoaded() = True Then
        Call m_oTableHelperMapItems.CreateSQLDelete(True)
    End If
        
    
    Call WriteProcStop(sRoutineName)
    'Exit the sub... on an error we will jump over this function
    Exit Sub
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount

End Sub

Private Sub Class_Initialize()

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".MapItem_Initialize"
    Call WriteProcStart(sRoutineName)


    Call m_oTableHelperMapItems.LoadSchema(g_oDB, "MapItems")


    Call WriteProcStop(sRoutineName)
    'Exit the sub... on an error we will jump over this function
    Exit Sub
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount

End Sub
Public Function Serialize() As String

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".Serialize"
    Call WriteProcStart(sRoutineName)
    
    
    Serialize = m_sName & m_cItemSubSep
    Serialize = Serialize & m_sDescription & m_cItemSubSep
    Serialize = Serialize & m_sHistory & m_cItemSubSep
    Serialize = Serialize & m_sPicture & m_cItemSubSep
    Serialize = Serialize & m_nX & m_cItemSubSep
    Serialize = Serialize & m_nY & m_cItemSubSep
    Serialize = Serialize & m_nWidth & m_cItemSubSep
    Serialize = Serialize & m_nHeight & m_cItemSubSep
    
    
    Call WriteProcStop(sRoutineName) ' Serialize)
    'Exit the sub... on an error we will jump over this function
    Exit Function
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount
    
End Function
Public Function DeSerialize(sItem As String) As String

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".DeSerialize"
    Call WriteProcStart(sRoutineName) ' sItem)


    Dim sRemStr As String
    sRemStr = sItem
    
    m_sName = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_sDescription = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_sHistory = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_sPicture = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_nX = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_nY = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_nWidth = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)
    m_nHeight = Left(sRemStr, InStr(sRemStr, m_cItemSubSep) - 1)
        sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSubSep) - Len(m_cItemSubSep) + 1)

    DeSerialize = sRemStr
    
    
    Call WriteProcStop(sRoutineName) ' sRemStr)
    'Exit the sub... on an error we will jump over this function
    Exit Function
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount
    
End Function

