// Button GoButton) public TransactionScript(Source sourceSource, Target targetTarget, Configuration config, DoneDelegate doneHandler) { this.sourceSource = sourceSource; this.targetTarget = targetTarget; this.config = config; this.doneHandler = doneHandler; //this.goButton = GoButton; }
private void TargetAddButton_Click(object sender, EventArgs e) { Source source = (Source)(sourceList.SelectedItem); if (source == null) { MessageBox.Show("Please select a source to which you want to add a target."); } else { bool AlreadyClosed = false; DatabaseForm form = new DatabaseForm(); if (form.ShowDialog() == DialogResult.OK) { OdbcCommand command = new OdbcCommand(); command.Connection = meta; command.CommandType = CommandType.Text; command.CommandText = "insert into meta_db_deploy_targets(meta_dbdt_server, meta_dbdt_name, meta_dbdt_connection_string) values(?,?,?)"; command.Parameters.Add(new OdbcParameter("1", form.ServerText.Text)); command.Parameters.Add(new OdbcParameter("2", form.DatabaseNameText.Text)); command.Parameters.Add(new OdbcParameter("3", form.ConnectionStringText.Text)); try { meta.Open(); try { if (command.ExecuteNonQuery() == 1) { log.log(Logger.LogLevel.info, "Target added successfully."); command.CommandText = "select max(meta_db_deploy_target) from meta_db_deploy_targets"; long id = (long)(command.ExecuteScalar()); Target target = new Target(id, form.ServerText.Text, form.DatabaseNameText.Text, form.ConnectionStringText.Text); targetList.Items.Add(target); meta.Close(); AlreadyClosed = true; targetList.SelectedItem = target; } else { log.log(Logger.LogLevel.error, "Target was not added."); } } catch (Exception ex) { log.log(Logger.LogLevel.error, "Exception occurred while trying to add target..."); log.log(Logger.LogLevel.error, ex.Message); } finally { if (!AlreadyClosed) { meta.Close(); } } } catch (Exception ex) { log.log(Logger.LogLevel.error, "Exception occurred while trying to add target..."); log.log(Logger.LogLevel.error, ex.Message); } } } }