123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Comal.Classes
- {
- [Caption("Roster Items")]
- public class EmployeeRosterTemplateItem : Entity, IEmployeeRosterItem, IOneToMany<EmployeeRoster>, ILicense<CoreLicense>, IRemotable, IPersistent
- {
- private static readonly Dictionary<string, Func<EmployeeRosterTemplateItem, TimeSpan>> times = new Dictionary<string, Func<EmployeeRosterTemplateItem, TimeSpan>>()
- {
- { "Start", x => x.Start },
- { "Finish", x => x.Finish },
- { "Break", x => x.Break },
- { "Start2", x => x.Start2 },
- { "Finish2", x => x.Finish2 },
- { "Break2", x => x.Break2 }
- };
- public EmployeeRosterLink Roster { get; set; }
- [IntegerEditor(Alignment = Alignment.MiddleCenter, Editable = Editable.Hidden, Visible = Visible.Hidden)]
- [EditorSequence(1)]
- [Caption("Day")]
- public int Day { get; set; }
- [TextBoxEditor(Alignment = Alignment.MiddleCenter, Editable = Editable.Disabled)]
- [EditorSequence(2)]
- public string Description { get; set; }
- [CheckBoxEditor]
- [EditorSequence(3)]
- [Caption("Rostered On?")]
- public bool Enabled { get; set; }
- [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
- [EditorSequence(4)]
- public TimeSpan Start { get; set; }
- [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
- [EditorSequence(5)]
- public TimeSpan Finish { get; set; }
- [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
- [EditorSequence(6)]
- public TimeSpan Break { get; set; }
- [CheckBoxEditor]
- [EditorSequence(7)]
- [Caption("Split")]
- public bool SplitShift { get; set; }
- [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
- [EditorSequence(8)]
- [Caption("Start 2")]
- public TimeSpan Start2 { get; set; }
- [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
- [EditorSequence(9)]
- [Caption("Finish 2")]
- public TimeSpan Finish2 { get; set; }
- [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
- [EditorSequence(10)]
- [Caption("Break 2")]
- public TimeSpan Break2 { get; set; }
- [DoubleEditor(Format = "F2", Visible = Visible.Default, Editable = Editable.Disabled, Summary = Summary.Sum, Width = 70,
- Alignment = Alignment.MiddleCenter)]
- [EditorSequence(12)]
- [Caption("Total")]
- public double Duration { get; set; }
- public OvertimeLink Overtime { get; set; }
- protected override void DoPropertyChanged(string name, object? before, object? after)
- {
- if (String.Equals(name, nameof(Day)))
- Description = $"Day {after}";
- base.DoPropertyChanged(name, before, after);
- (this as IEmployeeRosterItem).DoPropertyChanged(name, before, after);
- }
- public EmployeeRosterItem ToEmployeeRosterItem(IEmployee employee)
- {
- var newItem = new EmployeeRosterItem
- {
- Day = Day,
- Description = Description,
- Enabled = Enabled,
- Start = Start,
- Finish = Finish,
- Break = Break,
- SplitShift = SplitShift,
- Start2 = Start2,
- Finish2 = Finish2,
- Break2 = Break2,
- Duration = Duration
- };
- newItem.Employee.ID = employee.ID;
- newItem.Employee.Synchronise(employee);
- newItem.Overtime.ID = Overtime.ID;
- newItem.Overtime.Synchronise(Overtime);
- return newItem;
- }
- }
- }
|