예제 #1
0
 private void check_pair(int a, int b)//swap if exist
 {
     foreach (game g in tvlData.games)
     {
         if (((g.first == a) && (g.second == b)) || ((g.first == b) && (g.second == a)))
         {
             if (b != tvlData.players.Count - 1)
             {
                 int    p_num = MainForm.search_by_id(b);
                 player temp  = tvlData.players[p_num];
                 tvlData.players[p_num]     = tvlData.players[p_num + 1];
                 tvlData.players[p_num + 1] = temp;
             }
             else
             {
                 int    p_num = MainForm.search_by_id(a);// zero sometimes
                 player temp  = tvlData.players[p_num];
                 tvlData.players[p_num]     = tvlData.players[p_num - 1];
                 tvlData.players[p_num - 1] = temp;
             }
         }
     }
 }
예제 #2
0
        public string Ranks()
        {
            string   file_out     = "Выполнение разрядных норм " + DateTime.Today.ToShortDateString() + ".xlsx";
            string   file_in      = "разрядные нормы.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in); //Utils.GetFileInfo(file_in, false);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "разрядные нормы";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_name;
                worksheet.Cells["A3"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " " + tvlData.tournir_place;
                for (int i = 4; i < tvlData.players.Count - 2 + 4; i++)//add columns for opponents
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[5, i].Value = i - 2;
                }

                for (int i = 3; i < tvlData.players.Count - 1 + 4; i++)//set optimal columns width
                {
                    worksheet.Column(i).Width = 65 / tvlData.players.Count;
                }

                worksheet.Cells[4, 3, 4, tvlData.players.Count + 1].Merge = true;//merge opponents header

                int up_shift = 5;
                worksheet.InsertRow(up_shift + 2, tvlData.players.Count - 1, up_shift + 1);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = pl.fio();

                    for (int i = 3; i < 3 + tvlData.players.Count - 1; i++)//results (points)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.players[MainForm.search_by_id(pl.opponents[i - 3])].rank;
                    }
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 3].Value = pl.rank_INDEX; //необх кт
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 4].Value = pl.rank_coeft; //турн кт
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 5].Value = pl.point_norm; //норма очков
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 6].Value = pl.points;     // очки
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 7].Value = pl.rank;       //разр до
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Value = pl.new_rank;   //разр после
                    if (pl.rank_UP == 1)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Style.Font.Color.SetColor(System.Drawing.Color.Green);
                    }
                    if (pl.rank_UP == -1)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    }
                }
                worksheet.Cells[tvlData.players.Count + up_shift + 3, 5].Value = tvlData.tournir_main_judge;
                worksheet.Cells[tvlData.players.Count + up_shift + 5, 5].Value = tvlData.tournir_secretary;
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
            return(newFile.FullName);
        }
예제 #3
0
        private void Swiss_report()
        {
            if (MainForm.st == null)
            {
                MessageBox.Show("Сначала восстановите игру", "Внимание");
                return;
            }
            if (MainForm.st.finish != true)
            {
                MessageBox.Show("Турнир не завершен", "Внимание");
                return;
            }
            string   file_out     = "Турнир " + DateTime.Today.ToShortDateString() + " (швейцарская).xlsx";
            string   file_in      = "швейцарская.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "Тавлея (швейцарская)";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_name;
                worksheet.Cells["A3"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " " + tvlData.tournir_place;

                for (int i = 8; i < MainForm.st.tourscount - 1 + 8; i++)//add columns for tours
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[5, i].Value = i - 6;
                    worksheet.Column(i).Width   = 34 / MainForm.st.tourscount;//set optimal columns width
                }
                for (int i = 7; i < MainForm.st.tourscount - 1 + 8; i++)
                {
                    worksheet.Column(i).Width = 34 / MainForm.st.tourscount;       //set optimal columns width
                }
                worksheet.Cells[4, 7, 4, MainForm.st.tourscount + 6].Merge = true; //merge tours header

                int up_shift = 5;
                worksheet.InsertRow(up_shift + 2, tvlData.players.Count - 1, up_shift + 1);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = (pl.surname + " " + pl.name);
                    worksheet.Cells[pl_num + 1 + up_shift, 3].Value = pl.city;
                    worksheet.Cells[pl_num + 1 + up_shift, 4].Value = pl.year;
                    worksheet.Cells[pl_num + 1 + up_shift, 5].Value = pl.rank;
                    worksheet.Cells[pl_num + 1 + up_shift, 6].Value = pl.Adam;

                    for (int i = 7; i < 7 + MainForm.st.tourscount; i++)//results (points)
                    {
                        foreach (int g in pl.games)
                        {
                            if ((tvlData.games[g - 1].first == pl.id) && (tvlData.games[g - 1].round == i - 6))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt1 + "(" + tvlData.games[g - 1].second + ")";
                            }
                            if ((tvlData.games[g - 1].second == pl.id) && (tvlData.games[g - 1].round == i - 6))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt2 + "(" + tvlData.games[g - 1].first + ")";
                            }
                        }
                    }

                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 7].Value  = pl.points;
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 8].Value  = pl.coef[1];
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 9].Value  = pl.coef[5];
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 10].Value = pl.coef[2];
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 11].Value = pl.coef[3];
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 12].Value = pl.Adam_new;
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 13].Value = (pl.Adam_new - pl.Adam);
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 14].Value = pl.place;
                    worksheet.Cells[pl_num + 1 + up_shift, MainForm.st.tourscount + 15].Value = pl.new_rank;
                }
                worksheet.Cells[tvlData.players.Count + up_shift + 3, 5].Value = tvlData.tournir_main_judge;
                worksheet.Cells[tvlData.players.Count + up_shift + 5, 5].Value = tvlData.tournir_secretary;
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
        }
예제 #4
0
        private void Round_report2()
        {
            string   file_out     = "Турнир " + DateTime.Today.ToShortDateString() + " (КРУГОВАЯ).xlsx";
            string   file_in      = "круговая2.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in); //Utils.GetFileInfo(file_in, false);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "Тавлея (круговая)";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_name;
                worksheet.Cells["A3"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " " + tvlData.tournir_place;
                for (int i = 6; i < tvlData.players.Count - 1 + 6; i++)//add columns for opponents
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[5, i].Value = i - 4;
                }

                for (int i = 5; i < tvlData.players.Count - 1 + 6; i++)//set optimal columns width
                {
                    worksheet.Column(i).Width = 65 / tvlData.players.Count;
                }

                worksheet.Cells[4, 5, 4, tvlData.players.Count + 4].Merge = true;//merge opponents header

                int up_shift = 5;
                worksheet.InsertRow(up_shift + 2, tvlData.players.Count - 1, up_shift + 1);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = pl.fio();
                    worksheet.Cells[pl_num + 1 + up_shift, 3].Value = pl.year;
                    worksheet.Cells[pl_num + 1 + up_shift, 4].Value = pl.rank;
                    for (int i = 5; i < 5 + tvlData.players.Count; i++)//results (points)
                    {
                        foreach (int g in pl.games)
                        {
                            if ((tvlData.games[g - 1].first == pl.id) && (tvlData.games[g - 1].second == i - 4))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt1;
                            }
                            if ((tvlData.games[g - 1].second == pl.id) && (tvlData.games[g - 1].first == i - 4))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt2;
                            }
                        }
                    }
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 5].Value = pl.points;
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 6].Value = pl.coef[2];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 7].Value = pl.place;
                }
                worksheet.Cells[tvlData.players.Count + up_shift + 3, 5].Value = tvlData.tournir_main_judge;
                worksheet.Cells[tvlData.players.Count + up_shift + 5, 5].Value = tvlData.tournir_secretary;
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
        }
예제 #5
0
        private string Round_report()
        {
            string   file_out     = "Турнир " + DateTime.Today.ToShortDateString() + " (КРУГОВАЯ - стар).xlsx";
            string   file_in      = "круговая.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in); //Utils.GetFileInfo(file_in, false);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "Тавлея (круговая)";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " ''" + tvlData.tournir_name + "'' " + tvlData.tournir_place;

                for (int i = 7; i < tvlData.players.Count - 1 + 7; i++)//add columns for opponents
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[4, i].Value = i - 5;
                }

                for (int i = 6; i < tvlData.players.Count - 1 + 7; i++)//set optimal columns width
                {
                    worksheet.Column(i).Width = 40 / tvlData.players.Count;
                }

                worksheet.Cells[3, 6, 3, tvlData.players.Count + 5].Merge = true;//merge opponents header

                int up_shift = 4;
                worksheet.InsertRow(6, tvlData.players.Count - 1, 5);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = (pl.surname + " " + pl.name);
                    worksheet.Cells[pl_num + 1 + up_shift, 3].Value = pl.year;
                    worksheet.Cells[pl_num + 1 + up_shift, 4].Value = pl.Adam;
                    worksheet.Cells[pl_num + 1 + up_shift, 5].Value = pl.rank;
                    for (int i = 6; i < 6 + tvlData.players.Count; i++)//results (points)
                    {
                        foreach (int g in pl.games)
                        {
                            if ((tvlData.games[g - 1].first == pl.id) && (tvlData.games[g - 1].second == i - 5))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt1;
                            }
                            if ((tvlData.games[g - 1].second == pl.id) && (tvlData.games[g - 1].first == i - 5))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt2;
                            }
                        }
                    }
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 6].Value  = pl.points;
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 7].Value  = pl.coef[5];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 8].Value  = pl.coef[4];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 9].Value  = pl.coef[2];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 10].Value = pl.coef[3];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 11].Value = pl.Adam_new;
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 12].Value = (pl.Adam_new - pl.Adam);
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 13].Value = pl.place;
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 14].Value = pl.new_rank;
                }
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
            return(newFile.FullName);
        }
예제 #6
0
 public void init()
 {
     if (mode == 1)//add
     {
         if (tvlData.players.Count == 0)
         {
             this.Text = "Добавление участника ID: " + (0 + 1);
         }
         else
         {
             this.Text = "Добавление участника ID: " + (tvlData.players.Last().id + 1);
         }
         Addbutton.Text             = "Добавить";
         CitytextBox.Text           = "Севастополь";
         RankcomboBox.SelectedIndex = 0;
         SexcomboBox.SelectedIndex  = 0;
         Plusbutton.Enabled         = false;
         button_next.Enabled        = false;
         button_prev.Enabled        = false;
     }
     if (mode == 2 || mode == 3)//edit or view (data load)
     {
         this.Text           = "Редактирование данных участника ID: " + (tvlData.players[id].id);
         Addbutton.Text      = "Сохранить";
         pl                  = tvlData.players[id];
         SNtextBox.Text      = pl.surname;
         NtextBox.Text       = pl.name;
         PtextBox.Text       = pl.patronymic;
         CommandtextBox.Text = pl.group;
         YeartextBox.Text    = pl.year.ToString();
         CitytextBox.Text    = pl.city.ToString();
         RankcomboBox.Text   = pl.rank;
         SexcomboBox.Text    = pl.gender;
         Adam1textBox.Text   = pl.Adam.ToString();
         Adam2textBox.Text   = pl.Adam_new.ToString();
         //coefts
         Bcoef.Text  = pl.coef[1].ToString();
         Rcoef.Text  = pl.coef[2].ToString();
         Gcoef.Text  = pl.coef[3].ToString();
         SDcoef.Text = pl.coef[4].ToString();
         ZBcoef.Text = pl.coef[5].ToString();
         Scoef.Text  = pl.coef[6].ToString();
         cScoef.Text = pl.coef[7].ToString();
         //adv
         points_textBox.Text = pl.points.ToString();
         Pluses_textBox.Text = pl.pluses;
         games_textBox.Text  = String.Join(", ", pl.games.ToArray());
         win_textBox.Text    = String.Join(", ", pl.wins.ToArray());
         mid_textBox.Text    = String.Join(", ", pl.mid.ToArray());
         lost_textBox.Text   = String.Join(", ", pl.lost.ToArray());
         mark_textBox.Text   = pl.mark;
     }
     if (mode == 3)//view
     {
         this.Height             = 375;
         Addbutton.Text          = "Закрыть";
         this.Text               = "Просмотр данных участника ID: " + (tvlData.players[id].id);
         SNtextBox.ReadOnly      = true;
         NtextBox.ReadOnly       = true;
         PtextBox.ReadOnly       = true;
         SexcomboBox.Enabled     = false;
         RankcomboBox.Enabled    = false;
         YeartextBox.ReadOnly    = true;
         CommandtextBox.ReadOnly = true;
         CitytextBox.ReadOnly    = true;
         Adam1textBox.ReadOnly   = true;
         Adam2textBox.ReadOnly   = true;
     }
 }