private void personGroupProperties_OKClicked(object sender, EventArgs e)
        {
            DialogResult = true;

            if (ChangeAllSoundFiles && oldPersonGroup != personGroup.Name)
            {
                PersonGroupHelper.UpdateSoundfiles(this.dataBase, oldPersonGroupId, oldPersonGroup, personGroup.Name, null);
            }

            Close();
        }
Пример #2
0
        private void Delete()
        {
            PersonGroupDataSet.PersonGroupRow selPersonGroup = GetSelectedRow();
            int selectedIndex = GetSelectedIndex();

            if (selPersonGroup == null)
            {
                return;
            }

            if (MessageBox.Show(String.Format(StringTable.DeleteArtist, selPersonGroup.Name), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            // Prüfen, ob es noch Tracks oder CDs mit diesem Interpreten gibt.
            bool artistFound = IsPersonGroupUsed(selPersonGroup.PersonGroupID);

            if (artistFound)
            {
                FormDeleteExistingArtist formExisting = new FormDeleteExistingArtist(dataBase, selPersonGroup);

                if (formExisting.ShowDialog() == DialogResult.OK)
                {
                    string personGroupName = (string)formExisting.comboBoxArtists.SelectedItem;

                    PersonGroupDataSet.PersonGroupRow newPersonGroup = dataBase.GetPersonGroupRowByName(personGroupName, false);

                    PersonGroupHelper.UpdateSoundfiles(this.dataBase, selPersonGroup.PersonGroupID, selPersonGroup.Name, personGroupName, delegate
                    {
                        dataBase.ExecuteNonQuery(string.Format("UPDATE CD SET ArtistID={0} WHERE ArtistID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID));
                        dataBase.ExecuteNonQuery(string.Format("UPDATE Track SET ArtistID={0} WHERE ArtistID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID));
                        dataBase.ExecuteNonQuery(string.Format("UPDATE CD SET ComposerID={0} WHERE ComposerID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID));
                        dataBase.ExecuteNonQuery(string.Format("UPDATE Track SET ComposerID={0} WHERE ComposerID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID));

                        dataBase.ExecuteNonQuery(string.Format("UPDATE Participant SET PersonGroupID={0} WHERE PersonGroupID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID));

                        dataBase.ExecuteNonQuery(string.Format("DELETE FROM PersonGroup WHERE PersonGroupID={0}", selPersonGroup.PersonGroupID));

                        personGroupListBox.Items.Remove(selPersonGroup);
                        personGroupTable.TableModel.Rows.RemoveAt(selectedIndex);
                    });
                }
            }
            else
            {
                dataBase.ExecuteNonQuery(string.Format("DELETE FROM PersonGroup WHERE PersonGroupID={0}", selPersonGroup.PersonGroupID));

                personGroupListBox.Items.Remove(selPersonGroup);
                personGroupTable.TableModel.Rows.RemoveAt(selectedIndex);
            }
        }