private void button5_Click(object sender, EventArgs e) { ActiveForm.Hide(); MyResForm mrf = new MyResForm(runnerId); mrf.ShowDialog(); Close(); }
public MyResForm(int id) { InitializeComponent(); tm.Tick += timer1_Tick; tm.Interval = 1000; tm.Enabled = true; tm.Start(); runnerId = id; SqlConnClass scc = new SqlConnClass(); MyResForm mrf = this; scc.UpdMyResForm(mrf, id); }
public void UpdMyResForm(MyResForm mrf, int id) { string connStr = "server=localhost;user=root;database=pafenov;password="******"SELECT Gender FROM runner WHERE RunnerId =" + id; MySqlCommand command = new MySqlCommand(sql, conn); string gender = command.ExecuteScalar().ToString(); mrf.label9.Text += " " + gender; string sql1 = "SELECT DateOfBirth FROM runner WHERE RunnerId = " + id; command = new MySqlCommand(sql1, conn); DateTime date = Convert.ToDateTime(command.ExecuteScalar());//.ToString("yyyy.MM.dd hh:mm:ss"); int dt = DateTime.Now.Year - date.Year; if (dt < 18) { mrf.label4.Text += " от 18"; } if (dt >= 18 && dt <= 29) { mrf.label4.Text += " от 18 до 29"; } if (dt >= 30 && dt <= 39) { mrf.label4.Text += " от 30 до 39"; } if (dt >= 40 && dt <= 55) { mrf.label4.Text += " от 40 до 55"; } if (dt >= 56 && dt <= 70) { mrf.label4.Text += " от 56 до 70"; } if (dt > 70) { mrf.label4.Text += " более 70"; } string sql3 = "SELECT RegistrationId FROM registration WHERE RunnerId = " + id; command = new MySqlCommand(sql3, conn); int regid = Convert.ToInt32(command.ExecuteScalar()); string sql4 = "SELECT marathon.CityName,marathon.YearHeld,eventtype.EventTypeName,runner.DateOfBirth, `RaceTime`, `BibNumber` FROM registrationevent JOIN event ON registrationevent.EventId = event.EventId JOIN marathon ON event.MarathonId = marathon.MarathonId JOIN eventtype ON event.EventTypeId=eventtype.EventTypeId JOIN registration ON registrationevent.RegistrationId = registration.RegistrationId JOIN runner ON registration.RunnerId=runner.RunnerId WHERE registrationevent.RegistrationId = " + regid; command = new MySqlCommand(sql4, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string mar = reader[1].ToString() + " " + reader[0].ToString(); string dist = reader[2].ToString(); int hour = Convert.ToInt32(reader[4]) / 3600; int min = (Convert.ToInt32(reader[4]) - hour * 3600) / 60; int sec = Convert.ToInt32(reader[4]) - hour * 3600 - min * 60; ListViewItem item = new ListViewItem(new string[] { mar, dist, hour.ToString() + "h " + min.ToString() + "m " + sec.ToString() + "s", reader[5].ToString(), reader[3].ToString() }); mrf.listView1.Items.Add(item); } reader.Close(); conn.Close(); }