private void AddProductFromTextBox() { // Returns empty string if input is acceptable, and an error message if not. string validationResult = ValidateTextInput.ProductName(ProductNameInputTextBox.Text, Products); ProductModel newProduct = new ProductModel(ProductNameInputTextBox.Text); if (validationResult == "") { GlobalConfig.Connection.AddProduct(newProduct); EditTagsOfProduct editTagsOfProduct = new EditTagsOfProduct(newProduct); editTagsOfProduct.ShowDialog(); } else { MessageBox.Show(validationResult, "Invalid name"); return; } ProductNameInputTextBox.Text = ""; GetDataFromDatabase(); UpdateListBoxForSelectedTag(); }
private void AddTagFromTexBox() { string validationResult = ValidateTextInput.TagName(TagNameInputTextBox.Text, Tags); if (validationResult == "") { TagModel newTag = new TagModel(TagNameInputTextBox.Text); GlobalConfig.Connection.AddTag(newTag); EditProductsOfTag editProductsOfTag = new EditProductsOfTag(newTag); editProductsOfTag.ShowDialog(); } else { MessageBox.Show(validationResult, "Invalid name"); } TagNameInputTextBox.Text = ""; GetDataFromDatabase(); WireUpTags(); }