//private void setGroupNumber_comboBox_SelectedIndexChanged(object sender, EventArgs e) //{ // try // { // if (Path_textBox.Text != "") // { // //setNumber_textBox.Text = Convert.ToString(tournir.groups[Convert.ToInt32(setGroupNumber_comboBox.Text) - 1].SetList.Count() + 1); // //setCategory_comboBox.Items.Clear(); // //MessageBox.Show($"{tournir.groups[Convert.ToInt32(setGroupNumber_comboBox.Text) - 1].CategoryList.Count}"); // string retStr = ""; // //foreach (string category in tournir.groups[Convert.ToInt32(setGroupNumber_comboBox.Text) - 1].CategoryList) // //{ // // setCategory_comboBox.Items.Add(category); // // retStr += category; // //} // //MessageBox.Show(retStr); // } // } // catch(Exception ex) // { // MessageBox.Show(ex.Message); // } //} private void configButton_Click(object sender, EventArgs e) { if (Path_textBox.Text != "") { tournir.Show(); } else { MessageBox.Show("Сперва необходимо выбрать базу турнира!"); } }
public static TournirClass TakeTournir(string cn) { connectString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={cn}"; myConnection = new OleDbConnection(connectString); myConnection.Open(); int Num = 1; TournirClass RetTournir = new TournirClass(); 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 tournir WHERE ID = @Num"; command1.Parameters.AddWithValue("Num", Num); command2.CommandText = "SELECT Дата_Проведения FROM tournir WHERE ID = @Num"; command2.Parameters.AddWithValue("Num", Num); command3.CommandText = "SELECT Время_Проведения FROM tournir WHERE ID = @Num"; command3.Parameters.AddWithValue("Num", Num); command4.CommandText = "SELECT Место_Проведения FROM tournir WHERE ID = @Num"; command4.Parameters.AddWithValue("Num", Num); command5.CommandText = "SELECT Организация FROM tournir WHERE ID = @Num"; command5.Parameters.AddWithValue("Num", Num); command6.CommandText = "SELECT ФИО_Секретаря FROM tournir WHERE ID = @Num"; command6.Parameters.AddWithValue("Num", Num); command7.CommandText = "SELECT ФИО_Регистратора FROM tournir WHERE ID = @Num"; command7.Parameters.AddWithValue("Num", Num); try { RetTournir.name = command1.ExecuteScalar().ToString(); RetTournir.date.ToInt(command2.ExecuteScalar().ToString()); RetTournir.time.ToInt(command3.ExecuteScalar().ToString()); RetTournir.place = command4.ExecuteScalar().ToString(); RetTournir.organisation = command5.ExecuteScalar().ToString(); RetTournir.secretary = command6.ExecuteScalar().ToString(); RetTournir.registrator = command7.ExecuteScalar().ToString(); //MessageBox.Show($"Турнир: {RetTournir.name}\nДата: {RetTournir.date}\nВремя: {RetTournir.time}\nМесто: {RetTournir.place}\nОрганизация: {RetTournir.organisation}\nСекретарь: {RetTournir.secretary}\nРегистратор: {RetTournir.registrator}"); //myConnection.Close(); } catch (Exception ex) { MessageBox.Show("Упс, что-то пошло не так... код 1\nError: " + ex.Message); } //заполнение Турнира try { int i = 1; int k = 0; string name = ""; command = new OleDbCommand("", myConnection); command.CommandText = "SELECT COUNT(Номер_Группы) FROM groups"; k = Convert.ToInt32(command.ExecuteScalar()); //MessageBox.Show("Количество групп: " + Convert.ToString(k)); while (i <= k) { myConnection = new OleDbConnection(connectString); myConnection.Open(); command = new OleDbCommand("", myConnection); command.CommandText = "SELECT Категория FROM groups WHERE Номер_Группы = @id"; command.Parameters.AddWithValue("id", i); name = Convert.ToString(command.ExecuteScalar()); RetTournir.groups.Add(new GroupClass(i, RetTournir.name, name)); RetTournir.groups[i - 1].CategoryList = TakeCategory(RetTournir.groups[i - 1], cn); RetTournir.groups[i - 1].DancesList = TakeDances(RetTournir.groups[i - 1], cn); RetTournir.groups[i - 1].JudgeList = TakeJudges(RetTournir.groups[i - 1], cn); //MessageBox.Show(RetTournir.groups[i - 1].show()); //MessageBox.Show("Вытягивание списка пар"); RetTournir.groups[i - 1].duetList = TakeDuets(RetTournir.groups[i - 1], cn); //MessageBox.Show(RetTournir.groups[i - 1].show()); i++; } } catch (Exception ex) { MessageBox.Show("Упс, что-то пошло не так при определении списка групп\nError: " + ex.Message); } //заполнение групп try { myConnection = new OleDbConnection(connectString); myConnection.Open(); BitArray checkArray = Controller.GapCounter("Номер", "judges", myConnection); int i1 = 0; int counter = 0; int k1 = 0; int max = 0; command = new OleDbCommand("", myConnection); command.CommandText = "SELECT COUNT(Номер) FROM judges"; command3 = new OleDbCommand("", myConnection); command3.CommandText = "SELECT MAX(Номер) FROM judges"; k1 = Convert.ToInt32(command.ExecuteScalar()); //MessageBox.Show("Количество судей: " + Convert.ToString(k1)); if (k1 > 0) { max = Convert.ToInt32(command3.ExecuteScalar()); //MessageBox.Show("Максимальный номер судьи: " + Convert.ToString(max)); foreach (bool item in checkArray) { if (i1 < max) { if (checkArray[i1]) { Judge judge_new = new Judge(); command1 = new OleDbCommand("SELECT ФИО FROM judges WHERE Номер = @id", myConnection); //NSP command1.Parameters.AddWithValue("id", i1 + 1); command2 = new OleDbCommand("SELECT Категория_Судейства FROM judges WHERE Номер = @id", myConnection); //JudjeClass command2.Parameters.AddWithValue("id", i1 + 1); judge_new.ToJudge(command1.ExecuteScalar().ToString()); judge_new.JudgeClass = command2.ExecuteScalar().ToString(); judge_new.Number = (ushort)(i1 + 1); judge_new.judgeChar = (char)(64 + judge_new.Number); RetTournir.judges.Add(judge_new); //MessageBox.Show(RetTournir.judges[i1 - counter].ToNSP() + " " + RetTournir.judges[i1 - counter].JudgeClass); } else { counter++; } } i1++; } } else { //MessageBox.Show($"Не зарегистрировано ниодного судьи!"); } } catch (Exception ex) { MessageBox.Show("Упс, что-то пошло не так при определении списка судей\nError: " + ex.Message); } //заполнение судей myConnection.Close(); RetTournir.Show(); return(RetTournir); }