Example #1
0
 public Duet(int Num, int GroupNum, Sportsman Sportsman1, Sportsman Sportsman2)
 {
     this.number      = Num;
     this.sportsman1  = Sportsman1;
     this.sportsman2  = Sportsman2;
     this.groupNumber = GroupNum;
 }
Example #2
0
 public Duet(int Num, int GroupNum, Sportsman Sportsman1)
 {
     this.number      = Num;
     this.sportsman1  = Sportsman1;
     this.sportsman2  = new Sportsman(-1);
     this.groupNumber = GroupNum;
 }
        public static void insertInSportDB(Sportsman sportsman)
        {
            OleDbCommand command = new OleDbCommand("", myConnection);

            command.CommandText = "INSERT INTO Sportsmans(НомерКнижки, Фамилия, Имя, Отчество, НазваниеКлуба, Город, ДатаРождения, СпортивныйКласс, Разряд)" + "VALUES (@BookNumber,@Surname,@Name,@Patronymic,@ClubName,@City,@BirthDate,@SportClass,@SportCategory)";

            command.Parameters.AddWithValue("BookNumber", sportsman.BookNumber);
            command.Parameters.AddWithValue("Surname", sportsman.Surname);
            command.Parameters.AddWithValue("Name", sportsman.Name);
            command.Parameters.AddWithValue("Patronymic", sportsman.Patronymic);
            command.Parameters.AddWithValue("ClubName", sportsman.ClubName);
            command.Parameters.AddWithValue("City", sportsman.City);
            command.Parameters.AddWithValue("BirthDate", sportsman.BirthDate.ToString());
            command.Parameters.AddWithValue("SportClass", sportsman.SportClass);
            command.Parameters.AddWithValue("SportCategory", sportsman.SportCategory);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Попытка повторного ввода номера книжки:\n{sportsman.BookNumber}\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static void insertInParticipants(Sportsman sportsman, string path)
        {
            //try
            //{
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

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

            command.CommandText = "INSERT INTO participants(Номер, Фамилия, Имя, Отчество, Категория, Номер_Группы)" + "VALUES (@Number, @Surname, @Name, @Patronymic, @AgeCategory, @GroupNumber)";

            command.Parameters.AddWithValue("Number", sportsman.NumberInTournir);
            command.Parameters.AddWithValue("Surname", sportsman.Surname);
            command.Parameters.AddWithValue("Name", sportsman.Name);
            command.Parameters.AddWithValue("Patronymic", sportsman.Patronymic);
            command.Parameters.AddWithValue("AgeCategory", sportsman.AgeCategory);
            command.Parameters.AddWithValue("GroupNumber", sportsman.GroupNumber);

            command.ExecuteNonQuery();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show($"Упс, что-то пошло не так...\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            myConnection.Close();
        }
        public static void insertParticipantsInSet(int number, Sportsman sportsman1, Sportsman sportsman2, int groupNumber, string path)
        {
            try
            {
                connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path}";
                myConnection  = new OleDbConnection(connectString);
                myConnection.Open();

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

                command.CommandText = "INSERT INTO duets(Номер, Номер_Группы, Номер_Книжки1, Номер_Книжки2, Тип)" + "VALUES (@Number, @GroupNumber, @BookNumber1, @BookNumber2, @Type)";

                command.Parameters.AddWithValue("Number", number);
                command.Parameters.AddWithValue("GroupNumber", groupNumber);
                command.Parameters.AddWithValue("BookNumber1", sportsman1.BookNumber);
                command.Parameters.AddWithValue("BookNumber2", sportsman2.BookNumber);
                command.Parameters.AddWithValue("Type", "Пара");

                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Упс, что-то пошло не так при записи очередного пары...\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            myConnection.Close();
        }
        public static void insertParticipantsInDuet(int number, Sportsman sportsman, int groupNumber, string path)
        {
            //try
            //{
            connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path}";
            myConnection  = new OleDbConnection(connectString);
            myConnection.Open();

            command = new OleDbCommand("", myConnection);

            command.CommandText = "INSERT INTO duets(Номер, Номер_Группы, ФИО1, Тип)" + "VALUES (@Number, @GroupNumber, @SNP, @Type)";
            command.Parameters.AddWithValue("Number", number);
            command.Parameters.AddWithValue("GroupNumber", groupNumber);
            command.Parameters.AddWithValue("SNP", sportsman.Surname + ";" + sportsman.Name + ";" + sportsman.Patronymic + ";");
            command.Parameters.AddWithValue("Type", "Соло");

            MessageBox.Show($"Новый Солист:\n{sportsman.BookNumber}\nГруппа: {groupNumber}");

            command.ExecuteNonQuery();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show($"Упс, что-то пошло не так при записи очередного солиста...\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            myConnection.Close();
        }
        public registrFormSolo()
        {
            InitializeComponent();

            sportsman = new Sportsman();

            if (FirstTrainer_checkBox.Checked == false)
            {
                FirstTrainer_groupBox.ForeColor = Color.Gray;
            }
            if (SecondTrainer_checkBox.Checked == false)
            {
                SecondTrainer_groupBox.ForeColor = Color.Gray;
            }

            //danceCheckList.Add(danceCheckBox1);
            //danceCheckList.Add(danceCheckBox2);
            //danceCheckList.Add(danceCheckBox3);
            //danceCheckList.Add(danceCheckBox4);
            //danceCheckList.Add(danceCheckBox5);
            //danceCheckList.Add(danceCheckBox6);
            //danceCheckList.Add(danceCheckBox7);
            //danceCheckList.Add(danceCheckBox8);
            //danceCheckList.Add(danceCheckBox9);
            //danceCheckList.Add(danceCheckBox10);
        }
Example #8
0
        public static Sportsman SearchByBookNumberShort(int BookNumber)
        {
            Sportsman sportsman = new Sportsman();

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

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

            OleDbCommand command4 = new OleDbCommand("", myConnection);
            OleDbCommand command5 = new OleDbCommand("", myConnection);

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

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


            command1.CommandText = "SELECT Фамилия FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command1.Parameters.AddWithValue("BookNum", BookNumber);

            command2.CommandText = "SELECT Имя FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command2.Parameters.AddWithValue("BookNum", BookNumber);

            command3.CommandText = "SELECT Отчество FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command3.Parameters.AddWithValue("BookNum", BookNumber);

            command4.CommandText = "SELECT НазваниеКлуба FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command4.Parameters.AddWithValue("BookNum", BookNumber);

            command5.CommandText = "SELECT Город FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command5.Parameters.AddWithValue("BookNum", BookNumber);

            command6.CommandText = "SELECT СпортивныйКласс FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command6.Parameters.AddWithValue("BookNum", BookNumber);

            command7.CommandText = "SELECT Разряд FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command7.Parameters.AddWithValue("BookNum", BookNumber);

            try
            {
                sportsman.Surname    = command1.ExecuteScalar().ToString();
                sportsman.Name       = command2.ExecuteScalar().ToString();
                sportsman.Patronymic = command3.ExecuteScalar().ToString();
                sportsman.ClubName   = command4.ExecuteScalar().ToString();
                sportsman.City       = command5.ExecuteScalar().ToString();

                //MessageBox.Show(sportsman.BirthDate.ToString());

                sportsman.SportClass    = command6.ExecuteScalar().ToString();
                sportsman.SportCategory = command7.ExecuteScalar().ToString();
            }
            catch (/*System.NullReferenceException*/ Exception ex)
            {
                MessageBox.Show("Что-то пошло не так! \n" + ex.Message);
            }
            return(sportsman);
        }
 private void searchByBook_2_Button_Click(object sender, EventArgs e)
 {
     if (BookNumber2_textBox.Text != "")
     {
         try
         {
             sportsman_second = Controller.SearchByBookNumber(Convert.ToInt32(BookNumber2_textBox.Text));
             autoFilling_second(sportsman_second);
         }
         catch (Exception ex)
         {
             MessageBox.Show($"{ex.Message}");
         }
     }
     else
     {
         MessageBox.Show("Заполните поле 'Номер Книжки' для второго спортсмена!");
     }
 }
        public static void insertParticipantsInSet(int number, Sportsman sportsman, int groupNumber, int setNumber, string path)
        {
            try
            {
                connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={path}";
                myConnection  = new OleDbConnection(connectString);
                myConnection.Open();

                OleDbCommand command = new OleDbCommand("", myConnection);
                if (setNumber != -1)
                {
                    command.CommandText = "INSERT INTO duets(Номер, Номер_Группы, Номер_Захода, Номер_Книжки1, Тип)" + "VALUES (@Number, @GroupNumber, @SetNumber, @BookNumber, @Type)";
                    //command.CommandText = "INSERT INTO duets(Номер, Номер_Группы, Номер_Книжки1, Тип)" + "VALUES (@Number, @GroupNumber, @BookNumber, @Type)";
                    command.Parameters.AddWithValue("Number", number);
                    command.Parameters.AddWithValue("GroupNumber", groupNumber);
                    command.Parameters.AddWithValue("SetNumber", setNumber);
                    command.Parameters.AddWithValue("BookNumber", sportsman.BookNumber);
                    command.Parameters.AddWithValue("Type", "Соло");
                }
                else
                {
                    command.CommandText = "INSERT INTO duets(Номер, Номер_Группы, Номер_Книжки1, Тип)" + "VALUES (@Number, @GroupNumber, @BookNumber, @Type)";
                    command.Parameters.AddWithValue("Number", number);
                    command.Parameters.AddWithValue("GroupNumber", groupNumber);
                    command.Parameters.AddWithValue("BookNumber", sportsman.BookNumber);
                    command.Parameters.AddWithValue("Type", "Соло");
                }

                MessageBox.Show($"Новый Солист:\n{sportsman.BookNumber}\nГруппа: {groupNumber}\nЗаход: {setNumber}");

                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Упс, что-то пошло не так при записи очередного солиста...\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            myConnection.Close();
        }
Example #11
0
        private void formingSets_button_Click(object sender, EventArgs e)
        {
            if (this.tournir.name != "" && Path_textBox.Text != "" && duetCountTextBox.Text != "")
            {
                //Constants
                //int setCountInGroup = Convert.ToInt32(setCountTextBox.Text);
                int duetCountInSet = Convert.ToInt32(duetCountTextBox.Text);

                //задать количество участников в каждом заходе
                connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={folderName}";
                OleDbConnection con = new OleDbConnection(connectString);
                con.Open();

                List <Duet> DuetList_New = new List <Duet>();
                List <Duet> SoloList_New = new List <Duet>();
                //Sportsman sportsman1 = new Sportsman();
                //Sportsman sportsman2 = new Sportsman();

                int    countOfElements = 0;
                Random rnd             = new Random();

                Controller.myConnection.Open();

                for (int i = 0; i < tournir.groups.Count; i++)
                {
                    DuetList_New.Clear();
                    SoloList_New.Clear();
                    int          index   = 0;
                    OleDbCommand command = new OleDbCommand("SELECT COUNT(Номер_Книжки1) From duets WHERE Номер_Группы = @id", con);

                    command.Parameters.AddWithValue("id", i + 1);
                    countOfElements = Convert.ToInt32(command.ExecuteScalar().ToString());
                    //MessageBox.Show(Convert.ToString(countOfElements));

                    //List<Duet> newDuetList = new List<Duet>();
                    //List<int> newBookNumDuetList = new List<int>();
                    //List<int> newBookNumSoloList = new List<int>();

                    string outStr  = "Пары группы номер" + (i + 1).ToString() + "\n";
                    string outStr1 = "Солисты группы номер" + (i + 1).ToString() + "\n";

                    OleDbCommand command1 = new OleDbCommand("SELECT Номер, Номер_Книжки1, Номер_Книжки2 From duets WHERE Номер_Группы = @id", con);

                    command1.Parameters.AddWithValue("id", i + 1);
                    OleDbDataReader reader = command1.ExecuteReader();
                    int             j      = 0;
                    int             j1     = 0;

                    int Num1 = 0, Num2 = 0;

                    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
                        {
                            Sportsman sportsman1 = new Sportsman();
                            //newBookNumSoloList.Add(Convert.ToInt32(reader["Номер_Книжки1"]));
                            Num1 = (Convert.ToInt32(reader["Номер_Книжки1"]));

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

                            outStr1 += SoloList_New[j].ToString() + "\n";
                            j++;
                        }
                        outStr  += "\n";
                        outStr1 += "\n";
                    }
                    //MessageBox.Show(outStr);
                    outStr = "(Пара)Сортировка\n";
                    //DuetList_New.OrderBy(x => rnd.Next());
                    randomSort(DuetList_New);
                    foreach (Duet duetItem in DuetList_New)
                    {
                        outStr += duetItem.ToString();
                    }
                    //MessageBox.Show(outStr);

                    //MessageBox.Show(outStr1);
                    outStr1 = "(Соло)Сортировка\n";
                    //SoloList_New.OrderBy(x => rnd.Next());
                    randomSort(SoloList_New);
                    foreach (Duet soloItem in SoloList_New)
                    {
                        outStr1 += soloItem.ToString();
                    }
                    //MessageBox.Show(outStr1);

                    outStr = "";
                    tournir.groups[i].SetList.Clear();

                    //Заходы для пар
                    int setCountInGroup = DuetList_New.Count / duetCountInSet;
                    int remainder       = DuetList_New.Count % duetCountInSet;
                    int h = 0;

                    outStr += "Группа " + (i + 1).ToString() + "\n";
                    for (h = 0; h < setCountInGroup; h++)
                    {
                        tournir.groups[i].SetList.Add(new SetClass(i, h + 1 /*Добавить категорию*/));
                        outStr += "Заход " + (tournir.groups[i].SetList.Count).ToString() + "\n";
                        for (int h1 = 0; h1 < duetCountInSet; h1++)
                        {
                            if (index <= DuetList_New.Count - 1)
                            {
                                tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Add(DuetList_New[index]);
                                outStr += "Пара " + (tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Count).ToString() + "\n";
                                outStr += DuetList_New[index].ToString() + "\n";
                                index++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    tournir.groups[i].SetList.Add(new SetClass(i, h + 1 /*Добавить категорию*/));
                    outStr += "Заход " + (tournir.groups[i].SetList.Count).ToString() + "\n";
                    for (int h1 = 0; h1 < remainder; h1++)
                    {
                        if (index <= DuetList_New.Count - 1)
                        {
                            tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Add(DuetList_New[index]);
                            outStr += "Пара " + (tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Count).ToString() + "\n";
                            outStr += DuetList_New[index].ToString() + "\n";
                            index++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    ////Заходы для солистов
                    //setCountInGroup = DuetList_New.Count / duetCountInSet;
                    //remainder = DuetList_New.Count % duetCountInSet;
                    //int g = h;

                    //outStr += "Группа " + (i + 1).ToString() + "\n";
                    //for (h = 0; h < setCountInGroup; h++)
                    //{
                    //    tournir.groups[i].SetList.Add(new SetClass(i, g + h/*Добавить категорию*/));
                    //    outStr += "Заход " + (tournir.groups[i].SetList.Count).ToString() + "\n";
                    //    for (int h1 = 0; h1 < duetCountInSet; h1++)
                    //    {
                    //        if (index <= SoloList_New.Count - 1)
                    //        {
                    //            tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Add(SoloList_New[index]);
                    //            outStr += "Пара " + (tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Count).ToString() + "\n";
                    //            outStr += SoloList_New[index].ToString() + "\n";
                    //            index++;
                    //        }
                    //        else
                    //            break;
                    //    }
                    //}

                    //tournir.groups[i].SetList.Add(new SetClass(i, g + h + 1/*Добавить категорию*/));
                    //outStr += "Заход " + (tournir.groups[i].SetList.Count).ToString() + "\n";
                    //for (int h1 = 0; h1 < remainder; h1++)
                    //{
                    //    if (index <= DuetList_New.Count - 1)
                    //    {
                    //        tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Add(SoloList_New[index]);
                    //        outStr += "Пара " + (tournir.groups[i].SetList[tournir.groups[i].SetList.Count - 1].DuetList.Count).ToString() + "\n";
                    //        outStr += SoloList_New[index].ToString() + "\n";
                    //        index++;
                    //    }
                    //    else
                    //        break;
                    //}

                    MessageBox.Show(outStr);
                    //for (int i1 = 0; i1 < DuetList_New.Count; i1++)
                    //{
                    //    if(index % duetCountInSet)
                    //    tournir.groups[i].SetList[index];
                    //    if ()
                    //}
                }
                con.Close();
                Controller.myConnection.Close();
            }
            else
            {
                MessageBox.Show("Не все поля заполнены!");
            }
        }
        public void autoFilling_second(Sportsman sportsman_second)
        {
            Name2textBox.Text       = sportsman_second.Name;
            Surname2textBox.Text    = sportsman_second.Surname;
            Patronymic2textBox.Text = sportsman_second.Patronymic;

            DayOfBirth2_comboBox.SelectedIndex    = sportsman_second.BirthDate.Day - 1;
            MounthOfBirth2_comboBox.SelectedIndex = sportsman_second.BirthDate.Mounth - 1;
            if (sportsman_second.BirthDate.Year > 0)
            {
                YearOfBirth2_comboBox.SelectedIndex = 2020 - sportsman_second.BirthDate.Year;
            }

            ClubName_textBox.Text = sportsman_second.ClubName;
            City_textBox.Text     = sportsman_second.City;

            SurnameOfDuetTrainer_textBox.Text    = sportsman_second.OlderTrainer.Surname;
            NameOfDuetTrainer_textBox.Text       = sportsman_second.OlderTrainer.Name;
            PatronymicOfDuetTrainer_textBox.Text = sportsman_second.OlderTrainer.Patronymic;

            switch (sportsman_second.SportCategory)
            {
            case "Ю-I":
                SportCategory2_comboBox.SelectedIndex = 0;
                break;

            case "Ю-II":
                SportCategory2_comboBox.SelectedIndex = 1;
                break;

            case "Ю-III":
                SportCategory2_comboBox.SelectedIndex = 2;
                break;

            case "Вз-I":
                SportCategory2_comboBox.SelectedIndex = 3;
                break;

            case "Вз-II":
                SportCategory2_comboBox.SelectedIndex = 4;
                break;

            case "Вз-III":
                SportCategory2_comboBox.SelectedIndex = 5;
                break;

            case "КМС":
                SportCategory2_comboBox.SelectedIndex = 6;
                break;

            case "МС":
                SportCategory2_comboBox.SelectedIndex = 7;
                break;

            case "МСМК":
                SportCategory2_comboBox.SelectedIndex = 8;
                break;
            }

            switch (sportsman_second.SportClass)
            {
            case "H":
            case "Н":
                SportClass2_comboBox.SelectedIndex = 0;
                break;

            case "E":
            case "Е":
                SportClass2_comboBox.SelectedIndex = 1;
                break;

            case "Д":
                SportClass2_comboBox.SelectedIndex = 2;
                break;

            case "C":
            case "С":
                SportClass2_comboBox.SelectedIndex = 3;
                break;

            case "B":
            case "В":
                SportClass2_comboBox.SelectedIndex = 4;
                break;

            case "A":
            case "А":
                SportClass2_comboBox.SelectedIndex = 5;
                break;

            case "S":
                SportClass2_comboBox.SelectedIndex = 6;
                break;

            case "M":
            case "М":
                SportClass2_comboBox.SelectedIndex = 7;
                break;
            }
        }
        public static Sportsman SearchByBookNumber(int BookNumber)
        {
            Sportsman sportsman = new Sportsman();

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

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

            OleDbCommand command4 = new OleDbCommand("", myConnection);
            OleDbCommand command5 = new OleDbCommand("", myConnection);

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

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

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



            OleDbCommand command9  = new OleDbCommand("", myConnection); //OldTrainer.Surname
            OleDbCommand command10 = new OleDbCommand("", myConnection); //OldTrainer.Name
            OleDbCommand command11 = new OleDbCommand("", myConnection); //OldTrainer.Patronymic


            command1.CommandText = "SELECT Фамилия FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command1.Parameters.AddWithValue("BookNum", BookNumber);

            command2.CommandText = "SELECT Имя FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command2.Parameters.AddWithValue("BookNum", BookNumber);

            command3.CommandText = "SELECT Отчество FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command3.Parameters.AddWithValue("BookNum", BookNumber);

            command4.CommandText = "SELECT НазваниеКлуба FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command4.Parameters.AddWithValue("BookNum", BookNumber);

            command5.CommandText = "SELECT Город FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command5.Parameters.AddWithValue("BookNum", BookNumber);

            command6.CommandText = "SELECT ДатаРождения FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command6.Parameters.AddWithValue("BookNum", BookNumber);

            command7.CommandText = "SELECT СпортивныйКласс FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command7.Parameters.AddWithValue("BookNum", BookNumber);

            command8.CommandText = "SELECT Разряд FROM Sportsmans WHERE НомерКнижки = @BookNum";
            command8.Parameters.AddWithValue("BookNum", BookNumber);



            command9.CommandText = "SELECT Фамилия FROM Trainers WHERE НомерКнижки = @BookNum";
            command9.Parameters.AddWithValue("BookNum", BookNumber);

            command10.CommandText = "SELECT Имя FROM Trainers WHERE НомерКнижки = @BookNum";
            command10.Parameters.AddWithValue("BookNum", BookNumber);

            command11.CommandText = "SELECT Отчество FROM Trainers WHERE НомерКнижки = @BookNum";
            command11.Parameters.AddWithValue("BookNum", BookNumber);

            try
            {
                sportsman.Surname = command1.ExecuteScalar().ToString();

                sportsman.Name       = command2.ExecuteScalar().ToString();
                sportsman.Patronymic = command3.ExecuteScalar().ToString();
                sportsman.ClubName   = command4.ExecuteScalar().ToString();
                sportsman.City       = command5.ExecuteScalar().ToString();
                sportsman.BirthDate.ToInt(command6.ExecuteScalar().ToString());

                MessageBox.Show(sportsman.BirthDate.ToString());

                sportsman.SportClass    = command7.ExecuteScalar().ToString();
                sportsman.SportCategory = command8.ExecuteScalar().ToString();

                sportsman.OlderTrainer.Surname    = command9.ExecuteScalar().ToString();
                sportsman.OlderTrainer.Name       = command10.ExecuteScalar().ToString();
                sportsman.OlderTrainer.Patronymic = command11.ExecuteScalar().ToString();
            }
            catch (System.NullReferenceException ex)
            {
                MessageBox.Show("Спортсмен не найден!\n" + ex.Message);
            }
            return(sportsman);
        }
Example #14
0
        public void autoFillingCategoryAndClasses_second(Sportsman sportsman_second)
        {
            switch (sportsman_second.SportCategory)
            {
            case "Ю-I":
                SportCategory2_comboBox.SelectedIndex = 0;
                break;

            case "Ю-II":
                SportCategory2_comboBox.SelectedIndex = 1;
                break;

            case "Ю-III":
                SportCategory2_comboBox.SelectedIndex = 2;
                break;

            case "Вз-I":
                SportCategory2_comboBox.SelectedIndex = 3;
                break;

            case "Вз-II":
                SportCategory2_comboBox.SelectedIndex = 4;
                break;

            case "Вз-III":
                SportCategory2_comboBox.SelectedIndex = 5;
                break;

            case "КМС":
                SportCategory2_comboBox.SelectedIndex = 6;
                break;

            case "МС":
                SportCategory2_comboBox.SelectedIndex = 7;
                break;

            case "МСМК":
                SportCategory2_comboBox.SelectedIndex = 8;
                break;
            }

            switch (sportsman_second.SportClass)
            {
            case "H":
            case "Н":
                SportClass2_comboBox.SelectedIndex = 0;
                break;

            case "E":
            case "Е":
                SportClass2_comboBox.SelectedIndex = 1;
                break;

            case "Д":
                SportClass2_comboBox.SelectedIndex = 2;
                break;

            case "C":
            case "С":
                SportClass2_comboBox.SelectedIndex = 3;
                break;

            case "B":
            case "В":
                SportClass2_comboBox.SelectedIndex = 4;
                break;

            case "A":
            case "А":
                SportClass2_comboBox.SelectedIndex = 5;
                break;

            case "S":
                SportClass2_comboBox.SelectedIndex = 6;
                break;

            case "M":
            case "М":
                SportClass2_comboBox.SelectedIndex = 7;
                break;
            }
        }