|
|
@@ -25,7 +25,7 @@ namespace PRSDesktop
|
|
|
public partial class AttendancePanel : UserControl, IPanel<TimeSheet>
|
|
|
{
|
|
|
private string _search = "";
|
|
|
- public CoreTable Activities;
|
|
|
+ public Dictionary<Guid, Activity> Activities;
|
|
|
|
|
|
private bool bIncludeInactive;
|
|
|
|
|
|
@@ -187,10 +187,13 @@ namespace PRSDesktop
|
|
|
.Add(x => x.ID)
|
|
|
.Add(x => x.IsLeave)
|
|
|
.Add(x => x.IsDefault)
|
|
|
- .Add(x => x.Description)));
|
|
|
+ .Add(x => x.Description)
|
|
|
+ .Add(x => x.Color)));
|
|
|
|
|
|
Employees = data.Get<Employee>();
|
|
|
- Activities = data.Get<Activity>();
|
|
|
+ Activities = data.Get<Activity>()
|
|
|
+ .ToObjects<Activity>()
|
|
|
+ .ToDictionary(x => x.ID);
|
|
|
Rosters = data.GetObjects<EmployeeRosterItem>()
|
|
|
.GroupBy(x => x.Employee.ID)
|
|
|
.ToDictionary(x => x.Key, x => x.ToArray());
|
|
|
@@ -331,7 +334,7 @@ namespace PRSDesktop
|
|
|
var lastrow = TimeSheets.Rows.LastOrDefault(r => r.Get<TimeSheet, Guid>(c => c.EmployeeLink.ID).Equals(empid));
|
|
|
|
|
|
var actid = lastrow.Get<TimeSheet, Guid>(c => c.ActivityLink.ID);
|
|
|
- var actrow = Equals(actid, Guid.Empty) ? null : Activities.Rows.FirstOrDefault(r => r.Get<Activity, Guid>(c => c.ID) == actid);
|
|
|
+ var activity = actid != Guid.Empty ? Activities.GetValueOrDefault(actid) : null;
|
|
|
|
|
|
var color = "White";
|
|
|
var finish = lastrow.Get<TimeSheet, TimeSpan>(c => c.Finish);
|
|
|
@@ -341,7 +344,7 @@ namespace PRSDesktop
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- color = actrow != null ? actrow.Get<Activity, string>(c => c.Color) : "";
|
|
|
+ color = activity?.Color ?? "";
|
|
|
if (string.IsNullOrWhiteSpace(color))
|
|
|
color = "LightGreen";
|
|
|
}
|
|
|
@@ -352,7 +355,7 @@ namespace PRSDesktop
|
|
|
lastrow.Get<TimeSheet, string>(c => c.Address),
|
|
|
color,
|
|
|
"Black",
|
|
|
- actrow != null ? actrow.Get<Activity, string>(c => c.Description) : "",
|
|
|
+ activity?.Description ?? "",
|
|
|
lastrow.Get<TimeSheet, string>(c => c.SoftwareVersion)
|
|
|
);
|
|
|
//kanban.Clockin = firstrow != null ? String.Format("{0:hh\\:mm}", firstrow.Get<TimeSheet, TimeSpan>(c => c.Start)) : "";
|
|
|
@@ -372,12 +375,12 @@ namespace PRSDesktop
|
|
|
return false;
|
|
|
|
|
|
var actid = row.Get<StandardLeave, Guid>(c => c.LeaveType.ID);
|
|
|
- var actrow = Equals(actid, Guid.Empty) ? null : Activities.Rows.FirstOrDefault(r => r.Get<Activity, Guid>(c => c.ID) == actid);
|
|
|
- var color = actrow?.Get<Activity, string>(c => c.Color);
|
|
|
+ var activity = actid != Guid.Empty ? Activities.GetValueOrDefault(actid) : null;
|
|
|
+ var color = activity?.Color;
|
|
|
if (string.IsNullOrWhiteSpace(color))
|
|
|
color = "Gainsboro";
|
|
|
|
|
|
- var description = actrow?.Get<Activity, string>(c => c.Description);
|
|
|
+ var description = activity?.Description;
|
|
|
if (string.IsNullOrWhiteSpace(description))
|
|
|
description = "Leave";
|
|
|
|
|
|
@@ -404,12 +407,12 @@ namespace PRSDesktop
|
|
|
return false;
|
|
|
|
|
|
var actid = row.Get<LeaveRequest, Guid>(c => c.LeaveType.ID);
|
|
|
- var actrow = Equals(actid, Guid.Empty) ? null : Activities.Rows.FirstOrDefault(r => r.Get<Activity, Guid>(c => c.ID) == actid);
|
|
|
- var color = actrow?.Get<Activity, string>(c => c.Color);
|
|
|
+ var activity = actid != Guid.Empty ? Activities.GetValueOrDefault(actid) : null;
|
|
|
+ var color = activity?.Color;
|
|
|
if (string.IsNullOrWhiteSpace(color))
|
|
|
color = "Gainsboro";
|
|
|
|
|
|
- var description = actrow?.Get<Activity, string>(c => c.Description);
|
|
|
+ var description = activity?.Description;
|
|
|
if (string.IsNullOrWhiteSpace(description))
|
|
|
description = "Leave";
|
|
|
|
|
|
@@ -570,9 +573,7 @@ namespace PRSDesktop
|
|
|
|
|
|
private void SickLeave_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- var actrow = Activities.Rows.FirstOrDefault(
|
|
|
- r => r.Get<Activity, bool>(c => c.IsLeave) && r.Get<Activity, bool>(c => c.IsDefault)
|
|
|
- );
|
|
|
+ var actrow = Activities.Values.FirstOrDefault(x => x.IsLeave && x.IsDefault);
|
|
|
if (actrow == null)
|
|
|
{
|
|
|
MessageBox.Show("You must set up a default Sick Leave Activity before using this option!");
|
|
|
@@ -598,7 +599,7 @@ namespace PRSDesktop
|
|
|
request.To = DateTime.Today;
|
|
|
request.ToTime = new TimeSpan(23, 59, 59);
|
|
|
request.Status = LeaveRequestStatus.InProgress;
|
|
|
- request.LeaveType.ID = actrow.Get<Activity, Guid>(c => c.ID);
|
|
|
+ request.LeaveType.CopyFrom(actrow);
|
|
|
request.Notes = string.Format("Marked As Sick at {0:hh\\:mm} by {1}", DateTime.Now, ClientFactory.UserID);
|
|
|
|
|
|
if (new LeaveRequests().EditItems(new[] { request }))
|