private void btnSwapActivities_Click(object sender, EventArgs e) { // get the selected index int activity1 = cmbActivity1.SelectedIndex + 1; int activity2 = cmbActivity2.SelectedIndex + 1; // validate the given index if (activity1 == activity2) { MessageBox.Show("These dates are the same!"); // when the samen are selected show a messagebox } else { // get the start and end date for activity 1 string startactivity1 = activity_Service.GetDateTimeActivityStart(activity1); string endactivity1 = activity_Service.GetDateTimeActivityEnd(activity1); // get the start and end date for activity 2 string startactivity2 = activity_Service.GetDateTimeActivityStart(activity2); string endactivity2 = activity_Service.GetDateTimeActivityEnd(activity2); // swap the dates for the activities activity_Service.SwapActivities(activity1, startactivity2, endactivity2); activity_Service.SwapActivities(activity2, startactivity1, endactivity1); } }