302 lines
12 KiB
VB.net
302 lines
12 KiB
VB.net
Imports System.Windows.Forms
|
|
|
|
Public Class frmEditPublisher
|
|
Inherits BaseEditForm
|
|
|
|
Private mobjDetailPublisher As New clsPublisher
|
|
|
|
#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 lblPublisherName As Windows.Forms.Label
|
|
Friend WithEvents cboStreamingAllowed As ComboBox
|
|
Friend WithEvents lblPublisherStreamingAllowed As Label
|
|
Friend WithEvents txtPublisherName As Windows.Forms.TextBox
|
|
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
|
Me.lblPublisherName = New System.Windows.Forms.Label()
|
|
Me.txtPublisherName = New System.Windows.Forms.TextBox()
|
|
Me.lblPublisherStreamingAllowed = New System.Windows.Forms.Label()
|
|
Me.cboStreamingAllowed = New System.Windows.Forms.ComboBox()
|
|
Me.fraAddEdit.SuspendLayout()
|
|
Me.SuspendLayout()
|
|
'
|
|
'fraAddEdit
|
|
'
|
|
Me.fraAddEdit.Controls.Add(Me.cboStreamingAllowed)
|
|
Me.fraAddEdit.Controls.Add(Me.lblPublisherStreamingAllowed)
|
|
Me.fraAddEdit.Controls.Add(Me.txtPublisherName)
|
|
Me.fraAddEdit.Controls.Add(Me.lblPublisherName)
|
|
|
|
Me.fraAddEdit.Location = New System.Drawing.Point(8, 412)
|
|
Me.fraAddEdit.Size = New System.Drawing.Size(1072, 116)
|
|
Me.fraAddEdit.Controls.SetChildIndex(Me.lblPublisherName, 0)
|
|
Me.fraAddEdit.Controls.SetChildIndex(Me.txtPublisherName, 0)
|
|
Me.fraAddEdit.Controls.SetChildIndex(Me.lblPublisherStreamingAllowed, 0)
|
|
Me.fraAddEdit.Controls.SetChildIndex(Me.cboStreamingAllowed, 0)
|
|
'
|
|
'lblPublisherName
|
|
'
|
|
Me.lblPublisherName.Location = New System.Drawing.Point(16, 24)
|
|
Me.lblPublisherName.Name = "lblPublisherName"
|
|
Me.lblPublisherName.Size = New System.Drawing.Size(96, 16)
|
|
Me.lblPublisherName.TabIndex = 3
|
|
Me.lblPublisherName.Text = "Publisher Name"
|
|
'
|
|
'txtPublisherName
|
|
'
|
|
Me.txtPublisherName.Location = New System.Drawing.Point(135, 24)
|
|
Me.txtPublisherName.Name = "txtPublisherName"
|
|
Me.txtPublisherName.Size = New System.Drawing.Size(448, 20)
|
|
Me.txtPublisherName.TabIndex = 4
|
|
'
|
|
'lblPublisherStreamingAllowed
|
|
'
|
|
Me.lblPublisherStreamingAllowed.Location = New System.Drawing.Point(16, 46)
|
|
Me.lblPublisherStreamingAllowed.Name = "lblPublisherStreamingAllowed"
|
|
Me.lblPublisherStreamingAllowed.Size = New System.Drawing.Size(130, 16)
|
|
Me.lblPublisherStreamingAllowed.TabIndex = 5
|
|
Me.lblPublisherStreamingAllowed.Text = "Publisher Streaming Allowed"
|
|
'
|
|
'cboPublisherStreamingAllowed
|
|
'
|
|
Me.cboStreamingAllowed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
|
Me.cboStreamingAllowed.FormattingEnabled = True
|
|
Me.cboStreamingAllowed.Location = New System.Drawing.Point(135, 46)
|
|
Me.cboStreamingAllowed.Name = "cboStreamingAllowed"
|
|
Me.cboStreamingAllowed.Size = New System.Drawing.Size(120, 16)
|
|
Me.cboStreamingAllowed.TabIndex = 6
|
|
'
|
|
'frmEditComposer
|
|
'
|
|
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
|
|
Me.ClientSize = New System.Drawing.Size(1088, 534)
|
|
Me.Name = "frmEditComposer"
|
|
Me.StartPosition = Windows.Forms.FormStartPosition.Manual
|
|
Me.Text = "Edit Composer"
|
|
Me.fraAddEdit.ResumeLayout(False)
|
|
Me.fraAddEdit.PerformLayout()
|
|
Me.ResumeLayout(False)
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Overrides Sub LoadExistingItemsList()
|
|
Dim lobjPublisher As clsPublisher
|
|
Dim lobjPublishers As System.Collections.Generic.List(Of clsPublisher)
|
|
|
|
SetUpExistingItemsHeaders()
|
|
|
|
lobjPublishers = clsPublisher.GetAllPublishers
|
|
|
|
Me.ExistingItemsListSuspendLayout()
|
|
|
|
For Each lobjPublisher In lobjPublishers
|
|
Me.ExistingObjectsListItems.Add(ConvertPublisherToListViewItem(lobjPublisher))
|
|
Next
|
|
|
|
Me.ExistingItemsListResumeLayout()
|
|
|
|
End Sub
|
|
|
|
Private Sub SetUpExistingItemsHeaders()
|
|
Me.ExistingObjectsListColumns.Add("Publisher Name", 800, HorizontalAlignment.Left)
|
|
'Me.ExistingObjectsListColumns.Add("Column2", 0, HorizontalAlignment.Left)
|
|
'Me.ExistingObjectsListColumns.Add("Column3", 200, HorizontalAlignment.Left)
|
|
|
|
'Set up sorting rules
|
|
Dim lobjBaseEditFormColumnSortRules(0) As clsGridColumnSortRule
|
|
lobjBaseEditFormColumnSortRules(0) = New clsGridColumnSortRule(clsGridColumnSortRule.enumSortType.SortAsString)
|
|
MyBaseEditFormColumnSortRules = lobjBaseEditFormColumnSortRules
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub InitializeDetailControls()
|
|
'Load data to detail controls here at form load time
|
|
txtPublisherName.MaxLength = MyGlobals.PUBLISHER_NAME_SIZE
|
|
|
|
cboStreamingAllowed.Items.Clear()
|
|
cboStreamingAllowed.Items.Add(MyGlobals.PUBLISHER_STREAMING_ALLOWED_UNKNOWN)
|
|
cboStreamingAllowed.Items.Add("No")
|
|
cboStreamingAllowed.Items.Add("Yes")
|
|
cboStreamingAllowed.SelectedIndex = 0
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub SetFocusToFirstDetailControlForEdit()
|
|
txtPublisherName.Focus()
|
|
End Sub
|
|
|
|
Protected Overrides Function DetailControlsHaveDifferentDataThanExistingData(ByVal lstvwExistingItem As System.Windows.Forms.ListViewItem) As Boolean
|
|
Dim lobjSavedPublisher As clsPublisher
|
|
Dim lblnReturnValue As Boolean = False
|
|
|
|
lobjSavedPublisher = CType(lstvwExistingItem.Tag, clsPublisher)
|
|
|
|
mobjDetailPublisher.PublisherName = txtPublisherName.Text
|
|
mobjDetailPublisher.PublisherStreamingAllowed = cboStreamingAllowed.SelectedItem.ToString()
|
|
|
|
If lobjSavedPublisher.StateIsIdentical(mobjDetailPublisher) Then
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
End Function
|
|
|
|
Protected Overrides Function DetailControlsHaveSignificantData() As Boolean
|
|
If txtPublisherName.Text.Trim.Length > 0 Then
|
|
Return True
|
|
End If
|
|
|
|
Return False
|
|
End Function
|
|
|
|
Protected Overrides Sub EmptyOutDetailControls()
|
|
txtPublisherName.Text = String.Empty
|
|
cboStreamingAllowed.SelectedIndex = 0
|
|
mobjDetailPublisher = New clsPublisher
|
|
End Sub
|
|
|
|
Protected Overrides Function LoadExistingDataToDetailControls(ByVal lstvwExistingItem As System.Windows.Forms.ListViewItem) As Boolean
|
|
Dim lobjPublisher As clsPublisher
|
|
Dim lblnReturnValue As Boolean = False
|
|
lobjPublisher = CType(lstvwExistingItem.Tag, clsPublisher)
|
|
txtPublisherName.Text = lobjPublisher.PublisherName
|
|
|
|
Dim intSelectedIndex As Int32 = 0
|
|
Dim intIndex As Int32
|
|
For intIndex = 0 To cboStreamingAllowed.Items.Count
|
|
If String.Compare(cboStreamingAllowed.Items(intIndex).ToString, lobjPublisher.PublisherStreamingAllowed, True) = 0 Then
|
|
intSelectedIndex = intIndex
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
cboStreamingAllowed.SelectedIndex = intSelectedIndex
|
|
|
|
mobjDetailPublisher = CType(lobjPublisher.Clone(), clsPublisher)
|
|
Return True
|
|
End Function
|
|
|
|
Protected Overrides Function ConfirmOKToDeleteExistingItem(ByVal lstvwItemToDelete As System.Windows.Forms.ListViewItem) As Boolean
|
|
Dim lobjPublisher As clsPublisher
|
|
Dim lstrReferencedBy As String = ""
|
|
|
|
lobjPublisher = CType(lstvwItemToDelete.Tag, clsPublisher)
|
|
|
|
If Not lobjPublisher.OKToDelete(lstrReferencedBy) Then
|
|
MessageBox.Show("Can't delete publisher: " + lobjPublisher.PublisherName + ". 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 publisher: " + lobjPublisher.PublisherName + "?", "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 System.Windows.Forms.ListViewItem) As Boolean
|
|
Dim lobjPublisher As clsPublisher
|
|
lobjPublisher = CType(lstvwItemToDelete.Tag, clsPublisher)
|
|
|
|
Return lobjPublisher.Delete()
|
|
End Function
|
|
|
|
Protected Overrides Function SaveNewItem() As Boolean
|
|
Dim lstrErrorString As String = ""
|
|
|
|
mobjDetailPublisher.PublisherName = txtPublisherName.Text
|
|
mobjDetailPublisher.PublisherStreamingAllowed = cboStreamingAllowed.SelectedItem.ToString
|
|
|
|
If Not mobjDetailPublisher.Validate(lstrErrorString) Then
|
|
MessageBox.Show(lstrErrorString, "Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
Return False
|
|
End If
|
|
|
|
If Not mobjDetailPublisher.Save() Then
|
|
Return False
|
|
End If
|
|
|
|
Me.ExistingObjectsListItems.Add(ConvertPublisherToListViewItem(mobjDetailPublisher))
|
|
|
|
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 ConvertPublisherToListViewItem(ByVal lobjPublisher As clsPublisher) As ListViewItem
|
|
Dim lobjItem As ListViewItem
|
|
lobjItem = New ListViewItem(lobjPublisher.PublisherName)
|
|
'lobjItem.SubItems.Add("Item1Col2")
|
|
'lobjItem.SubItems.Add("Item1Col3")
|
|
lobjItem.Tag = lobjPublisher
|
|
|
|
Return lobjItem
|
|
|
|
End Function
|
|
|
|
Protected Overrides Function SaveNewDataForExistingItem(ByVal lstvwExistingItem As System.Windows.Forms.ListViewItem) As Boolean
|
|
Dim lstrErrorString As String = ""
|
|
|
|
mobjDetailPublisher.PublisherName = txtPublisherName.Text
|
|
mobjDetailPublisher.PublisherStreamingAllowed = cboStreamingAllowed.SelectedItem.ToString
|
|
|
|
If Not mobjDetailPublisher.Validate(lstrErrorString) Then
|
|
MessageBox.Show(lstrErrorString, "Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
|
Return False
|
|
End If
|
|
|
|
If Not mobjDetailPublisher.Save() Then
|
|
Return False
|
|
End If
|
|
|
|
Me.ExistingObjectsListItems.Remove(lstvwExistingItem)
|
|
Me.ExistingObjectsListItems.Add(ConvertPublisherToListViewItem(mobjDetailPublisher))
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub txtPublisherName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPublisherName.TextChanged
|
|
MyBase.DetailDataHasChanged()
|
|
End Sub
|
|
|
|
Private Sub cboStreamingAllowed_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboStreamingAllowed.SelectedIndexChanged
|
|
MyBase.DetailDataHasChanged()
|
|
End Sub
|
|
|
|
End Class |