private void Submit_Click(object sender, EventArgs e) { int id; if (jsonDictionary.database == null) { id = 0; } else { id = jsonDictionary.database.Count; } if ( nameText.Text == "" || descricaoTextBox.Text == "" || typeComboBox.SelectedIndex == -1 || stackNumericUpDown.Value < 1 || raridadeComboBox.SelectedIndex == -1 ) { MessageBox.Show("Há campos sem preencher"); } else { jsonDictionary.database.Add(new Item(nameText.Text, id, descricaoTextBox.Text, typeComboBox.Text, itemStackBox.Checked, int.Parse(stackNumericUpDown.Value.ToString()), raridadeComboBox.Text)); string type = typeComboBox.Text; switch (type) { case "Consumable": Consumables cons = new Consumables(id, jsonDictionary, false); ClearFields(); cons.ShowDialog(); break; case "Armor": frmArmor arm = new frmArmor(id, jsonDictionary, false); ClearFields(); arm.ShowDialog(); break; case "Weapon": FrmWeapon weap = new FrmWeapon(id, jsonDictionary, false); ClearFields(); weap.ShowDialog(); break; default: jsonHandler.GravarJson(jsonDictionary); break; } } }
private void Submit_Click(object sender, EventArgs e) { int id = int.Parse(comboBox1.Text); if ( nameText.Text == "" || descricaoTextBox.Text == "" || typeComboBox.SelectedIndex == -1 || stackNumericUpDown.Value < 1 || raridadeComboBox.SelectedIndex == -1 ) { MessageBox.Show("Há campos sem preencher"); } else { jsonDictionary.database[id].itemName = nameText.Text; jsonDictionary.database[id].itemDesc = descricaoTextBox.Text; jsonDictionary.database[id].itemStack = itemStackBox.Checked; jsonDictionary.database[id].itemMaxStack = (int)stackNumericUpDown.Value; jsonDictionary.database[id].itemRarity = raridadeComboBox.Text; string type = typeComboBox.Text; //bool edit = false; switch (type) { case "Consumable": Consumables cons = new Consumables(id, jsonDictionary, true); ClearFields(); cons.ShowDialog(); break; case "Armor": frmArmor arm = new frmArmor(id, jsonDictionary, true); ClearFields(); arm.ShowDialog(); break; case "Weapon": FrmWeapon weap = new FrmWeapon(id, jsonDictionary, true); ClearFields(); weap.ShowDialog(); break; } } }