public void CountVacationTime(DateTime dt1, DateTime dt2, out int days, out float hours) { int i1 = dt1.Day; int i2 = dt2.Day; float vp; days = 0; hours = 0.0f; for (int i = i1; i <= i2; i++) { bool factdayadded = false; for (int j = 0; j < this.Count; j++) { var dlset = this[j]; var daycodeplan = dlset.Plan.DxPlan[i - 1]; var daycodefact = dlset.Fact.DxFact[i - 1]; if (daycodeplan == EDayPlanId.None) { continue; } if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None) { continue; } var isPlanWorkDay = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD; var isFactPaidVacation = SomeDataDefs.IsDayPaidVacation(daycodefact); if (!isPlanWorkDay || !isFactPaidVacation) { continue; } vp = dlset.Plan.Vx[i - 1]; hours += vp; if (!factdayadded) { days += 1; factdayadded = true; } } } }
public int CountVacationDays(DateTime dt1, DateTime dt2) { int i1 = dt1.Day; int i2 = dt2.Day; int ret = 0; for (int i = i1; i <= i2; i++) { bool factdayadded = false; for (int j = 0; j < this.Count; j++) { var dlset = this[j]; var daycodeplan = dlset.Plan.DxPlan[i - 1]; var daycodefact = dlset.Fact.DxFact[i - 1]; if (daycodeplan == EDayPlanId.None) { continue; } if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None) { continue; } var isPlanWorkDay = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD; var isFactPaidVacation = SomeDataDefs.IsDayPaidVacation(daycodefact); if (!isPlanWorkDay) { continue; } if (!factdayadded && isFactPaidVacation) { ret += 1; factdayadded = true; } } } return(ret); }