Beispiel #1
0
        private void RenameArtist(CustomForm.AutoCompleteDataEntry entry, string newName)
        {
            int    id = int.Parse(entry.ValueMember.ToString());
            Artist a;

            if (!(id > 0 && (a = new Artist(id)).ID > 0))
            {
                return;
            }
            string type = string.IsNullOrEmpty(ArtistType) ? "artist" : ArtistType;

            if (newName == "")
            {   // ask for a new name
                Dialogs.Inputbox input = new Dialogs.Inputbox(
                    "Enter a new name for " + type + " "
                    + a.GetName(Artist.NameFormats.First_Last),
                    a.GetName(Artist.NameFormats.First_Last), false);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    newName = input.InputText;
                }
                else
                {
                    return;
                }
            }

            a.Name = newName;
            a.Update();

            UpdateCompletionSource();
            SetTextAndSelect(a.GetName(Artist.NameFormats.Last_First));
            SelectAll();
        }
Beispiel #2
0
        private bool AddArtist(string name)
        {
            string type = string.IsNullOrEmpty(ArtistType) ? "artist" : ArtistType;

            if (name == "")
            {   // ask for a new name
                Dialogs.Inputbox input = new Dialogs.Inputbox(
                    "Enter a new name for the new " + type,
                    "", false);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    name = input.InputText;
                }
                else
                {
                    return(false);
                }
            }
            else if (type == "artist")
            {
                Dialogs.Inputbox input = new Dialogs.Inputbox(
                    "Choose an artist type for " + name,
                    new ArtistTypeSearch().PerformSearchToScalar().ToArray(),
                    "", false);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    type = input.InputText;
                }
                else
                {
                    return(false);
                }
            }
            else if (MessageBox.Show("Do you want to add " + type + " "
                                     + name + " to the database?",
                                     "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return(false);
            }

            Artist c = new Artist(name, type);

            if (c.ID != 0)
            {
                MessageBox.Show("The new " + type + " you entered exists in the database as "
                                + c.GetName(Artist.NameFormats.Last_First_Type) + ".\n It is therefore not added to database");
            }
            else
            {
                c.Insert();
            }

            UpdateCompletionSource();
            SetTextAndSelect(c.GetName(Artist.NameFormats.Last_First));
            return(true);
        }
        private void RenamePiece(string newName)
        {
            if (currentPiece == null)
            {
                return;
            }
            if (SupressUpdate)
            {
                return;
            }

            if (newName == "")
            {   // ask for a new name
                Dialogs.Inputbox input = new Dialogs.Inputbox("Enter a new name for the piece",
                                                              currentPiece.Name, false);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    newName = input.InputText;
                }
                else
                {
                    return;
                }
            }

            if (currentPiece.Name == newName)
            {
                return;
            }

            try
            {
                change_status("Renaming piece...");
                this.Cursor = Cursors.WaitCursor;

                currentPiece.Name = newName;
                currentPiece.Update();

                SupressUpdate          = true;
                this.CurrentCell.Value = newName;
                SupressUpdate          = false;

                UpdateList(true);
                //UpdateDetail();
            }
            finally
            {
                this.Cursor = Cursors.Default;
                change_status("Rename successful");
            }
        }
Beispiel #4
0
        public static string GetGenre(string defaultGenre)
        {
            GenreSearch s = new GenreSearch(GenreSearch.Fields.Name);

            Inputbox ib = new Inputbox("Choose a genre: ", s.PerformSearchToScalar().ToArray(),
                                       defaultGenre, false);

            if (ib.ShowDialog() == DialogResult.Cancel)
            {
                return(null);
            }
            else
            {
                return(ib.SelectedItem.ToString());
            }
        }
Beispiel #5
0
        private bool AddNewComposer(string name)
        {
            try
            {
                SupressUpdate = true;
                if (name == "")
                {   // ask for a new name
                    Dialogs.Inputbox input = new Dialogs.Inputbox("Enter a new name for the new composer",
                                                                  currentPiece.Name, false);

                    if (input.ShowDialog() == DialogResult.OK)
                    {
                        name = input.InputText;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (MessageBox.Show("Do you want to add composer " + txbComposer.Text + " to the database?",
                                         "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return(false);
                }

                Artist c = new Artist(txbComposer.Text, "composer");
                if (c.ID != 0)
                {
                    MessageBox.Show("The new composer you entered exists in the database as "
                                    + c.GetName(Artist.NameFormats.Last_First_Type) + ".\n It is therefore not added to database");
                }
                else
                {
                    c.Insert();
                }

                SupressUpdate = false;
                UpdateArtistList();
                txbComposer.SetTextAndSelect(c.GetName(Artist.NameFormats.Last_First));
                change_status("Composer " + c.GetName(Artist.NameFormats.First_Last) + " has been added to database.", false);
                return(true);
            }
            finally
            {
                SupressUpdate = false;
            }
        }
Beispiel #6
0
        private void RenameComposer(int id, string newName)
        {
            Artist a;

            if (!(id > 0 && (a = new Artist(id)).ID > 0))
            {
                return;
            }

            if (newName == "")
            {   // ask for a new name
                Dialogs.Inputbox input = new Dialogs.Inputbox("Enter a new name for composer "
                                                              + a.GetName(Artist.NameFormats.First_Last),
                                                              a.GetName(Artist.NameFormats.First_Last), false);

                if (input.ShowDialog() == DialogResult.OK)
                {
                    newName = input.InputText;
                }
                else
                {
                    return;
                }
            }

            try
            {
                change_status("Renaming composer...");
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();

                a.Name = newName;
                a.Update();

                UpdateArtistList();
                txbComposer.SetTextAndSelect(a.GetName(Artist.NameFormats.Last_First));
                txbComposer.SelectAll();
                UpdatePieceList(false);
            }
            finally
            {
                this.Cursor = Cursors.Default;
                change_status("Rename successful");
            }
        }
Beispiel #7
0
        public static Artist GetComposer(Artist defaultComposer)
        {
            ArtistSearch s = new ArtistSearch(ArtistSearch.Fields.FullName);

            s.AddTypeToSearch(ArtistSearch.TypeCategory.Composers);

            Inputbox ib = new Inputbox("Choose a composer: ", s.PerformSearchToScalar().ToArray(),
                                       defaultComposer != null ? defaultComposer.GetName(Artist.NameFormats.Last_First) : "",
                                       false);

            if (ib.ShowDialog() == DialogResult.Cancel)
            {
                return(null);
            }
            else
            {
                Artist a = new Artist(ib.SelectedItem.ToString(), "composer");
                return(a);
            }
        }