/Source Code/PowerSong/Categories/frmProblemSongs.vb
Visual Basic | 92 lines | 66 code | 20 blank | 6 comment | 0 complexity | 067aedc039c33db1be9e4529c350a7e1 MD5 | raw file
- Imports System.Windows.Forms
- Imports PowerSong.SongDatabase
-
- Public Class frmProblemSongs
-
- Private FDatabase As Database = Nothing
- Private FCategoryID As Guid = Nothing
- Private FAffectedSongs As List(Of Guid) = Nothing
-
- Public Enum ChoiceResult
- DoNothing
- Delete
- Reassign
- End Enum
-
- Public Sub New(ByVal database As Database, ByVal categoryID As Guid, ByVal affectedSongs As List(Of Guid))
-
- InitializeComponent()
- FDatabase = database
- FCategoryID = categoryID
- FAffectedSongs = affectedSongs
- lblWarningMessage.Text = String.Format(lblWarningMessage.Text, FDatabase.Categories.GetCategoryName(categoryID))
-
- ' Populate the list of alternative categories
- cboCategories.Items.Clear()
- For Each AlternativeCategory As KeyValuePair(Of Guid, String) In FDatabase.Categories.GetAllCategories
- If AlternativeCategory.Key <> categoryID Then
- cboCategories.Items.Add(New ListItem(Of Guid)(AlternativeCategory.Value, AlternativeCategory.Key))
- End If
- Next
-
- ' Set available options
- If cboCategories.Items.Count = 0 Then optReassign.Enabled = False
-
- End Sub
-
- Public ReadOnly Property SelectedChoice() As ChoiceResult
- Get
- If optNothing.Checked Then Return ChoiceResult.DoNothing
- If optDelete.Checked Then Return ChoiceResult.Delete
- If optReassign.Checked Then Return ChoiceResult.Reassign
- Throw New Exception("Unknown choice selected.")
- End Get
- End Property
-
- Public ReadOnly Property SelectedReassignmentCategory() As Guid
- Get
- Dim Item As ListItem(Of Guid) = cboCategories.SelectedItem
- Return Item.Key
- End Get
- End Property
-
- Private Sub btnViewSongs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewSongs.Click
-
- ' Show the affected songs
- Call New frmSongList(FDatabase, _
- "Songs that are affected by the removal of category '" + FDatabase.Categories.GetCategoryName(FCategoryID) + "':", _
- FAffectedSongs).ShowDialog()
-
- End Sub
-
- Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
-
- ' Check a category has been selected
- If optReassign.Checked AndAlso cboCategories.SelectedItem Is Nothing Then
- MsgBox("Please select a category to reassign to.", MsgBoxStyle.Exclamation)
- Exit Sub
- End If
-
- ' Confirm deletion of songs
- Dim Proceed As Boolean = True
- If optDelete.Checked Then
- If MsgBox("Are you absolutely sure that you wish to permanently delete all of the songs " + _
- "assigned solely to the category '" + _
- FDatabase.Categories.GetCategoryName(FCategoryID) + "'?", _
- MsgBoxStyle.Question + MsgBoxStyle.YesNo) <> MsgBoxResult.Yes Then
- Proceed = False
- End If
- End If
- If Not Proceed Then Exit Sub
-
- ' Close the form
- DialogResult = Windows.Forms.DialogResult.OK
- Close()
-
- End Sub
-
- Private Sub optReassign_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optReassign.CheckedChanged
- cboCategories.Enabled = optReassign.Checked
- End Sub
-
- End Class