Example #1
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            if (Datastores.dbused)
            {
                switch (MessageBox.Show("Are you sure you want to delete the selected text from the database?", "Remove from database?", MessageBoxButtons.YesNoCancel))
                {
                case DialogResult.Yes:
                    string       query = SQLcreator.CreateDeleteQuery(localized_texts.map[text_id], "");
                    MySqlCommand c     = new MySqlCommand(query, SQLConnection.conn);
                    try
                    {
                        c.ExecuteNonQuery();
                        localized_texts.map.Remove(text_id);
                        UpdateListBox(false);
                        if (customlistBoxtexts.Items.Count != 0)
                        {
                            customlistBoxtexts.SelectedIndex = 0;
                        }
                        else
                        {
                            customlistBoxtexts.SelectedIndex = -1;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    break;

                case DialogResult.No:
                    localized_texts.map.Remove(text_id);
                    UpdateListBox(false);
                    if (customlistBoxtexts.Items.Count != 0)
                    {
                        customlistBoxtexts.SelectedIndex = 0;
                    }
                    else
                    {
                        customlistBoxtexts.SelectedIndex = -1;
                    }
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
            else
            {
                localized_texts.map.Remove(text_id);
                UpdateListBox(false);
                if (customlistBoxtexts.Items.Count != 0)
                {
                    customlistBoxtexts.SelectedIndex = 0;
                }
                else
                {
                    customlistBoxtexts.SelectedIndex = -1;
                }
            }
        }
Example #2
0
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Datastores.dbused && (npclistbox.SelectedIndex != -1))
            {
                switch (MessageBox.Show("Do you want to Remove it from Database Now? (Executing delete Query", "Remove from Database?", MessageBoxButtons.YesNoCancel))
                {
                case DialogResult.Yes:
                    string       query = SQLcreator.CreateDeleteQuery(creatures.GetCreature(System.Convert.ToUInt32(this.npclistbox.Items[npclistbox.SelectedIndex])), "");
                    MySqlCommand c     = new MySqlCommand(query, SQLConnection.conn);
                    try
                    {
                        if (npclistbox.SelectedIndex != -1)
                        {
                            foreach (Form item in MdiChildren)
                            {
                                if (item is NPCEditor)
                                {
                                    if ((item as NPCEditor).Id == System.Convert.ToInt32(this.npclistbox.Items[npclistbox.SelectedIndex]))
                                    {
                                        (item as NPCEditor).Close();
                                    }
                                }
                            }
                            c.ExecuteNonQuery();
                            creatures.DelCreature(System.Convert.ToUInt32(this.npclistbox.Items[npclistbox.SelectedIndex]));
                            UpdateNPCListBox();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    break;

                case DialogResult.No:
                    if (npclistbox.SelectedIndex != -1)
                    {
                        foreach (Form item in MdiChildren)
                        {
                            if (item is NPCEditor)
                            {
                                if ((item as NPCEditor).Id == System.Convert.ToInt32(this.npclistbox.Items[npclistbox.SelectedIndex]))
                                {
                                    (item as NPCEditor).Close();
                                }
                            }
                        }

                        creatures.DelCreature(System.Convert.ToUInt32(this.npclistbox.Items[npclistbox.SelectedIndex]));
                        UpdateNPCListBox();
                    }
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
            else
            {
                if (npclistbox.SelectedIndex != -1)
                {
                    //foreach (Form item in MdiChildren)
                    //{
                    //    if (item is NPCEditor)
                    //    {
                    //        if ((item as NPCEditor).npc_id == System.Convert.ToInt32(this.npclistbox.Items[npcofflistbox.SelectedIndex]))
                    //        {
                    //            (item as NPCEditor).Close();
                    //        }
                    //    }
                    //}

                    //creatures.DelCreature(System.Convert.ToUInt32(this.npclistbox.Items[npcofflistbox.SelectedIndex]));
                    //UpdateNPCListBox(false);
                }
            }
        }