private void wizardPage3_ShowFromNext(object sender, EventArgs e) { StoreSettings(); /*Try Connect*/ IDbConnection conn = null; try { conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOLAComp.Items.Clear(); cmd.CommandText = "select raceId, RaceName, raceDate from dbRaces"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["raceId"].ToString()); cmp.Name = Convert.ToString(reader["raceName"]) + " [" + Convert.ToDateTime(reader["raceDate"]).ToString("yyyy-MM-dd") + "]"; cmbOLAComp.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOLAComp.Items.Count > 0) { cmbOLAComp.SelectedIndex = 0; } } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) { conn.Close(); } } }
private void wizardPage4_ShowFromNext(object sender, EventArgs e) { /*Try Connect*/ IDbConnection conn = null; try { conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOLAEtapp.Items.Clear(); cmd.CommandText = "select eventraceid, name from EventRaces where eventid = " + ((OlaComp)cmbOLAComp.SelectedItem).Id; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventraceid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOLAEtapp.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOLAEtapp.Items.Count > 0) { cmbOLAEtapp.SelectedIndex = 0; } } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) { conn.Close(); } } }
private void wizardPageOLASelRace_ShowFromNext(object sender, EventArgs e) { EventSoftwareOLA ola = GetOlaEventSoftware(); /*Try Connect*/ IDbConnection conn = null; try { conn = ola.GetDBConnection(); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOlaRace.Items.Clear(); cmd.CommandText = "select eventraceid, name from EventRaces where eventid = " + ((OlaComp)cmbOlaEvent.SelectedItem).Id; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventraceid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOlaRace.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOlaRace.Items.Count > 0) cmbOlaRace.SelectedIndex = 0; } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) conn.Close(); } }
private void wizardPageOLASelEvent_ShowFromNext(object sender, EventArgs e) { EventSoftwareOLA ola = GetOlaEventSoftware(); IDbConnection conn = ola.GetDBConnection(); try { conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOlaEvent.Items.Clear(); cmd.CommandText = "SELECT VersionNumber FROM Version WHERE moduleId = 1"; try { object res = cmd.ExecuteScalar(); } catch (Exception ee) { if (ee.Message.ToUpper().Contains("ENOUGH RIGHTS")) { conn.Close(); conn = new H2Connection("jdbc:h2://" + txtOlaDBLoc.Text.Replace(".h2.db", "") + ";AUTO_SERVER=TRUE", "root", ""); try { conn.Open(); cmd = conn.CreateCommand(); TryApplyReadRights(cmd); } finally { conn.Close(); } conn = ola.GetDBConnection(); conn.Open(); cmd = conn.CreateCommand(); } } cmd.CommandText = "select eventid, name from Events"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOlaEvent.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOlaEvent.Items.Count > 0) cmbOlaEvent.SelectedIndex = 0; } finally { conn.Close(); } }
private void wizardPage3_ShowFromNext(object sender, EventArgs e) { /*Try Connect*/ IDbConnection conn = null; try { if (comboBox1.SelectedIndex == 0 && !System.IO.File.Exists(txtOlaDb.Text.Replace(".h2.", ".lock."))) { MessageBox.Show("OLA Does not seem to be started on server?\r\nPlease make sure OLA is running with connected clients when connecting, else all traffic will be redirected through this computer!"); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOLAComp.Items.Clear(); cmd.CommandText = "SELECT VersionNumber FROM Version WHERE moduleId = 1"; try { object res = cmd.ExecuteScalar(); } catch (Exception ee) { if (ee.Message.ToUpper().Contains("ENOUGH RIGHTS")) { conn.Close(); conn = new H2Connection("jdbc:h2://" + txtOlaDb.Text.Replace(".h2.db", "") + ";AUTO_SERVER=TRUE", "root", ""); try { conn.Open(); cmd = conn.CreateCommand(); TryApplyReadRights(cmd); } finally { conn.Close(); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); cmd = conn.CreateCommand(); } } cmd.CommandText = "select eventid, name from Events"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOLAComp.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOLAComp.Items.Count > 0) { cmbOLAComp.SelectedIndex = 0; } } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) { conn.Close(); } } }
private void wizardPage3_ShowFromNext(object sender, EventArgs e) { StoreSettings(); /*Try Connect*/ IDbConnection conn = null; try { if (comboBox1.SelectedIndex == 0 && !System.IO.File.Exists(txtOlaDb.Text.Replace(".h2.", ".lock."))) { MessageBox.Show("OLA Does not seem to be started on server?\r\nPlease make sure OLA is running with connected clients when connecting, else all traffic will be redirected through this computer!"); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOLAComp.Items.Clear(); cmd.CommandText = "SELECT VersionNumber FROM Version WHERE moduleId = 1"; try { object res = cmd.ExecuteScalar(); } catch (Exception ee) { if (ee.Message.ToUpper().Contains("ENOUGH RIGHTS")) { conn.Close(); conn = new H2Connection("jdbc:h2://" + txtOlaDb.Text.Replace(".h2.db", "") + ";AUTO_SERVER=TRUE", "root", ""); try { conn.Open(); cmd = conn.CreateCommand(); TryApplyReadRights(cmd); } finally { conn.Close(); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); cmd = conn.CreateCommand(); } } cmd.CommandText = "select eventid, name from Events"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOLAComp.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOLAComp.Items.Count > 0) cmbOLAComp.SelectedIndex = 0; } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) conn.Close(); } }