private void button7_Click(object sender, EventArgs e) { FileStream file1 = new FileStream("this_comp.txt", FileMode.Open); StreamReader reader2 = new StreamReader(file1); string competition_id = (reader2.ReadToEnd()); reader2.Close(); Form4 f = new Form4(); f.Owner = this; f.Show(); foreach (category_halder category in categories2) { int i = 0; TabPage myTabPage = new TabPage(category.a.Text); DataGridView l1 = new DataGridView(); List <archer_comp> smena = new List <archer_comp>(); l1.Show(); tabControl3.TabPages.Add(myTabPage); f.tabControl1.TabPages.Add(myTabPage); l1.Dock = DockStyle.Fill; myTabPage.Controls.Add(l1); int i5 = 1; foreach (DataGridViewColumn obj in dataGridView3.Columns) { i5++; DataGridViewColumn col = new DataGridViewColumn(); col.Width = obj.Width; col.CellTemplate = new DataGridViewTextBoxCell(); col.HeaderText = obj.HeaderText; col.Name = "col" + i5.ToString(); l1.Columns.Add(col); } l1.ReadOnly = true; l1.AllowUserToAddRows = false; l1.AllowUserToDeleteRows = false; string[] selected = category.d.Text.Split(','); int k = 0; List <string> list_id = new List <string>() { }; for (int j = 0; j < selected.Count(); j++) { foreach (object cat in category.d.Items) { checheckedComboBox_category categh = (checheckedComboBox_category)cat; if (categh.name == selected[j] || " " + categh.name == selected[j]) { list_id.Add(categh.id); } } } foreach (string categ_id in list_id) { string smena_buf = ""; string sqlQuery = " select * from(select * from (SELECT id_comp, id_smena,plase,shield,letter,id as p_id,id_user FROM performance WHERE id IN (SELECT id_perf FROM rounds ) and id_comp = '" + competition_id + "') a inner join users on a.id_user = users.id) a inner join(select id as s_id, title from smena_info where s_id = '" + categ_id + "') d on a.id_smena = d.s_id ORDER BY s_id,name ASC; "; SQLiteCommand command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader archer_reader = command.ExecuteReader(); while (archer_reader.Read()) { archer_comp archer = new archer_comp(); archer.fio = archer_reader["name"].ToString(); archer.age = Convert.ToDateTime(archer_reader["age"]); archer.region = archer_reader["region"].ToString(); archer.rang = archer_reader["rang"].ToString(); archer.sp_organization = archer_reader["sp_organization"].ToString(); archer.vedomstvo = archer_reader["vedomost"].ToString(); archer.id = archer_reader["id_user"].ToString(); archer.id_perf = archer_reader["p_id"].ToString(); archer.id_smena = archer_reader["s_id"].ToString(); archer.rounds.Clear(); sqlQuery = "select * from rounds where id_perf = '" + archer.id_perf + "'"; command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader round_reader = command.ExecuteReader(); while (round_reader.Read()) { round r = new round(); r.id = round_reader["id"].ToString(); r.result = round_reader["result"].ToString(); r.series = round_reader["array_series"].ToString(); r.distantion = round_reader["id_distantion"].ToString(); archer.rounds.Add(r); archer.nine = Convert.ToByte(round_reader["nine"]); archer.tens = Convert.ToByte(round_reader["ten"]); archer.x = Convert.ToByte(round_reader["x"]); } if (smena_buf != archer.id_smena) { } smena.Add(archer); l1.Rows.Add ( archer.stand, archer.letter, archer.plase, archer.fio, archer.age.ToString("dd:MM:yyyy"), archer.rang, archer.region, archer.vedomstvo, archer.sp_organization, archer.round, archer.tens, archer.x, archer.summ ); } comp_smena.Add(smena); l1.Rows.Add(); smena_tables.Add(l1); } f.comp_smena = comp_smena; i++; } }
private void button6_Click_1(object sender, EventArgs e) // работает- не трожь { dataGridView3.Rows.Clear(); FileStream file1 = new FileStream("this_comp.txt", FileMode.Open); StreamReader reader2 = new StreamReader(file1); string competition_id = (reader2.ReadToEnd()); reader2.Close(); string sqlQuery = "select * from smena_info where id_comp = '" + competition_id + "' "; SQLiteCommand command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader cat = command.ExecuteReader(); while (cat.Read()) { checheckedComboBox_category categ = new checheckedComboBox_category(); categ.id = cat["id"].ToString(); categ.name = cat["title"].ToString(); checkedComboBox3.Items.Add(categ); } string smena_buf = ""; sqlQuery = " select * from(select * from (SELECT id_comp, id_smena,plase,shield,letter,id as p_id,id_user FROM performance WHERE id IN (SELECT id_perf FROM rounds ) and id_comp = '" + competition_id + "') a inner join users on a.id_user = users.id) a inner join(select id as s_id, title from smena_info) d on a.id_smena = d.s_id ORDER BY s_id,name ASC; "; command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader archer_reader = command.ExecuteReader(); while (archer_reader.Read()) { archer_comp archer = new archer_comp(); archer.fio = archer_reader["name"].ToString(); archer.age = Convert.ToDateTime(archer_reader["age"]); archer.region = archer_reader["region"].ToString(); archer.rang = archer_reader["rang"].ToString(); archer.sp_organization = archer_reader["sp_organization"].ToString(); archer.vedomstvo = archer_reader["vedomost"].ToString(); archer.id = archer_reader["id_user"].ToString(); archer.id_perf = archer_reader["p_id"].ToString(); archer.id_smena = archer_reader["s_id"].ToString(); archer.rounds.Clear(); sqlQuery = "select * from rounds where id_perf = '" + archer.id_perf + "'"; command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader round_reader = command.ExecuteReader(); while (round_reader.Read()) { round r = new round(); r.id = round_reader["id"].ToString(); r.result = round_reader["result"].ToString(); r.series = round_reader["array_series"].ToString(); r.distantion = round_reader["id_distantion"].ToString(); archer.rounds.Add(r); archer.nine = Convert.ToByte(round_reader["nine"]); archer.tens = Convert.ToByte(round_reader["ten"]); archer.x = Convert.ToByte(round_reader["x"]); } if (smena_buf != archer.id_smena) { dataGridView3.Rows.Add(); smena_buf = archer.id_smena; } dataGridView3.Rows.Add ( archer.stand, archer.letter, archer.plase, archer.fio, archer.age.ToString("dd:MM:yyyy"), archer.rang, archer.region, archer.vedomstvo, archer.sp_organization, archer.round, archer.tens, archer.x, archer.summ ); } }