Пример #1
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormArmorDetails frmArmorDetails = new FormArmorDetails())
            {
                frmArmorDetails.ShowDialog();

                if (frmArmorDetails.Armor != null)
                {
                    AddArmor(frmArmorDetails.Armor);
                }
            }
        }
Пример #2
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormArmorDetails frmArmorDetails = new FormArmorDetails())
            {
                frmArmorDetails.ShowDialog();

                if (frmArmorDetails.Armor != null)
                {
                    AddArmor(frmArmorDetails.Armor);
                }
            }
        }
Пример #3
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string   detail = lbDetails.SelectedItem.ToString();
                string[] parts  = detail.Split(',');
                string   entity = parts[0].Trim();

                ArmorData data    = itemManager.ArmorData[entity];
                ArmorData newData = null;

                using (FormArmorDetails frmArmorData = new FormArmorDetails())
                {
                    frmArmorData.Armor = data;
                    frmArmorData.ShowDialog();

                    if (frmArmorData.Armor == null)
                    {
                        return;
                    }

                    if (frmArmorData.Armor.Name == entity)
                    {
                        itemManager.ArmorData[entity] = frmArmorData.Armor;
                        FillListBox();

                        return;
                    }

                    newData = frmArmorData.Armor;
                }

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

                if (result == DialogResult.No)
                {
                    return;
                }

                if (itemManager.ArmorData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                itemManager.ArmorData.Add(newData.Name, newData);
            }
        }
Пример #4
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = lbDetails.SelectedItem.ToString();
                string[] parts = detail.Split(',');
                string entity = parts[0].Trim();

                ArmorData data = itemManager.ArmorData[entity];
                ArmorData newData = null;

                using (FormArmorDetails frmArmorData = new FormArmorDetails())
                {
                    frmArmorData.Armor = data;
                    frmArmorData.ShowDialog();

                    if (frmArmorData.Armor == null)
                        return;

                    if (frmArmorData.Armor.Name == entity)
                    {
                        itemManager.ArmorData[entity] = frmArmorData.Armor;
                        FillListBox();
                        return;
                    }

                    newData = frmArmorData.Armor;
                }

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

                if (result == DialogResult.No)
                    return;

                if (itemManager.ArmorData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                itemManager.ArmorData.Add(newData.Name, newData);
            }
        }