private void bunifuTileButton_Execute_Click(object sender, EventArgs e) { if (mode == "view") { this.Close(); return; } ThreadManager.DisplayLoadingScreen(); StockItem newItem = new StockItem(); try { newItem.Name = bunifuCustomTextbox_Name.Text; newItem.Description = bunifuCustomTextbox_Note.Text; newItem.ProducerName = bunifuCustomTextbox_Producer.Text; if (mode == "add") { newItem.Quantity = 0; } } catch (Exception ex) { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(ex.Message, "", "Error: Can't get data from fields"); return; } string err = newItem.ValidateFields(); if (err != "") { ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "", "Data format error"); return; } err = manager.AddorUpdateStockIngredient(newItem); ThreadManager.CloseLoadingScreen(); ErrorManager.MessageDisplay(err, "Add/Update new item success", "Add/Update new item failed"); if (err == "") { this.Close(); } }