2ff390d577
- Primo commit.
214 lines
5.9 KiB
VB.net
214 lines
5.9 KiB
VB.net
Imports EgtWPFLib5
|
|
|
|
Public Class UpdateKeyPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_Key As Key
|
|
Public Property Key As Key
|
|
Get
|
|
Return m_Key
|
|
End Get
|
|
Set(value As Key)
|
|
m_Key = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_NameList As List(Of Client)
|
|
Public ReadOnly Property NameList As List(Of Client)
|
|
Get
|
|
Return m_NameList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelName As Client
|
|
Public Property SelName As Client
|
|
Get
|
|
Return m_SelName
|
|
End Get
|
|
Set(value As Client)
|
|
m_SelName = value
|
|
NotifyPropertyChanged("SelName")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ClientID As Integer
|
|
Public Property ClientID As Integer
|
|
Get
|
|
Return m_ClientID
|
|
End Get
|
|
Set(value As Integer)
|
|
m_ClientID = value
|
|
NotifyPropertyChanged("ClientID")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StateList As List(Of Key.KeyState)
|
|
Public ReadOnly Property StateList As List(Of Key.KeyState)
|
|
Get
|
|
Return m_StateList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelState As Key.KeyState
|
|
Public Property SelState As Key.KeyState
|
|
Get
|
|
Return m_SelState
|
|
End Get
|
|
Set(value As Key.KeyState)
|
|
m_SelState = value
|
|
NotifyPropertyChanged("SelState")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_State As Key.KeyState
|
|
Public Property State As Key.KeyState
|
|
Get
|
|
Return m_State
|
|
End Get
|
|
Set(value As Key.KeyState)
|
|
m_State = value
|
|
NotifyPropertyChanged("State")
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdUpdate As Command
|
|
Private m_cmdCancel As Command
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property UpdateKeyMsg As String
|
|
Get
|
|
Return "Update key"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NameMsg As String
|
|
Get
|
|
Return "Name client"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StateMsg As String
|
|
Get
|
|
Return "State"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property UpdateMsg As String
|
|
Get
|
|
Return "Update"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
Return "Cancel"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Imposto riferimento nella mappa
|
|
Map.SetRefUpdateKeyPageVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitUpdateKeyPage()
|
|
' Carico lista Name
|
|
Dim Query As String = "SELECT * FROM " & DB_CLIENT
|
|
m_NameList = ManageDb.ExecuteClientQuery(Query)
|
|
NotifyPropertyChanged("NameList")
|
|
' Carico lista State
|
|
Dim sList As New List(Of Key.KeyState)
|
|
sList.Add(Key.KeyState.Consegnata)
|
|
sList.Add(Key.KeyState.InDeposito)
|
|
sList.Add(Key.KeyState.Guasta)
|
|
m_StateList = sList
|
|
NotifyPropertyChanged("StateList")
|
|
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Update"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property UpdateKey_Command As ICommand
|
|
Get
|
|
If m_cmdUpdate Is Nothing Then
|
|
m_cmdUpdate = New Command(AddressOf Update)
|
|
End If
|
|
Return m_cmdUpdate
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Update(ByVal param As Object)
|
|
If Not IsNothing(Key) Then
|
|
If Not IsNothing(SelName) Then
|
|
'Cerco IDClient associato a Name
|
|
Dim Query As String = "SELECT " & DB_CLIENTID & " FROM " & DB_CLIENT & " WHERE " & DB_NAME & " = '" & SelName.Name & "'"
|
|
ClientID = ManageDb.ExecuteIntegerQuery(Query, DB_CLIENTID)(0)
|
|
' Aggiorno tabella Key col Client scelto
|
|
Query = "UPDATE " & DB_KEY & " SET " & DB_CLIENTID & " = '" & m_ClientID & "' WHERE " & DB_LOCKID & " = '" & Key.LockID & "' "
|
|
Query = Query.TrimEnd(","c, " "c)
|
|
|
|
ManageDb.ExecuteQuery(Query)
|
|
End If
|
|
If Not IsNothing(SelState) Then
|
|
' Aggiorno tabella Key con lo State scelto
|
|
Dim Query As String = "UPDATE " & DB_KEY & " SET " & DB_STATE & " = '" & m_SelState.ToString() & "' WHERE " & DB_LOCKID & " = '" & Key.LockID & "' "
|
|
Query = Query.TrimEnd(","c, " "c)
|
|
|
|
ManageDb.ExecuteQuery(Query)
|
|
End If
|
|
Else
|
|
MessageBox.Show("Non è stata selezionata nessuna chiave")
|
|
End If
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.MAINMENU
|
|
' Else
|
|
' MessageBox.Show("Completare il campo presente")
|
|
'End If
|
|
End Sub
|
|
|
|
#End Region ' Update
|
|
|
|
#Region "Cancel"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property Cancel_Command As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Cancel)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Cancel(ByVal param As Object)
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.SEARCHKEY
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region 'COMMANDS
|
|
|
|
|
|
End Class
|