08237de2d8
- In UpdateLicencePage viene mostrato il nome del Prodotto della Licenza che si sta aggiornando - Ogni pulsante "Close" fa ritornare alla pagina precedente (Correzione simile per i vari pulsanti Update e New, mentre Delete rimane nella stessa pagina) - Correzione pulsanti del Main Menu (non hanno più la scritta "Cerca...") - I DataGrid non tagliano più l'ultima riga visibile ma si aggiustano in base al numero intero di righe visibili (implementato per tutte le pagine Search tranne che per Product per via di errori che non riesco a risolvere
265 lines
7.6 KiB
VB.net
265 lines
7.6 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
|
|
|
|
Private m_KeyDate As Nullable(Of Date)
|
|
Public Property KeyDate As Nullable(Of Date)
|
|
Get
|
|
Return m_KeyDate
|
|
End Get
|
|
Set(value As Nullable(Of Date))
|
|
m_KeyDate = value
|
|
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 KeyDateMsg As String
|
|
Get
|
|
Return "Key date"
|
|
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 "Close"
|
|
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")
|
|
|
|
Dim nQuery As String = "SELECT * FROM " & DB_CLIENT & " WHERE " & DB_CLIENTID & " = '" & Key.ClientID & "'"
|
|
If ManageDb.ExecuteClientQuery(nQuery).Count <> 0 Then
|
|
m_SelName = m_NameList.FirstOrDefault(Function(namel) namel.Name.Equals(ManageDb.ExecuteClientQuery(nQuery)(0).Name)) 'ManageDb.ExecuteClientQuery(nQuery)(0)
|
|
Else
|
|
m_SelName = Nothing
|
|
End If
|
|
NotifyPropertyChanged("SelName")
|
|
|
|
' 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.InDepositoEgt)
|
|
sList.Add(Key.KeyState.Guasta)
|
|
sList.Add(Key.KeyState.Interna)
|
|
sList.Add(Key.KeyState.InternaEgt)
|
|
m_StateList = sList
|
|
NotifyPropertyChanged("StateList")
|
|
|
|
'Dim sQuery As String = "SELECT * FROM " & DB_KEY & " WHERE " & DB_LOCKID & " = '" & Key.LockID & "'"
|
|
'm_SelState = m_StateList.ElementAt(2) ' m_StateList.FirstOrDefault(Function(statel) statel.Equals(ManageDb.ExecuteKeyQuery(sQuery)(0).State))
|
|
|
|
|
|
'Dim item As Key.KeyState = m_StateList(2)
|
|
'm_StateList.RemoveAt(2)
|
|
''If (newIndex > oldIndex) Then newIndex--;
|
|
'' the actual index could have shifted due to the removal
|
|
'm_StateList.Insert(0, item)
|
|
|
|
m_SelState = m_StateList(Key.State)
|
|
NotifyPropertyChanged("SelState")
|
|
|
|
m_KeyDate = Key.KeyDate
|
|
NotifyPropertyChanged("KeyDate")
|
|
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)
|
|
ClientID = SelName.ClientID
|
|
' Aggiorno tabella Key col Client scelto
|
|
Dim Query As String = "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
|
|
If Not IsNothing(SelState) Then
|
|
' Aggiorno tabella Key con KeyDate scelto
|
|
Dim Query As String = "UPDATE " & DB_KEY & " SET " & DB_DATE & " = '" & Format(m_KeyDate, "yyyy-MM-dd") & "' 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.SEARCHKEY
|
|
' 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
|