private void bunifuTileButton_Execute_Click(object sender, EventArgs e) { if (mode == "view") { this.Close(); return; } ThreadManager.DisplayLoadingScreen(); BookDetails newWishlist = new BookDetails(); try { newWishlist.Name = bunifuCustomTextbox_Title.Text; newWishlist.Price = double.Parse(bunifuCustomTextbox_Price.Text); newWishlist.PublishDate = Convert.ToDateTime(bunifuCustomTextbox_PulishDate.Text).Date; newWishlist.AuthorName = bunifuCustomTextbox_Author.Text; newWishlist.PublisherName = bunifuCustomTextbox_Pulisher.Text; } catch (Exception ex) { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(ex.Message, "", "Error: Can't get data from fields"); return; } string err = ""; if (mode != "delete") { err = newWishlist.ValidateFields(); } if (err != "") { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "", "Incorrect format"); return; } if (mode == "add" || mode == "update") { err = manager.AddOrUpdateBookToWishlist(newWishlist); ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "Add/Update a book to wishlist successfully", "Failed to add/update a book to wishlist"); } else if (mode == "delete") { err = manager.DeleteBookFromWishlist(bunifuCustomTextbox_Title.Text); ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "Delete a book successfully", "Failed to delete a book"); } if (err == "") { this.Close(); } }