static private void NewSearch(char type) { string id; Console.Clear(); Console.WriteLine("------ New Search ------ \n"); switch (type) { case 'A': Console.Write("Type the artistID you want to search:"); id = Console.ReadLine(); Console.WriteLine(); Artist a = gal.SearchArtist(id); if (a != null) { Console.WriteLine(a.ToString()); } else { Console.WriteLine("ID not found!"); } break; case 'C': Console.Write("Type the curatorID you want to search:"); id = Console.ReadLine(); Console.WriteLine(); Curator c = gal.SearchCurator(id); if (c != null) { Console.WriteLine(c.ToString()); } else { Console.WriteLine("ID not found!"); } break; case 'P': Console.Write("Type the pieceID you want to search:"); id = Console.ReadLine(); Console.WriteLine(); ArtPiece p = gal.SearchArtPiece(id); if (p != null) { Console.WriteLine(p.ToString()); } else { Console.WriteLine("ID not found!"); } break; } Console.WriteLine(); Console.WriteLine("Press any key to continue."); Console.ReadLine(); }
private void DeletePiece_Click(object sender, RoutedEventArgs e) { piecesText.Text = ""; if (pieceID.Text == "") { MessageBox.Show("Art Piece ID is required!"); return; } ArtPiece p = gal.DeleteArtPiece(pieceID.Text); if (p != null) { piecesText.Text = "Art Piece deleted!\n"; piecesText.Text += p.ToString(); } else { MessageBox.Show("Art Piece ID not registred!"); return; } }
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 = ""; }