Imports DBUtilsDataTable
Imports log4net
Imports VCBC_Performance.Balances.Operator.ConfigActivityType.DataAccess

Namespace Balances.Operator.ConfigActivityType.Entities

    Public Class ConfigActivityTypeManager
        Private Shared ReadOnly log As ILog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)

#Region "constructor"

        Public Sub New(Optional ByVal useEmptyRow As Boolean = False)
            Try
                SetBalanceActivityTypeToList()
            Catch ex As Exception
                log.ErrorFormat(ex.StackTrace)
                log.Error("ConfigActivityTypeManager() - Load balance activity type Failed")
                MsgBox("Fel vid laddning av aktivitetstyp. Vid upprepning felanmäl felet till SPOC:en", MsgBoxStyle.OkOnly, "Felmeddelande")
                HasError = True
            End Try
        End Sub

        Public Sub New(ByVal processType As String, Optional ByVal useEmptyRow As Boolean = False)
            Try
                SetBalanceActivityTypeToList()
            Catch ex As Exception
                log.ErrorFormat(ex.StackTrace)
                log.Error("ConfigActivityTypeManager() - Load balance activity type Failed")
                MsgBox("Fel vid laddning av aktivitetstyp. Vid upprepning felanmäl felet till SPOC:en", MsgBoxStyle.OkOnly, "Felmeddelande")
                HasError = True
            End Try
        End Sub

#End Region

#Region "Properties"

        Public Property BalanceActivityTypeList As New List(Of ConfigActivityTypeItem)
        Public Property HasError() As Boolean = False

        Public ReadOnly Property BalanceActivityTypeListIndex(ByVal balanceActivityTypeID As Integer) As Integer
            Get
                Return GetBalanceActivityTypeListIndex(balanceActivityTypeID)
            End Get
        End Property

#End Region

#Region "Methods"

        Private Sub SetBalanceActivityTypeToList()
            BalanceActivityTypeList.Clear()
            Try
                Dim item1 As New ConfigActivityTypeItem
                item1.ActivityTypeID = 1
                item1.ActivityTypeName = "I"
                item1.ActivityTypeDescription = "Inner Parts"
                item1.ProcessType = "S"
                BalanceActivityTypeList.Add(item1)

                Dim item2 As New ConfigActivityTypeItem
                item2.ActivityTypeID = 2
                item2.ActivityTypeName = "G"
                item2.ActivityTypeDescription = "All Machines Stamping"
                item2.ProcessType = "S"
                BalanceActivityTypeList.Add(item2)

                Dim item3 As New ConfigActivityTypeItem
                item3.ActivityTypeID = 3
                item3.ActivityTypeName = "G"
                item3.ActivityTypeDescription = "All Machines Stamping"
                item3.ProcessType = "A"
                BalanceActivityTypeList.Add(item3)

            Catch ex As Exception
                log.ErrorFormat(ex.StackTrace)
                log.Error("ConfigActivityTypeManager() - Failed when set balance activity type to list")
            End Try
        End Sub

        'Friend Sub SaveBalanceActivityType(ByVal balanceActivityTypeName As String, ByVal balanceActivityTypeDescription As String,
        '                                   ByVal processType As Char, ByVal comment As String)
        '    Try
        '        oConfigActivityTypeDAO.SetNewBalanceActivityType(balanceActivityTypeName, balanceActivityTypeDescription, processType, comment)

        '    Catch ex As Exception
        '        Throw
        '    End Try
        'End Sub

        'Friend Sub UpdateBalanceActivityType(ByVal balanceActivityTypeID As Integer, ByVal balanceActivityTypeName As String,
        '                                     ByVal balanceActivityTypeDescription As String, ByVal processType As Char, ByVal comment As String)

        '    Try
        '        oConfigActivityTypeDAO.UpDateBalanceActivityType(balanceActivityTypeID, balanceActivityTypeName, balanceActivityTypeDescription, processType, comment)
        '    Catch ex As Exception
        '        Throw
        '    End Try
        'End Sub

        'Friend Sub DeleteBalanceActivityType(ByVal balanceActivityTypeID As Integer, ByVal balanceActivityTypeName As String)
        '    Try
        '        oConfigActivityTypeDAO.DeleteBalanceActivityType(balanceActivityTypeID, balanceActivityTypeName)
        '    Catch ex As Exception
        '        Throw
        '    End Try
        'End Sub

#End Region

#Region "Functions"

        Private Function GetBalanceActivityTypeListIndex(ByVal balanceActivityTypeID As Integer) As Integer
            Dim result As Integer = -1I
            Try
                result = BalanceActivityTypeList.FindIndex(Function(item) item.ActivityTypeID = balanceActivityTypeID)
            Catch ex As Exception
                log.ErrorFormat(ex.StackTrace)
                log.Error("ConfigActivityTypeManager() - Failed when get balance activity type index")
            End Try

            Return result
        End Function

#End Region

    End Class

End Namespace
