Initial population
This commit is contained in:
588
frmEditBook.vb
Normal file
588
frmEditBook.vb
Normal file
@@ -0,0 +1,588 @@
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Public Class frmEditBook
|
||||
Inherits OrganLit.BaseEditForm
|
||||
|
||||
Private mobjDetailBook As New clsBook
|
||||
Private m_objComposersHash As Hashtable
|
||||
Private m_objInstrumentationsHash As Hashtable
|
||||
Private m_objPublishersHash As Hashtable
|
||||
|
||||
#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.
|
||||
Friend WithEvents lblBookTitle As Windows.Forms.Label
|
||||
Friend WithEvents txtBookTitle As Windows.Forms.TextBox
|
||||
Friend WithEvents lblComposer As Windows.Forms.Label
|
||||
Friend WithEvents cboComposer As ComboTypeAhead.ComboTypeAhead
|
||||
Friend WithEvents lblPublisher As Windows.Forms.Label
|
||||
Friend WithEvents cboPublisher As ComboTypeAhead.ComboTypeAhead
|
||||
Friend WithEvents cboInstrumentation As ComboTypeAhead.ComboTypeAhead
|
||||
Friend WithEvents lblInstrumentation As Windows.Forms.Label
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.lblBookTitle = New Windows.Forms.Label
|
||||
Me.txtBookTitle = New Windows.Forms.TextBox
|
||||
Me.lblComposer = New Windows.Forms.Label
|
||||
Me.cboComposer = New ComboTypeAhead.ComboTypeAhead
|
||||
Me.lblPublisher = New Windows.Forms.Label
|
||||
Me.cboPublisher = New ComboTypeAhead.ComboTypeAhead
|
||||
Me.cboInstrumentation = New ComboTypeAhead.ComboTypeAhead
|
||||
Me.lblInstrumentation = New Windows.Forms.Label
|
||||
Me.fraAddEdit.SuspendLayout()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'fraAddEdit
|
||||
'
|
||||
Me.fraAddEdit.Controls.Add(Me.cboInstrumentation)
|
||||
Me.fraAddEdit.Controls.Add(Me.lblInstrumentation)
|
||||
Me.fraAddEdit.Controls.Add(Me.cboPublisher)
|
||||
Me.fraAddEdit.Controls.Add(Me.lblPublisher)
|
||||
Me.fraAddEdit.Controls.Add(Me.cboComposer)
|
||||
Me.fraAddEdit.Controls.Add(Me.lblComposer)
|
||||
Me.fraAddEdit.Controls.Add(Me.txtBookTitle)
|
||||
Me.fraAddEdit.Controls.Add(Me.lblBookTitle)
|
||||
Me.fraAddEdit.Location = New System.Drawing.Point(10, 438)
|
||||
Me.fraAddEdit.Size = New System.Drawing.Size(1064, 142)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.lblBookTitle, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.txtBookTitle, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.lblComposer, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.cboComposer, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.lblPublisher, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.cboPublisher, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.lblInstrumentation, 0)
|
||||
Me.fraAddEdit.Controls.SetChildIndex(Me.cboInstrumentation, 0)
|
||||
'
|
||||
'lblBookTitle
|
||||
'
|
||||
Me.lblBookTitle.Location = New System.Drawing.Point(16, 24)
|
||||
Me.lblBookTitle.Name = "lblBookTitle"
|
||||
Me.lblBookTitle.Size = New System.Drawing.Size(96, 16)
|
||||
Me.lblBookTitle.TabIndex = 3
|
||||
Me.lblBookTitle.Text = "Book Title"
|
||||
'
|
||||
'txtBookTitle
|
||||
'
|
||||
Me.txtBookTitle.Location = New System.Drawing.Point(109, 24)
|
||||
Me.txtBookTitle.Name = "txtBookTitle"
|
||||
Me.txtBookTitle.Size = New System.Drawing.Size(424, 20)
|
||||
Me.txtBookTitle.TabIndex = 4
|
||||
'
|
||||
'lblComposer
|
||||
'
|
||||
Me.lblComposer.Location = New System.Drawing.Point(16, 48)
|
||||
Me.lblComposer.Name = "lblComposer"
|
||||
Me.lblComposer.Size = New System.Drawing.Size(80, 16)
|
||||
Me.lblComposer.TabIndex = 5
|
||||
Me.lblComposer.Text = "Composer"
|
||||
'
|
||||
'cboComposer
|
||||
'
|
||||
Me.cboComposer.Location = New System.Drawing.Point(109, 48)
|
||||
Me.cboComposer.Name = "cboComposer"
|
||||
Me.cboComposer.Size = New System.Drawing.Size(288, 21)
|
||||
Me.cboComposer.Sorted = True
|
||||
Me.cboComposer.TabIndex = 6
|
||||
'
|
||||
'lblPublisher
|
||||
'
|
||||
Me.lblPublisher.Location = New System.Drawing.Point(16, 107)
|
||||
Me.lblPublisher.Name = "lblPublisher"
|
||||
Me.lblPublisher.Size = New System.Drawing.Size(80, 16)
|
||||
Me.lblPublisher.TabIndex = 9
|
||||
Me.lblPublisher.Text = "Publisher"
|
||||
'
|
||||
'cboPublisher
|
||||
'
|
||||
Me.cboPublisher.Location = New System.Drawing.Point(109, 107)
|
||||
Me.cboPublisher.Name = "cboPublisher"
|
||||
Me.cboPublisher.Size = New System.Drawing.Size(288, 21)
|
||||
Me.cboPublisher.Sorted = True
|
||||
Me.cboPublisher.TabIndex = 10
|
||||
'
|
||||
'cboInstrumentation
|
||||
'
|
||||
Me.cboInstrumentation.Location = New System.Drawing.Point(109, 80)
|
||||
Me.cboInstrumentation.Name = "cboInstrumentation"
|
||||
Me.cboInstrumentation.Size = New System.Drawing.Size(288, 21)
|
||||
Me.cboInstrumentation.Sorted = True
|
||||
Me.cboInstrumentation.TabIndex = 8
|
||||
'
|
||||
'lblInstrumentation
|
||||
'
|
||||
Me.lblInstrumentation.Location = New System.Drawing.Point(16, 80)
|
||||
Me.lblInstrumentation.Name = "lblInstrumentation"
|
||||
Me.lblInstrumentation.Size = New System.Drawing.Size(96, 16)
|
||||
Me.lblInstrumentation.TabIndex = 7
|
||||
Me.lblInstrumentation.Text = "Instrumentation"
|
||||
'
|
||||
'frmEditBook
|
||||
'
|
||||
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
||||
Me.ClientSize = New System.Drawing.Size(1080, 586)
|
||||
Me.Name = "frmEditBook"
|
||||
Me.StartPosition = Windows.Forms.FormStartPosition.Manual
|
||||
Me.Text = "Edit Book"
|
||||
Me.fraAddEdit.ResumeLayout(False)
|
||||
Me.fraAddEdit.PerformLayout()
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Overrides Sub LoadExistingItemsList()
|
||||
Dim lobjBook As clsBook
|
||||
Dim lobjBooks As System.Collections.Generic.List(Of clsBook)
|
||||
|
||||
SetUpExistingItemsHeaders()
|
||||
|
||||
lobjBooks = clsBook.GetAllBooks
|
||||
|
||||
Me.ExistingItemsListSuspendLayout()
|
||||
|
||||
For Each lobjBook In lobjBooks
|
||||
Me.ExistingObjectsListItems.Add(ConvertBookToListViewItem(lobjBook))
|
||||
Next
|
||||
|
||||
Me.ExistingItemsListResumeLayout()
|
||||
End Sub
|
||||
|
||||
Private Sub SetUpExistingItemsHeaders()
|
||||
Me.ExistingObjectsListColumns.Add("Composer", 300, HorizontalAlignment.Left)
|
||||
Me.ExistingObjectsListColumns.Add("Book Title", 400, HorizontalAlignment.Left)
|
||||
Me.ExistingObjectsListColumns.Add("Publisher", 200, HorizontalAlignment.Left)
|
||||
|
||||
'Set up sorting rules
|
||||
Dim lobjBaseEditFormColumnSortRules(2) As clsGridColumnSortRule
|
||||
lobjBaseEditFormColumnSortRules(0) = New clsGridColumnSortRule(clsGridColumnSortRule.enumSortType.SortAsString)
|
||||
lobjBaseEditFormColumnSortRules(0).SubColumnSort = New clsGridSubColumnSortRule(1, clsGridSubColumnSortRule.enumSortType.SortAsString, Nothing)
|
||||
lobjBaseEditFormColumnSortRules(1) = New clsGridColumnSortRule(clsGridColumnSortRule.enumSortType.SortAsString)
|
||||
lobjBaseEditFormColumnSortRules(1).SubColumnSort = New clsGridSubColumnSortRule(0, clsGridSubColumnSortRule.enumSortType.SortAsString, Nothing)
|
||||
lobjBaseEditFormColumnSortRules(2) = New clsGridColumnSortRule(clsGridColumnSortRule.enumSortType.SortAsString)
|
||||
lobjBaseEditFormColumnSortRules(2).SubColumnSort = New clsGridSubColumnSortRule(0, clsGridSubColumnSortRule.enumSortType.SortAsString, New clsGridSubColumnSortRule(0, clsGridSubColumnSortRule.enumSortType.SortAsString, Nothing))
|
||||
|
||||
MyBaseEditFormColumnSortRules = lobjBaseEditFormColumnSortRules
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub InitializeDetailControls()
|
||||
'Load data to detail controls here at form load time
|
||||
txtBookTitle.MaxLength = MyGlobals.BOOK_TITLE_SIZE
|
||||
cboComposer.MaxLength = MyGlobals.COMPOSER_NAME_SIZE
|
||||
cboInstrumentation.MaxLength = MyGlobals.INSTRUMENTATION_NAME_SIZE
|
||||
cboPublisher.MaxLength = MyGlobals.PUBLISHER_NAME_SIZE
|
||||
|
||||
txtBookTitle.Text = ""
|
||||
|
||||
Dim objComposer As clsComposer
|
||||
Dim objComposers As System.Collections.Generic.List(Of clsComposer)
|
||||
|
||||
If cboComposer.Items.Count = 0 Then
|
||||
Me.cboComposer.Items.Clear()
|
||||
m_objComposersHash = New Hashtable
|
||||
|
||||
objComposers = clsComposer.GetAllComposers
|
||||
For Each objComposer In objComposers
|
||||
AddComposerToForm(objComposer)
|
||||
Next
|
||||
|
||||
Me.cboComposer.Items.Add(MyGlobals.COLLECTION_STRING)
|
||||
End If
|
||||
|
||||
Dim objInstrumentation As clsInstrumentation
|
||||
Dim objInstrumentations As System.Collections.Generic.List(Of clsInstrumentation)
|
||||
|
||||
If cboInstrumentation.Items.Count = 0 Then
|
||||
Me.cboInstrumentation.Items.Clear()
|
||||
m_objInstrumentationsHash = New Hashtable
|
||||
|
||||
objInstrumentations = clsInstrumentation.GetAllInstrumentations
|
||||
For Each objInstrumentation In objInstrumentations
|
||||
AddInstrumentationToForm(objInstrumentation)
|
||||
Next
|
||||
End If
|
||||
|
||||
If cboPublisher.Items.Count = 0 Then
|
||||
Dim objPublisher As clsPublisher
|
||||
Dim objPublishers As System.Collections.Generic.List(Of clsPublisher)
|
||||
|
||||
Me.cboPublisher.Items.Clear()
|
||||
m_objPublishersHash = New Hashtable
|
||||
|
||||
objPublishers = clsPublisher.GetAllPublishers
|
||||
For Each objPublisher In objPublishers
|
||||
AddPublisherToForm(objPublisher)
|
||||
Next
|
||||
|
||||
Me.cboPublisher.Items.Add(MyGlobals.NONE_STRING)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub SetFocusToFirstDetailControlForEdit()
|
||||
txtBookTitle.Focus()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Function DetailControlsHaveDifferentDataThanExistingData(ByVal lstvwExistingItem As Windows.Forms.ListViewItem) As Boolean
|
||||
Dim lobjSavedBook As clsBook
|
||||
Dim lblnReturnValue As Boolean = False
|
||||
|
||||
lobjSavedBook = CType(lstvwExistingItem.Tag, clsBook)
|
||||
|
||||
Dim objComposer As clsComposer
|
||||
Select Case cboComposer.Text.ToUpper.Trim
|
||||
Case MyGlobals.COLLECTION_STRING.ToUpper, ""
|
||||
objComposer = Nothing
|
||||
Case Else
|
||||
objComposer = CType(MyGlobals.GetItemFromHashWithStringKey(cboComposer.Text.ToUpper.Trim, m_objComposersHash), clsComposer)
|
||||
If objComposer Is Nothing Then
|
||||
objComposer = New clsComposer(cboComposer.Text.Trim)
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objInstrumentation As clsInstrumentation
|
||||
Select Case cboInstrumentation.Text.ToUpper.Trim
|
||||
Case ""
|
||||
objInstrumentation = Nothing
|
||||
Case Else
|
||||
objInstrumentation = CType(MyGlobals.GetItemFromHashWithStringKey(cboInstrumentation.Text.ToUpper.Trim, m_objInstrumentationsHash), clsInstrumentation)
|
||||
If objInstrumentation Is Nothing Then
|
||||
objInstrumentation = New clsInstrumentation(cboInstrumentation.Text.Trim)
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objPublisher As clsPublisher
|
||||
Select Case cboPublisher.Text.ToUpper.Trim
|
||||
Case MyGlobals.NONE_STRING.ToUpper, ""
|
||||
objPublisher = Nothing
|
||||
Case Else
|
||||
objPublisher = CType(MyGlobals.GetItemFromHashWithStringKey(cboPublisher.Text.ToUpper.Trim, m_objPublishersHash), clsPublisher)
|
||||
If objPublisher Is Nothing Then
|
||||
objPublisher = New clsPublisher(cboPublisher.Text.Trim, MyGlobals.PUBLISHER_STREAMING_ALLOWED_UNKNOWN)
|
||||
End If
|
||||
End Select
|
||||
|
||||
mobjDetailBook.BookTitle = txtBookTitle.Text
|
||||
mobjDetailBook.Composer = objComposer
|
||||
mobjDetailBook.Instrumentation = objInstrumentation
|
||||
mobjDetailBook.Publisher = objPublisher
|
||||
|
||||
If lobjSavedBook.StateIsIdentical(mobjDetailBook) Then
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Protected Overrides Function DetailControlsHaveSignificantData() As Boolean
|
||||
If txtBookTitle.Text.Trim.Length > 0 Then
|
||||
Return True
|
||||
End If
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Protected Overrides Sub EmptyOutDetailControls()
|
||||
InitializeDetailControls()
|
||||
txtBookTitle.Text = ""
|
||||
mobjDetailBook = New clsBook
|
||||
End Sub
|
||||
|
||||
Protected Overrides Function LoadExistingDataToDetailControls(ByVal lstvwExistingItem As Windows.Forms.ListViewItem) As Boolean
|
||||
Dim lobjBook As clsBook
|
||||
Dim lblnReturnValue As Boolean = False
|
||||
lobjBook = CType(lstvwExistingItem.Tag, clsBook)
|
||||
txtBookTitle.Text = lobjBook.BookTitle
|
||||
|
||||
If lobjBook.Composer Is Nothing Then
|
||||
cboComposer.Text = MyGlobals.COLLECTION_STRING
|
||||
Else
|
||||
cboComposer.Text = lobjBook.Composer.ComposerName
|
||||
End If
|
||||
|
||||
If lobjBook.Instrumentation Is Nothing Then
|
||||
cboInstrumentation.Text = ""
|
||||
Else
|
||||
cboInstrumentation.Text = lobjBook.Instrumentation.InstrumentationName
|
||||
End If
|
||||
|
||||
If lobjBook.Publisher Is Nothing Then
|
||||
cboPublisher.Text = MyGlobals.NONE_STRING
|
||||
Else
|
||||
cboPublisher.Text = lobjBook.Publisher.PublisherName
|
||||
End If
|
||||
|
||||
mobjDetailBook = CType(lobjBook.Clone(), clsBook)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Protected Overrides Function ConfirmOKToDeleteExistingItem(ByVal lstvwItemToDelete As Windows.Forms.ListViewItem) As Boolean
|
||||
Dim lobjBook As clsBook
|
||||
Dim lstrReferencedBy As String = ""
|
||||
|
||||
lobjBook = CType(lstvwItemToDelete.Tag, clsBook)
|
||||
|
||||
If Not lobjBook.OKToDelete(lstrReferencedBy) Then
|
||||
MessageBox.Show("Can't delete book: " + lobjBook.ToString + ". Currently used by " + lstrReferencedBy + ".", "Unable to delete", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim ldrDialogResult As DialogResult = MessageBox.Show("Are you sure you want to delete book: " + lobjBook.ToString + "?", "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
|
||||
If ldrDialogResult = Windows.Forms.DialogResult.No Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Protected Overrides Function DeleteExistingItem(ByVal lstvwItemToDelete As Windows.Forms.ListViewItem) As Boolean
|
||||
Dim lobjBook As clsBook
|
||||
lobjBook = CType(lstvwItemToDelete.Tag, clsBook)
|
||||
|
||||
Return lobjBook.Delete()
|
||||
End Function
|
||||
|
||||
Protected Overrides Function SaveNewItem() As Boolean
|
||||
Dim lstrErrorString As String = ""
|
||||
Dim lblnAddedComposer As Boolean
|
||||
Dim lblnAddedInstrumentation As Boolean
|
||||
Dim lblnAddedPublisher As Boolean
|
||||
|
||||
lblnAddedComposer = False
|
||||
lblnAddedInstrumentation = False
|
||||
lblnAddedPublisher = False
|
||||
|
||||
Dim objComposer As clsComposer
|
||||
Select Case cboComposer.Text.ToUpper.Trim
|
||||
Case MyGlobals.COLLECTION_STRING.ToUpper, ""
|
||||
objComposer = Nothing
|
||||
Case Else
|
||||
objComposer = CType(MyGlobals.GetItemFromHashWithStringKey(cboComposer.Text.ToUpper.Trim, m_objComposersHash), clsComposer)
|
||||
If objComposer Is Nothing Then
|
||||
objComposer = New clsComposer(cboComposer.Text.Trim)
|
||||
lblnAddedComposer = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objInstrumentation As clsInstrumentation
|
||||
Select Case cboInstrumentation.Text.ToUpper.Trim
|
||||
Case ""
|
||||
objInstrumentation = Nothing
|
||||
Case Else
|
||||
objInstrumentation = CType(MyGlobals.GetItemFromHashWithStringKey(cboInstrumentation.Text.ToUpper.Trim, m_objInstrumentationsHash), clsInstrumentation)
|
||||
If objInstrumentation Is Nothing Then
|
||||
objInstrumentation = New clsInstrumentation(cboInstrumentation.Text.Trim)
|
||||
lblnAddedInstrumentation = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objPublisher As clsPublisher
|
||||
Select Case cboPublisher.Text.ToUpper.Trim
|
||||
Case MyGlobals.NONE_STRING.ToUpper, ""
|
||||
objPublisher = Nothing
|
||||
Case Else
|
||||
objPublisher = CType(MyGlobals.GetItemFromHashWithStringKey(cboPublisher.Text.ToUpper.Trim, m_objPublishersHash), clsPublisher)
|
||||
If objPublisher Is Nothing Then
|
||||
objPublisher = New clsPublisher(cboPublisher.Text.Trim, MyGlobals.PUBLISHER_STREAMING_ALLOWED_UNKNOWN)
|
||||
lblnAddedPublisher = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
mobjDetailBook.BookTitle = txtBookTitle.Text
|
||||
mobjDetailBook.Composer = objComposer
|
||||
mobjDetailBook.Instrumentation = objInstrumentation
|
||||
mobjDetailBook.Publisher = objPublisher
|
||||
|
||||
If Not mobjDetailBook.Validate(lstrErrorString) Then
|
||||
MessageBox.Show(lstrErrorString, "Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not mobjDetailBook.Save() Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Me.ExistingObjectsListItems.Add(ConvertBookToListViewItem(mobjDetailBook))
|
||||
|
||||
If lblnAddedComposer Then
|
||||
AddComposerToForm(objComposer)
|
||||
End If
|
||||
|
||||
If lblnAddedInstrumentation Then
|
||||
AddInstrumentationToForm(objInstrumentation)
|
||||
End If
|
||||
|
||||
If lblnAddedPublisher Then
|
||||
AddPublisherToForm(objPublisher)
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Protected Overrides Sub UserRequestedToExit()
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub EditOrAddStarting()
|
||||
CType(Me.ParentForm, frmMain).DisableMenus()
|
||||
End Sub
|
||||
Protected Overrides Sub EditOrAddCompleted()
|
||||
CType(Me.ParentForm, frmMain).EnableMenus()
|
||||
End Sub
|
||||
|
||||
Private Function ConvertBookToListViewItem(ByVal lobjBook As clsBook) As ListViewItem
|
||||
Dim lobjItem As ListViewItem
|
||||
If lobjBook.Composer Is Nothing Then
|
||||
lobjItem = New ListViewItem(MyGlobals.COLLECTION_STRING)
|
||||
Else
|
||||
lobjItem = New ListViewItem(lobjBook.Composer.ComposerName)
|
||||
End If
|
||||
|
||||
lobjItem.SubItems.Add(lobjBook.BookTitle)
|
||||
|
||||
If lobjBook.Publisher Is Nothing Then
|
||||
lobjItem.SubItems.Add(MyGlobals.NONE_STRING)
|
||||
Else
|
||||
lobjItem.SubItems.Add(lobjBook.Publisher.PublisherName)
|
||||
End If
|
||||
|
||||
lobjItem.Tag = lobjBook
|
||||
|
||||
Return lobjItem
|
||||
|
||||
End Function
|
||||
|
||||
Protected Overrides Function SaveNewDataForExistingItem(ByVal lstvwExistingItem As Windows.Forms.ListViewItem) As Boolean
|
||||
Dim lstrErrorString As String = ""
|
||||
Dim lblnAddedComposer As Boolean
|
||||
Dim lblnAddedInstrumentation As Boolean
|
||||
Dim lblnAddedPublisher As Boolean
|
||||
|
||||
lblnAddedComposer = False
|
||||
lblnAddedInstrumentation = False
|
||||
lblnAddedPublisher = False
|
||||
|
||||
Dim objComposer As clsComposer
|
||||
Select Case cboComposer.Text.ToUpper.Trim
|
||||
Case MyGlobals.COLLECTION_STRING.ToUpper, ""
|
||||
objComposer = Nothing
|
||||
Case Else
|
||||
objComposer = CType(MyGlobals.GetItemFromHashWithStringKey(cboComposer.Text.ToUpper.Trim, m_objComposersHash), clsComposer)
|
||||
If objComposer Is Nothing Then
|
||||
objComposer = New clsComposer(cboComposer.Text.Trim)
|
||||
lblnAddedComposer = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objInstrumentation As clsInstrumentation
|
||||
Select Case cboInstrumentation.Text.ToUpper.Trim
|
||||
Case ""
|
||||
objInstrumentation = Nothing
|
||||
Case Else
|
||||
objInstrumentation = CType(MyGlobals.GetItemFromHashWithStringKey(cboInstrumentation.Text.ToUpper.Trim, m_objInstrumentationsHash), clsInstrumentation)
|
||||
If objInstrumentation Is Nothing Then
|
||||
objInstrumentation = New clsInstrumentation(cboInstrumentation.Text.Trim)
|
||||
lblnAddedInstrumentation = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
Dim objPublisher As clsPublisher
|
||||
Select Case cboPublisher.Text.ToUpper.Trim
|
||||
Case MyGlobals.NONE_STRING.ToUpper, ""
|
||||
objPublisher = Nothing
|
||||
Case Else
|
||||
objPublisher = CType(MyGlobals.GetItemFromHashWithStringKey(cboPublisher.Text.ToUpper.Trim, m_objPublishersHash), clsPublisher)
|
||||
If objPublisher Is Nothing Then
|
||||
objPublisher = New clsPublisher(cboPublisher.Text.Trim, MyGlobals.PUBLISHER_STREAMING_ALLOWED_UNKNOWN)
|
||||
lblnAddedPublisher = True
|
||||
End If
|
||||
End Select
|
||||
|
||||
mobjDetailBook.BookTitle = txtBookTitle.Text
|
||||
mobjDetailBook.Composer = objComposer
|
||||
mobjDetailBook.Instrumentation = objInstrumentation
|
||||
mobjDetailBook.Publisher = objPublisher
|
||||
|
||||
If Not mobjDetailBook.Validate(lstrErrorString) Then
|
||||
MessageBox.Show(lstrErrorString, "Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If Not mobjDetailBook.Save() Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Me.ExistingObjectsListItems.Remove(lstvwExistingItem)
|
||||
Me.ExistingObjectsListItems.Add(ConvertBookToListViewItem(mobjDetailBook))
|
||||
|
||||
If lblnAddedComposer Then
|
||||
AddComposerToForm(objComposer)
|
||||
End If
|
||||
|
||||
If lblnAddedInstrumentation Then
|
||||
AddInstrumentationToForm(objInstrumentation)
|
||||
End If
|
||||
|
||||
If lblnAddedPublisher Then
|
||||
AddPublisherToForm(objPublisher)
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub txtBookTitle_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBookTitle.TextChanged
|
||||
MyBase.DetailDataHasChanged()
|
||||
End Sub
|
||||
|
||||
Private Sub cboComposer_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboComposer.TextChanged
|
||||
MyBase.DetailDataHasChanged()
|
||||
End Sub
|
||||
|
||||
Private Sub cboInstrumentation_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboInstrumentation.TextChanged
|
||||
MyBase.DetailDataHasChanged()
|
||||
End Sub
|
||||
|
||||
Private Sub cboPublisher_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboPublisher.TextChanged
|
||||
MyBase.DetailDataHasChanged()
|
||||
End Sub
|
||||
|
||||
Protected Sub AddComposerToForm(ByVal objComposer As clsComposer)
|
||||
Me.cboComposer.Items.Add(objComposer.ComposerName)
|
||||
m_objComposersHash.Add(objComposer.ComposerName.ToUpper, objComposer)
|
||||
End Sub
|
||||
|
||||
Protected Sub AddInstrumentationToForm(ByVal objInstrumentation As clsInstrumentation)
|
||||
Me.cboInstrumentation.Items.Add(objInstrumentation.InstrumentationName)
|
||||
m_objInstrumentationsHash.Add(objInstrumentation.InstrumentationName.ToUpper, objInstrumentation)
|
||||
End Sub
|
||||
|
||||
Protected Sub AddPublisherToForm(ByVal objPublisher As clsPublisher)
|
||||
Me.cboPublisher.Items.Add(objPublisher.PublisherName)
|
||||
m_objPublishersHash.Add(objPublisher.PublisherName.ToUpper, objPublisher)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user