EmployeeRosterItem.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class EmployeeRosterItem : Entity, IRemotable, IPersistent, IImportable, IExportable, IEmployeeRosterItem, ILicense<CoreLicense>, IOneToMany<Employee>
  8. {
  9. private static readonly Dictionary<string, Func<EmployeeRosterItem, TimeSpan>> times = new Dictionary<string, Func<EmployeeRosterItem, TimeSpan>>()
  10. {
  11. { "Start", x => x.Start },
  12. { "Finish", x => x.Finish },
  13. { "Break", x => x.Break },
  14. { "Start2", x => x.Start2 },
  15. { "Finish2", x => x.Finish2 },
  16. { "Break2", x => x.Break2 }
  17. };
  18. public EmployeeLink Employee { get; set; }
  19. [IntegerEditor(Alignment = Alignment.MiddleCenter, Editable = Editable.Hidden, Visible = Visible.Hidden)]
  20. [EditorSequence(1)]
  21. [Caption("Day")]
  22. public int Day { get; set; }
  23. [TextBoxEditor(Alignment = Alignment.MiddleCenter, Editable = Editable.Disabled)]
  24. [EditorSequence(2)]
  25. public string Description { get; set; }
  26. [CheckBoxEditor]
  27. [EditorSequence(3)]
  28. [Caption("Rostered On?")]
  29. public bool Enabled { get; set; }
  30. [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
  31. [EditorSequence(4)]
  32. public TimeSpan Start { get; set; }
  33. [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
  34. [EditorSequence(5)]
  35. public TimeSpan Finish { get; set; }
  36. [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
  37. [EditorSequence(6)]
  38. public TimeSpan Break { get; set; }
  39. [CheckBoxEditor]
  40. [EditorSequence(7)]
  41. [Caption("Split")]
  42. public bool SplitShift { get; set; }
  43. [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
  44. [EditorSequence(8)]
  45. [Caption("Start 2")]
  46. public TimeSpan Start2 { get; set; }
  47. [TimeOfDayEditor(Format = "hh:mm", Width = 70)]
  48. [EditorSequence(9)]
  49. [Caption("Finish 2")]
  50. public TimeSpan Finish2 { get; set; }
  51. [DurationEditor(Format = "hh:mm", Visible = Visible.Default, Editable = Editable.Enabled, Width = 70)]
  52. [EditorSequence(10)]
  53. [Caption("Break 2")]
  54. public TimeSpan Break2 { get; set; }
  55. [DoubleEditor(Format = "F2", Visible = Visible.Default, Editable = Editable.Disabled, Summary = Summary.Sum, Width = 70,
  56. Alignment = Alignment.MiddleCenter)]
  57. [EditorSequence(12)]
  58. [Caption("Total")]
  59. public double Duration { get; set; }
  60. public OvertimeLink Overtime { get; set; }
  61. protected override void DoPropertyChanged(string name, object? before, object? after)
  62. {
  63. if (String.Equals(name, nameof(Day)))
  64. Description = $"Day {after}";
  65. base.DoPropertyChanged(name, before, after);
  66. (this as IEmployeeRosterItem).DoPropertyChanged(name, before, after);
  67. }
  68. }
  69. }