Initial population

This commit is contained in:
Jon
2026-03-07 19:38:21 -06:00
commit 46735bddd3
59 changed files with 12911 additions and 0 deletions

492
BaseEditForm.vb Normal file
View File

@@ -0,0 +1,492 @@
Imports System.Windows.Forms
Public Class BaseEditForm
Inherits Windows.Forms.Form
Enum EditingOrAdding
Editing
Adding
Loading
NoAction
End Enum 'EditingOrAdding
Private mvalEditingOrAdding As EditingOrAdding
Private mintCurrentSortColumn As Integer
Private mobjEditFormExistingItemColumnSortRules() As clsGridColumnSortRule
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Protected WithEvents fraAddEdit As Windows.Forms.GroupBox
Private WithEvents btnEdit As Windows.Forms.Button
Private WithEvents btnDelete As Windows.Forms.Button
Private WithEvents btnSave As Windows.Forms.Button
Private WithEvents btnCancel As Windows.Forms.Button
Private WithEvents btnRevert As Windows.Forms.Button
Private WithEvents btnExit As Windows.Forms.Button
Private WithEvents lvwExistingItemsList As Windows.Forms.ListView
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(BaseEditForm))
Me.btnEdit = New Windows.Forms.Button
Me.btnDelete = New Windows.Forms.Button
Me.btnExit = New Windows.Forms.Button
Me.fraAddEdit = New Windows.Forms.GroupBox
Me.btnRevert = New Windows.Forms.Button
Me.btnCancel = New Windows.Forms.Button
Me.btnSave = New Windows.Forms.Button
Me.lvwExistingItemsList = New Windows.Forms.ListView
Me.fraAddEdit.SuspendLayout()
Me.SuspendLayout()
'
'btnEdit
'
Me.btnEdit.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnEdit.Location = New System.Drawing.Point(976, 8)
Me.btnEdit.Name = "btnEdit"
Me.btnEdit.Size = New System.Drawing.Size(96, 24)
Me.btnEdit.TabIndex = 1
Me.btnEdit.Text = "&Edit"
'
'btnDelete
'
Me.btnDelete.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnDelete.Location = New System.Drawing.Point(976, 40)
Me.btnDelete.Name = "btnDelete"
Me.btnDelete.Size = New System.Drawing.Size(96, 24)
Me.btnDelete.TabIndex = 2
Me.btnDelete.Text = "&Delete"
'
'btnExit
'
Me.btnExit.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnExit.Location = New System.Drawing.Point(976, 72)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(96, 24)
Me.btnExit.TabIndex = 3
Me.btnExit.Text = "E&xit"
'
'fraAddEdit
'
Me.fraAddEdit.Anchor = CType(((Windows.Forms.AnchorStyles.Bottom Or Windows.Forms.AnchorStyles.Left) _
Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.fraAddEdit.Controls.Add(Me.btnRevert)
Me.fraAddEdit.Controls.Add(Me.btnCancel)
Me.fraAddEdit.Controls.Add(Me.btnSave)
Me.fraAddEdit.Location = New System.Drawing.Point(10, 320)
Me.fraAddEdit.Name = "fraAddEdit"
Me.fraAddEdit.Size = New System.Drawing.Size(1064, 272)
Me.fraAddEdit.TabIndex = 4
Me.fraAddEdit.TabStop = False
Me.fraAddEdit.Text = "Add..."
'
'btnRevert
'
Me.btnRevert.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnRevert.Location = New System.Drawing.Point(952, 80)
Me.btnRevert.Name = "btnRevert"
Me.btnRevert.Size = New System.Drawing.Size(104, 24)
Me.btnRevert.TabIndex = 2
Me.btnRevert.Text = "&Revert"
'
'btnCancel
'
Me.btnCancel.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnCancel.Location = New System.Drawing.Point(952, 48)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(104, 24)
Me.btnCancel.TabIndex = 1
Me.btnCancel.Text = "&Cancel"
'
'btnSave
'
Me.btnSave.Anchor = CType((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.btnSave.Location = New System.Drawing.Point(952, 16)
Me.btnSave.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(104, 24)
Me.btnSave.TabIndex = 0
Me.btnSave.Text = "&Save"
'
'lvwExistingItemsList
'
Me.lvwExistingItemsList.Anchor = CType(((Windows.Forms.AnchorStyles.Top Or Windows.Forms.AnchorStyles.Left) _
Or Windows.Forms.AnchorStyles.Right), Windows.Forms.AnchorStyles)
Me.lvwExistingItemsList.FullRowSelect = True
Me.lvwExistingItemsList.GridLines = True
Me.lvwExistingItemsList.HideSelection = False
Me.lvwExistingItemsList.Location = New System.Drawing.Point(8, 8)
Me.lvwExistingItemsList.MultiSelect = False
Me.lvwExistingItemsList.Name = "lvwExistingItemsList"
Me.lvwExistingItemsList.Size = New System.Drawing.Size(960, 312)
Me.lvwExistingItemsList.TabIndex = 0
Me.lvwExistingItemsList.UseCompatibleStateImageBehavior = False
Me.lvwExistingItemsList.View = Windows.Forms.View.Details
'
'BaseEditForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(1080, 598)
Me.Controls.Add(Me.lvwExistingItemsList)
Me.Controls.Add(Me.fraAddEdit)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnDelete)
Me.Controls.Add(Me.btnEdit)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MinimumSize = New System.Drawing.Size(848, 568)
Me.Name = "BaseEditForm"
Me.Text = "BaseEditForm"
Me.fraAddEdit.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub BaseEditForm_FormClosed(ByVal sender As Object, ByVal e As Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
MyGlobals.FlushCachedObjects()
End Sub
Private Sub BaseEditForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Me.DesignMode Then
MessageBox.Show("The BaseEditForm 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
MyGlobals.FlushCachedObjects()
lvwExistingItemsList.Sorting = SortOrder.None
mintCurrentSortColumn = 0
mvalEditingOrAdding = EditingOrAdding.NoAction
LoadExistingItemsList()
InitializeDetailControls()
EnableDisableControls()
'Dim lobjColumnClickEventArgs As New Windows.Forms.ColumnClickEventArgs(0)
'lvwExistingItemsList_ColumnClick(Me, lobjColumnClickEventArgs)
lvwExistingItemsList.Height = fraAddEdit.Top - lvwExistingItemsList.Top - 10
End Sub
Protected Overridable Sub LoadExistingItemsList()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Sub InitializeDetailControls()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Sub EmptyOutDetailControls()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Function DetailControlsHaveSignificantData() As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return False
End Function
Protected Overridable Function DetailControlsHaveDifferentDataThanExistingData(ByVal lstvwExistingItem As ListViewItem) As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return False
End Function
Protected Overridable Function DeleteExistingItem(ByVal lstvwItemToDelete As ListViewItem) As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return True
End Function
Protected Overridable Function ConfirmOKToDeleteExistingItem(ByVal lstvwItemToDelete As ListViewItem) As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return True
End Function
Protected Overridable Function SaveNewItem() As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return True
End Function
Protected Overridable Function SaveNewDataForExistingItem(ByVal lstvwExistingItem As ListViewItem) As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return True
End Function
Protected Overridable Function LoadExistingDataToDetailControls(ByVal lstvwExistingItem As ListViewItem) As Boolean
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
Return True
End Function
Protected Overridable Sub SetFocusToFirstDetailControlForEdit()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Sub UserRequestedToExit()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Sub EditOrAddStarting()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected Overridable Sub EditOrAddCompleted()
If Not Me.DesignMode Then
Throw New NotImplementedException
End If
End Sub
Protected ReadOnly Property ExistingObjectsListItems() As ListView.ListViewItemCollection
Get
Return lvwExistingItemsList.Items
End Get
End Property
Protected ReadOnly Property ExistingObjectsListColumns() As ListView.ColumnHeaderCollection
Get
Return lvwExistingItemsList.Columns
End Get
End Property
Protected ReadOnly Property GetEditingOrAdding() As EditingOrAdding
Get
Return mvalEditingOrAdding
End Get
End Property
Protected Property MyBaseEditFormColumnSortRules() As clsGridColumnSortRule()
Get
Return mobjEditFormExistingItemColumnSortRules
End Get
Set(ByVal iValue As clsGridColumnSortRule())
mobjEditFormExistingItemColumnSortRules = iValue
End Set
End Property
Private Sub EnableDisableControls()
Select Case mvalEditingOrAdding
Case EditingOrAdding.Loading
Exit Sub
Case EditingOrAdding.Adding, EditingOrAdding.NoAction
If DetailControlsHaveSignificantData() Then
If btnCancel.Enabled = False Then
EditOrAddStarting()
End If
mvalEditingOrAdding = EditingOrAdding.Adding
lvwExistingItemsList.Enabled = False
btnEdit.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
fraAddEdit.Text = "Add..."
btnSave.Enabled = True
btnCancel.Enabled = True
btnRevert.Enabled = False
Else
If btnCancel.Enabled = True Then
EditOrAddCompleted()
End If
mvalEditingOrAdding = EditingOrAdding.NoAction
lvwExistingItemsList.Enabled = True
btnEdit.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
fraAddEdit.Text = "Add..."
btnSave.Enabled = False
btnCancel.Enabled = False
btnRevert.Enabled = False
End If
Case EditingOrAdding.Editing
If btnCancel.Enabled = False Then
EditOrAddStarting()
End If
lvwExistingItemsList.Enabled = False
btnEdit.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
fraAddEdit.Text = "Edit..."
btnCancel.Enabled = True
If DetailControlsHaveDifferentDataThanExistingData(lvwExistingItemsList.SelectedItems(0)) Then
btnSave.Enabled = True
btnRevert.Enabled = True
Else
btnSave.Enabled = False
btnRevert.Enabled = False
End If
End Select
If Not Me.DesignMode Then
If btnCancel.Enabled Then
Me.CancelButton = btnCancel
Else
Me.CancelButton = Nothing
End If
If btnSave.Enabled Then
Me.AcceptButton = btnSave
Else
Me.AcceptButton = Nothing
End If
End If
End Sub
Private Sub btnEdit_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click
DoEditClick()
End Sub
Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If lvwExistingItemsList.SelectedItems.Count = 0 Then
MessageBox.Show("Must select an item to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If ConfirmOKToDeleteExistingItem(lvwExistingItemsList.SelectedItems(0)) Then
If DeleteExistingItem(lvwExistingItemsList.SelectedItems(0)) Then
lvwExistingItemsList.Items.Remove(lvwExistingItemsList.SelectedItems(0))
End If
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
EmptyOutDetailControls()
mvalEditingOrAdding = EditingOrAdding.NoAction
EnableDisableControls()
SetFocusToFirstDetailControlForEdit()
End Sub
Private Sub btnRevert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRevert.Click
LoadExistingDataToDetailControls(lvwExistingItemsList.SelectedItems(0))
SetFocusToFirstDetailControlForEdit()
End Sub
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
If mvalEditingOrAdding = EditingOrAdding.Adding Then
If SaveNewItem() Then
mvalEditingOrAdding = EditingOrAdding.NoAction
EmptyOutDetailControls()
EnableDisableControls()
End If
Else
If SaveNewDataForExistingItem(lvwExistingItemsList.SelectedItems(0)) Then
mvalEditingOrAdding = EditingOrAdding.NoAction
EmptyOutDetailControls()
EnableDisableControls()
End If
End If
SetFocusToFirstDetailControlForEdit()
End Sub
Private Sub DoEditClick()
If lvwExistingItemsList.SelectedItems.Count = 0 Then
MessageBox.Show("Must select an item to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
mvalEditingOrAdding = EditingOrAdding.Loading
If LoadExistingDataToDetailControls(lvwExistingItemsList.SelectedItems(0)) Then
mvalEditingOrAdding = EditingOrAdding.Editing
EnableDisableControls()
Else
mvalEditingOrAdding = EditingOrAdding.NoAction
EmptyOutDetailControls()
Exit Sub
End If
End Sub
Protected Sub DetailDataHasChanged()
EnableDisableControls()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
UserRequestedToExit()
End Sub
Private Sub lvwExistingItemsList_ColumnClick(ByVal sender As System.Object, ByVal e As Windows.Forms.ColumnClickEventArgs) Handles lvwExistingItemsList.ColumnClick
mintCurrentSortColumn = e.Column
lvwExistingItemsList.ListViewItemSorter = New clsGridSorter(e.Column, mobjEditFormExistingItemColumnSortRules)
End Sub
Private Sub lvwExistingItemsList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwExistingItemsList.DoubleClick
DoEditClick()
End Sub
Private Sub BaseEditForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
lvwExistingItemsList.Height = fraAddEdit.Top - lvwExistingItemsList.Top - 10
End Sub
Private Sub fraAddEdit_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles fraAddEdit.Resize
lvwExistingItemsList.Height = fraAddEdit.Top - lvwExistingItemsList.Top - 10
End Sub
Private Sub BaseEditForm_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
If mobjEditFormExistingItemColumnSortRules Is Nothing Then
Exit Sub
End If
Dim intSavedSortColumn As Integer = mintCurrentSortColumn
'If there is more than one column, temporarily sort by some other column
'This is because, when first shown, for some reason, it was sorting only by the first
'column, with no subsorts. I'm not sure if this is because .NET thinks that we're already
'sorted by the first column.
If mobjEditFormExistingItemColumnSortRules.Length > 1 Then
Dim intTempSortColumn As Integer
If mintCurrentSortColumn = 0 Then
intTempSortColumn = 1
Else
intTempSortColumn = 0
End If
Dim lobjTempColumnClickEventArgs As New Windows.Forms.ColumnClickEventArgs(intTempSortColumn)
lvwExistingItemsList_ColumnClick(Me, lobjTempColumnClickEventArgs)
End If
'Sort by the current column
Dim lobjColumnClickEventArgs As New Windows.Forms.ColumnClickEventArgs(intSavedSortColumn)
lvwExistingItemsList_ColumnClick(Me, lobjColumnClickEventArgs)
End Sub
Public Sub ExistingItemsListSuspendLayout()
lvwExistingItemsList.SuspendLayout()
End Sub
Public Sub ExistingItemsListResumeLayout()
lvwExistingItemsList.ResumeLayout()
End Sub
End Class