/// <summary> /// Update current DataRow StartTime back to the SQL-Server database table /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void updateButton_Click(object sender, EventArgs e) { var row = ((DataRowView)_bindingSource.Current).Row; var success = _dataOperations.UpdateStartTime(row.Field <int>("id"), row.Field <TimeSpan>("StartTime")); if (!success) { MessageBox.Show($"Update failed: {_dataOperations.LastExceptionMessage}"); } }
/// <summary> /// Update start time of current person in DataGridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Although the TimeComboBox is used to update the current person /// using the DomainUpDown could had been used. /// </remarks> private void UpdateStartTimeButton_Click(object sender, EventArgs e) { var person = (Person)_bindingSource.Current; var startTime = person.StartTime; if (timeComboBox1.TimeSpan.IsValidStartTime(person.EndTime)) { var success = _dataOperations.UpdateStartTime(person.Id, timeComboBox1.TimeSpan); if (!success) { MessageBox.Show($"Update failed: {_dataOperations.LastExceptionMessage}"); } } else { MessageBox.Show("Start time must be prior to end time"); person.StartTime = startTime; timeComboBox1.SetCurrentItem(person.StartTime); } }