コード例 #1
0
ファイル: Stats.cs プロジェクト: Pavlo7/NBLStats
        private void init_data()
        {
            string   text;
            DateTime dt;

            g_f = false;

            CPlayer clPlayer;

            STStats itog = new STStats();

            try
            {
                dataGridViewStats.Rows.Clear();

                list = clStats.GetList(IS.idseason, (int)gSTGame.idgame, curridteam);

                list.Sort(clfs);

                if (list.Count < 12)
                {
                    groupBoxAdd.Enabled = true;
                }
                else
                {
                    groupBoxAdd.Enabled = false;
                }

                if (list.Count > 0)
                {
                    g_f = true;

                    dataGridViewStats.Rows.Add(list.Count + 1);

                    for (int i = 0; i < list.Count; i++)
                    {
                        if (flawour.Equals(list[i]))
                        {
                            gpos = i;
                        }

                        if (list[i].flagstart == 1)
                        {
                            dataGridViewStats.Rows[i].DefaultCellStyle.BackColor = Color.LightYellow;
                        }
                        else
                        {
                            dataGridViewStats.Rows[i].DefaultCellStyle.BackColor = Color.White;
                        }

                        /* игровой номер */
                        dataGridViewStats.Rows[i].Cells[0].Value = list[i].number;
                        /* фамилия имя */
                        clPlayer = new CPlayer(connect, list[i].idplayer);
                        dataGridViewStats.Rows[i].Cells[1].Value = string.Format("{0} {1}",
                                                                                 clPlayer.stPlayer.family, clPlayer.stPlayer.name);
                        /* очки */
                        dataGridViewStats.Rows[i].Cells[2].Value = list[i].points.ToString();
                        itog.points += list[i].points;
                        /* 2 */
                        dataGridViewStats.Rows[i].Cells[3].Value = string.Format("{0}\\{1}",
                                                                                 list[i].hfg, list[i].afg);
                        itog.afg += list[i].afg;
                        itog.hfg += list[i].hfg;
                        /* 3 */
                        dataGridViewStats.Rows[i].Cells[4].Value = string.Format("{0}\\{1}",
                                                                                 list[i].h3fg, list[i].a3fg);
                        itog.a3fg += list[i].a3fg;
                        itog.h3fg += list[i].h3fg;
                        /* штрафные */
                        dataGridViewStats.Rows[i].Cells[5].Value = string.Format("{0}\\{1}",
                                                                                 list[i].hft, list[i].aft);
                        itog.aft += list[i].aft;
                        itog.hft += list[i].hft;
                        /* подборы */
                        dataGridViewStats.Rows[i].Cells[6].Value = string.Format("{0} ({1}\\{2})",
                                                                                 list[i].rebounds, list[i].rebits, list[i].rebstg);
                        itog.rebounds += list[i].rebounds;
                        itog.rebits   += list[i].rebits;
                        itog.rebstg   += list[i].rebstg;
                        /* передачи */
                        dataGridViewStats.Rows[i].Cells[7].Value = list[i].assists.ToString();
                        itog.assists += list[i].assists;
                        /* перехваты */
                        dataGridViewStats.Rows[i].Cells[8].Value = list[i].steals.ToString();
                        itog.steals += list[i].steals;
                        /* блок-шоты */
                        dataGridViewStats.Rows[i].Cells[9].Value = list[i].blocks.ToString();
                        itog.blocks += list[i].blocks;
                        /* фолы соперников */
                        dataGridViewStats.Rows[i].Cells[10].Value = list[i].foulsadv.ToString();
                        itog.foulsadv  += list[i].foulsadv;
                        itog.foulsd    += list[i].foulsd;
                        itog.foulsdash += list[i].foulsdash;
                        itog.foulst    += list[i].foulst;
                        itog.foulsu    += list[i].foulsu;
                        /* потери */
                        dataGridViewStats.Rows[i].Cells[11].Value = string.Format("{0} ({1}\\{2})",
                                                                                  list[i].turnovers, list[i].turnass, list[i].turnteh);
                        itog.turnovers += list[i].turnovers;
                        itog.turnass   += list[i].turnass;
                        itog.turnteh   += list[i].turnteh;
                        /* фолы */
                        text = string.Format("{0} ({1}/{2}/{3}/{4})", list[i].psfouls, list[i].foulsu, list[i].foulst,
                                             list[i].foulsd, list[i].foulsdash);
                        dataGridViewStats.Rows[i].Cells[12].Value = text;
                        itog.psfouls += list[i].psfouls;
                        /* сыграное время */
                        dataGridViewStats.Rows[i].Cells[13].Value = string.Format("{0:00}:{1:00}",
                                                                                  list[i].ptime / 60, list[i].ptime % 60);
                        itog.ptime += list[i].ptime;
                        /* +\- */
                        dataGridViewStats.Rows[i].Cells[14].Value = list[i].pm.ToString();
                        itog.pm += list[i].pm;
                        /* КПИ */
                        KPI kpi = new KPI(list[i]);
                        text = string.Format("{0:f3}", kpi.kpi);
                        dataGridViewStats.Rows[i].Cells[15].Value = text;
                    }

                    dataGridViewStats.Rows[list.Count].Cells[1].Value = "ИТОГО:";
                    /* очки */
                    dataGridViewStats.Rows[list.Count].Cells[2].Value = itog.points.ToString();
                    /* 2 */
                    dataGridViewStats.Rows[list.Count].Cells[3].Value = string.Format("{0}\\{1}",
                                                                                      itog.hfg, itog.afg);
                    /* 3 */
                    dataGridViewStats.Rows[list.Count].Cells[4].Value = string.Format("{0}\\{1}",
                                                                                      itog.h3fg, itog.a3fg);
                    /* штрафные */
                    dataGridViewStats.Rows[list.Count].Cells[5].Value = string.Format("{0}\\{1}",
                                                                                      itog.hft, itog.aft);
                    /* подборы */
                    dataGridViewStats.Rows[list.Count].Cells[6].Value = string.Format("{0} ({1}\\{2})",
                                                                                      itog.rebounds, itog.rebits, itog.rebstg);
                    /* передачи */
                    dataGridViewStats.Rows[list.Count].Cells[7].Value = itog.assists.ToString();
                    /* перехваты */
                    dataGridViewStats.Rows[list.Count].Cells[8].Value = itog.steals.ToString();
                    /* блок-шоты */
                    dataGridViewStats.Rows[list.Count].Cells[9].Value = itog.blocks.ToString();
                    /* фолы соперников */
                    dataGridViewStats.Rows[list.Count].Cells[10].Value = itog.foulsadv.ToString();
                    /* потери */
                    dataGridViewStats.Rows[list.Count].Cells[11].Value = string.Format("{0} ({1}\\{2})",
                                                                                       itog.turnovers, itog.turnass, itog.turnteh);
                    /* фолы */
                    dataGridViewStats.Rows[list.Count].Cells[12].Value = string.Format("{0} ({1}/{2}/{3}/{4})",
                                                                                       itog.psfouls, itog.foulsu, itog.foulst, itog.foulsd, itog.foulsdash);
                    /* сыграное время */
                    dataGridViewStats.Rows[list.Count].Cells[13].Value = string.Format("{0:000}:{1:00}",
                                                                                       itog.ptime / 60, itog.ptime % 60);
                    /* +\- */
                    dataGridViewStats.Rows[list.Count].Cells[14].Value = itog.pm.ToString();

                    if (itog.points == currentpoints)
                    {
                        dataGridViewStats.Rows[list.Count].DefaultCellStyle.BackColor = Color.LightGreen;
                    }
                    else
                    {
                        dataGridViewStats.Rows[list.Count].DefaultCellStyle.BackColor = Color.Red;
                    }

                    dataGridViewStats.ClearSelection();

                    dataGridViewStats.AllowUserToAddRows = false;
                }
                else
                {
                    dataGridViewStats.AllowUserToAddRows = false;
                }

                init_combo();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }