diff --git a/ClientPage/ClientPageV.xaml.vb b/ClientPage/ClientPageV.xaml.vb index 927664d..1078c8d 100644 --- a/ClientPage/ClientPageV.xaml.vb +++ b/ClientPage/ClientPageV.xaml.vb @@ -1,5 +1,5 @@ Public Class ClientPageV - Private Sub ResellerComboBox_Loaded(sender As Object, e As RoutedEventArgs) Handles ResellerComboBox.Loaded - ResellerComboBox.SelectedIndex = -1 - End Sub + 'Private Sub ResellerComboBox_Loaded(sender As Object, e As RoutedEventArgs) Handles ResellerComboBox.Loaded + ' ResellerComboBox.SelectedIndex = -1 + 'End Sub End Class diff --git a/KeyPage/KeyPageV.xaml b/KeyPage/KeyPageV.xaml index 7ce65ce..f3e4cf5 100644 --- a/KeyPage/KeyPageV.xaml +++ b/KeyPage/KeyPageV.xaml @@ -12,7 +12,8 @@ - + + + Style="{StaticResource ParametersComboBox}" SelectedIndex="-1"/> - - + + + + + + + + diff --git a/KeyPage/KeyPageV.xaml.vb b/KeyPage/KeyPageV.xaml.vb index 0bf6219..93bdbc2 100644 --- a/KeyPage/KeyPageV.xaml.vb +++ b/KeyPage/KeyPageV.xaml.vb @@ -4,7 +4,7 @@ End Sub Private Sub IsDongleComboBox_Loaded(sender As Object, e As RoutedEventArgs) Handles IsDongleComboBox.Loaded - IsDongleComboBox.SelectedIndex = 3 + IsDongleComboBox.SelectedIndex = -1 End Sub End Class diff --git a/KeyPage/KeyPageVM.vb b/KeyPage/KeyPageVM.vb index e739c73..8491176 100644 --- a/KeyPage/KeyPageVM.vb +++ b/KeyPage/KeyPageVM.vb @@ -1,163 +1,226 @@ Imports EgtWPFLib5 Public Class KeyPageVM - Inherits VMBase + Inherits VMBase #Region "FIELDS & PROPERTIES" - Private m_IsDongleList As New List(Of String)({"Hardware", "Software", "---ANY---", " "}) + Private m_IsDongleList As New List(Of String)({"Hardware", "Software", "---ANY---"}) Public ReadOnly Property IsDongleList As List(Of String) - Get - Return m_IsDongleList - End Get - End Property + Get + Return m_IsDongleList + End Get + End Property - Private m_SelIsDongle As Integer - Public Property SelIsDongle As Integer - Get - If (m_SelIsDongle = 1) Then - Return 0 - End If - If (m_SelIsDongle = 0) Then - Return 1 - Else - Return 2 - End If - End Get - Set(value As Integer) - If value = 0 Then - m_SelIsDongle = 1 ' True - ' Rendo visibile Number - Number_Visibility = Visibility.Visible - LockID_Visibility = Visibility.Collapsed - ElseIf value = 1 Then ' Else - m_SelIsDongle = 0 ' False - ' Rendo visibile LockID - Number_Visibility = Visibility.Collapsed - LockID_Visibility = Visibility.Visible - ElseIf value > 1 Then - m_SelIsDongle = 2 - Number_Visibility = Visibility.Collapsed - LockID_Visibility = Visibility.Visible - End If - NotifyPropertyChanged("SelIsDongle") - End Set - End Property - Friend Function GetSelIsDongle() As Integer - Return m_SelIsDongle - End Function + Private m_SelIsDongle As Integer + Public Property SelIsDongle As String + Get + If (m_SelIsDongle = 1) Then + Return "Hardware" + End If + If (m_SelIsDongle = 0) Then + Return "Software" + Else + Return "---ANY---" + End If + End Get + Set(value As String) + If value = "Hardware" Then + m_SelIsDongle = 1 ' True + ' Rendo visibile Number e GeneratedLockID + Number_Visibility = Visibility.Visible + LockID_Visibility = Visibility.Collapsed + GeneratedNumber_Visibility = Visibility.Collapsed + GeneratedLockID_Visibility = Visibility.Visible + ElseIf value = "Software" Then ' Else + m_SelIsDongle = 0 ' False + ' Rendo visibile LockID e GeneratedNumber + Number_Visibility = Visibility.Collapsed + LockID_Visibility = Visibility.Visible + GeneratedNumber_Visibility = Visibility.Visible + GeneratedLockID_Visibility = Visibility.Collapsed + Else + m_SelIsDongle = 2 + Number_Visibility = Visibility.Collapsed + LockID_Visibility = Visibility.Collapsed + GeneratedNumber_Visibility = Visibility.Collapsed + GeneratedLockID_Visibility = Visibility.Collapsed + End If + NotifyPropertyChanged("SelIsDongle") + End Set + End Property + Friend Function GetSelIsDongle() As Integer + Return m_SelIsDongle + End Function - Private m_Number_Visibility As Visibility - Public Property Number_Visibility As Visibility - Get - Return m_Number_Visibility - End Get - Set(value As Visibility) - m_Number_Visibility = value - NotifyPropertyChanged("Number_Visibility") - End Set - End Property + Private m_Number_Visibility As Visibility + Public Property Number_Visibility As Visibility + Get + Return m_Number_Visibility + End Get + Set(value As Visibility) + m_Number_Visibility = value + NotifyPropertyChanged("Number_Visibility") + End Set + End Property - Private m_LockID As String - Public Property LockID As String - Get - Return m_LockID - End Get - Set(value As String) - m_LockID = value - NotifyPropertyChanged("LockID") - End Set - End Property + Private m_LockID As String + Public Property LockID As String + Get + Return m_LockID + End Get + Set(value As String) + m_LockID = value + NotifyPropertyChanged("LockID") + End Set + End Property - Private m_LockID_Visibility As Visibility - Public Property LockID_Visibility As Visibility - Get - Return m_LockID_Visibility - End Get - Set(value As Visibility) - m_LockID_Visibility = value - NotifyPropertyChanged("LockID_Visibility") - End Set - End Property + Private m_LockID_Visibility As Visibility + Public Property LockID_Visibility As Visibility + Get + Return m_LockID_Visibility + End Get + Set(value As Visibility) + m_LockID_Visibility = value + NotifyPropertyChanged("LockID_Visibility") + End Set + End Property - Private m_ClientList As List(Of Client) - Public ReadOnly Property ClientList As List(Of Client) - Get - Return m_ClientList - End Get - End Property - Friend Sub SetClientList(value As List(Of Client)) - m_ClientList = value - End Sub + Private m_GeneratedLockID As String + Public Property GeneratedLockID As String + Get + Return m_GeneratedLockID + End Get + Set(value As String) + m_GeneratedLockID = value + NotifyPropertyChanged("GeneratedLockID") + End Set + End Property - Private m_SelClient As Client - Public Property SelClient As Client - Get - Return m_SelClient - End Get - Set(value As Client) - m_SelClient = value - NotifyPropertyChanged("SelClient") - End Set - End Property + Private m_GeneratedLockID_Visibility As Visibility + Public Property GeneratedLockID_Visibility As Visibility + Get + Return m_GeneratedLockID_Visibility + End Get + Set(value As Visibility) + m_GeneratedLockID_Visibility = value + NotifyPropertyChanged("GeneratedLockID_Visibility") + End Set + End Property - Private m_StateList As New List(Of String)({" ", "Consegnata", "InDeposito", "Guasta", "---ANY---"}) ' Key.KeyState)({Key.KeyState.Consegnata, Key.KeyState.InDeposito, Key.KeyState.Guasta, Key.KeyState.ANY}) + Private m_GeneratedNumber As Integer + Public Property GeneratedNumber As Integer + Get + Return m_GeneratedNumber + End Get + Set(value As Integer) + m_GeneratedNumber = value + NotifyPropertyChanged("GeneratedNumber") + End Set + End Property + + Private m_GeneratedNumber_Visibility As Visibility + Public Property GeneratedNumber_Visibility As Visibility + Get + Return m_GeneratedNumber_Visibility + End Get + Set(value As Visibility) + m_GeneratedNumber_Visibility = value + NotifyPropertyChanged("GeneratedNumber_Visibility") + End Set + End Property + + Private m_ClientList As List(Of Client) + Public ReadOnly Property ClientList As List(Of Client) + Get + Return m_ClientList + End Get + End Property + Friend Sub SetClientList(value As List(Of Client)) + m_ClientList = value + End Sub + + Private m_SelClient As Client + Public Property SelClient As Client + Get + Return m_SelClient + End Get + Set(value As Client) + m_SelClient = value + NotifyPropertyChanged("SelClient") + End Set + End Property + + Private m_StateList As New List(Of String)({"Consegnata", "InDeposito", "InDepositoEgt", "Guasta", "---ANY---"}) ' Key.KeyState)({Key.KeyState.Consegnata, Key.KeyState.InDeposito, Key.KeyState.Guasta, Key.KeyState.ANY}) Public ReadOnly Property StateList As List(Of String) ' Key.KeyState) - Get - Return m_StateList - End Get - End Property - Friend Sub SetStateList(value As List(Of String)) ' Key.KeyState)) - m_StateList = value - End Sub + Get + Return m_StateList + End Get + End Property + Friend Sub SetStateList(value As List(Of String)) ' Key.KeyState)) + m_StateList = value + End Sub - Private m_SelState As Key.KeyState - Public Property SelState As String - Get - Return m_SelState.ToString() - End Get - Set(value As String) ' Key.KeyState) - 'm_SelState = value - If (value.Equals(" ")) Then m_SelState = Nothing - If (value.Equals("Consegnata")) Then m_SelState = Key.KeyState.Consegnata - If (value.Equals("InDeposito")) Then m_SelState = Key.KeyState.InDeposito - If (value.Equals("Guasta")) Then m_SelState = Key.KeyState.Guasta - If (value.Equals("---ANY---")) Then m_SelState = Key.KeyState.ANY - NotifyPropertyChanged("SelState") - End Set - End Property + Private m_SelState As Key.KeyState + Public Property SelState As String + Get + Return m_SelState.ToString() + End Get + Set(value As String) ' Key.KeyState) + 'm_SelState = value + 'If (value.Equals(" ")) Then m_SelState = Nothing + If (value.Equals("Consegnata")) Then m_SelState = Key.KeyState.Consegnata + If (value.Equals("InDeposito")) Then m_SelState = Key.KeyState.InDeposito + If (value.Equals("InDepositoEgt")) Then m_SelState = Key.KeyState.InDepositoEgt + If (value.Equals("Guasta")) Then m_SelState = Key.KeyState.Guasta + If (value.Equals("---ANY---")) Then m_SelState = Key.KeyState.ANY + NotifyPropertyChanged("SelState") + End Set + End Property #Region "Messages" - Public ReadOnly Property IsDongleMsg As String - Get - Return "Is dongle" - End Get - End Property + Public ReadOnly Property IsDongleMsg As String + Get + Return "Is dongle" + End Get + End Property - Public ReadOnly Property NumberMsg As String - Get - Return "Number" - End Get - End Property + Public ReadOnly Property NumberMsg As String + Get + Return "Number" + End Get + End Property - Public ReadOnly Property LockIDMsg As String - Get - Return "LockID" - End Get - End Property + Public ReadOnly Property LockIDMsg As String + Get + Return "LockID" + End Get + End Property - Public ReadOnly Property ClientNameMsg As String - Get - Return "Client name" - End Get - End Property + Public ReadOnly Property GeneratedLockIDMsg As String + Get + Return "Generated LockID" + End Get + End Property - Public ReadOnly Property StateMsg As String - Get - Return "State" - End Get - End Property + Public ReadOnly Property GeneratedNumberMsg As String + Get + Return "Generated Number" + End Get + End Property + + Public ReadOnly Property ClientNameMsg As String + Get + Return "Client name" + End Get + End Property + + Public ReadOnly Property StateMsg As String + Get + Return "State" + End Get + End Property #End Region ' Messages @@ -165,25 +228,26 @@ Public Class KeyPageVM #Region "METHODS" - Friend Sub InitKeyPage() + Friend Sub InitKeyPage() - ' Svuoto campi - m_LockID = String.Empty - NotifyPropertyChanged("LockID") + ' Svuoto campi + m_LockID = String.Empty + NotifyPropertyChanged("LockID") - ' Carico valore di default IsDongle - SelIsDongle = 0 + ' Carico valore di default IsDongle + SelIsDongle = String.Empty + NotifyPropertyChanged("SelIsDongle") - ' Carico lista Client - Dim Query As String = "SELECT * FROM " & DB_CLIENT - m_ClientList = ManageDb.ExecuteClientQuery(Query) + ' Carico lista Client + Dim Query As String = "SELECT * FROM " & DB_CLIENT + m_ClientList = ManageDb.ExecuteClientQuery(Query) m_ClientList.Add(New Client("---ANY---", 0, 0, "")) NotifyPropertyChanged("ClientList") - ' Carico valore di default State (InDeposito) - ' m_SelState = Key.KeyState.Guasta - NotifyPropertyChanged("StateList") - End Sub + ' Carico valore di default State (InDeposito) + ' m_SelState = Key.KeyState.Guasta + NotifyPropertyChanged("StateList") + End Sub #End Region ' METHODS diff --git a/MainWindow/Objects.vb b/MainWindow/Objects.vb index 972975e..a4d6255 100644 --- a/MainWindow/Objects.vb +++ b/MainWindow/Objects.vb @@ -1,9 +1,8 @@ -Imports System.Data.SQLite -Imports MySql.Data.MySqlClient +Imports MySql.Data.MySqlClient Public Class Client - Private m_Name As String + Private m_Name As String Public ReadOnly Property Name As String Get Return m_Name @@ -18,18 +17,18 @@ Public Class Client End Property Private m_ResellerID As Integer - Public ReadOnly Property ResellerID As Integer - Get - Return m_ResellerID - End Get - End Property + Public ReadOnly Property ResellerID As Integer + Get + Return m_ResellerID + End Get + End Property - Private m_ClientID As Integer - Public ReadOnly Property ClientID As Integer - Get - Return m_ClientID - End Get - End Property + Private m_ClientID As Integer + Public ReadOnly Property ClientID As Integer + Get + Return m_ClientID + End Get + End Property Sub New(Name As String, ResellerID As Integer, ClientID As Integer, Email As String) m_Name = Name @@ -39,8 +38,8 @@ Public Class Client End Sub Sub New(ClientReader As MySqlDataReader) - m_Name = CType(ClientReader(DB_NAME), String) - m_ResellerID = CInt(ClientReader(DB_RESELLERID)) + m_Name = CType(ClientReader(DB_NAME), String) + m_ResellerID = CInt(ClientReader(DB_RESELLERID)) m_ClientID = CInt(ClientReader(DB_CLIENTID)) m_Email = CType(ClientReader(DB_EMAIL), String) End Sub @@ -49,285 +48,288 @@ End Class Public Class Key - Private m_Number As Integer - Public ReadOnly Property Number As Integer - Get - Return m_Number - End Get - End Property + Private m_Number As Integer + Public ReadOnly Property Number As Integer + Get + Return m_Number + End Get + End Property - Private m_ClientID As Integer - Public ReadOnly Property ClientID As Integer - Get - Return m_ClientID - End Get - End Property + Private m_ClientID As Integer + Public ReadOnly Property ClientID As Integer + Get + Return m_ClientID + End Get + End Property - Private m_IsDongle As Integer - Public ReadOnly Property IsDongle As Integer - Get - Return m_IsDongle - End Get - End Property + Private m_IsDongle As Integer + Public ReadOnly Property IsDongle As Integer + Get + Return m_IsDongle + End Get + End Property - Private m_LockID As String - Public ReadOnly Property LockID As String - Get - Return m_LockID - End Get - End Property + Private m_LockID As String + Public ReadOnly Property LockID As String + Get + Return m_LockID + End Get + End Property - Public Enum KeyState - Consegnata = 0 - InDeposito = 1 - Guasta = 2 - ANY = 3 - End Enum + Public Enum KeyState + Consegnata = 0 + InDeposito = 1 + InDepositoEgt = 2 + Guasta = 3 + ANY = 4 + End Enum - Private m_State As KeyState - Public ReadOnly Property State As KeyState - Get - Return m_State - End Get - End Property + Private m_State As KeyState + Public ReadOnly Property State As KeyState + Get + Return m_State + End Get + End Property - Sub New(Number As Integer, ClientID As Integer, IsDongle As Integer, LockID As String, State As KeyState) - m_Number = Number - m_ClientID = ClientID - m_IsDongle = IsDongle - m_LockID = LockID - m_State = State - End Sub + Sub New(Number As Integer, ClientID As Integer, IsDongle As Integer, LockID As String, State As KeyState) + m_Number = Number + m_ClientID = ClientID + m_IsDongle = IsDongle + m_LockID = LockID + m_State = State + End Sub - Sub New(KeyReader As MySqlDataReader) - m_Number = CInt(KeyReader(DB_NUMBER)) - m_ClientID = CInt(KeyReader(DB_CLIENTID)) - m_IsDongle = CInt(KeyReader(DB_ISDONGLE)) - m_LockID = CType(KeyReader(DB_LOCKID), String) - m_State = DirectCast([Enum].Parse(GetType(KeyState), KeyReader(DB_STATE)), KeyState) - End Sub + Sub New(KeyReader As MySqlDataReader) + m_Number = CInt(KeyReader(DB_NUMBER)) + If (Not KeyReader(DB_CLIENTID).Equals(DBNull.Value)) Then + m_ClientID = CInt(KeyReader(DB_CLIENTID)) + End If + m_IsDongle = CInt(KeyReader(DB_ISDONGLE)) + m_LockID = CType(KeyReader(DB_LOCKID), String) + m_State = DirectCast([Enum].Parse(GetType(KeyState), KeyReader(DB_STATE)), KeyState) + End Sub End Class Public Class Licence - Private m_ProductID As Integer - Public ReadOnly Property ProductID As Integer - Get - Return m_ProductID - End Get - End Property + Private m_ProductID As Integer + Public ReadOnly Property ProductID As Integer + Get + Return m_ProductID + End Get + End Property - Private m_ProductVersion As String - Public ReadOnly Property ProductVersion As String - Get - Return m_ProductVersion - End Get - End Property + Private m_ProductVersion As String + Public ReadOnly Property ProductVersion As String + Get + Return m_ProductVersion + End Get + End Property - Private m_ProductLevel As Integer - Public ReadOnly Property ProductLevel As Integer - Get - Return m_ProductLevel - End Get - End Property + Private m_ProductLevel As Integer + Public ReadOnly Property ProductLevel As Integer + Get + Return m_ProductLevel + End Get + End Property - Private m_ProductDeadline As Date - Public ReadOnly Property ProductDeadline As Date - Get - Return m_ProductDeadline - End Get - End Property + Private m_ProductDeadline As Date + Public ReadOnly Property ProductDeadline As Date + Get + Return m_ProductDeadline + End Get + End Property - Private m_Option1 As Integer - Public ReadOnly Property Option1 As Integer - Get - Return m_Option1 - End Get - End Property + Private m_Option1 As Integer + Public ReadOnly Property Option1 As Integer + Get + Return m_Option1 + End Get + End Property - Private m_Option2 As Integer - Public ReadOnly Property Option2 As Integer - Get - Return m_Option2 - End Get - End Property + Private m_Option2 As Integer + Public ReadOnly Property Option2 As Integer + Get + Return m_Option2 + End Get + End Property - Private m_OptionDeadline As Date - Public ReadOnly Property OptionDeadline As Date - Get - Return m_OptionDeadline - End Get - End Property + Private m_OptionDeadline As Date + Public ReadOnly Property OptionDeadline As Date + Get + Return m_OptionDeadline + End Get + End Property - Private m_LockID As String - Public ReadOnly Property Number As String - Get - Return m_LockID - End Get - End Property + Private m_LockID As String + Public ReadOnly Property Number As String + Get + Return m_LockID + End Get + End Property - Private m_File As String - Public ReadOnly Property File As String - Get - Return m_File - End Get - End Property + Private m_File As String + Public ReadOnly Property File As String + Get + Return m_File + End Get + End Property - Private m_LicenceID As String - Public ReadOnly Property LicenceID As String - Get - Return m_LicenceID - End Get - End Property + Private m_LicenceID As String + Public ReadOnly Property LicenceID As String + Get + Return m_LicenceID + End Get + End Property - Sub New(ProductID As Integer, ProductVersion As String, ProductLevel As Integer, ProductDeadline As Date, Option1 As Integer, Option2 As Integer, OptionDeadline As Date, LockID As String, File As String, LicenceID As String) - m_ProductID = ProductID - m_ProductVersion = ProductVersion - m_ProductLevel = ProductLevel - m_ProductDeadline = ProductDeadline - m_Option1 = Option1 - m_Option2 = Option2 - m_OptionDeadline = OptionDeadline - m_LockID = LockID - m_File = File - m_LicenceID = LicenceID - End Sub + Sub New(ProductID As Integer, ProductVersion As String, ProductLevel As Integer, ProductDeadline As Date, Option1 As Integer, Option2 As Integer, OptionDeadline As Date, LockID As String, File As String, LicenceID As String) + m_ProductID = ProductID + m_ProductVersion = ProductVersion + m_ProductLevel = ProductLevel + m_ProductDeadline = ProductDeadline + m_Option1 = Option1 + m_Option2 = Option2 + m_OptionDeadline = OptionDeadline + m_LockID = LockID + m_File = File + m_LicenceID = LicenceID + End Sub - Sub New(LicenceReader As MySqlDataReader) - m_ProductID = CInt(LicenceReader(DB_PRODUCTID)) - m_ProductVersion = CType(LicenceReader(DB_PRODUCTVERSION), String) - m_ProductLevel = CInt(LicenceReader(DB_PRODUCTLEVEL)) - m_ProductDeadline = CDate(LicenceReader(DB_PRODUCTDEADLINE)) - m_Option1 = CInt(LicenceReader(DB_OPTION1)) - m_Option2 = CInt(LicenceReader(DB_OPTION2)) - m_OptionDeadline = CDate(LicenceReader(DB_OPTIONDEADLINE)) - m_LockID = CType(LicenceReader(DB_LOCKID), String) - m_File = CType(LicenceReader(DB_FILE), String) - m_LicenceID = CType(LicenceReader(DB_LICENCEID), String) + Sub New(LicenceReader As MySqlDataReader) + m_ProductID = CInt(LicenceReader(DB_PRODUCTID)) + m_ProductVersion = CType(LicenceReader(DB_PRODUCTVERSION), String) + m_ProductLevel = CInt(LicenceReader(DB_PRODUCTLEVEL)) + m_ProductDeadline = CDate(LicenceReader(DB_PRODUCTDEADLINE)) + m_Option1 = CInt(LicenceReader(DB_OPTION1)) + m_Option2 = CInt(LicenceReader(DB_OPTION2)) + m_OptionDeadline = CDate(LicenceReader(DB_OPTIONDEADLINE)) + m_LockID = CType(LicenceReader(DB_LOCKID), String) + m_File = CType(LicenceReader(DB_FILE), String) + m_LicenceID = CType(LicenceReader(DB_LICENCEID), String) - End Sub + End Sub End Class Public Class Product - Private m_ProductName As String - Public ReadOnly Property ProductName As String - Get - Return m_ProductName - End Get - End Property + Private m_ProductName As String + Public ReadOnly Property ProductName As String + Get + Return m_ProductName + End Get + End Property - Private m_ProductID As Integer - Public ReadOnly Property ProductID As Integer - Get - Return m_ProductID - End Get - End Property + Private m_ProductID As Integer + Public ReadOnly Property ProductID As Integer + Get + Return m_ProductID + End Get + End Property - Private m_ProductNumber As Integer - Public ReadOnly Property ProductNumber As Integer - Get - Return m_ProductNumber - End Get - End Property + Private m_ProductNumber As Integer + Public ReadOnly Property ProductNumber As Integer + Get + Return m_ProductNumber + End Get + End Property - Private m_ProductOption1 As Integer - Public ReadOnly Property ProductOption1 As Integer - Get - Return m_ProductOption1 - End Get - End Property + Private m_ProductOption1 As Integer + Public ReadOnly Property ProductOption1 As Integer + Get + Return m_ProductOption1 + End Get + End Property - Private m_ProductOption2 As Integer - Public ReadOnly Property ProductOption2 As Integer - Get - Return m_ProductOption2 - End Get - End Property + Private m_ProductOption2 As Integer + Public ReadOnly Property ProductOption2 As Integer + Get + Return m_ProductOption2 + End Get + End Property - Sub New(ProductName As String, ProductID As Integer, ProductNumber As Integer, ProductOption1 As Integer, ProductOption2 As Integer) - m_ProductName = ProductName - m_ProductID = ProductID - m_ProductNumber = ProductNumber - m_ProductOption1 = ProductOption1 - m_ProductOption2 = ProductOption2 - End Sub + Sub New(ProductName As String, ProductID As Integer, ProductNumber As Integer, ProductOption1 As Integer, ProductOption2 As Integer) + m_ProductName = ProductName + m_ProductID = ProductID + m_ProductNumber = ProductNumber + m_ProductOption1 = ProductOption1 + m_ProductOption2 = ProductOption2 + End Sub - Sub New(ProductReader As MySqlDataReader) - m_ProductName = CType(ProductReader(DB_PRODUCTNAME), String) - m_ProductID = CInt(ProductReader(DB_PRODUCTID)) - m_ProductNumber = CInt(ProductReader(DB_PRODUCTNUMBER)) - m_ProductOption1 = CInt(ProductReader(DB_PRODUCTOPTION1)) - m_ProductOption2 = CInt(ProductReader(DB_PRODUCTOPTION2)) - End Sub + Sub New(ProductReader As MySqlDataReader) + m_ProductName = CType(ProductReader(DB_PRODUCTNAME), String) + m_ProductID = CInt(ProductReader(DB_PRODUCTID)) + m_ProductNumber = CInt(ProductReader(DB_PRODUCTNUMBER)) + m_ProductOption1 = CInt(ProductReader(DB_PRODUCTOPTION1)) + m_ProductOption2 = CInt(ProductReader(DB_PRODUCTOPTION2)) + End Sub End Class Public Class Version - Private m_VersionID As Integer - Public ReadOnly Property VersionID As Integer - Get - Return m_VersionID - End Get - End Property + Private m_VersionID As Integer + Public ReadOnly Property VersionID As Integer + Get + Return m_VersionID + End Get + End Property - Private m_ProductID As Integer - Public ReadOnly Property ProductID As Integer - Get - Return m_ProductID - End Get - End Property + Private m_ProductID As Integer + Public ReadOnly Property ProductID As Integer + Get + Return m_ProductID + End Get + End Property - Private m_VersionNumber As Integer - Public ReadOnly Property VersionNumber As Integer - Get - Return m_VersionNumber - End Get - End Property + Private m_VersionNumber As Integer + Public ReadOnly Property VersionNumber As Integer + Get + Return m_VersionNumber + End Get + End Property - Sub New(VersionID As String, ProductID As String, VersionNumber As Integer) - m_VersionID = CInt(VersionID) - m_ProductID = CInt(ProductID) - m_VersionNumber = VersionNumber - End Sub + Sub New(VersionID As String, ProductID As String, VersionNumber As Integer) + m_VersionID = CInt(VersionID) + m_ProductID = CInt(ProductID) + m_VersionNumber = VersionNumber + End Sub - Sub New(VersionReader As MySqlDataReader) - m_VersionID = CInt(VersionReader(DB_VERSIONID)) - m_ProductID = CInt(VersionReader(DB_PRODUCTID)) - m_VersionNumber = CInt(VersionReader(DB_VERSIONNUMBER)) - End Sub + Sub New(VersionReader As MySqlDataReader) + m_VersionID = CInt(VersionReader(DB_VERSIONID)) + m_ProductID = CInt(VersionReader(DB_PRODUCTID)) + m_VersionNumber = CInt(VersionReader(DB_VERSIONNUMBER)) + End Sub End Class Public Class Reseller - Private m_ResellerName As String - Public ReadOnly Property ResellerName As String - Get - Return m_ResellerName - End Get - End Property + Private m_ResellerName As String + Public ReadOnly Property ResellerName As String + Get + Return m_ResellerName + End Get + End Property - Private m_ResellerID As Integer - Public ReadOnly Property ResellerID As Integer - Get - Return m_ResellerID - End Get - End Property + Private m_ResellerID As Integer + Public ReadOnly Property ResellerID As Integer + Get + Return m_ResellerID + End Get + End Property - Sub New(ResellerName As String, ResellerID As Integer) - m_ResellerName = ResellerName - m_ResellerID = ResellerID - End Sub + Sub New(ResellerName As String, ResellerID As Integer) + m_ResellerName = ResellerName + m_ResellerID = ResellerID + End Sub - Sub New(ResellerReader As MySqlDataReader) - m_ResellerName = CType(ResellerReader(DB_RESELLERNAME), String) - m_ResellerID = CInt(ResellerReader(DB_RESELLERID)) - End Sub + Sub New(ResellerReader As MySqlDataReader) + m_ResellerName = CType(ResellerReader(DB_RESELLERNAME), String) + m_ResellerID = CInt(ResellerReader(DB_RESELLERID)) + End Sub End Class \ No newline at end of file diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index a1c30f3..d19e8d6 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -55,5 +55,5 @@ Imports System.Windows ' usando l'asterisco '*' come illustrato di seguito: ' - - + + diff --git a/NewKeyPage/NewKeyPageVM.vb b/NewKeyPage/NewKeyPageVM.vb index 3c76daa..78b4a94 100644 --- a/NewKeyPage/NewKeyPageVM.vb +++ b/NewKeyPage/NewKeyPageVM.vb @@ -12,6 +12,41 @@ Public Class NewKeyPageVM End Get Set(value As String) If Not String.IsNullOrWhiteSpace(value) AndAlso Not Integer.TryParse(value, m_Number) Then m_Number = 0 + + ' Costruisco GeneratedLockID string + Dim sCompleteNumber As String = m_Number.ToString("D6") + Dim sCompleteChar As String = sCompleteNumber + sCompleteChar = sCompleteChar.Replace("0"c, "o"c) + sCompleteChar = sCompleteChar.Replace("1"c, "a"c) + sCompleteChar = sCompleteChar.Replace("2"c, "b"c) + sCompleteChar = sCompleteChar.Replace("3"c, "c"c) + sCompleteChar = sCompleteChar.Replace("4"c, "d"c) + sCompleteChar = sCompleteChar.Replace("5"c, "e"c) + sCompleteChar = sCompleteChar.Replace("6"c, "f"c) + sCompleteChar = sCompleteChar.Replace("7"c, "g"c) + sCompleteChar = sCompleteChar.Replace("8"c, "h"c) + sCompleteChar = sCompleteChar.Replace("9"c, "i"c) + Dim CompleteChar() As Char = sCompleteChar.ToCharArray() + For I = 0 To sCompleteChar.Count - 1 + If I Mod 2 = 1 Then + CompleteChar(I) = Char.ToUpper(CompleteChar(I)) + Else + CompleteChar(I) = Char.ToLower(CompleteChar(I)) + End If + Next + m_GeneratedLockID = "EGTECH-" & sCompleteNumber & "-" & CompleteChar + NotifyPropertyChanged("GeneratedLockID") + End Set + End Property + + Private m_GeneratedLockID As String + Public Property GeneratedLockID As String + Get + Return m_GeneratedLockID + End Get + Set(value As String) + m_GeneratedLockID = value + NotifyPropertyChanged("GeneratedLockID") End Set End Property @@ -28,16 +63,37 @@ Public Class NewKeyPageVM Dim MaxLockID As Integer = ExecuteNumberQuery(Query) If ExecuteNumberQuery(Query) = 0 Then m_LockID = value + + ' Recupero ultimo Number di chiave software usato + Query = "SELECT MAX(" & DB_NUMBER & ") AS " & DB_MAXNUMBER & " FROM " & DB_KEY & " WHERE " & DB_ISDONGLE & " = 0" + m_Number = ExecuteNumberQuery(Query) + ' Setto number + m_Number += 1 + m_GeneratedNumber = m_Number + NotifyPropertyChanged("GeneratedNumber") + Else - MessageBox.Show("Il numero di chiave inserito esiste già!!") - m_LockID = "" - MyBase.NotifyPropertyChanged("LockID") + MessageBox.Show("Il LockID inserito esiste già!!") + m_LockID = value + 'm_LockID = "" + 'MyBase.NotifyPropertyChanged("LockID") End If End If NotifyPropertyChanged("LockID") End Set End Property + Private m_GeneratedNumber As Integer + Public Property GeneratedNumber As Integer + Get + Return m_GeneratedNumber + End Get + Set(value As Integer) + m_GeneratedNumber = value + NotifyPropertyChanged("GeneratedNumber") + End Set + End Property + ' Definizione comandi Private m_cmdAddKey As Command Private m_cmdCancel As Command @@ -85,8 +141,12 @@ Public Class NewKeyPageVM m_LockID = String.Empty NotifyPropertyChanged("LockID") + ' Mostro la GeneratedLockID + GeneratedLockID_Visibility = Visibility.Visible + ' Carico valore di default IsDongle - SelIsDongle = 0 + IsDongleList.Remove("---ANY---") + SelIsDongle = String.Empty ' Carico lista Client Dim Query As String = "SELECT * FROM " & DB_CLIENT @@ -94,7 +154,8 @@ Public Class NewKeyPageVM NotifyPropertyChanged("ClientList") ' Carico valore di default State (InDeposito) - SelState = 1 + StateList.Remove("---ANY---") + SelState = String.Empty End Sub #End Region ' METHODS @@ -141,31 +202,51 @@ Public Class NewKeyPageVM m_LockID = "EGTECH-" & sCompleteNumber & "-" & CompleteChar ' Se chiave software Else - ' Recupero ultimo Number di chiave software usato - Query = "SELECT MAX(" & DB_NUMBER & ") AS " & DB_MAXNUMBER & " FROM " & DB_KEY & " WHERE " & DB_ISDONGLE & " = 0" - m_Number = ExecuteNumberQuery(Query) - ' Setto number - m_Number += 1 + '' Recupero ultimo Number di chiave software usato + 'Query = "SELECT MAX(" & DB_NUMBER & ") AS " & DB_MAXNUMBER & " FROM " & DB_KEY & " WHERE " & DB_ISDONGLE & " = 0" + 'm_Number = ExecuteNumberQuery(Query) + '' Setto number + 'm_Number += 1 + m_Number = m_GeneratedNumber End If - 'Verifico che valore LockID si a valido - If Not String.IsNullOrWhiteSpace(m_LockID) And - Not IsNothing(SelClient) Then - ' Aggiungo un rivenditore al Db - Dim dongleValue As Integer = 0 - If (GetSelIsDongle() = 0) Then dongleValue = 0 - If (GetSelIsDongle() = 1) Then dongleValue = 1 - Query = "INSERT INTO " & DB_KEY & " (" & DB_NUMBER & ", " & DB_CLIENTID & ", " & DB_ISDONGLE & ", " & DB_LOCKID & ", " & DB_STATE & ")" & + If (Not IsNothing(m_Number)) Then + ' Verifico se Number già esistente + Dim numQuery As String = "SELECT COUNT(" & DB_NUMBER & ") AS " & DB_MAXNUMBER & " FROM " & DB_KEY & " WHERE " & DB_NUMBER & " = '" & m_Number & "'" + Dim MaxLockID As Integer = ExecuteNumberQuery(numQuery) + If ExecuteNumberQuery(numQuery) = 0 Then + 'Verifico che valore LockID sia valido + If Not String.IsNullOrWhiteSpace(m_LockID) Then + ' Aggiungo un rivenditore al Db + Dim dongleValue As Integer = 0 + If (GetSelIsDongle() = 0) Then dongleValue = 0 + If (GetSelIsDongle() = 1) Then dongleValue = 1 + If (Not IsNothing(SelClient)) Then + Query = "INSERT INTO " & DB_KEY & " (" & DB_NUMBER & ", " & DB_CLIENTID & ", " & DB_ISDONGLE & ", " & DB_LOCKID & ", " & DB_STATE & ")" & " VALUES ('" & Number & "', " & - " '" & SelClient.ClientID & "', " & + " '" & SelClient.ClientID & "', " & " '" & dongleValue & "', " & " '" & m_LockID & "', " & " '" & SelState.ToString() & "')" - ManageDb.ExecuteQuery(Query) - Else - MessageBox.Show("Completare i campi presenti") + Else + Query = "INSERT INTO " & DB_KEY & " (" & DB_NUMBER & ", " & DB_ISDONGLE & ", " & DB_LOCKID & ", " & DB_STATE & ")" & + " VALUES ('" & Number & "', " & + " '" & dongleValue & "', " & + " '" & m_LockID & "', " & + " '" & SelState.ToString() & "')" + End If + ManageDb.ExecuteQuery(Query) + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.MAINMENU + Else + MessageBox.Show("Completare i campi necessari") + End If + Else + MessageBox.Show("Il Numero di chiave esiste già!") + End If End If - ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. - Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.MAINMENU + '' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + 'Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.MAINMENU End Sub #End Region ' AddKey diff --git a/SearchKeyPage/SearchKeyPageVM.vb b/SearchKeyPage/SearchKeyPageVM.vb index 11aae62..d2faa72 100644 --- a/SearchKeyPage/SearchKeyPageVM.vb +++ b/SearchKeyPage/SearchKeyPageVM.vb @@ -1,47 +1,46 @@ Imports System.Collections.ObjectModel -Imports System.Data.SQLite Imports EgtWPFLib5 Imports MySql.Data.MySqlClient Public Class SearchKeyPageVM - Inherits KeyPageVM + Inherits KeyPageVM #Region "FIELDS & PROPERTIES" - Private m_SelSearchResult As SearchKey - Public Property SelSearchResult As SearchKey - Get - Return m_SelSearchResult - End Get - Set(value As SearchKey) - m_SelSearchResult = value - End Set - End Property + Private m_SelSearchResult As SearchKey + Public Property SelSearchResult As SearchKey + Get + Return m_SelSearchResult + End Get + Set(value As SearchKey) + m_SelSearchResult = value + End Set + End Property - Private m_Number As Integer - Public Property Number As String - Get - Return If(m_Number <> 0, m_Number.ToString(), "") - End Get - Set(value As String) - If Not String.IsNullOrWhiteSpace(value) Then - If Not Integer.TryParse(value, m_Number) Then - m_Number = Nothing - End If - Else - m_Number = Nothing + Private m_Number As Integer + Public Property Number As String + Get + Return If(m_Number <> 0, m_Number.ToString(), "") + End Get + Set(value As String) + If Not String.IsNullOrWhiteSpace(value) Then + If Not Integer.TryParse(value, m_Number) Then + m_Number = Nothing End If - End Set - End Property + Else + m_Number = Nothing + End If + End Set + End Property - Private m_SearchResult As ObservableCollection(Of SearchKey) + Private m_SearchResult As ObservableCollection(Of SearchKey) Public ReadOnly Property SearchResult As ObservableCollection(Of SearchKey) Get Return m_SearchResult End Get End Property - Private m_StateList As New List(Of String)({" ", "Consegnata", "InDeposito", "Guasta", "---ANY---"}) ' Key.KeyState)({Key.KeyState.Consegnata, Key.KeyState.InDeposito, Key.KeyState.Guasta, Key.KeyState.ANY}) + Private m_StateList As New List(Of String)({"Consegnata", "InDeposito", "InDepositoEgt", "Guasta", "---ANY---"}) ' Key.KeyState)({Key.KeyState.Consegnata, Key.KeyState.InDeposito, Key.KeyState.Guasta, Key.KeyState.ANY}) Public ReadOnly Property StateList As List(Of String) ' Key.KeyState) Get Return m_StateList @@ -61,6 +60,7 @@ Public Class SearchKeyPageVM If (value.Equals(" ")) Then m_SelState = Nothing If (value.Equals("Consegnata")) Then m_SelState = Key.KeyState.Consegnata If (value.Equals("InDeposito")) Then m_SelState = Key.KeyState.InDeposito + If (value.Equals("InDepositoEgt")) Then m_SelState = Key.KeyState.InDepositoEgt If (value.Equals("Guasta")) Then m_SelState = Key.KeyState.Guasta If (value.Equals("---ANY---")) Then m_SelState = Key.KeyState.ANY NotifyPropertyChanged("SelState") @@ -69,34 +69,34 @@ Public Class SearchKeyPageVM ' Definizione comandi Private m_cmdSearch As Command - Private m_cmdCancel As Command - Private m_cmdUpdate As Command + Private m_cmdCancel As Command + Private m_cmdUpdate As Command #Region "Messages" - Public ReadOnly Property SearchKeyMsg As String - Get - Return "Search key" - End Get - End Property + Public ReadOnly Property SearchKeyMsg As String + Get + Return "Search key" + End Get + End Property - Public ReadOnly Property SearchMsg As String - Get - Return "Search" - End Get - End Property + Public ReadOnly Property SearchMsg As String + Get + Return "Search" + End Get + End Property - Public ReadOnly Property CancelMsg As String - Get - Return "Cancel" - End Get - End Property + Public ReadOnly Property CancelMsg As String + Get + Return "Cancel" + End Get + End Property - Public ReadOnly Property UpdateMsg As String - Get - Return "Update" - End Get - End Property + Public ReadOnly Property UpdateMsg As String + Get + Return "Update" + End Get + End Property #End Region ' Messages @@ -104,22 +104,26 @@ Public Class SearchKeyPageVM #Region "CONSTRUCTOR" - Sub New() - MyBase.New() - ' Imposto riferimento nella mappa - Map.SetRefSearchKeyPageVM(Me) - End Sub + Sub New() + MyBase.New() + ' Imposto riferimento nella mappa + Map.SetRefSearchKeyPageVM(Me) + End Sub #End Region ' CONSTRUCTOR #Region "METHODS" - Friend Sub InitSearchKeyPage() - MyBase.InitKeyPage() - ' Svuoto campi - m_Number = 0 - NotifyPropertyChanged("Number") - m_SearchResult = New ObservableCollection(Of SearchKey)() + Friend Sub InitSearchKeyPage() + MyBase.InitKeyPage() + ' Svuoto campi + m_Number = 0 + NotifyPropertyChanged("Number") + + ' Nascondo la GeneratedLockID + GeneratedLockID_Visibility = Visibility.Collapsed + + m_SearchResult = New ObservableCollection(Of SearchKey)() NotifyPropertyChanged("SearchResult") m_SelState = Key.KeyState.ANY NotifyPropertyChanged("SelState") @@ -131,115 +135,115 @@ Public Class SearchKeyPageVM #Region "Search" - ' Returns a command that manage the MainWindow_Unloaded command - Public ReadOnly Property SearchKey_Command As ICommand - Get - If m_cmdSearch Is Nothing Then - m_cmdSearch = New Command(AddressOf Search) - End If - Return m_cmdSearch - End Get - End Property + ' Returns a command that manage the MainWindow_Unloaded command + Public ReadOnly Property SearchKey_Command As ICommand + Get + If m_cmdSearch Is Nothing Then + m_cmdSearch = New Command(AddressOf Search) + End If + Return m_cmdSearch + End Get + End Property - Public Sub Search(ByVal param As Object) - ' Cerco nella tabella Key - Dim Query As String = "SELECT * FROM " & DB_KEY & " INNER JOIN " & DB_CLIENT & " ON " & DB_KEY & "." & DB_CLIENTID & " = " & DB_CLIENT & "." & DB_CLIENTID & " " - Dim bFirstWhere As Boolean = True - If Not String.IsNullOrWhiteSpace(Number) OrElse - Not IsNothing(SelClient) OrElse - Not IsNothing(SelIsDongle) OrElse - Not IsNothing(SelState) OrElse - Not String.IsNullOrWhiteSpace(LockID) Then - Query &= "WHERE " - If Not IsNothing(SelIsDongle) And Not (SelIsDongle > 1) Then ' If Not IsNothing(SelIsDongle) Then - EvalWhere(bFirstWhere, Query) - Query &= DB_ISDONGLE & " = " - If (GetSelIsDongle() = 1) Then Query &= 1 & " " Else Query &= 0 & " " - End If - If m_Number <> 0 Then - EvalWhere(bFirstWhere, Query) - Query &= DB_NUMBER & " LIKE '%" & Number & "%' " - End If - If Not String.IsNullOrWhiteSpace(LockID) Then - EvalWhere(bFirstWhere, Query) - Query &= DB_LOCKID & " LIKE '%" & LockID & "%' " - End If - If Not IsNothing(SelClient) Then - If Not SelClient.Name.Equals("---ANY---") Then - EvalWhere(bFirstWhere, Query) - Query &= DB_NAME & " LIKE '" & SelClient.Name & "%' " - End If + Public Sub Search(ByVal param As Object) + ' Cerco nella tabella Key + Dim Query As String = "SELECT * FROM " & DB_KEY & " LEFT JOIN " & DB_CLIENT & " ON " & DB_KEY & "." & DB_CLIENTID & " = " & DB_CLIENT & "." & DB_CLIENTID & " " + Dim bFirstWhere As Boolean = True + If Not String.IsNullOrWhiteSpace(Number) OrElse + Not IsNothing(SelClient) OrElse + Not IsNothing(SelIsDongle) OrElse + Not IsNothing(SelState) OrElse + Not String.IsNullOrWhiteSpace(LockID) Then + Query &= "WHERE " + If Not IsNothing(SelIsDongle) And (SelIsDongle = "Hardware" Or SelIsDongle = "Software") Then ' If Not IsNothing(SelIsDongle) Then + EvalWhere(bFirstWhere, Query) + Query &= DB_ISDONGLE & " = " + If (GetSelIsDongle() = 1) Then Query &= 1 & " " Else Query &= 0 & " " + End If + If m_Number <> 0 Then + EvalWhere(bFirstWhere, Query) + Query &= DB_NUMBER & " LIKE '%" & Number & "%' " + End If + If Not String.IsNullOrWhiteSpace(LockID) Then + EvalWhere(bFirstWhere, Query) + Query &= DB_LOCKID & " LIKE '%" & LockID & "%' " + End If + If Not IsNothing(SelClient) Then + If Not SelClient.Name.Equals("---ANY---") Then + EvalWhere(bFirstWhere, Query) + Query &= DB_NAME & " LIKE '" & SelClient.Name & "%' " End If + End If If Not IsNothing(SelState) And Not SelState.Equals(Key.KeyState.ANY.ToString()) Then ' If Not IsNothing(SelState) Then EvalWhere(bFirstWhere, Query) Query &= DB_STATE & " LIKE '" & SelState.ToString() & "%' " End If Query = Query.TrimEnd(","c, " "c) - Dim suffixToRemove As String = " WHERE" - If Not IsNothing(Query) And Not IsNothing(suffixToRemove) And Query.EndsWith(suffixToRemove) Then - Query = Query.Substring(0, Query.Length - suffixToRemove.Length) - End If - End If - m_SearchResult = New ObservableCollection(Of SearchKey)(ManageDb.ExecuteSearchKeyQuery(Query)) - If (m_SearchResult.Count = 0) Then - MessageBox.Show("Nessun risultato per i filtri impostati") - End If - NotifyPropertyChanged("SearchResult") - End Sub + Dim suffixToRemove As String = " WHERE" + If Not IsNothing(Query) And Not IsNothing(suffixToRemove) And Query.EndsWith(suffixToRemove) Then + Query = Query.Substring(0, Query.Length - suffixToRemove.Length) + End If + End If + m_SearchResult = New ObservableCollection(Of SearchKey)(ManageDb.ExecuteSearchKeyQuery(Query)) + If (m_SearchResult.Count = 0) Then + MessageBox.Show("Nessun risultato per i filtri impostati") + End If + NotifyPropertyChanged("SearchResult") + End Sub - Private Sub EvalWhere(ByRef bFirst As Boolean, ByRef Query As String) - If bFirst Then - bFirst = False - Else - Query &= " AND " - End If - End Sub + Private Sub EvalWhere(ByRef bFirst As Boolean, ByRef Query As String) + If bFirst Then + bFirst = False + Else + Query &= " AND " + End If + End Sub #End Region ' Search #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 + ' 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) + 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.MAINMENU + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.MAINMENU - End Sub + End Sub #End Region ' Cancel #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 + ' 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(m_SelSearchResult) Then - ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. - Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.UPDATEKEY - Map.refUpdateKeyPageVM.Key = m_SelSearchResult - Else - MessageBox.Show("Non è stata selezionata nessuna chiave") - End If + Public Sub Update(ByVal param As Object) + If Not IsNothing(m_SelSearchResult) Then + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Map.refUpdateKeyPageVM.Key = m_SelSearchResult + Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.UPDATEKEY + Else + MessageBox.Show("Non è stata selezionata nessuna chiave") + End If - End Sub + End Sub #End Region ' Update @@ -248,18 +252,23 @@ Public Class SearchKeyPageVM End Class Public Class SearchKey - Inherits Key + Inherits Key - Private m_ClientName As String - Public ReadOnly Property ClientName As String - Get - Return m_ClientName - End Get - End Property + Private m_ClientName As String + Public ReadOnly Property ClientName As String + Get + Return m_ClientName + End Get + End Property - Sub New(ClientReader As MySqlDataReader) - MyBase.New(ClientReader) - m_ClientName = CType(ClientReader(DB_NAME), String) - End Sub + Sub New(ClientReader As MySqlDataReader) + MyBase.New(ClientReader) + 'm_ClientName = CType(ClientReader(DB_NAME), String) + If (Not ClientReader(DB_NAME).Equals(DBNull.Value)) Then + m_ClientName = CType(ClientReader(DB_NAME), String) + Else + m_ClientName = Nothing + End If + End Sub End Class \ No newline at end of file diff --git a/SearchLicencePage/SearchLicencePageVM.vb b/SearchLicencePage/SearchLicencePageVM.vb index fefa143..89a8a9c 100644 --- a/SearchLicencePage/SearchLicencePageVM.vb +++ b/SearchLicencePage/SearchLicencePageVM.vb @@ -1,5 +1,4 @@ Imports System.Collections.ObjectModel -Imports System.Data.SQLite Imports EgtWPFLib5 Imports MySql.Data.MySqlClient @@ -62,9 +61,11 @@ Public Class SearchLicencePageVM Set(value As Product) m_SelProduct = value NotifyPropertyChanged("SelProduct") - ' Carico opzioni1 + ' Carico opzioni1 e opzioni2 LoadOptions(1, m_Option1) LoadOptions(2, m_Option2) + NotifyPropertyChanged("Option1") + NotifyPropertyChanged("Option2") End Set End Property diff --git a/UpdateClientPage/UpdateClientPageVM.vb b/UpdateClientPage/UpdateClientPageVM.vb index e9e02bd..c275299 100644 --- a/UpdateClientPage/UpdateClientPageVM.vb +++ b/UpdateClientPage/UpdateClientPageVM.vb @@ -73,22 +73,32 @@ Public Class UpdateClientPageVM #Region "METHODS" Friend Sub InitUpdateClientPage() - ' Svuoto campi - ' Name = String.Empty + ' Carico campo Name Dim Query As String = "SELECT " & DB_NAME & " FROM " & DB_CLIENT & " WHERE " & DB_CLIENTID & " LIKE " & IdToUpdate Name = ManageDb.ExecuteStringQuery(Query, DB_NAME)(0) NotifyPropertyChanged("Name") + ' Carico campo Email Dim eQuery As String = "SELECT " & DB_EMAIL & " FROM " & DB_CLIENT & " WHERE " & DB_CLIENTID & " LIKE " & IdToUpdate - Name = ManageDb.ExecuteStringQuery(eQuery, DB_EMAIL)(0) + Email = ManageDb.ExecuteStringQuery(eQuery, DB_EMAIL)(0) NotifyPropertyChanged("Email") ' Carico lista Reseller Dim rQuery As String = "SELECT * FROM " & DB_RESELLER m_ResellerList = ManageDb.ExecuteResellerQuery(rQuery) NotifyPropertyChanged("ResellerList") + + ' Carico elemento della lista Reseller selezionato precdentemente + Dim selQuery As String = "SELECT * FROM " & DB_CLIENT & + " INNER JOIN " & DB_RESELLER & " ON " & DB_CLIENT & "." & DB_RESELLERID & " = " & + DB_RESELLER & "." & DB_RESELLERID & + " WHERE " & DB_CLIENTID & " LIKE " & IdToUpdate + 'm_SelReseller = ManageDb.ExecuteResellerQuery(rQuery)(0) + 'm_SelReseller = m_ResellerList(2) + m_SelReseller = m_ResellerList.FirstOrDefault(Function(resel) resel.ResellerName.Equals(ManageDb.ExecuteResellerQuery(selQuery)(0).ResellerName)) + NotifyPropertyChanged("SelReseller") End Sub #End Region ' METHODS diff --git a/UpdateKeyPage/UpdateKeyPageVM.vb b/UpdateKeyPage/UpdateKeyPageVM.vb index 916a8d0..65e5890 100644 --- a/UpdateKeyPage/UpdateKeyPageVM.vb +++ b/UpdateKeyPage/UpdateKeyPageVM.vb @@ -1,113 +1,113 @@ Imports EgtWPFLib5 Public Class UpdateKeyPageVM - Inherits VMBase + 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_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_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_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_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_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_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_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 + ' 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 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 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 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 UpdateMsg As String + Get + Return "Update" + End Get + End Property - Public ReadOnly Property CancelMsg As String - Get - Return "Cancel" - End Get - End Property + Public ReadOnly Property CancelMsg As String + Get + Return "Cancel" + End Get + End Property #End Region ' Messages @@ -115,29 +115,47 @@ Public Class UpdateKeyPageVM #Region "CONSTRUCTOR" - Sub New() - ' Imposto riferimento nella mappa - Map.SetRefUpdateKeyPageVM(Me) - End Sub + 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") + Friend Sub InitUpdateKeyPage() + ' Carico lista Name + Dim Query As String = "SELECT * FROM " & DB_CLIENT + m_NameList = ManageDb.ExecuteClientQuery(Query) + NotifyPropertyChanged("NameList") - End Sub + Dim nQuery As String = "SELECT * FROM " & DB_CLIENT & " WHERE " & DB_CLIENTID & " = '" & Key.ClientID & "'" + m_SelName = m_NameList.FirstOrDefault(Function(namel) namel.Name.Equals(ManageDb.ExecuteClientQuery(nQuery)(0).Name)) 'ManageDb.ExecuteClientQuery(nQuery)(0) + 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) + 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") + End Sub #End Region ' METHODS @@ -145,65 +163,66 @@ Public Class UpdateKeyPageVM #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 + ' 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) + 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 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 + 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 + ' 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 + ' 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) + 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 + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Map.refMainWindowVM.SelProjectMode = MainWindowVM.ProjectModeOpt.SEARCHKEY + End Sub #End Region ' Cancel diff --git a/UpdateLicencePage/UpdateLicencePageV.xaml b/UpdateLicencePage/UpdateLicencePageV.xaml index 1dee16e..adb73fb 100644 --- a/UpdateLicencePage/UpdateLicencePageV.xaml +++ b/UpdateLicencePage/UpdateLicencePageV.xaml @@ -41,7 +41,7 @@ diff --git a/UpdateLicencePage/UpdateLicencePageVM.vb b/UpdateLicencePage/UpdateLicencePageVM.vb index 3bf53b4..6bad76d 100644 --- a/UpdateLicencePage/UpdateLicencePageVM.vb +++ b/UpdateLicencePage/UpdateLicencePageVM.vb @@ -190,24 +190,44 @@ Public Class UpdateLicencePageVM #Region "METHODS" Friend Sub InitUpdateLicencePage() - ' Svuoto campi - SelVersion = Nothing - NotifyPropertyChanged("SelVersion") - SelProductLevel = String.Empty - NotifyPropertyChanged("SelProductLevel") - ClientName = String.Empty - NotifyPropertyChanged("File") - ' Carico lista ProductVersion Dim Query As String = "SELECT * FROM " & DB_VERSION m_VersionList = ManageDb.ExecuteVersionQuery(Query) NotifyPropertyChanged("VersionList") + ' Carico elemento della lista ProductVersion selezionato precedentemente + Dim selQuery As String = "SELECT * FROM " & DB_LICENCE & + " INNER JOIN " & DB_VERSION & " ON " & DB_LICENCE & "." & DB_PRODUCTID & " = " & + DB_VERSION & "." & DB_PRODUCTID & " AND " & DB_LICENCE & "." & DB_PRODUCTVERSION & " = " & + DB_VERSION & "." & DB_VERSIONNUMBER & + " WHERE " & DB_LICENCEID & " LIKE " & Licence.LicenceID + SelVersion = m_VersionList.FirstOrDefault(Function(vers) vers.VersionNumber.Equals(ManageDb.ExecuteVersionQuery(selQuery)(0).VersionNumber)) + NotifyPropertyChanged("SelVersion") + + SelProductLevel = Licence.ProductLevel ' String.Empty + NotifyPropertyChanged("SelProductLevel") + ClientName = Licence.File ' String.Empty + NotifyPropertyChanged("File") + + '' Carico elemento della lista Version selezionato precedentemente + 'Dim selQuery As String = "SELECT " & DB_RESELLERID & " FROM " & DB_CLIENT & + '" INNER JOIN " & DB_RESELLER & " ON " & DB_CLIENT & "." & DB_CLIENTID & " = " & + 'DB_RESELLER & "." & DB_RESELLERID & + '" WHERE " & DB_CLIENTID & " LIKE " & IdToUpdate + ''m_SelReseller = ManageDb.ExecuteResellerQuery(rQuery)(0) + ''m_SelReseller = m_ResellerList(2) + 'm_SelVersion = m_VersionList.FirstOrDefault(Function(vers) vers.VersionNumber.Equals(ManageDb.ExecuteVersionQuery(selQuery)(0))) + 'NotifyPropertyChanged("SelReseller") ' Carico lista ProductLevel - Query = "SELECT " & DB_PRODUCTLEVEL & " FROM " & DB_LICENCE - m_ProductLevelList = ManageDb.ExecuteStringQuery(Query, DB_PRODUCTLEVEL) + Dim plQuery As String = "SELECT " & DB_PRODUCTLEVEL & " FROM " & DB_LICENCE + m_ProductLevelList = ManageDb.ExecuteStringQuery(plQuery, DB_PRODUCTLEVEL) NotifyPropertyChanged("ProductLevelList") + m_ProductDeadline = Licence.ProductDeadline + NotifyPropertyChanged("ProductDeadline") + m_OptionDeadline = Licence.OptionDeadline + NotifyPropertyChanged("OptionDeadline") + ' Inizializzo liste opzioni LoadOptions(1, m_Option1) LoadOptions(2, m_Option2)