private void update_Click(object sender, EventArgs e) { if (hoursGridView.SelectedCells.Count > 0) { var pyrh = ((List <PositionYearRateHours>)hoursGridView.DataSource)[hoursGridView.SelectedCells[0].RowIndex]; pyrh.year = Utilities.ParseIntOrZero(year.Text); pyrh.position = position.Text; pyrh.rate_hours = Utilities.ParseIntOrZero(rate_hours.Text); pyrhRepo.update(pyrh, pyrh.id); ReloadYearHours(currentYear); ReloadYearsList(); } }