Esempio n. 1
0
        static private void NewArtPiece()
        {
            Console.Clear();
            Console.WriteLine("------ Add new art piece ------ \n");

            Console.Write("Type the piece ID: ");
            string artPieceID = Console.ReadLine();

            while (artPieceID.Length != 5 || gal.SearchArtPiece(artPieceID) != null)
            {
                Console.WriteLine("Invalid ID!Please try again.");
                artPieceID = Console.ReadLine();
            }

            Console.Write("Type the piece title: ");
            string pieceTitle = Console.ReadLine();

            while (pieceTitle.Length > 40)
            {
                Console.WriteLine("Title must have a maximum of 40 caracters!Please try again.");
                pieceTitle = Console.ReadLine();
            }

            Console.Write("Type the piece year: ");
            string pieceYear = Console.ReadLine();

            while (!ryear.IsMatch(pieceYear))
            {
                Console.WriteLine("Year must be exactly 4 numbers!Please try again.");
                pieceYear = Console.ReadLine();
            }

            Console.Write("Type the piece estimated price: ");
            double pieceValue = double.Parse(Console.ReadLine());

            Console.Write("Type the artist ID: ");
            string artistID = Console.ReadLine();

            while (artistID.Length != 5 || gal.SearchArtist(artistID) == null)
            {
                Console.WriteLine("Invalid ID!Please try again.");
                artistID = Console.ReadLine();
            }

            Console.Write("Type the curator ID: ");
            string curatorID = Console.ReadLine();

            while (curatorID.Length != 5 || gal.SearchCurator(curatorID) == null)
            {
                Console.WriteLine("Invalid ID!Please try again.");
                curatorID = Console.ReadLine();
            }

            gal.AddArtPiece(artPieceID, pieceTitle, pieceYear, pieceValue, artistID, curatorID);

            Console.WriteLine();
            Console.WriteLine("Art Piece added!Press any key to continue.");
            Console.ReadLine();
        }
Esempio n. 2
0
        private void addArtPiece_Click(object sender, RoutedEventArgs e)
        {
            if (pieceID.Text == "" || pieceTitle.Text == "" || pieceYear.Text == "" || pieceEstimate.Text == "" || pieceArtistID.Text == "" || pieceCuratorID.Text == "")
            {
                MessageBox.Show("All fields are required!");
                return;
            }

            if (!fieldsValidation("id", pieceID))
            {
                MessageBox.Show("Invalid ID!\nID should have 5 characteres.");
                return;
            }
            if (!fieldsValidation("pieceTitle", pieceTitle))
            {
                MessageBox.Show("Invalid Name!\nName must have maximum 40 characteres.");
                return;
            }
            if (!fieldsValidation("pieceYear", pieceYear))
            {
                MessageBox.Show("Invalid Year!\nYear must have 4 digits.");
                return;
            }
            if (!fieldsValidation("pieceEstimate", pieceEstimate))
            {
                MessageBox.Show("Invalid Estimate Value!\nValue must be a number.");
                return;
            }

            piecesText.Text = "";
            ArtPiece p = gal.SearchArtPiece(pieceID.Text);

            if (p != null)
            {
                MessageBox.Show("Piece ID already exists!");
                return;
            }

            Artist a = gal.SearchArtist(pieceArtistID.Text);

            if (a == null)
            {
                MessageBox.Show("Artist ID doesn`t exists!");
                return;
            }
            Curator c = gal.SearchCurator(pieceCuratorID.Text);

            if (c == null)
            {
                MessageBox.Show("Curator ID doesn`t exists!");
                return;
            }

            p = gal.AddArtPiece(pieceID.Text, pieceTitle.Text, pieceYear.Text, double.Parse(pieceEstimate.Text), pieceArtistID.Text, pieceCuratorID.Text);
            if (pieceInStorage.IsChecked == true)
            {
                gal.SetStatus(pieceID.Text, 'O');
            }
            if (pieceOnDisplay.IsChecked == true)
            {
                gal.SetStatus(pieceID.Text, 'D');
            }

            piecesText.Text  = "Art Piece added!\n";
            piecesText.Text += p.ToString();

            //Clear fields
            pieceID.Text        = "";
            pieceTitle.Text     = "";
            pieceYear.Text      = "";
            pieceEstimate.Text  = "";
            pieceArtistID.Text  = "";
            pieceCuratorID.Text = "";
        }