private void ResultDownButton_Click(object sender, EventArgs e) { if (_starterCompetitionDataGridView.CurrentRow.DataBoundItem is PonyCompetition) { int rowIndex = _starterCompetitionDataGridView.CurrentRow.Index; if (rowIndex < _starterCompetitionDataGridView.RowCount - 1) { PonyCompetition current = (PonyCompetition)_starterCompetitionDataGridView.CurrentRow.DataBoundItem; PonyCompetition next = (PonyCompetition)_starterCompetitionDataGridView.Rows[rowIndex + 1].DataBoundItem; int sortIndex = current.SortIndex; current.SortIndex = next.SortIndex; next.SortIndex = sortIndex; if (current.SortIndex == next.SortIndex) { next.SortIndex--; } current.Save(); next.Save(); ReloadStarterCompetitionList(); _starterCompetitionDataGridView.SetCurrentRow(rowIndex + 1); } } }
private void ResultUpButton_Click(object sender, EventArgs e) { if (_starterCompetitionDataGridView.CurrentRow.DataBoundItem is PonyCompetition) { int rowIndex = _starterCompetitionDataGridView.CurrentRow.Index; if (rowIndex > 0) { PonyCompetition current = (PonyCompetition)_starterCompetitionDataGridView.CurrentRow.DataBoundItem; PonyCompetition prev = (PonyCompetition)_starterCompetitionDataGridView.Rows[rowIndex - 1].DataBoundItem; int sortIndex = current.SortIndex; current.SortIndex = prev.SortIndex; prev.SortIndex = sortIndex; if (current.SortIndex == prev.SortIndex) { prev.SortIndex++; } current.Save(); prev.Save(); ReloadStarterCompetitionList(); _starterCompetitionDataGridView.SetCurrentRow(rowIndex - 1); } } }
private void Save() { if (_isDirty) { // update the values from the textboxes _result.Assessment = _assessment.GetTextAsDecimal(); _result.Comment = _comment.Text; _result.Save(); _isDirty = false; } }