private void Start() { CEntryPlayers clEP = new CEntryPlayers(connect); List <STEntryPlayers> data_list = clEP.GetListEntryPlayers(IS.idseason, 0, "IdTeam"); RecordDisplayStats record; CEntryTeam clET; CStats clSatas = new CStats(connect); List <STStats> stats; STParamStats prst; CPlayer clPlayer; string text; try { container = new List <RecordDisplayStats>(); foreach (STEntryPlayers data in data_list) { if (data.dateout == null) { record = new RecordDisplayStats(); /* Номер и команда */ record.idplayer = data.idplayer; clPlayer = new CPlayer(connect, data.idplayer); text = string.Format("{0} {1}", clPlayer.stPlayer.family.ToUpper(), clPlayer.stPlayer.name); record.fio = text; record.idteam = data.idteam; clTeam = new CTeam(connect, data.idteam); record.nameteam = clTeam.stTeam.name; /*Дивизион */ clET = new CEntryTeam(connect, IS.idseason, data.idteam); record.iddivision = clET.gstTeamPart.iddivision; /* Гражданство */ clPlayer = new CPlayer(connect, data.idplayer); if (clPlayer.stPlayer.idcountry != null) { record.idcountry = (int)clPlayer.stPlayer.idcountry; } else { record.idcountry = 0; } /* Число сезонов */ record.cntseason = clEP.GetCntSeasonPlayer(data.idplayer); /* Возраст */ CAge age = new CAge(); if (clPlayer.stPlayer.datebirth != null) { record.age = age.GetAge((DateTime)clPlayer.stPlayer.datebirth, DateTime.Now); record.agestart = age.GetAge((DateTime)clPlayer.stPlayer.datebirth, IS.datebegin); } else { record.age = 0; record.agestart = 0; } /* Считам статистику */ prst = new STParamStats(); prst.idseason = IS.idseason; prst.idplayer = data.idplayer; stats = clSatas.GetStats(prst); if (stats.Count > 0) { foreach (STStats statplayer in stats) { record.cntgame++; record.afg += statplayer.afg; record.a3fg += statplayer.a3fg; record.aft += statplayer.aft; record.hfg += statplayer.hfg; record.h3fg += statplayer.h3fg; record.hft += statplayer.hft; record.points += statplayer.points; record.rebits += statplayer.rebits; record.rebounds += statplayer.rebounds; record.rebstg += statplayer.rebstg; record.assists += statplayer.assists; record.steals += statplayer.steals; record.blocks += statplayer.blocks; record.foulsadv += statplayer.foulsadv; record.turnass += statplayer.turnass; record.turnovers += statplayer.turnovers; record.turnteh += statplayer.turnteh; record.psfouls += statplayer.psfouls; record.ptime += statplayer.ptime; record.pm += statplayer.pm; KPI kpi = new KPI(statplayer); record.kpi += kpi.kpi; } if (record.afg > 0) { record.pc2 = (1.0 * record.hfg) / record.afg * 100; } else { record.pc2 = 0; } if (record.a3fg > 0) { record.pc3 = (1.0 * record.h3fg) / record.a3fg * 100; } else { record.pc3 = 0; } if (record.aft > 0) { record.pcft = (1.0 * record.hft) / record.aft * 100; } else { record.pcft = 0; } if (record.afg + record.a3fg > 0) { record.pcall = ((1.0 * record.hfg + record.h3fg) / (record.afg + record.a3fg)) * 100; } else { record.pcall = 0; } if (record.cntgame > 0) { record.averpoints = 1.0 * record.points / record.cntgame; record.averrebounds = 1.0 * record.rebounds / record.cntgame; record.averassists = 1.0 * record.assists / record.cntgame; record.averblocks = 1.0 * record.blocks / record.cntgame; record.aversteals = 1.0 * record.steals / record.cntgame; record.averfoulsadv = 1.0 * record.foulsadv / record.cntgame; record.averkpi = 1.0 * record.kpi / record.cntgame; record.averptime = 1.0 * record.ptime / record.cntgame; record.averturnovers = 1.0 * record.turnovers / record.cntgame; record.averafg = 1.0 * record.afg / record.cntgame; record.avera3fg = 1.0 * record.a3fg / record.cntgame; record.averaft = 1.0 * record.aft / record.cntgame; record.averhfg = 1.0 * record.hfg / record.cntgame; record.averh3fg = 1.0 * record.h3fg / record.cntgame; record.averhft = 1.0 * record.hft / record.cntgame; record.averpsfouls = 1.0 * record.psfouls / record.cntgame; if (record.averafg > 0) { record.averpc2 = (1.0 * record.averhfg) / record.averafg * 100; } else { record.averpc2 = 0; } if (record.avera3fg > 0) { record.averpc3 = (1.0 * record.averh3fg) / record.avera3fg * 100; } else { record.averpc3 = 0; } if (record.averaft > 0) { record.averpcft = (1.0 * record.averhft) / record.averaft * 100; } else { record.averpcft = 0; } if (record.averafg + record.avera3fg > 0) { record.averpcall = ((1.0 * record.averhfg + record.averh3fg) / (record.averafg + record.avera3fg)) * 100; } else { record.averpcall = 0; } } else { record.averpoints = 0; record.averrebounds = 0; record.averassists = 0; record.averblocks = 0; record.aversteals = 0; record.averfoulsadv = 0; record.averkpi = 0; record.averptime = 0; record.averturnovers = 0; record.averafg = 0; record.avera3fg = 0; record.averaft = 0; record.averhfg = 0; record.averh3fg = 0; record.averhft = 0; record.averpcall = 0; record.averpcft = 0; record.averpc3 = 0; record.averpc2 = 0; record.averpsfouls = 0; } } container.Add(record); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private List <STDataRating> calculate() { List <STDataRating> ret = new List <STDataRating>(); STDataRating item; CPlayer clPlayer; List <STPlayer> lst_player; STPlayerParam paramPlayer = new STPlayerParam(); paramPlayer.idseason = null; CStats clStats; List <STStats> stStats; STParamStats paramStats; CEntryPlayers clEP; STEntryPlayers stEP; int idteam = 0; CTeam clTeam; try { clPlayer = new CPlayer(connect); clStats = new CStats(connect); clEP = new CEntryPlayers(connect); lst_player = clPlayer.GetList(paramPlayer); foreach (STPlayer st in lst_player) { item = new STDataRating(); clPlayer = new CPlayer(connect, st.idplayer); item.name = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name, clPlayer.stPlayer.payname); idteam = clEP.IsEntryPlayer(IS.idseason, st.idplayer); if (idteam > 0) { clTeam = new CTeam(connect, idteam); item.nameteam = clTeam.stTeam.name; } else { item.nameteam = "не заявлен в текущем сезоне"; } paramStats = new STParamStats(); paramStats.idplayer = st.idplayer; stStats = clStats.GetStats(paramStats); foreach (STStats stst in stStats) { item.cntgame++; item.points += stst.points; item.rebounds += stst.rebounds; item.steals += stst.steals; item.fouls += stst.psfouls; item.blocks += stst.blocks; item.assists += stst.assists; } ret.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void init_data_stats() { CStats clP = new CStats(connect); STParamStats param = new STParamStats(); string text; try { dataGridViewStats.Rows.Clear(); param.idgame = null; param.idseason = null; param.idteam = null; param.idplayer = gstPlayer.idplayer; param.order = "IdSeason,IdGame"; List <STStats> list = clP.GetStats(param);; if (list.Count > 0) { dataGridViewStats.Rows.Add(list.Count); for (int i = 0; i < list.Count; i++) { dataGridViewStats.Rows[i].Cells[0].Value = list[i].idseason.ToString(); dataGridViewStats.Rows[i].Cells[1].Value = list[i].idgame.ToString(); dataGridViewStats.Rows[i].Cells[2].Value = list[i].points.ToString(); dataGridViewStats.Rows[i].Cells[3].Value = string.Format("{0}\\{1}", list[i].hfg, list[i].afg); dataGridViewStats.Rows[i].Cells[4].Value = string.Format("{0}\\{1}", list[i].h3fg, list[i].a3fg); dataGridViewStats.Rows[i].Cells[5].Value = string.Format("{0}\\{1}", list[i].hft, list[i].aft); dataGridViewStats.Rows[i].Cells[6].Value = list[i].rebounds.ToString(); dataGridViewStats.Rows[i].Cells[7].Value = list[i].assists.ToString(); dataGridViewStats.Rows[i].Cells[8].Value = list[i].steals.ToString(); dataGridViewStats.Rows[i].Cells[9].Value = list[i].blocks.ToString(); dataGridViewStats.Rows[i].Cells[10].Value = list[i].foulsadv.ToString(); dataGridViewStats.Rows[i].Cells[11].Value = list[i].turnovers.ToString(); dataGridViewStats.Rows[i].Cells[12].Value = list[i].psfouls.ToString(); dataGridViewStats.Rows[i].Cells[13].Value = string.Format("{0:00}:{1:00}", list[i].ptime / 60, list[i].ptime % 60); dataGridViewStats.Rows[i].Cells[14].Value = list[i].pm.ToString(); KPI kpi = new KPI(list[i]); text = string.Format("{0:f3}", kpi.kpi); dataGridViewStats.Rows[i].Cells[15].Value = text; } dataGridViewStats.ClearSelection(); dataGridViewStats.AllowUserToAddRows = false; } else { dataGridViewStats.AllowUserToAddRows = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void insert_report(List <STGame> lst_game, StreamWriter sw, string name) { CStats clSatas = new CStats(connect); List <STStats> stats; STParamStats prst; List <STStats> data = new List <STStats>(); try { if (lst_game.Count > 0) { sw.WriteLine(name); sw.WriteLine("---------------------------"); sw.WriteLine("<p> </p>"); lst_center = new List <STDataSymbol5>(); lst_defender = new List <STDataSymbol5>(); lst_forward = new List <STDataSymbol5>(); data = new List <STStats>(); // вытягиваем стаистику foreach (STGame game in lst_game) { int r = 0; STStats newst; prst = new STParamStats(); prst.idseason = game.idseason; prst.idgame = game.idgame; prst.idteam = game.idteam1; stats = clSatas.GetStats(prst); if (game.apoints >= 0 && game.bpoints >= 0) { r = (int)game.apoints - (int)game.bpoints; } foreach (STStats st in stats) { newst = st; newst.pm = r; data.Add(newst); } prst = new STParamStats(); prst.idseason = game.idseason; prst.idgame = game.idgame; prst.idteam = game.idteam2; stats = clSatas.GetStats(prst); if (game.apoints >= 0 && game.bpoints >= 0) { r = (int)game.bpoints - (int)game.apoints; } foreach (STStats st in stats) { newst = st; newst.pm = r; data.Add(newst); } } // сортируем по id ListCompareStatsByID clCompareStats = new ListCompareStatsByID(); data.Sort(clCompareStats); // расчитываем int currid = 0; int curteam = 0; int cnt = 1; STDataSymbol5 item; CEntryPlayers clEP = new CEntryPlayers(connect); STEntryPlayers stEP; CTeam clTeam = new CTeam(connect); CPlayer clPlayer = new CPlayer(connect); int point = 0; int reb = 0; int ass = 0; int stl = 0; int blk = 0; int res = 0; double kf = 0; bool first = true; for (int i = 0; i < data.Count; i++) { if (first) { currid = data[0].idplayer; curteam = data[0].idteam; point = data[0].points; reb = data[0].rebounds; ass = data[0].assists; stl = data[0].steals; blk = data[0].blocks; res = data[0].pm; cnt = 1; first = false; } else { if (currid == data[i].idplayer) { cnt++; ass += data[i].assists; blk += data[i].blocks; point += data[i].points; reb += data[i].rebounds; stl += data[i].steals; res += data[i].pm; } else { // item = new STDataSymbol5(); clTeam = new CTeam(connect, curteam); clPlayer = new CPlayer(connect, currid); stEP = clEP.GetEntryPlayerLast(data[i].idseason, currid); item.team = clTeam.stTeam.name; item.name = clPlayer.stPlayer.family + " " + clPlayer.stPlayer.name; item.points = (1.0 * point) / cnt; item.assists = (1.0 * ass) / cnt; item.block = (1.0 * blk) / cnt; item.rebounds = (1.0 * reb) / cnt; item.steals = (1.0 * stl) / cnt; item.res = res; if (item.res > 30) { kf = 1.1; } if (item.res > 20 && item.res <= 30) { kf = 1.2; } if (item.res > 10 && item.res <= 20) { kf = 1.25; } if (item.res > 5 && item.res <= 10) { kf = 1.3; } if (item.res > 0 && item.res <= 5) { kf = 1.35; } if (item.res > -5 && item.res <= 0) { kf = 0.95; } if (item.res > -10 && item.res <= -5) { kf = 0.9; } if (item.res > -20 && item.res <= -10) { kf = 0.85; } if (item.res > -30 && item.res <= -20) { kf = 0.8; } if (item.res <= -30) { kf = 0.7; } if (stEP.amplua != null) { if (stEP.amplua == 1) { item.amplua = "защитник"; item.ball = ((item.points * 1.5) + (item.assists * 2.5) + item.rebounds + (item.steals * 2) + item.block) * kf; lst_defender.Add(item); } if (stEP.amplua == 2) { item.amplua = "форвард"; item.ball = ((item.points * 2.5) + (item.assists * 1.5) + item.rebounds + item.steals + item.block) * kf; lst_forward.Add(item); } if (stEP.amplua == 3) { item.amplua = "центровой"; item.ball = ((item.points + item.assists + (item.rebounds * 2.5) + item.steals + (item.block * 2))) * kf; lst_center.Add(item); } } currid = data[i].idplayer; curteam = data[i].idteam; point = data[i].points; reb = data[i].rebounds; ass = data[i].assists; stl = data[i].steals; blk = data[i].blocks; res = data[i].pm; cnt = 1; } } } item = new STDataSymbol5(); clTeam = new CTeam(connect, curteam); clPlayer = new CPlayer(connect, currid); stEP = clEP.GetEntryPlayerLast(IS.idseason, currid); item.team = clTeam.stTeam.name; item.name = clPlayer.stPlayer.family + " " + clPlayer.stPlayer.name; item.points = (1.0 * point) / cnt; item.assists = (1.0 * ass) / cnt; item.block = (1.0 * blk) / cnt; item.rebounds = (1.0 * reb) / cnt; item.steals = (1.0 * stl) / cnt; item.res = res; if (item.res > 30) { kf = 1.1; } if (item.res > 20 && item.res <= 30) { kf = 1.2; } if (item.res > 10 && item.res <= 20) { kf = 1.25; } if (item.res > 5 && item.res <= 10) { kf = 1.3; } if (item.res > 0 && item.res <= 5) { kf = 1.35; } if (item.res > -5 && item.res <= 0) { kf = 0.95; } if (item.res > -10 && item.res <= -5) { kf = 0.9; } if (item.res > -20 && item.res <= -10) { kf = 0.85; } if (item.res > -30 && item.res <= -20) { kf = 0.8; } if (item.res <= -30) { kf = 0.7; } if (stEP.amplua != null) { if (stEP.amplua == 1) { item.amplua = "защитник"; item.ball = ((item.points * 1.5) + (item.assists * 2.5) + item.rebounds + (item.steals * 2) + item.block) * kf; lst_defender.Add(item); } if (stEP.amplua == 2) { item.amplua = "форвард"; item.ball = ((item.points * 2.5) + (item.assists * 1.5) + item.rebounds + item.steals + item.block) * kf; lst_forward.Add(item); } if (stEP.amplua == 3) { item.amplua = "центровой"; item.ball = ((item.points + item.assists + (item.rebounds * 2.5) + item.steals + (item.block * 2))) * kf; lst_center.Add(item); } } // сортируем по баллам ListCompareByBall clComparyBall = new ListCompareByBall(); lst_center.Sort(clComparyBall); lst_defender.Sort(clComparyBall); lst_forward.Sort(clComparyBall); // выводим в файл int x = 1; foreach (STDataSymbol5 set in lst_defender) { // if (x == 5) break; sw.WriteLine(string.Format ("<p>{0,2}.{1,-20} ({2}) {3} , баллы:{4}, о:{5}, пб:{6}, пр:{7}, пх:{8}, б:{9}</p>", x, set.name, set.team, set.amplua, set.ball, set.points, set.rebounds, set.assists, set.steals, set.block)); x++; } foreach (STDataSymbol5 set in lst_forward) { // if (x == 9) break; sw.WriteLine(string.Format ("<p>{0,2}.{1,-20} ({2}) {3} , баллы:{4}, о:{5}, пб:{6}, пр:{7}, пх:{8}, б:{9}</p>", x, set.name, set.team, set.amplua, set.ball, set.points, set.rebounds, set.assists, set.steals, set.block)); x++; } foreach (STDataSymbol5 set in lst_center) { // if (x == 11) break; sw.WriteLine(string.Format ("<p>{0,2}.{1,-20} ({2}) {3} , баллы:{4}, о:{5}, пб:{6}, пр:{7}, пх:{8}, б:{9}</p>", x, set.name, set.team, set.amplua, set.ball, set.points, set.rebounds, set.assists, set.steals, set.block)); x++; } sw.WriteLine("<p> </p>"); sw.WriteLine("<p><img src=\"\" alt=\"\" /></p>"); sw.WriteLine("<p> </p>"); sw.WriteLine("<p> </p>"); sw.WriteLine("------------"); sw.WriteLine(""); sw.WriteLine(""); sw.WriteLine(""); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private List <RecordPlayerPreView> CalculateStats(List <STEntryPlayers> list_players) { List <RecordPlayerPreView> ret = new List <RecordPlayerPreView>(); RecordPlayerPreView item; STParamStats prst; int cntgame = 0; int afg = 0; int a3fg = 0; int aft = 0; int hfg = 0; int h3fg = 0; int hft = 0; int points = 0; int rebounds = 0; int assists = 0; int steals = 0; int blocks = 0; try { CStats clSatas = new CStats(connect); List <STStats> stats; foreach (STEntryPlayers data in list_players) { item = new RecordPlayerPreView(); item.idplayer = data.idplayer; /* Считам статистику */ prst = new STParamStats(); prst.idseason = IS.idseason; prst.idplayer = data.idplayer; stats = clSatas.GetStats(prst); cntgame = 0; afg = 0; a3fg = 0; aft = 0; hfg = 0; h3fg = 0; hft = 0; points = 0; rebounds = 0; assists = 0; steals = 0; blocks = 0; if (stats.Count > 0) { foreach (STStats statplayer in stats) { cntgame++; afg += statplayer.afg; a3fg += statplayer.a3fg; aft += statplayer.aft; hfg += statplayer.hfg; h3fg += statplayer.h3fg; hft += statplayer.hft; points += statplayer.points; rebounds += statplayer.rebounds; assists += statplayer.assists; steals += statplayer.steals; blocks += statplayer.blocks; } if (afg > 0) { item.pc2 = (1.0 * hfg) / afg * 100; } else { item.pc2 = 0; } if (a3fg > 0) { item.pc3 = (1.0 * h3fg) / a3fg * 100; } else { item.pc3 = 0; } if (aft > 0) { item.pcft = (1.0 * hft) / aft * 100; } else { item.pcft = 0; } if (afg + a3fg > 0) { item.pcall = ((1.0 * hfg + h3fg) / (afg + a3fg)) * 100; } else { item.pcall = 0; } if (cntgame > 0) { item.averpoints = 1.0 * points / cntgame; item.averpoints = 1.0 * rebounds / cntgame; item.averass = 1.0 * assists / cntgame; item.averstl = 1.0 * blocks / cntgame; item.averblk = 1.0 * steals / cntgame; } else { item.averpoints = 0; item.averpoints = 0; item.averass = 0; item.averstl = 0; item.averblk = 0; } } ret.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }