private void button3_Click(object sender, EventArgs e) { competitioons competition = new competitioons(); competition.name = textBox3.Text; competition.start_date = (dateTimePicker1.Value); competition.end_date = (dateTimePicker2.Value); string sqlQuery = ""; SQLiteCommand command = new SQLiteCommand(); int i = 0; sqlQuery = "INSERT INTO competition (name, start_date, end_date)VALUES ('" + competition.name + "','" + competition.start_date.ToString("yyyy-MM-dd") + "','" + competition.end_date.ToString("yyyy-MM-dd") + "');"; command = new SQLiteCommand(sqlQuery, m_dbConn); command.ExecuteNonQuery(); sqlQuery = "SELECT id FROM competition WHERE id=last_insert_rowid();"; command = new SQLiteCommand(sqlQuery, m_dbConn); string id_comp = command.ExecuteScalar().ToString(); foreach (CheckedListBox l1 in tables) { category_halder a = categories[i]; distantion dist = (distantion)a.f.SelectedItem; sqlQuery = "INSERT INTO `smena_info` (title, table_name, id_comp)VALUES ('" + a.a.Text + "','smena" + (i).ToString() + "','" + id_comp + "');"; command = new SQLiteCommand(sqlQuery, m_dbConn); command.ExecuteNonQuery(); sqlQuery = "SELECT id FROM smena_info WHERE id=last_insert_rowid();"; command = new SQLiteCommand(sqlQuery, m_dbConn); string id_smena = command.ExecuteScalar().ToString(); foreach (Object obj in l1.CheckedItems) { table_names archer = (table_names)obj; sqlQuery = "INSERT INTO performance (id_user,id_comp,id_smena) values ('" + archer.id.ToString() + "','" + id_comp + "','" + id_smena + "');"; command = new SQLiteCommand(sqlQuery, m_dbConn); command.ExecuteNonQuery(); sqlQuery = "SELECT id FROM performance WHERE id=last_insert_rowid();"; command = new SQLiteCommand(sqlQuery, m_dbConn); string id_perfomanse = command.ExecuteScalar().ToString(); for (int j = 0; j++ < dist.rounds_col; j++) { sqlQuery = "INSERT INTO `rounds` (id_distantion,id_perf)VALUES ('" + dist.id + "','" + id_perfomanse + "');"; command = new SQLiteCommand(sqlQuery, m_dbConn); command.ExecuteNonQuery(); } } i++; } if (!File.Exists("this_comp.txt")) { File.Create("this_comp.txt").Close();; } sqlQuery = "SELECT id FROM 'competition' order by id desc limit 1"; command = new SQLiteCommand(sqlQuery, m_dbConn); string id = command.ExecuteScalar().ToString(); File.AppendAllText("this_comp.txt", id); }
private void button4_Click(object sender, EventArgs e) { tables.Clear(); tabControl2.TabPages.Clear(); foreach (category_halder category in categories) { string title = (category.title()); TabPage myTabPage = new TabPage(title); tabControl2.TabPages.Add(myTabPage); CheckedListBox l1 = new CheckedListBox(); l1.Dock = DockStyle.Fill; myTabPage.Controls.Add(l1); CheckedListBox c1 = new CheckedListBox(); string sqlQuery; DataTable dTable = new DataTable(); sqlQuery = category.query(); SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, m_dbConn); SQLiteCommand command = new SQLiteCommand(sqlQuery, m_dbConn); SQLiteDataReader reader = command.ExecuteReader(); dTable = new DataTable(); adapter.Fill(dTable); command = new SQLiteCommand(sqlQuery, m_dbConn); reader = command.ExecuteReader(); while (reader.Read()) { table_names archer = new table_names(); archer.name = reader["name"].ToString(); archer.id = Convert.ToInt32(reader["id"]); archer.bowtype = reader["bow_type"].ToString(); archer.pol = Convert.ToBoolean(reader["pol"]); c1.DisplayMember = archer.name; c1.Items.Add(archer); } c1.Dock = DockStyle.Fill; c1.DisplayMember = "FullName"; c1.ValueMember = "id"; l1.Controls.Add(c1); tables.Add(c1); } }