示例#1
0
        private void RemoveDatabase()
		{
			//remove selected database
            if (containerListView1.CheckedItems.Count <= 0)
				return;

            DatabaseEditor de = new DatabaseEditor();
            de.Username = MySqlDatabaseManager.Username;
            de.Password = MySqlDatabaseManager.Password;
            de.Template = MySqlDatabaseManager.Template;
            de.Database = containerListView1.CheckedItems[0].Text;
            de.EditorMode = DatabaseEditor.Mode.Remove;

            if (de.ShowDialog() == DialogResult.OK)
            {
                if (MessageBox.Show(string.Format(Properties.Resources.MB_AskDelete, de.Database), Properties.Resources.MB_AskDeleteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes && 
                    MySqlDatabaseManager.DeleteDatabase(de.Database, de.Username, de.Password))
                    //refresh listView
                    //GetDatabaseList();
                    //remove database and if successful clvi from listview
                    containerListView1.CheckedItems[0].Delete();
            }
		}
示例#2
0
        private void EditDatabase()
		{
            //edit selected database
            if (containerListView1.CheckedItems.Count <= 0)
                return;

            DatabaseEditor de = new DatabaseEditor();
            de.Username = MySqlDatabaseManager.Username;
            de.Password = MySqlDatabaseManager.Password;
            de.Template = MySqlDatabaseManager.Template;
            de.Database = containerListView1.CheckedItems[0].Text;
            de.EditorMode = DatabaseEditor.Mode.Edit;

            if (de.ShowDialog() == DialogResult.OK)
            {
                if (MySqlDatabaseManager.RenameDatabase(de.Database, de.Username, de.Password))
                    //refresh listView
                    GetDatabaseList();
            }
		}
示例#3
0
        private void AddDatabase()
		{
			//add new database
            DatabaseEditor de = new DatabaseEditor();
            de.Username = MySqlDatabaseManager.Username;
            de.Password = MySqlDatabaseManager.Password;
            de.Template = MySqlDatabaseManager.Template;
            if (this.containerListView1.CheckedItems.Count > 0)
                de.Database = containerListView1.CheckedItems[0].Text;

			if (de.ShowDialog() == DialogResult.OK)
            {
                bool ok = MySqlDatabaseManager.SetupDatabase(de.Database, de.Username, de.Password);
                
                if (ok && de.UseEditedTemplate)
                    ok = MySqlDatabaseManager.CreateTables(de.Database, de.Username, de.Password, de.EditedTemplate);
                else if (ok)
                    ok = MySqlDatabaseManager.CreateTables(de.Database, de.Username, de.Password, new System.IO.FileInfo(de.Template));
                
                if (ok)
				    //refresh listView
				    GetDatabaseList();
            }
		}