private void CopyOverBlockouts(int numRepeat) { if (DateCopyStart.Year < 1880) { MsgBox.Show(this, "Please copy a selection to the clipboard first."); return; } if (_isWeekend && !checkWeekend.Checked) //user is trying to 'paste' onto a weekend date { MsgBox.Show(this, "You must check 'Include Weekends' if you would like to paste into weekends."); return; } //calculate which day or week is currently selected. DateTime dateSelectedStart; DateTime dateSelectedEnd; bool isWeek = DateCopyStart != DateCopyEnd; if (isWeek) { //Always start week on Monday if (DateSelected.DayOfWeek == DayOfWeek.Sunday) //if selecting Sunday, go back to the previous Monday. { dateSelectedStart = DateSelected.AddDays(-6); } else //Any other day. eg Wed.AddDays(1-3)=Wed.AddDays(-2)=Monday { dateSelectedStart = DateSelected.AddDays(1 - (int)DateSelected.DayOfWeek); //eg Wed.AddDays(1-3)=Wed.AddDays(-2)=Monday } //DateCopyEnd is greater than DateCopyStart and is either 4 days greater or 6 days greater, so clear/paste the same number of days dateSelectedEnd = dateSelectedStart.AddDays((DateCopyEnd - DateCopyStart).Days); } else { dateSelectedStart = DateSelected; dateSelectedEnd = DateSelected; } //When pasting, it's not allowed to paste back over the same day or week. if (dateSelectedStart == DateCopyStart && numRepeat == 1) { MsgBox.Show(this, "Not allowed to paste back onto the same date as is on the clipboard."); return; } Cursor = Cursors.WaitCursor; string errors = Schedules.CopyBlockouts(ApptViewNumCur, isWeek, checkWeekend.Checked, checkReplace.Checked, DateCopyStart, DateCopyEnd, dateSelectedStart, dateSelectedEnd, numRepeat); Cursor = Cursors.Default; if (!string.IsNullOrEmpty(errors)) { MessageBox.Show(errors); //Error was translated inside of the S class method. return; } Close(); }