Files
OmagPHOTO/SearchPanel/SearchPanelVM.vb
T
Emmanuele Sassi 68ee9ec34f OmagPHOTO 1.8k1 :
- Primo rilascio.
2017-11-18 10:22:46 +00:00

228 lines
6.2 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Public Class SearchPanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private m_Id As String
Public Property Id As String
Get
Return m_Id
End Get
Set(value As String)
m_Id = value
End Set
End Property
Private m_ImagePath As String
Public Property ImagePath As String
Get
Return m_ImagePath
End Get
Set(value As String)
m_ImagePath = value
End Set
End Property
Private m_StateList As List(Of IdNameStruct)
Public ReadOnly Property StateList As List(Of IdNameStruct)
Get
Return m_StateList
End Get
End Property
Friend Sub SetStateList(StateList As List(Of IdNameStruct))
m_StateList = StateList
End Sub
Private m_State As Slab.StateOpt
Public Property State As Integer
Get
Return m_State
End Get
Set(value As Integer)
m_State = value
End Set
End Property
Private m_ProjectAssignedTo As String
Public Property ProjectAssignedTo As String
Get
Return m_ProjectAssignedTo
End Get
Set(value As String)
m_ProjectAssignedTo = value
End Set
End Property
Private m_MaterialList As List(Of String)
Public ReadOnly Property MaterialList As List(Of String)
Get
Return m_MaterialList
End Get
End Property
Private m_Material As String
Public Property Material As String
Get
Return m_Material
End Get
Set(value As String)
m_Material = value
End Set
End Property
Private m_Thickness As String
Public Property Thickness As String
Get
Return m_Thickness
End Get
Set(value As String)
m_Thickness = value
End Set
End Property
Private m_WarehousePosition As String
Public Property WarehousePosition As String
Get
Return m_WarehousePosition
End Get
Set(value As String)
m_WarehousePosition = value
End Set
End Property
Private m_SearchPanel_Visibility As Visibility
Public ReadOnly Property SearchPanel_Visibility As Visibility
Get
Return m_SearchPanel_Visibility
End Get
End Property
Friend Sub SetSearchPanel_Visibility(IsVisible As Boolean)
If IsVisible Then
m_SearchPanel_Visibility = Visibility.Visible
Else
m_SearchPanel_Visibility = Visibility.Collapsed
End If
NotifyPropertyChanged("SearchPanel_Visibility")
End Sub
#Region "Messages"
Public ReadOnly Property IdMsg As String
Get
Return "Id"
End Get
End Property
Public ReadOnly Property ImagePathMsg As String
Get
Return "Image Path"
End Get
End Property
Public ReadOnly Property StateMsg As String
Get
Return "State"
End Get
End Property
Public ReadOnly Property ProjectAssignedToMsg As String
Get
Return "Project Assigned To"
End Get
End Property
Public ReadOnly Property MaterialMsg As String
Get
Return "Material"
End Get
End Property
Public ReadOnly Property ThicknessMsg As String
Get
Return "Thickness"
End Get
End Property
Public ReadOnly Property WarehousePositionMsg As String
Get
Return "Warehouse position"
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdSearch As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in Map
Map.SetRefSearchPanelVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Sub InitSearchPanel()
' Creo lista materiali
m_MaterialList = New List(Of String)(Map.refProjectVM.MaterialList)
m_MaterialList.Insert(0, String.Empty)
NotifyPropertyChanged("MaterialList")
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "Search"
''' <summary>
''' Returns a command that do New.
''' </summary>
Public ReadOnly Property Search_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
''' <summary>
''' Execute the New. This method is invoked by the NewCommand.
''' </summary>
Friend Sub Search(Optional bUseDefaults As Boolean = False)
Dim Query As String = "SELECT * FROM " & Slab.DB_SLABS & " "
If Not String.IsNullOrWhiteSpace(m_Id) OrElse
Not String.IsNullOrWhiteSpace(m_ImagePath) OrElse
Not m_State = 0 OrElse
Not String.IsNullOrWhiteSpace(m_ProjectAssignedTo) OrElse
Not String.IsNullOrWhiteSpace(m_Material) OrElse
Not String.IsNullOrWhiteSpace(m_Thickness) OrElse
Not String.IsNullOrWhiteSpace(m_WarehousePosition) Then
Query &= "WHERE " &
If(Not String.IsNullOrWhiteSpace(m_Id), Slab.DB_ID & " = '" & m_Id & "' ", "") &
If(Not String.IsNullOrWhiteSpace(m_ImagePath), Slab.DB_IMAGEPATH & " = '" & m_ImagePath & "' ", "") &
If(Not m_State = 0, Slab.DB_STATE & " = " & m_State & " ", "") &
If(Not String.IsNullOrWhiteSpace(m_ProjectAssignedTo), Slab.DB_PROJASSIGNEDTO & " = '" & m_ProjectAssignedTo & "' ", "") &
If(Not String.IsNullOrWhiteSpace(m_Material), Slab.DB_MATERIAL & " = '" & m_Material & "' ", "") &
If(Not String.IsNullOrWhiteSpace(m_Thickness), Slab.DB_THICKNESS & " = " & m_Thickness & " ", "") &
If(Not String.IsNullOrWhiteSpace(m_WarehousePosition), Slab.DB_WAREHOUSEPOS & " = '" & m_WarehousePosition & "' ", "")
Query = Query.TrimEnd(","c, " "c)
End If
Map.refProjectVM.SlabList = New ObservableCollection(Of Slab)(ManageDb.ExecuteSlabReaderQuery(Query))
End Sub
#End Region ' Search
#End Region ' Commands
End Class