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
207 lines
6.0 KiB
VB.net
207 lines
6.0 KiB
VB.net
Imports EgtWPFLib5
|
|
|
|
Public Class NewProductPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_ProductName As String
|
|
Public Property ProductName As String
|
|
Get
|
|
Return m_ProductName
|
|
End Get
|
|
Set(value As String)
|
|
If Not String.IsNullOrWhiteSpace(value) Then
|
|
' Verifico se valore inserito già esistente
|
|
Dim Query As String = "SELECT COUNT(" & DB_PRODUCTNAME & ") AS " & DB_MAXNUMBER & " FROM " & DB_PRODUCT & " WHERE " & DB_PRODUCTNAME & " = '" & value & "'" ' COLLATE NOCASE"
|
|
If ExecuteNumberQuery(Query) = 0 Then
|
|
m_ProductName = value
|
|
Else
|
|
MessageBox.Show("Il nome del prodotto inserito esiste già!!")
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged("ProductName")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ProductNumber As String
|
|
Public Property ProductNumber As String
|
|
Get
|
|
Return m_ProductNumber
|
|
End Get
|
|
Set(value As String)
|
|
'If Not String.IsNullOrWhiteSpace(value) Then
|
|
' ' Verifico se valore inserito già esistente
|
|
' Dim Query As String = "SELECT COUNT(" & DB_PRODUCTNUMBER & ") AS " & DB_MAXNUMBER & " FROM " & DB_PRODUCT & " WHERE " & DB_PRODUCTNUMBER & " = '" & value & "'" ' COLLATE NOCASE"
|
|
' If ExecuteNumberQuery(Query) = 0 Then
|
|
' m_ProductNumber = value
|
|
' Else
|
|
' MessageBox.Show("Il numero del prodotto inserito esiste già!!")
|
|
' End If
|
|
'End If
|
|
m_ProductNumber = value
|
|
NotifyPropertyChanged("ProductNumber")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ProductOption1 As String
|
|
Public Property ProductOption1 As String
|
|
Get
|
|
Return m_ProductOption1
|
|
End Get
|
|
Set(value As String)
|
|
m_ProductOption1 = value
|
|
NotifyPropertyChanged("ProductOption1")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ProductOption2 As String
|
|
Public Property ProductOption2 As String
|
|
Get
|
|
Return m_ProductOption2
|
|
End Get
|
|
Set(value As String)
|
|
m_ProductOption2 = value
|
|
NotifyPropertyChanged("ProductOption2")
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdAddProduct As Command
|
|
Private m_cmdCancel As Command
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property NewProductMsg As String
|
|
Get
|
|
Return "New product"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProductNameMsg As String
|
|
Get
|
|
Return "Name"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProductNumberMsg As String
|
|
Get
|
|
Return "Number"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProductOption1Msg As String
|
|
Get
|
|
Return "Option 1"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProductOption2Msg As String
|
|
Get
|
|
Return "Option 2"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AddMsg As String
|
|
Get
|
|
Return "Add"
|
|
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.SetRefNewProductPageVM(Me)
|
|
End Sub
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitNewProductPage()
|
|
|
|
' Svuoto campi
|
|
ProductName = String.Empty
|
|
NotifyPropertyChanged("ProductName")
|
|
ProductNumber = String.Empty
|
|
NotifyPropertyChanged("ProductNumber")
|
|
ProductOption1 = String.Empty
|
|
NotifyPropertyChanged("ProductOption1")
|
|
ProductOption2 = String.Empty
|
|
NotifyPropertyChanged("ProductOption2")
|
|
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "AddProduct"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property AddProduct_Command As ICommand
|
|
Get
|
|
If m_cmdAddProduct Is Nothing Then
|
|
m_cmdAddProduct = New Command(AddressOf AddProduct)
|
|
End If
|
|
Return m_cmdAddProduct
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub AddProduct(ByVal param As Object)
|
|
If Not String.IsNullOrWhiteSpace(ProductName) And
|
|
Not String.IsNullOrWhiteSpace(ProductNumber) And
|
|
Not String.IsNullOrWhiteSpace(ProductOption1) And
|
|
Not String.IsNullOrWhiteSpace(ProductOption2) Then
|
|
' Aggiungo un rivenditore al Db
|
|
Dim Query As String = "INSERT INTO " & DB_PRODUCT & " (" & DB_PRODUCTNAME & ", " & DB_PRODUCTNUMBER & "," & DB_PRODUCTOPTION1 & ", " & DB_PRODUCTOPTION2 & ")" &
|
|
" VALUES ('" & m_ProductName & "', " &
|
|
"'" & m_ProductNumber & "', " &
|
|
"'" & m_ProductOption1 & "', " &
|
|
"'" & m_ProductOption2 & "')"
|
|
ManageDb.ExecuteQuery(Query)
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.SEARCHPRODUCT
|
|
Else
|
|
MessageBox.Show("Completare tutti i campi presenti")
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' AddProduct
|
|
|
|
#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.SEARCHPRODUCT
|
|
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|