//creates the container and add to database private void CreateContainer() { List <string> tagNamesList = new List <string>(); foreach (TagButton button in tagDisplay.GetTags()) { if (!tagNamesList.Contains(button.GetButtonText())) { tagNamesList.Add(button.GetButtonText()); } } if (isEditing) //if editing a previous container, change the value { previousContainer.name = nameInput.Text.Trim(); previousContainer.tags = tagNamesList; previousContainer.notes = notesEditor.Text; } else { StorageContainer newContainer = new StorageContainer(newContainerId, location, nameInput.Text.Trim(), tagNamesList, notesEditor.Text); Console.WriteLine("tags"); foreach (string tag in tagNamesList) { Console.WriteLine(tag); } location.AddContainer(newContainer); DatabaseHandler.GetDatabase().AddContainer(newContainer); } }
//creates the location and add to database private void CreateLocation() { List <string> tagNamesList = new List <string>(); foreach (TagButton button in tagDisplay.GetTags()) { tagNamesList.Add(button.GetButtonText()); } if (isEditing) //if editing a previous location, change the value { previousLocation.name = nameInput.Text.Trim(); previousLocation.address = streetAddressInput.Text.Trim(); previousLocation.city = cityInput.Text.Trim(); previousLocation.country = countryInput.Text.Trim(); previousLocation.tags = tagNamesList; previousLocation.notes = notesEditor.Text; } else { StorageLocation newLocation = new StorageLocation(newLocationId, nameInput.Text.Trim(), streetAddressInput.Text.Trim(), cityInput.Text.Trim(), countryInput.Text.Trim(), tagNamesList, notesEditor.Text); DatabaseHandler.GetDatabase().AddLocation(newLocation); } }
//creates the item and adds to database private void CreateItem() { List <string> tagNamesList = new List <string>(); foreach (TagButton button in tagDisplay.GetTags()) { if (!tagNamesList.Contains(button.GetButtonText())) { tagNamesList.Add(button.GetButtonText()); } } if (isEditing) //if editing a previous container, change the value { previousItem.name = nameInput.Text.Trim(); previousItem.tags = tagNamesList; previousItem.notes = notesEditor.Text; previousItem.barcode = codeInput.Text; previousItem.SetAmount(Int32.Parse(amountInput.Text)); } else { Item newItem = new Item(newItemId, container, nameInput.Text.Trim(), tagNamesList, notesEditor.Text, Int32.Parse(amountInput.Text), codeInput.Text); Console.WriteLine("tags"); foreach (string tag in tagNamesList) { Console.WriteLine(tag); } container.AddItem(newItem); DatabaseHandler.GetDatabase().AddItem(newItem); } }