Beispiel #1
0
        public void drawTournirEnding(GroupClass inputGroup)
        {
            ComboBox comboBoxOfJudge = new ComboBox();
            Label    newLabel        = new Label();

            graduatePanel.Controls.Clear();
            graduatePanel.Visible = true;
            graduatePanel.Visible = true;
            List <int> positionsInComboBoxList = new List <int>();

            int height = 0;
            int weidh  = 0;

            height += 45;
            weidh  += 30;

            for (int i = 0; i < inputGroup.JudgeList.Count; i++)
            {
                graduatePanel.Controls.Add(newLabel = new Label()
                {
                    Text     = inputGroup.JudgeList[i].judgeChar.ToString(),
                    Location = new Point(105 + 80 * i, 15),
                    Size     = new Size(30, 25),
                    Font     = new Font("", 12)
                });
                t.SetToolTip(newLabel, inputGroup.JudgeList[i].ToString());
            }

            int j = 0;

            foreach (Duet duetItem in inputGroup.duetList)
            {
                graduatePanel.Controls.Add(newLabel = new Label()
                {
                    Text     = "Пара" + Convert.ToString(duetItem.number),
                    Location = new Point(10, height),
                    Size     = new Size(90, 25),
                    Font     = new Font("", 12),
                });
                t.SetToolTip(newLabel, duetItem.ToString());

                for (int i = 0; i < inputGroup.JudgeList.Count; i++)
                {
                    graduatePanel.Controls.Add(comboBoxOfJudge = new ComboBox()
                    {
                        Location = new Point(105 + 80 * i, height),
                        Size     = new Size(45, 33),
                        Font     = new Font("", 12)
                    });

                    for (int g = 1; g <= 5 /*countsOfPositionsNumericUpDown.Value*/; g++)
                    {
                        comboBoxOfJudge.Items.Add(g);
                    }

                    comboBoxOfJudge.BringToFront();

                    //tourList[currentMark.tourNumber].groupList[currentMark.groupNumber].resultOfGroup_list.Add(new tournirResultComboBox(markerForCheckList, comboBoxOfJudge));
                    resultOfTournir_list.Add(comboBoxOfJudge);
                }
                height += 30;
                j++;
            }
        }
Beispiel #2
0
        private void CreateGroupSecond_button_Click(object sender, EventArgs e)
        {
            GroupClass group_new = new GroupClass();

            if (NumberOfGroup_textBox.Text != "")
            {
                group_new.number = Convert.ToInt32(NumberOfGroup_textBox.Text);
                CheckBox[] CategoriesList = new CheckBox[] { D0_checkBox, D1_checkBox, D2_checkBox, M_checkBox, M2_checkBox, U1_checkBox, U2_checkBox, Vz_checkBox, other_checkBox };
                CheckBox[] DancesList     = new CheckBox[] { W_dance_checkBox, V_dance_checkBox, T_dance_checkBox, F_dance_checkBox, Q_dance_checkBox, S_dance_checkBox, Ch_dance_checkBox, R_dance_checkBox, P_dance_checkBox, J_dance_checkBox };

                string str = "";

                foreach (CheckBox item in DancesList)
                {
                    if (item.Checked)
                    {
                        group_new.DancesList.Add(item.Text);
                        str += item.Text;
                    }
                }
                //MessageBox.Show(str);

                foreach (CheckBox item in CategoriesList)
                {
                    if (item.Checked)
                    {
                        group_new.CategoryList.Add(item.Text);
                        str += item.Text;
                    }
                }
                MessageBox.Show(str);

                group_new.tournir_name = tournir.name;
                group_new.name         = categoryNameTextBox.Text;

                if (Path_textBox.Text != "")
                {
                    try
                    {
                        OleDbConnection cn = new OleDbConnection($"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={folderName}");
                        cn.Open();
                        OleDbCommand com1 = new OleDbCommand();
                        OleDbCommand com2 = new OleDbCommand();

                        com1 = new OleDbCommand("INSERT INTO groups(Название_Турнира, Номер_Группы, Категория, Категории, Танцы)" + "VALUES (@tournir_name, @group_number, @category, @categories, @dances)", cn);

                        com1.Parameters.AddWithValue("tournir_name", group_new.tournir_name);
                        com1.Parameters.AddWithValue("group_number", group_new.number);
                        com1.Parameters.AddWithValue("category", group_new.name);
                        string testStr = "";
                        for (int i = 0; i < CategoriesList.Length; i++)
                        {
                            if (CategoriesList[i].Checked == true)
                            {
                                switch (i)
                                {
                                case 0:
                                    testStr += "Д-0;";
                                    group_new.CategoryList.Add("Д-0");
                                    break;

                                case 1:
                                    testStr += "Д-1;";
                                    group_new.CategoryList.Add("Д-1");
                                    break;

                                case 2:
                                    testStr += "Д-2;";
                                    group_new.CategoryList.Add("Д-2");
                                    break;

                                case 3:
                                    testStr += "М;";
                                    group_new.CategoryList.Add("М");
                                    break;

                                case 4:
                                    testStr += "М-2;";
                                    group_new.CategoryList.Add("М-2");
                                    break;

                                case 5:
                                    testStr += "Ю-1;";
                                    group_new.CategoryList.Add("Ю-1");
                                    break;

                                case 6:
                                    testStr += "Ю-2;";
                                    group_new.CategoryList.Add("Ю-2");
                                    break;

                                case 7:
                                    testStr += "Вз;";
                                    group_new.CategoryList.Add("Вз");
                                    break;

                                default:
                                    testStr += "Другая;";
                                    group_new.CategoryList.Add("Другая");
                                    break;
                                }
                            }
                        }
                        com1.Parameters.AddWithValue("categories", testStr);

                        string testStr1 = "";
                        for (int i = 0; i < DancesList.Length; i++)
                        {
                            if (DancesList[i].Checked == true)
                            {
                                switch (i)
                                {
                                case 0:
                                    testStr1 += "W;";
                                    group_new.DancesList.Add("W");
                                    break;

                                case 1:
                                    testStr1 += "V;";
                                    group_new.DancesList.Add("V");
                                    break;

                                case 2:
                                    testStr1 += "T;";
                                    group_new.DancesList.Add("T");
                                    break;

                                case 3:
                                    testStr1 += "F;";
                                    group_new.DancesList.Add("F");
                                    break;

                                case 4:
                                    testStr1 += "Q;";
                                    group_new.DancesList.Add("Q");
                                    break;

                                case 5:
                                    testStr1 += "S;";
                                    group_new.DancesList.Add("S");
                                    break;

                                case 6:
                                    testStr1 += "Ch;";
                                    group_new.DancesList.Add("Ch");
                                    break;

                                case 7:
                                    testStr1 += "R;";
                                    group_new.DancesList.Add("R");
                                    break;

                                case 8:
                                    testStr1 += "P;";
                                    group_new.DancesList.Add("P");
                                    break;

                                case 9:
                                    testStr1 += "J;";
                                    group_new.DancesList.Add("J");
                                    break;
                                }
                            }
                        }
                        com1.Parameters.AddWithValue("dances", testStr1);

                        try
                        {
                            com1.ExecuteNonQuery();
                            tournir.groups.Add(group_new);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show($"Возникла непредвиденная проблема при обращении к базе:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        for (int i = 0; i < CategoriesList.Length; i++)
                        {
                            com2 = new OleDbCommand("INSERT INTO categories(Номер, Номер_Группы, Категория)" + "VALUES (@number, @group_number, @category)", cn);
                            com2.Parameters.AddWithValue("number", i + 1);
                            com2.Parameters.AddWithValue("group_number", group_new.number);

                            if (CategoriesList[i].Checked == true)
                            {
                                switch (i)
                                {
                                case 0:
                                    com2.Parameters.AddWithValue("category", "Д-0");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 1:
                                    com2.Parameters.AddWithValue("category", "Д-1");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 2:
                                    com2.Parameters.AddWithValue("category", "Д-2");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 3:
                                    com2.Parameters.AddWithValue("category", "М");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 4:
                                    com2.Parameters.AddWithValue("category", "М-2");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 5:
                                    com2.Parameters.AddWithValue("category", "Ю-1");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 6:
                                    com2.Parameters.AddWithValue("category", "Ю-2");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 7:
                                    com2.Parameters.AddWithValue("category", "Вз");
                                    com2.ExecuteNonQuery();
                                    break;

                                default:
                                    com2.Parameters.AddWithValue("category", "Другая");
                                    com2.ExecuteNonQuery();
                                    break;
                                }
                            }
                        }

                        for (int i = 0; i < DancesList.Length; i++)
                        {
                            com2 = new OleDbCommand("INSERT INTO dances(Номер_Группы, Танец)" + "VALUES (@group_number, @dance)", cn);
                            com2.Parameters.AddWithValue("group_number", group_new.number);

                            if (DancesList[i].Checked == true)
                            {
                                switch (i)
                                {
                                case 0:
                                    com2.Parameters.AddWithValue("dance", "W");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 1:
                                    com2.Parameters.AddWithValue("dance", "V");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 2:
                                    com2.Parameters.AddWithValue("dance", "T");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 3:
                                    com2.Parameters.AddWithValue("dance", "F");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 4:
                                    com2.Parameters.AddWithValue("dance", "Q");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 5:
                                    com2.Parameters.AddWithValue("dance", "S");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 6:
                                    com2.Parameters.AddWithValue("dance", "Ch");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 7:
                                    com2.Parameters.AddWithValue("dance", "R");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 8:
                                    com2.Parameters.AddWithValue("dance", "P");
                                    com2.ExecuteNonQuery();
                                    break;

                                case 9:
                                    com2.Parameters.AddWithValue("dance", "J");
                                    com2.ExecuteNonQuery();
                                    break;
                                }
                            }
                        }

                        NumberOfGroup_textBox.Text = Convert.ToString(tournir.groups.Count + 1);
                        MessageBox.Show("Новая группа успешно создана!\nУказаны категории: " + testStr);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Упс...Что-то пошло не так\n" + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Необходимо выбрать базу турнира!");
                }
            }
            else
            {
                MessageBox.Show("Поле номера группы не может быть пустым!");
            }
        }
        public static List <string> TakeDances(GroupClass input_group, string cn)
        {
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={cn}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

            List <string> CategoryList_New = new List <string>();

            try
            {
                int i       = 1;
                int max     = 0;
                int counter = 0;

                BitArray checkArray = Controller.GapCounter("Номер", "dances", "Номер_Группы", input_group.number, myConnection);

                command             = new OleDbCommand("", myConnection);
                command.CommandText = "SELECT MAX(Номер) FROM dances WHERE Номер_Группы = @id";
                command.Parameters.AddWithValue("id", input_group.number);

                if (command.ExecuteScalar() != DBNull.Value && checkArray != null)
                {
                    max = Convert.ToInt32(command.ExecuteScalar());

                    //MessageBox.Show($"MAX в группе {input_group.number}: " + Convert.ToString(max));

                    foreach (bool item in checkArray)
                    {
                        if (i <= max)
                        {
                            if (checkArray[i - 1])
                            {
                                command             = new OleDbCommand("", myConnection);
                                command.CommandText = "SELECT Танец FROM dances WHERE Номер = @id AND Номер_Группы = @num";
                                command.Parameters.AddWithValue("id", i);
                                command.Parameters.AddWithValue("num", input_group.number);

                                string category = command.ExecuteScalar().ToString();
                                //MessageBox.Show(category);
                                CategoryList_New.Add(category); //ДОРАБОТКА
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        i++;
                    }
                }
                else
                {
                    MessageBox.Show("Нулевой результат запроса");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Упс, что-то пошло не так при определении списка танцев\nError: " + ex.Message);
            }

            myConnection.Close();
            return(CategoryList_New);
        }
        public static List <Judge> TakeJudges(GroupClass input_group, string cn)
        {
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={cn}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

            Judge        new_judge = new Judge();
            List <Judge> judgeList = new List <Judge>();

            try
            {
                string   judgesString = "";
                string[] judgesStringList;

                command             = new OleDbCommand("", myConnection);
                command.CommandText = "SELECT Судьи FROM groups WHERE Номер_Группы = @id";
                command.Parameters.AddWithValue("id", input_group.number);

                judgesString     = command.ExecuteScalar().ToString().Replace(" ", "");
                judgesStringList = judgesString.Split(new char[] { ';' });
                //MessageBox.Show(judgesString);

                judgeList = new List <Judge>();

                for (int i = 0; i < judgesStringList.Length - 1; i++)
                {
                    new_judge = new Judge();
                    int number = Convert.ToInt32(judgesStringList[i]);

                    //MessageBox.Show(number.ToString());

                    OleDbCommand command1 = new OleDbCommand("", myConnection);

                    command1.CommandText = "SELECT ФИО FROM judges WHERE Номер = @num";
                    command1.Parameters.AddWithValue("num", number);
                    string jSNP = command1.ExecuteScalar().ToString();

                    command1             = new OleDbCommand("", myConnection);
                    command1.CommandText = "SELECT Категория_Судейства FROM judges WHERE Номер = @num";
                    command1.Parameters.AddWithValue("num", number);
                    string jcategory = command1.ExecuteScalar().ToString().Replace(" ", "");

                    string[] jSNPList = jSNP.Split(new char[] { ' ' });
                    if (jSNPList.Length >= 3)
                    {
                        new_judge.Surname    = jSNPList[0];
                        new_judge.Name       = jSNPList[1];
                        new_judge.Patronymic = jSNPList[2];
                    }

                    new_judge.JudgeClass = jcategory;
                    new_judge.Number     = (ushort)number;
                    new_judge.judgeChar  = (char)(64 + number);

                    //MessageBox.Show(new_judge.ToString());

                    judgeList.Add(new_judge);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Упс, что-то пошло не так при определении списка судей\nError: " + ex.Message);
            }

            myConnection.Close();
            return(judgeList);
        }
        public static List <Duet> TakeDuets(GroupClass input_group, string cn)
        {
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={cn}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

            List <Duet> DuetList_New = new List <Duet>();

            try
            {
                int max = 0;

                command             = new OleDbCommand("", myConnection);
                command.CommandText = "SELECT Count(Номер) FROM duets WHERE Номер_Группы = @id";
                command.Parameters.AddWithValue("id", input_group.number);

                max = Convert.ToInt32(command.ExecuteScalar());
                //MessageBox.Show(max.ToString());

                for (int i = 0; i < max; i++)
                {
                    string Type;
                    string SNP1;
                    string SNP2;
                    int    number;
                    Duet   set_new = new Duet();

                    OleDbCommand command1 = new OleDbCommand("", myConnection);
                    OleDbCommand command2 = new OleDbCommand("", myConnection);
                    OleDbCommand command3 = new OleDbCommand("", myConnection);
                    OleDbCommand command4 = new OleDbCommand("", myConnection);

                    command1.CommandText = "SELECT Номер FROM duets WHERE Номер_Группы = @num AND Номер = @id";
                    command1.Parameters.AddWithValue("num", input_group.number);
                    command1.Parameters.AddWithValue("id", i + 1);
                    number = Convert.ToInt32(command1.ExecuteScalar());
                    //MessageBox.Show(number.ToString());

                    command2             = new OleDbCommand("", myConnection);
                    command2.CommandText = "SELECT Тип FROM duets WHERE Номер_Группы = @num AND Номер = @id";
                    command2.Parameters.AddWithValue("num", input_group.number);
                    command2.Parameters.AddWithValue("id", i + 1);
                    Type = command2.ExecuteScalar().ToString().Replace(" ", "");
                    //MessageBox.Show(Type);

                    command3             = new OleDbCommand("", myConnection);
                    command3.CommandText = "SELECT ФИО1 FROM duets WHERE Номер_Группы = @num AND Номер = @id";
                    command3.Parameters.AddWithValue("num", input_group.number);
                    command3.Parameters.AddWithValue("id", i + 1);
                    SNP1 = command3.ExecuteScalar().ToString().Replace(" ", "");
                    //SNP1 = command3.ExecuteScalar().ToString();
                    //MessageBox.Show(SNP1);

                    if (Type == "Пара")
                    {
                        command4             = new OleDbCommand("", myConnection);
                        command4.CommandText = "SELECT ФИО2 FROM duets WHERE Номер_Группы = @num AND Номер = @id";
                        command4.Parameters.AddWithValue("num", input_group.number);
                        command4.Parameters.AddWithValue("id", i + 1);
                        SNP2 = command4.ExecuteScalar().ToString().Replace(" ", "");
                        //MessageBox.Show(SNP2);
                        set_new = new Duet(number, input_group.number, SNP1, SNP2);
                    }
                    else
                    {
                        set_new = new Duet(number, input_group.number, SNP1);
                    }

                    DuetList_New.Add(set_new); //ДОРАБОТКА
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Упс, что-то пошло не так при определении списка пар\nError: " + ex.Message);
            }

            myConnection.Close();
            return(DuetList_New);
        }
        public static List <SetClass> TakeSet(GroupClass input_group, string cn)
        {
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={cn}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

            List <SetClass> SetList_New = new List <SetClass>();

            try
            {
                int i       = 1;
                int max     = 0;
                int counter = 0;

                BitArray checkArray = Controller.GapCounter("Номер_Захода", "sets", "Номер_Группы", input_group.number, myConnection);

                command             = new OleDbCommand("", myConnection);
                command.CommandText = "SELECT MAX(Номер_Захода) FROM sets WHERE Номер_Группы = @id";
                command.Parameters.AddWithValue("id", input_group.number);

                if (command.ExecuteScalar() != DBNull.Value && checkArray != null)
                {
                    max = Convert.ToInt32(command.ExecuteScalar());

                    //MessageBox.Show($"MAX в группе {input_group.number}: " + Convert.ToString(max));

                    foreach (bool item in checkArray)
                    {
                        if (i <= max)
                        {
                            if (checkArray[i - 1])
                            {
                                command             = new OleDbCommand("", myConnection);
                                command.CommandText = "SELECT Категория FROM categories WHERE Номер_Группы = @num";
                                command.Parameters.AddWithValue("id", i);
                                command.Parameters.AddWithValue("num", input_group.number);

                                OleDbDataReader reader = command.ExecuteReader();

                                while (reader.Read())
                                {
                                    //if (reader["Номер_Книжки2"].ToString() != "")
                                    //{
                                    //    Sportsman sportsman1 = new Sportsman();
                                    //    Sportsman sportsman2 = new Sportsman();
                                    //    outStr += " ";
                                    //    Num1 = (Convert.ToInt32(reader["Номер_Книжки1"]));
                                    //    Num2 = (Convert.ToInt32(reader["Номер_Книжки2"]));

                                    //    sportsman1 = Controller.SearchByBookNumberShort(Num1);
                                    //    sportsman1.BookNumber = Num1;
                                    //    sportsman1.GroupNumber = i + 1;
                                    //    sportsman2 = Controller.SearchByBookNumberShort(Num2);
                                    //    sportsman2.BookNumber = Num2;
                                    //    sportsman2.GroupNumber = i + 1;
                                    //    DuetList_New.Add(new Duet(Convert.ToInt32(reader["Номер"]) - 1, i, sportsman1, sportsman2));

                                    //    outStr += DuetList_New[j1].ToString() + "\n";
                                    //    j1++;
                                    //}
                                }
                            }
                            else
                            {
                                counter++;
                            }
                        }
                        i++;
                    }
                }
                else
                {
                    MessageBox.Show("Нулевой результат запроса");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Упс, что-то пошло не так при определении списка заходов\nError: " + ex.Message);
            }

            myConnection.Close();
            return(SetList_New);
        }