150 lines
6.0 KiB
VB.net
150 lines
6.0 KiB
VB.net
Imports System.Windows.Forms
|
|
|
|
Public Class BaseQueryForm
|
|
Private mintCurrentQueryBySortColumn As Integer
|
|
Private mintCurrentReportSortColumn As Integer
|
|
Private mobjQueryFormQueryByItemColumnSortRules() As clsGridColumnSortRule
|
|
Private mobjQueryFormReportItemColumnSortRules() As clsGridColumnSortRule
|
|
|
|
Private Sub BaseQueryForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
If Me.DesignMode Then
|
|
MessageBox.Show("The BaseQueryForm class must be inherited, and contains methods that must be overridden." + vbCrLf + "They have been declared in the base class and will throw NotImplementedException at runtime if not overridden.")
|
|
End If
|
|
lvwQueryByItemsList.Sorting = SortOrder.None
|
|
lvwReportItemsList.Sorting = SortOrder.None
|
|
LoadQueryByItemsList()
|
|
InitializeReportControls()
|
|
Dim lobjQueryByColumnClickEventArgs As New System.Windows.Forms.ColumnClickEventArgs(0)
|
|
lvwQueryByItemsList_ColumnClick(Me, lobjQueryByColumnClickEventArgs)
|
|
Dim lobjReportColumnClickEventArgs As New System.Windows.Forms.ColumnClickEventArgs(0)
|
|
lvwReportItemsList_ColumnClick(Me, lobjReportColumnClickEventArgs)
|
|
fraQueryBy.Height() = fraReport.Top - fraQueryBy.Top - 10
|
|
If fraOtherQueryParms.Controls.Count > 0 Then
|
|
fraOtherQueryParms.Visible = False
|
|
lvwQueryByItemsList.Height = fraQueryBy.Height - 10
|
|
Else
|
|
lvwQueryByItemsList.Height = fraOtherQueryParms.Top - 10
|
|
End If
|
|
lvwReportItemsList.Height = fraReport.Height - 10
|
|
End Sub
|
|
|
|
Protected Overridable Sub LoadQueryByItemsList()
|
|
If Not Me.DesignMode Then
|
|
Throw New NotImplementedException
|
|
End If
|
|
End Sub
|
|
|
|
Protected Overridable Sub InitializeReportControls()
|
|
If Not Me.DesignMode Then
|
|
Throw New NotImplementedException
|
|
End If
|
|
End Sub
|
|
|
|
Protected Overridable Function ReportOnQueryByItem(ByVal lstvwQueryByItem As ListViewItem) As Boolean
|
|
If Not Me.DesignMode Then
|
|
Throw New NotImplementedException
|
|
End If
|
|
End Function
|
|
|
|
Protected Overridable Function UserWantsDetailOnResult(ByVal lstvwResultItem As ListViewItem) As Boolean
|
|
If Not Me.DesignMode Then
|
|
Throw New NotImplementedException
|
|
End If
|
|
End Function
|
|
|
|
Protected Overridable Sub UserRequestedToExit()
|
|
If Not Me.DesignMode Then
|
|
Throw New NotImplementedException
|
|
End If
|
|
End Sub
|
|
|
|
Protected ReadOnly Property QueryByListItems() As ListView.ListViewItemCollection
|
|
Get
|
|
Return lvwQueryByItemsList.Items
|
|
End Get
|
|
End Property
|
|
|
|
Protected ReadOnly Property QueryByListColumns() As ListView.ColumnHeaderCollection
|
|
Get
|
|
Return lvwQueryByItemsList.Columns
|
|
End Get
|
|
End Property
|
|
|
|
Protected Property MyBaseQueryFormQueryByColumnSortRules() As clsGridColumnSortRule()
|
|
Get
|
|
Return mobjQueryFormQueryByItemColumnSortRules
|
|
End Get
|
|
Set(ByVal iValue As clsGridColumnSortRule())
|
|
mobjQueryFormQueryByItemColumnSortRules = iValue
|
|
End Set
|
|
End Property
|
|
|
|
Protected ReadOnly Property ReportListItems() As ListView.ListViewItemCollection
|
|
Get
|
|
Return lvwReportItemsList.Items
|
|
End Get
|
|
End Property
|
|
|
|
Protected ReadOnly Property ReportListColumns() As ListView.ColumnHeaderCollection
|
|
Get
|
|
Return lvwReportItemsList.Columns
|
|
End Get
|
|
End Property
|
|
|
|
Protected Property MyBaseQueryFormReportColumnSortRules() As clsGridColumnSortRule()
|
|
Get
|
|
Return mobjQueryFormReportItemColumnSortRules
|
|
End Get
|
|
Set(ByVal iValue As clsGridColumnSortRule())
|
|
mobjQueryFormReportItemColumnSortRules = iValue
|
|
End Set
|
|
End Property
|
|
|
|
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
|
|
UserRequestedToExit()
|
|
End Sub
|
|
|
|
Private Sub lvwQueryByItemsList_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs)
|
|
mintCurrentQueryBySortColumn = e.Column
|
|
lvwQueryByItemsList.ListViewItemSorter = New clsGridSorter(e.Column, mobjQueryFormQueryByItemColumnSortRules)
|
|
End Sub
|
|
|
|
Private Sub lvwQueryByItemsList_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
|
|
DoReportClick()
|
|
End Sub
|
|
|
|
Private Sub lvwReportItemsList_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles lvwReportItemsList.ColumnClick
|
|
mintCurrentReportSortColumn = e.Column
|
|
lvwReportItemsList.ListViewItemSorter = New clsGridSorter(e.Column, mobjQueryFormReportItemColumnSortRules)
|
|
End Sub
|
|
|
|
Private Sub lvwReportItemsList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwReportItemsList.DoubleClick
|
|
DoUserWantsDetailOnResult()
|
|
End Sub
|
|
|
|
Private Sub DoReportClick()
|
|
If lvwQueryByItemsList.SelectedItems.Count = 0 Then
|
|
MessageBox.Show("Must select an item to query by", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Sub
|
|
End If
|
|
|
|
ReportOnQueryByItem(lvwQueryByItemsList.SelectedItems(0))
|
|
'Check if there are results - if so show them
|
|
' - if not hide them
|
|
If lvwReportItemsList.Items.Count = 0 Then
|
|
lvwReportItemsList.Visible = False
|
|
Else
|
|
lvwReportItemsList.Visible = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DoUserWantsDetailOnResult()
|
|
If lvwReportItemsList.SelectedItems.Count = 0 Then
|
|
MessageBox.Show("Must select an item to show details results for", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Sub
|
|
End If
|
|
|
|
UserWantsDetailOnResult(lvwReportItemsList.SelectedItems(0))
|
|
End Sub
|
|
|
|
End Class |