private void buttonAddDatabase_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Controller.Instance.AppConfig.TemplateFileName)) { MessageBox.Show("Please select a template on the Project Details screen before adding a database.", "No Template", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } FormSelectDatabase form = new FormSelectDatabase(); if (form.ShowAddDatabase()) { ArchAngel.Providers.Database.Model.Database database = new ArchAngel.Providers.Database.Model.Database(form.DatabaseName, form.ConnectionString, form.DatabaseType); Controller.Instance.BllDatabase.AddDatabase(database); DisplayDatabaseList(); } }
private void buttonAddDatabase_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Interfaces.SharedData.TemplateFileName)) { MessageBox.Show("Please select a template on the Project Details screen before adding a database.", "No Template", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } FormSelectDatabase form = new FormSelectDatabase(); if (form.ShowAddDatabase(ParentForm)) { Model.Database database = new Model.Database(form.DatabaseName, form.ConnectionString, form.DatabaseType); if (ProviderInfo.TheBllDatabase == null) { ProviderInfo.TheBllDatabase = new BLL.Database(); } ProviderInfo.TheBllDatabase.AddDatabase(database); DisplayDatabaseList(); } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listBoxDatabase.SelectedItems.Count == 0) { MessageBox.Show("Please select a database from the list.", "No Database Selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int foundIndex = -1; // Find the selected database for (int i = 0; i < ProviderInfo.TheBllDatabase.Databases.Length; i++) { if (ProviderInfo.TheBllDatabase.Databases[i].Name == ((Model.Database)listBoxDatabase.SelectedItems[0]).Name) { foundIndex = i; break; } } if (foundIndex < 0) { MessageBox.Show("Database not found in internal collection.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FormSelectDatabase form = new FormSelectDatabase(); if (form.ShowEditDatabase(ProviderInfo.TheBllDatabase.Databases[foundIndex].ConnectionString)) { Model.Database database = (Model.Database)listBoxDatabase.SelectedItem; database.Name = form.DatabaseName; database.DatabaseType = form.DatabaseType; database.ConnectionString = form.ConnectionString; ProviderInfo.TheBllDatabase.UpdateDatabase(database, listBoxDatabase.SelectedIndex); DisplayDatabaseList(); } }