179 lines
4.7 KiB
VB.net
179 lines
4.7 KiB
VB.net
Imports EgtWPFLib5
|
|
|
|
Public Class UpdateResellerPageVM
|
|
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_Name As String
|
|
Public Property Name As String
|
|
Get
|
|
Return m_Name
|
|
End Get
|
|
Set(value As String)
|
|
m_Name = value
|
|
NotifyPropertyChanged("Name")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Note As String
|
|
Public Property Note As String
|
|
Get
|
|
Return m_Note
|
|
End Get
|
|
Set(value As String)
|
|
m_Note = value
|
|
NotifyPropertyChanged("Note")
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdUpdate As Command
|
|
Private m_cmdCancel As Command
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property UpdateResellerMsg As String
|
|
Get
|
|
Return "Update reseller"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NameMsg As String
|
|
Get
|
|
Return "Name"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NoteMsg As String
|
|
Get
|
|
Return "Note"
|
|
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.SetRefUpdateResellerPageVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitUpdateResellerPage()
|
|
' Svuoto campi
|
|
' Name = String.Empty
|
|
Dim Query As String = "SELECT * FROM " & DB_RESELLER &
|
|
" WHERE " & DB_RESELLERID & " LIKE " & IdToUpdate
|
|
Dim m_UpdateResDict As Dictionary(Of String, String) = ManageDb.ExecuteStringDictionaryQuery(Query)
|
|
Name = m_UpdateResDict(DB_RESELLERNAME)
|
|
NotifyPropertyChanged("Name")
|
|
Note = m_UpdateResDict(DB_NOTE)
|
|
NotifyPropertyChanged("Note")
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Update"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property UpdateReseller_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 String.IsNullOrWhiteSpace(Name) Then
|
|
' Cerco nella tabella Reseller
|
|
Dim bFirstWhere As Boolean = True
|
|
Dim Query As String = "UPDATE " & DB_RESELLER
|
|
If Not String.IsNullOrWhiteSpace(Name) OrElse
|
|
Not String.IsNullOrWhiteSpace(Note) Then
|
|
Query &= " SET "
|
|
If Not String.IsNullOrWhiteSpace(Name) Then
|
|
EvalWhere(bFirstWhere, Query)
|
|
Query &= DB_RESELLERNAME & " = '" & Name & "' "
|
|
End If
|
|
If Not String.IsNullOrWhiteSpace(Note) Then
|
|
EvalWhere(bFirstWhere, Query)
|
|
Query &= DB_NOTE & " = '" & Note.Replace("\", "\\").Replace("'", "\'").Replace("""", "\""").Replace("%", "\%") & "' "
|
|
End If
|
|
Query &= "WHERE " & DB_RESELLERID & " = " & 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.SEARCHRESELLER
|
|
Else
|
|
MessageBox.Show("Completare 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.SEARCHRESELLER
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region 'COMMANDS
|
|
|
|
End Class |