Exemplo n.º 1
0
 private void AddButtonClick(object sender, EventArgs e)
 {
     using (var dataForm = new FormContainerData())
     {
         dataForm.ShowDialog();
         if (dataForm.ContainerData != null)
             AddContainer(dataForm.ContainerData);
     }
 }
Exemplo n.º 2
0
        private void EditButtonClick(object sender, EventArgs e)
        {
            if (DetailList.SelectedItem == null)
                return;

            string name = DetailList.SelectedItem.ToString().Split(':')[0];
            ContainerData data = ItemManager.ContainerData[name];
            ContainerData newData;

            using (var dataForm = new FormContainerData())
            {
                dataForm.ContainerData = data;
                dataForm.ShowDialog();

                if (dataForm.ContainerData == null)
                    return;

                if (dataForm.ContainerData.Name == name)
                {
                    ItemManager.ContainerData[name] = dataForm.ContainerData;
                    LoadContainers();
                    return;
                }

                newData = dataForm.ContainerData;
            }

            DialogResult result = MessageBox.Show("Name has changed. Do you want to add a new entry?", "New Entry",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result != DialogResult.Yes)
                return;

            if (ItemManager.ContainerData.ContainsKey(newData.Name))
            {
                MessageBox.Show("Entry already exists. Use Edit to modify the entry.", "Container Exists",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DetailList.Items.Add(newData);
            ItemManager.ContainerData.Add(newData.Name, newData);
        }