private void butDelete_Click(object sender, EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } TimeAdjusts.Delete(TimeAdjustCur); DialogResult = DialogResult.OK; }
private void butCompute_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { return; } //first, delete all existing overtime entries for (int i = 0; i < TimeAdjustList.Length; i++) { if (TimeAdjustList[i].OTimeHours.TotalHours != 0) { TimeAdjusts.Delete(TimeAdjustList[i]); } } //then, fill grid FillMain(true); Calendar cal = CultureInfo.CurrentCulture.Calendar; CalendarWeekRule rule = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule; //loop through all rows for (int i = 0; i < mergedAL.Count; i++) { //ignore rows that aren't weekly totals if (i < mergedAL.Count - 1 //if not the last row //if the next row has the same week as this row && cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday) == cal.GetWeekOfYear(GetDateForRow(i), rule, DayOfWeek.Sunday)) { continue; } if (WeeklyTotals[i] <= TimeSpan.FromHours(40)) { continue; } //found a weekly total over 40 hours TimeAdjust adjust = new TimeAdjust(); adjust.EmployeeNum = EmployeeCur.EmployeeNum; adjust.TimeEntry = GetDateForRow(i).AddHours(20); //puts it at 8pm on the same day. adjust.OTimeHours = WeeklyTotals[i] - TimeSpan.FromHours(40); adjust.RegHours = -adjust.OTimeHours; TimeAdjusts.Insert(adjust); } FillMain(true); }