192 lines
5.5 KiB
VB.net
192 lines
5.5 KiB
VB.net
Imports EgtWPFLib5
|
|
|
|
Public Class UpdateVersionPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_IdToUpdate As Integer
|
|
Public Property IdToUpdate As Integer
|
|
Get
|
|
Return m_IdToUpdate
|
|
End Get
|
|
Set(value As Integer)
|
|
m_IdToUpdate = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ProductList As List(Of Product)
|
|
Public ReadOnly Property ProductList As List(Of Product)
|
|
Get
|
|
Return m_ProductList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelProduct As Product
|
|
Public Property SelProduct As Product
|
|
Get
|
|
Return m_SelProduct
|
|
End Get
|
|
Set(value As Product)
|
|
m_SelProduct = value
|
|
NotifyPropertyChanged("SelProduct")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_VersionNumber As Integer
|
|
Public Property VersionNumber As Integer
|
|
Get
|
|
Return m_VersionNumber
|
|
End Get
|
|
Set(value As Integer)
|
|
m_VersionNumber = value
|
|
NotifyPropertyChanged("VersionNumber")
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdUpdate As Command
|
|
Private m_cmdCancel As Command
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property UpdateVersionMsg As String
|
|
Get
|
|
Return "Update version"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProductNameMsg As String
|
|
Get
|
|
Return "Product name"
|
|
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.SetRefUpdateVersionPageVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitUpdateVersionPage()
|
|
|
|
Dim Query As String = "SELECT * FROM " & DB_VERSION &
|
|
" WHERE " & DB_VERSIONID & " LIKE " & IdToUpdate
|
|
VersionNumber = ManageDb.ExecuteVersionQuery(Query)(0).VersionNumber
|
|
NotifyPropertyChanged("VersionNumber")
|
|
' Carico lista Product
|
|
Dim pQuery As String = "SELECT * FROM " & DB_PRODUCT
|
|
m_ProductList = ManageDb.ExecuteProductQuery(pQuery)
|
|
NotifyPropertyChanged("ProductList")
|
|
Dim pvQuery As String = "SELECT * FROM " & DB_PRODUCT &
|
|
" JOIN " & DB_VERSION &
|
|
" ON " & DB_PRODUCT & "." & DB_PRODUCTID &
|
|
"=" & DB_VERSION & "." & DB_PRODUCTID &
|
|
" WHERE " & DB_VERSIONID & " LIKE " & IdToUpdate
|
|
Dim ProdId As Integer = ManageDb.ExecuteVersionQuery(pvQuery)(0).ProductID
|
|
SelProduct = m_ProductList.FirstOrDefault(Function(prodl) prodl.ProductID.Equals(ProdId))
|
|
NotifyPropertyChanged("SelProduct")
|
|
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Update"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property UpdateVersion_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(SelProduct) OrElse
|
|
Not IsNothing(VersionNumber) Then
|
|
' Aggiorno tabella Version
|
|
Dim Query As String = "UPDATE " & DB_VERSION
|
|
Dim bFirstWhere As Boolean = True
|
|
If Not IsNothing(SelProduct) OrElse
|
|
Not IsNothing(VersionNumber) Then
|
|
Query &= " SET "
|
|
If Not IsNothing(SelProduct) Then
|
|
EvalWhere(bFirstWhere, Query)
|
|
Query &= DB_PRODUCTID & " = '" & SelProduct.ProductID & "' "
|
|
End If
|
|
If Not IsNothing(VersionNumber) Then
|
|
EvalWhere(bFirstWhere, Query)
|
|
Query &= DB_VERSIONNUMBER & " = '" & VersionNumber & "' "
|
|
End If
|
|
Query &= "WHERE " & DB_VERSIONID & " = " & IdToUpdate
|
|
Query = Query.TrimEnd(","c, " "c)
|
|
End If
|
|
ManageDb.ExecuteQuery(Query)
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.SEARCHVERSION
|
|
Else
|
|
MessageBox.Show("Compleatare il campo presente")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub EvalWhere(ByRef bFirst As Boolean, ByRef Query As String)
|
|
If bFirst Then
|
|
bFirst = False
|
|
Else
|
|
Query &= ", "
|
|
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.SEARCHVERSION
|
|
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region 'COMMANDS
|
|
End Class
|
|
|