Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core

Public Class UpdateBTLWndVM
   Inherits VMBase

#Region "FIELDS & PROPERTIES"

   Friend Event m_CloseWindow(bDialogResult As Boolean)

   Protected m_UpdateBTLColumns As New ObservableCollection(Of EgtDataGridColumn)
   Public Property UpdateBTLColumns As ObservableCollection(Of EgtDataGridColumn)
      Get
         Return m_UpdateBTLColumns
      End Get
      Set(value As ObservableCollection(Of EgtDataGridColumn))
         m_UpdateBTLColumns = value
      End Set
   End Property

   Private m_BTLPartList As New ObservableCollection(Of BTLPartToUpdate)
   Public Property BTLPartList As ObservableCollection(Of BTLPartToUpdate)
      Get
         Return m_BTLPartList
      End Get
      Set(value As ObservableCollection(Of BTLPartToUpdate))
         m_BTLPartList = value
      End Set
   End Property

   Private m_SelBTLPart As BTLPartToUpdate
   Public Property SelBTLPart As BTLPartToUpdate
      Get
         Return m_SelBTLPart
      End Get
      Set(value As BTLPartToUpdate)
         m_SelBTLPart = value
      End Set
   End Property

   ' Definizione comandi
   Private m_cmdOk As ICommand
   Private m_cmdCancel As ICommand

#End Region    ' FIELDS & PROPERTIES

#Region "MESSAGES"

   Public ReadOnly Property Name_Msg As String
      Get
         Return EgtMsg(61808)
      End Get
   End Property

   Public ReadOnly Property NAM_Msg As String
      Get
         Return EgtMsg(61603)
      End Get
   End Property

   Public ReadOnly Property PDN_Msg As String
      Get
         Return EgtMsg(61809)
      End Get
   End Property

   Public ReadOnly Property Insert_Msg As String
      Get
         Return EgtMsg(30505)
      End Get
   End Property

   Public ReadOnly Property Ok_Msg As String
      Get
         Return EgtMsg(61761)
      End Get
   End Property

   Public ReadOnly Property Cancel_Msg As String
      Get
         Return EgtMsg(61763)
      End Get
   End Property

   Public ReadOnly Property UpdateBTLWnd_Msg As String
      Get
         Return EgtMsg(61960)
      End Get
   End Property

#End Region    ' MESSAGES

#Region "CONSTRUCTOR"

   Sub New(InputBTLPartList As List(Of BTLPartToUpdate))
      ' carico le colonne della datagrid
      GetPrivateProfileColumns(S_UPDATEBTLPARTLIST, UpdateBTLColumns)
      ' carica la lista dei Part importati
      BTLPartList = New ObservableCollection(Of BTLPartToUpdate)(InputBTLPartList)
   End Sub

#End Region    ' CONSTRUCTOR

#Region "COMMANDS"

#Region "Ok"

   Public ReadOnly Property Ok_Command As ICommand
      Get
         If m_cmdOk Is Nothing Then
            m_cmdOk = New Command(AddressOf Ok)
         End If
         Return m_cmdOk
      End Get
   End Property

   Public Sub Ok()
      RaiseEvent m_CloseWindow(True)
   End Sub

#End Region ' Ok

#End Region    ' COMMANDS

End Class

Public Class BTLPartToUpdate

   Private m_nPartId As Integer
   Public ReadOnly Property nPartId As Integer
      Get
         Return m_nPartId
      End Get
   End Property

   Private m_nPDN As Integer
   Public ReadOnly Property nPDN As Integer
      Get
         Return m_nPDN
      End Get
   End Property

   Private m_sNAM As String
   Public ReadOnly Property sNAM As String
      Get
         Return m_sNAM
      End Get
   End Property

   Private m_UIDList As List(Of Integer)
   Public ReadOnly Property UIDList As List(Of Integer)
      Get
         Return m_UIDList
      End Get
   End Property

   Private m_bInsert As Boolean = False
   Public Property bInsert As Boolean
      Get
         Return m_bInsert
      End Get
      Set(value As Boolean)
         m_bInsert = value
      End Set
   End Property

   Private m_bOverwrite As Boolean = False
   Public ReadOnly Property bOverwrite As Boolean
      Get
         Return m_bOverwrite
      End Get
   End Property
   Public ReadOnly Property Overwrite_Visibility As Visibility
      Get
         Return If(m_bOverwrite, Visibility.Visible, Visibility.Collapsed)
      End Get
   End Property

   Sub New(PartId As Integer, PDN As Integer, NAM As String, UIDList As List(Of Integer), Overwrite As Boolean)
      m_nPartId = PartId
      m_nPDN = PDN
      m_sNAM = NAM
      m_UIDList = UIDList
      m_bOverwrite = Overwrite
   End Sub

End Class