Пример #1
0
        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++;
            }
        }
Пример #2
0
 private void treeView1_DoubleClick(object sender, EventArgs e)                     //не доделан
 {
     if (treeView1.SelectedNode.Name[0] == 'y')
     {
     }
     else
     {
         int               sportsmen_count = 0;
         string            getname         = "";
         DateTime          start           = new DateTime();
         DateTime          end             = new DateTime();
         string            sqlQuery        = "SELECT * from competition where competition.id = '" + treeView1.SelectedNode.Name + "';";
         SQLiteDataAdapter adapter         = new SQLiteDataAdapter(sqlQuery, m_dbConn);
         SQLiteCommand     command         = new SQLiteCommand(sqlQuery, m_dbConn);
         SQLiteDataReader  reader          = command.ExecuteReader();
         while (reader.Read())
         {
             getname = reader["array_rounds_sets"].ToString();
             start   = Convert.ToDateTime(reader["start_date"]);
             end     = Convert.ToDateTime(reader["end_date"]);
         }
         string[] comp_sets = getname.Split(',');
         reader.Close();
         reader = null;
         foreach (string id in comp_sets)
         {
             archer_comp archer = new archer_comp();
             round_set   set    = new round_set();
             sqlQuery = "select * from `set` where id = '" + id + "'";
             adapter  = new SQLiteDataAdapter(sqlQuery, m_dbConn);
             command  = new SQLiteCommand(sqlQuery, m_dbConn);
             SQLiteDataReader reader1 = command.ExecuteReader();
             while (reader1.Read())
             {
                 sportsmen_count++;
                 set.id_aecher       = reader1["id"].ToString();
                 set.array_id_rounds = reader1["array_id_rounds"].ToString().Split(',');
                 archer.stand        = reader1["stand"].ToString() + reader1["latter"].ToString();
                 archer.category_id  = reader1["id_category"].ToString();
             }
             archer.id = set.id_aecher;
             reader1.Close();
             reader = null;
             foreach (string id1 in set.array_id_rounds)
             {
                 round round = new round();
                 sqlQuery = "select * from `rounds` where id = '" + id1 + "' ";
                 adapter  = new SQLiteDataAdapter(sqlQuery, m_dbConn);
                 command  = new SQLiteCommand(sqlQuery, m_dbConn);
                 reader   = command.ExecuteReader();
                 while (reader.Read())
                 {
                     round.id         = reader["id"].ToString();
                     round.result     = reader["result"].ToString();
                     round.distantion = reader["distantion"].ToString();
                 }
                 reader.Close();
                 reader = null;
                 archer.rounds.Add(round);
             }
             sqlQuery = "select * from `users` where id = '" + archer.id + "' ";
             adapter  = new SQLiteDataAdapter(sqlQuery, m_dbConn);
             command  = new SQLiteCommand(sqlQuery, m_dbConn);
             reader   = command.ExecuteReader();
             while (reader.Read())
             {
                 archer.fio             = reader["name"].ToString();
                 archer.age             = Convert.ToDateTime(reader["age"]);
                 archer.region          = reader["region"].ToString();
                 archer.rang            = reader["rang"].ToString();
                 archer.sp_organization = reader["sp_organization"].ToString();
                 archer.vedomstvo       = reader["vedomost"].ToString();
             }
             //archer_comp archer1 = archer;
             dataGridView2.Rows.Add(
                 archer.plase,
                 archer.stand,
                 archer.fio,
                 archer.age,
                 archer.rang,
                 archer.region,
                 archer.vedomstvo,
                 archer.sp_organization,
                 archer.round,
                 archer.tens,
                 archer.x,
                 archer.summ);
         }
         label13.Text = (treeView1.SelectedNode.Text);
         label12.Text = (start.ToString("dd:MM:yyyy"));
         label19.Text = (sportsmen_count.ToString());
         label20.Text = (end.ToString("dd:MM:yyyy"));
     }
 }
Пример #3
0
        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
                );
            }
        }