private void AddRow(DataTable penaltyTable, IPenalty penalty) { DataRow row = penaltyTable.NewRow(); row["PenaltyObject"] = (object)penalty; row["Player"] = (object)penalty.Player.FullName; row["Infraction"] = (object)PenaltyClass.GetName(penalty.Infraction); row["Penalty"] = (object)CommonEnumLists.PenaltyEnumNames[penalty.Penalty]; row["Round"] = (object)penalty.Round; row["Judge"] = (object)penalty.Judge.FullName; row["Notes"] = (object)penalty.Notes; penaltyTable.Rows.Add(row); }
private void DialogPenalties_Load(object sender, EventArgs e) { DataTable table = this.GenerateTable(); foreach (IPenalty penalty in this.currentTournament.Penalties) { DataRow row = table.NewRow(); row["PenaltyObject"] = (object)penalty; row["Player"] = (object)penalty.Player.FullName; row["Infraction"] = (object)PenaltyClass.GetName(penalty.Infraction); row["Penalty"] = (object)CommonEnumLists.PenaltyEnumNames[penalty.Penalty]; row["Round"] = (object)penalty.Round; row["Judge"] = (object)penalty.Judge.FullName; row["Notes"] = (object)penalty.Notes; table.Rows.Add(row); } this.dgPenalties.DataSource = (object)table; this.dgPenalties.Columns["PenaltyObject"].Visible = false; if (this.PreselectedPlayer == null) { return; } int val1 = 1000000; for (int val2 = 0; val2 < this.dgPenalties.Rows.Count; ++val2) { DataGridViewRow row = this.dgPenalties.Rows[val2]; if (((PenaltyClass)row.Cells["PenaltyObject"].Value).Player.ID == this.PreselectedPlayer.ID) { if (val1 == 1000000) { val1 = Math.Min(val1, val2); this.dgPenalties.FirstDisplayedScrollingRowIndex = val1; } row.Selected = true; break; } row.Selected = false; } if (val1 != 1000000) { return; } int num = (int)MessageBox.Show(string.Format("{0} does not have any penalties", (object)this.PreselectedPlayer.FullNameWithId)); }
private void btnEditPenalty_Click(object sender, EventArgs e) { if (this.dgPenalties.SelectedRows.Count != 1) { return; } DialogNewPenalty dialogNewPenalty = new DialogNewPenalty(); dialogNewPenalty.CurrentTournament = this.currentTournament; dialogNewPenalty.CurrentPenalty = (IPenalty)this.dgPenalties.SelectedRows[0].Cells["PenaltyObject"].Value; if (dialogNewPenalty.ShowDialog() != DialogResult.OK) { return; } this.dgPenalties.SelectedRows[0].Cells["PenaltyObject"].Value = (object)dialogNewPenalty.CurrentPenalty; this.dgPenalties.SelectedRows[0].Cells["Player"].Value = (object)dialogNewPenalty.CurrentPenalty.Player.FullName; this.dgPenalties.SelectedRows[0].Cells["Infraction"].Value = (object)PenaltyClass.GetName(dialogNewPenalty.CurrentPenalty.Infraction); this.dgPenalties.SelectedRows[0].Cells["Penalty"].Value = (object)CommonEnumLists.PenaltyEnumNames[dialogNewPenalty.CurrentPenalty.Penalty]; this.dgPenalties.SelectedRows[0].Cells["Round"].Value = (object)dialogNewPenalty.CurrentPenalty.Round; this.dgPenalties.SelectedRows[0].Cells["Judge"].Value = (object)dialogNewPenalty.CurrentPenalty.Judge.FullName; this.dgPenalties.SelectedRows[0].Cells["Notes"].Value = (object)dialogNewPenalty.CurrentPenalty.Notes; }
private void DialogNewPenalty_Load(object sender, EventArgs e) { if (this.CurrentTournament != null) { ITournPlayer[] array1 = new ITournPlayer[this.CurrentTournament.Players.Count]; this.CurrentTournament.Players.SortByLastname(); this.CurrentTournament.Players.CopyTo(array1, 0); this.ddlPlayers.Items.AddRange((object[])array1); if (!this.CurrentPenalty.Player.IsBye) { for (int index = 0; index < this.ddlPlayers.Items.Count; ++index) { if (((IPlayer)this.ddlPlayers.Items[index]).ID == this.CurrentPenalty.Player.ID) { this.ddlPlayers.SelectedIndex = index; break; } } } TournStaffArray tournStaffArray = new TournStaffArray(); foreach (TournStaff tournStaff in (IEnumerable <ITournStaff>) this.CurrentTournament.Staff) { if (tournStaff.Position == StaffPosition.Judge || tournStaff.Position == StaffPosition.JudgeTeamLead || (tournStaff.Position == StaffPosition.HeadJudge || tournStaff.Position == StaffPosition.AssistantHeadJudge)) { tournStaffArray.Add((ITournStaff)tournStaff); } } ITournStaff[] array2 = new ITournStaff[tournStaffArray.Count]; tournStaffArray.SortByLastname(); tournStaffArray.CopyTo(array2, 0); this.ddlJudges.Items.AddRange((object[])array2); if (!this.CurrentPenalty.Judge.IsBye) { for (int index = 0; index < this.ddlJudges.Items.Count; ++index) { if (((IPlayer)this.ddlJudges.Items[index]).ID == this.CurrentPenalty.Judge.ID) { this.ddlJudges.SelectedIndex = index; break; } } } } foreach (InfractionEnum inf in Enum.GetValues(typeof(InfractionEnum))) { this.ddlInfraction.Items.Add((object)new InfractionListItem(inf)); } if (this.CurrentPenalty.Infraction != InfractionEnum.None) { this.ddlInfraction.SelectedIndex = this.ddlInfraction.FindString(PenaltyClass.GetName(this.CurrentPenalty.Infraction)); } else { this.ddlInfraction.SelectedIndex = 0; } foreach (PenaltyEnum key in CommonEnumLists.PenaltyEnumNames.Keys) { ListItemPenaltyEnum listItemPenaltyEnum = new ListItemPenaltyEnum(key); this.ddlPenalty.Items.Add((object)listItemPenaltyEnum); if (listItemPenaltyEnum.Value == this.CurrentPenalty.Penalty) { this.ddlPenalty.SelectedItem = (object)listItemPenaltyEnum; } } this.txtNotes.Text = this.CurrentPenalty.Notes; this.txtRound.Text = this.CurrentPenalty.Round.ToString(); }
public override string ToString() { return(PenaltyClass.GetName(this.Value)); }