private void main_Load(object sender, EventArgs e) { var version = new Version(Application.ProductVersion); versionNumber.Text = "Versión: " + version.Major.ToString() + "." + version.Minor.ToString(); errorTimer = new Timer(); errorTimer.Interval = 1000; errorTimer.Tick += ErrorTimer_Tick; errorTimer.Enabled = true; check.Checked = true; check.Text = "Sólo lectura"; check.CheckedChanged += setSoloLectura; ConfigError = string.IsNullOrWhiteSpace(Properties.Settings.Default.serverAddress) || string.IsNullOrWhiteSpace(Properties.Settings.Default.databaseName) || string.IsNullOrWhiteSpace(Properties.Settings.Default.databaseUsername) || string.IsNullOrWhiteSpace(Properties.Settings.Default.serverPort) || string.IsNullOrWhiteSpace(Properties.Settings.Default.databasePassword) || string.IsNullOrWhiteSpace(Properties.Settings.Default.reportUNC); if (ConfigError) { return; } db = new dbMySql.dbMySql(); db.serverAddress = Properties.Settings.Default.serverAddress; db.serverPort = Properties.Settings.Default.serverPort; db.databaseName = Properties.Settings.Default.databaseName; db.databaseUsername = Properties.Settings.Default.databaseUsername; db.databasePassword = SSTCryptographer.Decrypt( Properties.Settings.Default.databasePassword, Properties.Settings.Default.databaseUsername + "as56afs65qer3g654afg"); db.limitResults = Properties.Settings.Default.limitResults; db.limitResultsTo = Properties.Settings.Default.limitResultsTo; db.useWildcard = Properties.Settings.Default.useWildcard; reportUNC = Properties.Settings.Default.reportUNC; db.CreateConnection(); dataGridView1.DataSource = mainBindingSource; backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += databaseTransaction; backgroundWorker.RunWorkerCompleted += databaseTransactionResult; bgwObj = new backgroundObject(); bgwObj.db = db; bgwObj.actionIs = backgroundObject.action.justConnect; backgroundWorker.RunWorkerAsync(bgwObj); }
private void button3_Click(object sender, EventArgs e) { dbMySql.dbMySql db = new dbMySql.dbMySql(); db.serverAddress = textBox[0].Text; db.serverPort = textBox[1].Text; db.databaseName = textBox[2].Text; db.databaseUsername = textBox[3].Text; db.databasePassword = textBox[4].Text; progressBar1.Visible = true; button3.Enabled = false; var bgw = new BackgroundWorker(); bgw.DoWork += (bgwSender, bgwE) => { ((dbMySql.dbMySql)bgwE.Argument).CreateConnection(); ((dbMySql.dbMySql)bgwE.Argument).TestConnection(); }; bgw.RunWorkerCompleted += dbResult; bgw.RunWorkerAsync(db); }