private STStats verify_player(STStats data) { STStats ret = new STStats(); try { CPlayer clPlayer = new CPlayer(connect, data.idplayer); if (clPlayer.stPlayer.idplayer <= 0) { ret = data; DlgEntryId dlg = new DlgEntryId(connect, IS, data.idteam, data.idgame, data.number); if (dlg.ShowDialog() == DialogResult.OK) { ret.idplayer = dlg.GetData(); } } else { ret = data; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void edit() { try { STStats data = GetSelectionData(); if (data.idplayer > 0) { DlgStats wnd = new DlgStats(connect, mode, data); DialogResult result = wnd.ShowDialog(); if (result == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewStats.Rows.Count > 0) { dataGridViewStats.Rows[gpos].Selected = true; // dataGridViewStats.FirstDisplayedScrollingRowIndex = gpos; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private STStats GetSelectionData() { STStats ret = new STStats(); string number = null; try { foreach (DataGridViewRow item in dataGridViewStats.SelectedRows) { if (item.Cells[0].Value != null) { number = item.Cells[0].Value.ToString().Trim(); } foreach (STStats stat in list) { if (stat.number == number) { ret = stat; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }
private void buttonSave_Click(object sender, EventArgs e) { try { stC = read_data(); clStats = new CStats(connect); if (type == 0) { if (clStats.Insert(stC)) { DialogResult = DialogResult.OK; } } else if (type == 1) { if (clStats.Update(stC, gSTStats.idseason, gSTStats.idgame, gSTStats.idplayer)) { DialogResult = DialogResult.OK; } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgStats(SqlConnection cn, ushort md, STStats st) { InitializeComponent(); connect = cn; gSTStats = st; idseason = gSTStats.idseason; idgame = gSTStats.idgame; idteam = gSTStats.idteam; idplayer = gSTStats.idplayer; type = 1; }
private void buttonAdd_Click(object sender, EventArgs e) { STEntryPlayers tc = new STEntryPlayers(); try { if (comboBoxPlayers.Text.Length > 0) { string text = comboBoxPlayers.Text.Trim(); char[] del = { '#', ' ' }; string[] words = text.Split(del); string number = words[1]; string famili = words[2]; string name = words[3]; foreach (STEntryPlayers item in currteam) { CPlayer clp = new CPlayer(connect, item.idplayer); if (number.Equals(item.number) && famili.Equals(clp.stPlayer.family) && name.Equals(clp.stPlayer.name)) { tc = item; } } DlgStats wnd = new DlgStats(connect, mode, tc.idseason, gSTGame.idgame, tc.idteam, tc.idplayer, tc.number, lst_records); if (wnd.ShowDialog() == DialogResult.OK) { flawour = wnd.GetFl(); init_data(); if (gpos >= 0 && dataGridViewStats.Rows.Count > 0) { dataGridViewStats.Rows[gpos].Selected = true; // dataGridViewStats.FirstDisplayedScrollingRowIndex = gpos; } if (wnd.GetRec()) { init_records(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
public DlgStats(SqlConnection cn, ushort md, STStats st, List <STRecordsPerson> rec) { InitializeComponent(); connect = cn; gSTStats = st; idseason = gSTStats.idseason; idgame = gSTStats.idgame; idteam = gSTStats.idteam; idplayer = gSTStats.idplayer; lst_records = rec; type = 1; }
private void del() { try { STStats data = GetSelectionData(); if (data.idplayer > 0) { if (MessageBox.Show("Вы действиетльно желаете удалить запись?", "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { clStats.Delete(data); init_data(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
private void verify_records(STStats stats) { CRecordsPerson clRec = new CRecordsPerson(connect); string text; STRecordsPerson newrecord; try { foreach (STRecordsPerson st in lst_records) { if (st.coderecord == 1) { if (stats.points > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 1; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.points; text = string.Format("Новый рекорд по очкам. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 2) { if (stats.rebounds > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 2; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.rebounds; text = string.Format("Новый рекорд по подборам. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 3) { if (stats.assists > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 3; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.assists; text = string.Format("Новый рекорд по результативным передачам. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 4) { if (stats.steals > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 4; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.steals; text = string.Format("Новый рекорд по перехватам. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 5) { if (stats.blocks > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 5; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.blocks; text = string.Format("Новый рекорд по блок-шотам. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 6) { if (stats.hfg > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 6; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.hfg; text = string.Format("Новый рекорд по количеству забитых средних бросков. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 7) { if (stats.h3fg > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 7; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.h3fg; text = string.Format("Новый рекорд по количеству забитых дальних бросков. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } if (st.coderecord == 8) { if (stats.hft > st.result) { newrecord = new STRecordsPerson(); newrecord.coderecord = 8; newrecord.iddivision = st.iddivision; newrecord.idgame = stats.idgame; newrecord.idplayer = stats.idplayer; newrecord.idseason = stats.idseason; newrecord.idteam = stats.idteam; newrecord.result = stats.hft; text = string.Format("Новый рекорд по количеству забитых штрафных бросков. Сохранить?"); if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { clRec.Update(newrecord, st); brec = true; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }
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); } }
private STStats read_data() { STStats ret = new STStats(); try { /* идентификатор сезона */ ret.idseason = idseason; /* идентификатор команды */ ret.idteam = idteam; /* идентификатор игры */ ret.idgame = idgame; /* идентификатор игрока */ ret.idplayer = idplayer; /* номер */ if (textBoxNumber.Text.Length > 0) { ret.number = textBoxNumber.Text.Trim(); } else { ret.number = null; } /* стартовый состав */ if (checkBoxStart.Checked == true) { ret.flagstart = 1; } else { ret.flagstart = 0; } /* очки */ if (textBoxPoints.Text.Length > 0) { ret.points = int.Parse(textBoxPoints.Text.Trim()); } else { ret.points = 0; } /* броски */ if (numericUpDownAFG.Text.Length > 0) { ret.afg = int.Parse(numericUpDownAFG.Text.Trim()); } else { ret.afg = 0; } if (numericUpDownHFG.Text.Length > 0) { ret.hfg = int.Parse(numericUpDownHFG.Text.Trim()); } else { ret.hfg = 0; } if (numericUpDownA3FG.Text.Length > 0) { ret.a3fg = int.Parse(numericUpDownA3FG.Text.Trim()); } else { ret.a3fg = 0; } if (numericUpDownH3FG.Text.Length > 0) { ret.h3fg = int.Parse(numericUpDownH3FG.Text.Trim()); } else { ret.h3fg = 0; } if (numericUpDownAFT.Text.Length > 0) { ret.aft = int.Parse(numericUpDownAFT.Text.Trim()); } else { ret.aft = 0; } if (numericUpDownHFT.Text.Length > 0) { ret.hft = int.Parse(numericUpDownHFT.Text.Trim()); } else { ret.hft = 0; } /* подборы */ if (textBoxRebounds.Text.Length > 0) { ret.rebounds = int.Parse(textBoxRebounds.Text.Trim()); } else { ret.rebounds = 0; } if (numericUpDownRebIts.Text.Length > 0) { ret.rebits = int.Parse(numericUpDownRebIts.Text.Trim()); } else { ret.rebits = 0; } if (numericUpDownRebStg.Text.Length > 0) { ret.rebstg = int.Parse(numericUpDownRebStg.Text.Trim()); } else { ret.rebstg = 0; } /* передачи */ if (numericUpDownAssists.Text.Length > 0) { ret.assists = int.Parse(numericUpDownAssists.Text.Trim()); } else { ret.assists = 0; } /* перехваты */ if (numericUpDownSteals.Text.Length > 0) { ret.steals = int.Parse(numericUpDownSteals.Text.Trim()); } else { ret.steals = 0; } /* блоки */ if (numericUpDownBlock.Text.Length > 0) { ret.blocks = int.Parse(numericUpDownBlock.Text.Trim()); } else { ret.blocks = 0; } /* фолы соперников */ if (numericUpDownFoulsAdv.Text.Length > 0) { ret.foulsadv = int.Parse(numericUpDownFoulsAdv.Text.Trim()); } else { ret.foulsadv = 0; } /* фолы*/ if (numericUpDownFouls.Text.Length > 0) { ret.psfouls = int.Parse(numericUpDownFouls.Text.Trim()); } else { ret.psfouls = 0; } if (numericUpDownFoulsU.Text.Length > 0) { ret.foulsu = int.Parse(numericUpDownFoulsU.Text.Trim()); } else { ret.foulsu = 0; } if (numericUpDownFoulsT.Text.Length > 0) { ret.foulst = int.Parse(numericUpDownFoulsT.Text.Trim()); } else { ret.foulst = 0; } if (numericUpDownFoulsD.Text.Length > 0) { ret.foulsd = int.Parse(numericUpDownFoulsD.Text.Trim()); } else { ret.foulsd = 0; } if (numericUpDownFoulsDash.Text.Length > 0) { ret.foulsdash = int.Parse(numericUpDownFoulsDash.Text.Trim()); } else { ret.foulsdash = 0; } /* потери */ if (textBoxTurnovers.Text.Length > 0) { ret.turnovers = int.Parse(textBoxTurnovers.Text.Trim()); } else { ret.turnovers = 0; } if (numericUpDownTurnAss.Text.Length > 0) { ret.turnass = int.Parse(numericUpDownTurnAss.Text.Trim()); } else { ret.turnass = 0; } if (numericUpDownTurnTeh.Text.Length > 0) { ret.turnteh = int.Parse(numericUpDownTurnTeh.Text.Trim()); } else { ret.turnteh = 0; } /* потери */ if (textBoxTime.Text.Length > 0) { ret.ptime = int.Parse(textBoxTime.Text.Trim()); } else { ret.ptime = 0; } /* +\- */ if (textBoxPM.Text.Length > 0) { ret.pm = int.Parse(textBoxPM.Text.Trim()); } else { ret.pm = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } return(ret); }