private void CalcAndSet(TableItemUcVm rec) { _calendarBinding.TotalDays++; switch (rec.Record.Type) { case ERecordType.Hours: SetHoursStats((IHoursRecord)rec.Record); break; case ERecordType.Pieces: _calendarBinding.TotalPieces += ((IPiecesRecord)rec.Record).Pieces; break; } if (rec.Record.Type != ERecordType.Vacation) { _calendarBinding.TotalBonus += ((IRecord)rec.Record).Bonus; double.TryParse(rec.Record.TotalPrice, NumberStyles.Any, CultureInfo.InvariantCulture, out double price); /*if (rec.Record.Type == ERecordType.Hours) * { * _totalPriceForHourType += price; * }*/ _calendarBinding.TotalPrice += price; } else { _calendarBinding.VacationDays++; } }
private void DrawMonthAsCalendar(int year, int month) { int offset = (int)(GetTheFirstDayOfMonth(new DateTime(year, month, 1))); if (offset == 0) //ošetření sunday == 0 => offset = 6 { offset = 6; } else { offset -= 1; } for (int i = 0; i < DateTime.DaysInMonth(year, month); i++) { DateTime today = new DateTime(year, month, i + 1); Color backgroundColor = SelectBackgroundColor(today); TableItemUcVm item = null; if (TableUcVm.SavedRecordList?.Count > 0) { foreach (TableItemUcVm tableItem in TableUcVm.SavedRecordList) { if (tableItem?.Record?.Date.Year == today.Year && tableItem?.Record?.Date.Month == today.Month && tableItem?.Record?.Date.Day == today.Day) { item = tableItem; backgroundColor = tableItem?.Record?.Type == ERecordType.Vacation ? Color.DarkOrange : Color.Green; if (tableItem?.Record?.Type == ERecordType.Hours) { if (((IHoursRecord)tableItem.Record).OverTime != new WorkTime(0, 0)) { backgroundColor = Color.LightBlue; } } break; } } } if (today.Year == DateTime.Today.Year && today.Month == DateTime.Today.Month && today.Day == DateTime.Today.Day) { backgroundColor = Color.Gold; } CalendarButton butt = new CalendarButton() { Text = (i + 1).ToString(), BackgroundColor = backgroundColor, Item = item }; if (item != null) { butt.Command = new Command(() => item.MoreInformationRecord(butt.Item)); } else { butt.Command = new Command(() => ChangeTabToAddRecordAndSetupDate(today)); } _grid.Children.Add(butt, (i + offset) % 7, (i + offset) / 7 + 1); } }