123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media.Imaging;
- using System.Windows.Threading;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- using Syncfusion.UI.Xaml.Kanban;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for AttendancePanel.xaml
- /// </summary>
- public partial class AttendancePanel : UserControl, IPanel<TimeSheet>
- {
- private string _search = "";
- public CoreTable Activities;
- private bool bIncludeInactive;
- private readonly DispatcherTimer columnsizer = new();
- public CoreTable Employees;
- private readonly List<AttendanceKanban> Kanbans = new();
- public CoreTable LeaveRequests;
- public CoreTable TimeSheets;
- public CoreTable StandardLeaves;
- public AttendancePanel()
- {
- InitializeComponent();
- columnsizer.Interval = new TimeSpan(0, 0, 0, 0, 500);
- columnsizer.Tick += Columnsizer_Tick;
- columnsizer.IsEnabled = true;
- }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent OnUpdateDataModel;
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>
- {
- { typeof(Employee).EntityName(), Employees.Rows.ToArray() },
- { typeof(TimeSheet).EntityName(), TimeSheets.Rows.ToArray() }
- };
- }
- public void CreateToolbarButtons(IPanelHost host)
- {
- }
- public string SectionName => "Attendance";
- public DataModel DataModel(Selection selection)
- {
- var ids = selection != Selection.None ? Employees.ExtractValues<Employee, Guid>(x => x.ID).ToArray() : new Guid[] { };
- var filter = new Filter<Employee>(x => x.ID).InList(ids);
- if (!bIncludeInactive)
- {
- filter.And(x => x.ShowOnInOutBoard);
- }
- return new AttendanceDataModel(filter);
- }
- public void Refresh()
- {
-
- // if there is a current timesheet (start < now, finish > now or empty), => activity color
- // if there is a current standard leave (start < now, finish > now) => activity color
- // if there is a current leave request (start < now, finish > now) => activity color
- // if there is a roster (day = today, start < now, finish > now) => red
- // => lightgray
-
- using (var cursor = new WaitCursor())
- {
- var query = new MultiQuery();
- query.Add(
- new Filter<TimeSheet>(x => x.Date).IsEqualTo(DateTime.Today),
- new Columns<TimeSheet>(x => x.EmployeeLink.ID)
- .Add(x => x.Start)
- .Add(x => x.Finish)
- .Add(x => x.Address)
- .Add(x => x.ActivityLink.ID)
- .Add(x => x.SoftwareVersion),
- new SortOrder<TimeSheet>(x => x.Start)
- );
- query.Add(
- new Filter<StandardLeave>(x => x.From).IsLessThanOrEqualTo(DateTime.Today)
- .And(x => x.To).IsGreaterThanOrEqualTo(DateTime.Today),
- new Columns<StandardLeave>(x => x.From)
- .Add(x => x.FromTime)
- .Add(x => x.To)
- .Add(x => x.ToTime)
- .Add(x => x.LeaveType.ID)
- );
-
- query.Add(
- new Filter<LeaveRequest>(x => x.From).IsLessThanOrEqualTo(DateTime.Today)
- .And(x => x.To).IsGreaterThanOrEqualTo(DateTime.Today)
- .And(x => x.Status).IsEqualTo(LeaveRequestStatus.InProgress),
- new Columns<LeaveRequest>(x => x.EmployeeLink.ID)
- .Add(x => x.From)
- .Add(x => x.FromTime)
- .Add(x => x.To)
- .Add(x => x.ToTime)
- .Add(x => x.LeaveType.ID)
- );
- query.Query();
- TimeSheets = query.Get<TimeSheet>();
- StandardLeaves = query.Get<StandardLeave>();
- LeaveRequests = query.Get<LeaveRequest>();
- foreach (var emprow in Employees.Rows)
- {
- var empid = emprow.Get<Employee, Guid>(c => c.ID);
- var kanban = Kanbans.FirstOrDefault(x => string.Equals(x.ID, empid.ToString()));
- if (kanban != null)
- {
- var bOK = CheckTimeSheet(empid, kanban);
- if (!bOK)
- bOK = CheckStandardLeave(empid, kanban);
- if (!bOK)
- bOK = CheckLeaveRequest(empid, kanban);
- if (!bOK)
- bOK = CheckRoster(empid, kanban, emprow);
- if (!bOK)
- UpdateKanban(kanban,
- TimeSpan.MinValue,
- TimeSpan.MinValue,
- "",
- "White",
- "Gainsboro",
- "",
- ""
- );
- }
- }
- FilterKanbans();
- }
- }
- public void Setup()
- {
- Kanban.Columns.Clear();
-
- MultiQuery query = new MultiQuery();
- query.Add<Employee>(
- LookupFactory.DefineFilter<Employee>(),
- new Columns<Employee>(
- x => x.ID,
- x => x.Name,
- x => x.Thumbnail.ID,
- x => x.Group.ID,
- x => x.Group.Description,
- x => x.Type,
- x => x.ShowOnInOutBoard,
- x => x.Roster,
- x => x.RosterStart
- ),
- new SortOrder<Employee>(x => x.Name)
- );
- query.Add<Activity>();
- query.Query();
-
- Employees = query.Get<Employee>();
- Activities = query.Get<Activity>();
- CreateColumns();
- CreateKanbans();
- var imageids = Employees.Rows
- .Select(r => r.EntityLinkID<Employee, ImageDocumentLink>(x => x.Thumbnail) ?? Guid.Empty)
- .Where(x => x != Guid.Empty).ToArray();
- new Client<Document>().Query(
- new Filter<Document>(x => x.ID).InList(imageids),
- new Columns<Document>(
- x => x.ID,
- x => x.Data
- ),
- null,
- (data, error) => ProcessImages(data)
- );
- }
- public void Shutdown()
- {
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- private void Columnsizer_Tick(object sender, EventArgs e)
- {
- columnsizer.IsEnabled = false;
- ResizeColumns();
- columnsizer.IsEnabled = true;
- }
- private void ResizeColumns()
- {
- using (var d = Dispatcher.DisableProcessing())
- {
- var CollapsedWidth = 50;
- var CollapsedColumns = 0;
- Array.ForEach(Kanban.Columns.ToArray(), x => { CollapsedColumns += x.IsExpanded ? 0 : 1; });
- if (Kanban.Columns.Count > 0 && CollapsedColumns != Kanban.Columns.Count)
- {
- var ColumnWidth = (Kanban.ActualWidth - CollapsedColumns * CollapsedWidth) / (Kanban.Columns.Count - CollapsedColumns) - 2;
- if (ColumnWidth != Kanban.ColumnWidth) Kanban.ColumnWidth = ColumnWidth;
- }
- }
- }
- private void CreateKanbans()
- {
- foreach (var row in Employees.Rows)
- {
- var empid = row.Get<Employee, Guid>(x => x.ID);
- var empname = row.Get<Employee, string>(x => x.Name);
- var groupid = row.Get<Employee, Guid>(x => x.Group.ID);
- var imgid = row.Get<Employee, Guid>(x => x.Thumbnail.ID);
- var img = PRSDesktop.Resources.anonymous.AsBitmapImage();
- var active = row.Get<Employee, bool>(x => x.ShowOnInOutBoard);
- var color = "White";
- var kanban = new AttendanceKanban
- {
- ID = empid.ToString(),
- Name = empname,
- Category = groupid.ToString(),
- Image = img,
- Clockin = "",
- Clockout = "",
- Address = "",
- ColorKey = "White",
- TextColor = "Gainsboro",
- Type = "",
- Version = "",
- Active = active
- };
- Kanbans.Add(kanban);
- }
- }
- private void CreateColumns()
- {
- //Dictionary<Guid, String> columns = Employees.ToDictionary<Employee, Guid>(x => x.ID, new System.Linq.Expressions.Expression<Func<Employee, object>>[] { x => x.Group.Description });
- Kanban.Columns.Clear();
- var columns = new List<Tuple<Guid, string>>();
- foreach (var row in Employees.Rows)
- {
- var active = row.Get<Employee, bool>(c => c.ShowOnInOutBoard);
- if (bIncludeInactive || active)
- {
- var id = row.Get<Employee, Guid>(c => c.Group.ID);
- var desc = row.Get<Employee, string>(c => c.Group.Description);
- if (!columns.Any(x => x.Item1.Equals(id)))
- columns.Add(new Tuple<Guid, string>(id, desc));
- }
- }
- columns = columns.OrderBy(x => x.Item2).ToList();
- foreach (var column in columns)
- {
- var newcol = new KanbanColumn
- {
- Title = column.Item1 != Guid.Empty ? column.Item2 : "(No Group Assigned)",
- Categories = column.Item1.ToString()
- };
- newcol.AllowDrag = false;
- newcol.AllowDrop = false;
- Kanban.Columns.Add(newcol);
- }
- }
- private void UpdateKanban(AttendanceKanban kanban, TimeSpan start, TimeSpan finish, string address, string background, string foreground,
- string description, string version)
- {
- kanban.Clockin = start.TotalMilliseconds > 0 ? string.Format("{0:hh\\:mm}", start) : "";
- kanban.Clockout = finish.TotalMilliseconds > 0 ? string.Format("{0:hh\\:mm}", finish) : "";
- kanban.Address = address;
- kanban.ColorKey = background;
- kanban.TextColor = foreground;
- kanban.Type = description;
- kanban.Version = version;
- }
- private bool CheckTimeSheet(Guid empid, AttendanceKanban kanban)
- {
- var firstrow = TimeSheets.Rows.FirstOrDefault(r => r.Get<TimeSheet, Guid>(c => c.EmployeeLink.ID).Equals(empid));
- if (firstrow == null)
- return false;
- 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).Equals(actid));
- var color = "White";
- var finish = lastrow.Get<TimeSheet, TimeSpan>(c => c.Finish);
- if (finish.Ticks > 0 && finish < DateTime.Now - DateTime.Today)
- {
- color = "Gainsboro";
- }
- else
- {
- color = actrow != null ? actrow.Get<Activity, string>(c => c.Color) : "";
- if (string.IsNullOrWhiteSpace(color))
- color = "LightGreen";
- }
- UpdateKanban(kanban,
- firstrow.Get<TimeSheet, TimeSpan>(c => c.Start),
- lastrow.Get<TimeSheet, TimeSpan>(c => c.Finish),
- lastrow.Get<TimeSheet, string>(c => c.Address),
- color,
- "Black",
- actrow != null ? actrow.Get<Activity, string>(c => c.Description) : "",
- lastrow.Get<TimeSheet, string>(c => c.SoftwareVersion)
- );
- //kanban.Clockin = firstrow != null ? String.Format("{0:hh\\:mm}", firstrow.Get<TimeSheet, TimeSpan>(c => c.Start)) : "";
- //kanban.Clockout = (lastrow != null) && (lastrow.Get<TimeSheet, TimeSpan>(c => c.Finish).Ticks > 0) ? String.Format("{0:hh\\:mm}", lastrow.Get<TimeSheet, TimeSpan>(c => c.Finish)) : "";
- //kanban.Address = lastrow != null ? lastrow.Get<TimeSheet, String>(c => c.Address) : "";
- //kanban.ColorKey = color;
- //kanban.TextColor = lastrow != null ? "Black" : "Gainsboro";
- //kanban.Type = actrow != null ? actrow.Get<Activity, String>(c => c.Description) : "";
- //kanban.Version = lastrow != null ? lastrow.Get<TimeSheet, String>(c => c.SoftwareVersion) : "";
- return true;
- }
-
- private bool CheckStandardLeave(Guid empid, AttendanceKanban kanban)
- {
- var row = StandardLeaves.Rows.FirstOrDefault();
- if (row == null)
- 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).Equals(actid));
- var color = actrow?.Get<Activity, string>(c => c.Color);
- if (string.IsNullOrWhiteSpace(color))
- color = "Gainsboro";
- var description = actrow?.Get<Activity, string>(c => c.Description);
- if (string.IsNullOrWhiteSpace(description))
- description = "Leave";
- UpdateKanban(kanban,
- row.Get<StandardLeave, DateTime>(c => c.From) == DateTime.Today
- ? row.Get<StandardLeave, TimeSpan>(c => c.FromTime)
- : TimeSpan.MinValue,
- row.Get<StandardLeave, DateTime>(c => c.To) == DateTime.Today
- ? row.Get<StandardLeave, TimeSpan>(c => c.ToTime)
- : TimeSpan.MinValue,
- "",
- color,
- "Black",
- description,
- ""
- );
- return true;
- }
-
- private bool CheckLeaveRequest(Guid empid, AttendanceKanban kanban)
- {
- var row = LeaveRequests.Rows.FirstOrDefault(r => r.Get<LeaveRequest, Guid>(c => c.EmployeeLink.ID) == empid);
- if (row == null)
- 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).Equals(actid));
- var color = actrow?.Get<Activity, string>(c => c.Color);
- if (string.IsNullOrWhiteSpace(color))
- color = "Gainsboro";
- var description = actrow?.Get<Activity, string>(c => c.Description);
- if (string.IsNullOrWhiteSpace(description))
- description = "Leave";
- UpdateKanban(kanban,
- row.Get<LeaveRequest, DateTime>(c => c.From) == DateTime.Today
- ? row.Get<LeaveRequest, TimeSpan>(c => c.FromTime)
- : TimeSpan.MinValue,
- row.Get<LeaveRequest, DateTime>(c => c.To) == DateTime.Today
- ? row.Get<LeaveRequest, TimeSpan>(c => c.ToTime)
- : TimeSpan.MinValue,
- "",
- color,
- "Black",
- description,
- ""
- );
- return true;
- }
- private bool CheckRoster(Guid empid, AttendanceKanban kanban, CoreRow empdata)
- {
- var rosterdata = empdata.Get<Employee, String>(c => c.Roster);
- var rosters = !String.IsNullOrWhiteSpace(rosterdata)
- ? Serialization.Deserialize<List<EmployeeRosterItem>>(rosterdata).ToArray()
- : null;
- var roster = RosterUtils.GetRoster(rosters, empdata.Get<Employee,DateTime>(c=>c.RosterStart), DateTime.Today);
-
- if ((roster == null) || (!roster.Enabled))
- return false;
-
- var time = DateTime.Now.TimeOfDay;
-
- var backgroundcolor = "Gainsboro";
- var foregroundcolor = "Black";
- var text = "";
- var starttime = TimeSpan.MinValue;
- var endtime = TimeSpan.MinValue;
- if (time < roster.Start)
- {
- starttime = roster.Start;
- endtime = roster.Finish;
- text = $"Not Yet Started";
- }
- else if (time < roster.Finish)
- {
- starttime = roster.Start;
- endtime = roster.Finish;
- text = "Overdue";
- backgroundcolor = "LightSalmon";
- }
- else if (time < roster.Start2)
- {
- starttime = roster.Start2;
- endtime = roster.Finish2;
- text = "Not Yet Started (2nd Shift)";
- }
- else if (time < roster.Finish2)
- {
- starttime = roster.Start2;
- endtime = roster.Finish2;
- text = "Overdue (2nd Shift)";
- backgroundcolor = "LightSalmon";
- }
- else
- {
- text = "No time recorded";
- backgroundcolor = "LightSalmon";
- }
-
- UpdateKanban(kanban,
- starttime,
- endtime,
- "",
- backgroundcolor,
- foregroundcolor,
- text,
- ""
- );
- return true;
- }
-
- private void FilterKanbans()
- {
- var visible = Kanbans.Where(x =>
- (x.Name?.ToUpper().Contains(_search.ToUpper()) == true || x.Address?.ToUpper().Contains(_search.ToUpper()) == true)
- && (bIncludeInactive || x.Active)
- );
- Kanban.ItemsSource = visible;
- }
- private void ProcessImages(CoreTable data)
- {
- foreach (var row in data.Rows)
- {
- var imageid = row.Get<Document, Guid>(c => c.ID);
- BitmapImage img = null;
- var empids = Employees.Rows.Where(r => r.Get<Employee, Guid>(c => c.Thumbnail.ID).Equals(imageid))
- .Select(r => r.Get<Employee, Guid>(c => c.ID));
- foreach (var empid in empids)
- {
- var kanban = Kanbans.FirstOrDefault(x => string.Equals(x.ID, empid.ToString()));
- if (kanban != null)
- {
- if (img == null)
- {
- img = new BitmapImage();
- img.LoadImage(row.Get<Document, byte[]>(c => c.Data));
- }
- kanban.Image = img;
- }
- }
- }
- Dispatcher.Invoke(() => { FilterKanbans(); });
- }
- private void AttendanceMenu_Opened(object sender, RoutedEventArgs e)
- {
- var menu = sender as ContextMenu;
- var model = menu.Tag as AttendanceKanban;
- var sick = menu.Items[0] as MenuItem;
- var onoff = menu.Items[2] as MenuItem;
- if (string.IsNullOrWhiteSpace(model.Clockin) || !string.IsNullOrWhiteSpace(model.Clockout))
- onoff.Header = "Clock Employee On to PRS";
- else
- onoff.Header = "Clock Employee Out of PRS";
- var show = menu.Items[4] as MenuItem;
- show.Visibility = !model.Active ? Visibility.Visible : Visibility.Collapsed;
- var hide = menu.Items[5] as MenuItem;
- hide.Visibility = model.Active ? Visibility.Visible : Visibility.Collapsed;
- }
- 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)
- );
- if (actrow == null)
- {
- MessageBox.Show("You must set up a default Sick Leave Activity before using this option!");
- return;
- }
- var item = (MenuItem)sender;
- var model = (AttendanceKanban)item.Tag;
- var empid = Guid.Parse(model.ID);
- var row = Employees.Rows.FirstOrDefault(r => r.Get<Employee, Guid>(c => c.ID).Equals(empid));
- if (row == null)
- {
- MessageBox.Show("Cannot Find Employee: " + empid);
- return;
- }
- var emp = row.ToObject<Employee>();
- var request = new LeaveRequest();
- request.EmployeeLink.ID = empid;
- request.From = DateTime.Today;
- request.FromTime = DateTime.Now.TimeOfDay;
- 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.Notes = string.Format("Marked As Sick at {0:hh\\:mm} by {1}", DateTime.Now, ClientFactory.UserID);
- if (new LeaveRequests().EditItems(new[] { request }))
- Refresh();
- }
- private void ClockOnOff_Click(object sender, RoutedEventArgs e)
- {
- var item = (MenuItem)sender;
- var model = (AttendanceKanban)item.Tag;
- var empid = Guid.Parse(model.ID);
- var bOK = true;
- var time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0);
- if (Security.IsAllowed<CanChangeStartFinishTimes>())
- bOK = TimeEdit.Execute("Enter Time", ref time);
- if (!bOK)
- return;
- if (string.IsNullOrWhiteSpace(model.Clockin) || !string.IsNullOrWhiteSpace(model.Clockout))
- {
- var timesheet = new TimeSheet();
- timesheet.EmployeeLink.ID = empid;
- timesheet.Date = DateTime.Today;
- timesheet.Start = time;
- timesheet.Notes = string.Format("Clocked in at {0:hh\\:mm} by {1}", DateTime.Now, ClientFactory.UserID);
- new Client<TimeSheet>().Save(timesheet, "Clocked on from In/Out Board");
- Refresh();
- }
- else
- {
- var timesheet = new Client<TimeSheet>().Load(
- new Filter<TimeSheet>(x => x.Date).IsEqualTo(DateTime.Today).And(x => x.Finish).IsEqualTo(new TimeSpan())
- .And(x => x.EmployeeLink.ID)
- .IsEqualTo(empid),
- new SortOrder<TimeSheet>(x => x.Start)
- ).LastOrDefault();
- if (timesheet != null)
- {
- if (!string.IsNullOrWhiteSpace(timesheet.Notes))
- timesheet.Notes = timesheet.Notes + "\n";
- else
- timesheet.Notes = "";
- timesheet.Notes = string.Format("{0}Clocked out at {1:hh\\:mm} by {2}", timesheet.Notes, DateTime.Now, ClientFactory.UserID);
- timesheet.Finish = time;
- new Client<TimeSheet>().Save(timesheet, "Clocked off from In/Out Board");
- Refresh();
- }
- }
- }
- private void Search_KeyUp(object sender, KeyEventArgs e)
- {
- _search = Search.Text;
- if (string.IsNullOrWhiteSpace(Search.Text) || e.Key == Key.Return) FilterKanbans();
- }
- private void Export_Click(object sender, RoutedEventArgs e)
- {
- var form = new DynamicExportForm(typeof(TimeSheet), TimeSheets.Columns.Select(x => x.ColumnName));
- if (form.ShowDialog() != true)
- return;
- var export = new Client<TimeSheet>().Query(
- new Filter<TimeSheet>(x => x.Date).IsEqualTo(DateTime.Today),
- new Columns<TimeSheet>(form.Fields),
- LookupFactory.DefineSort<TimeSheet>()
- );
- ExcelExporter.DoExport<TimeSheet>(export, string.Format("Attendance {0:dd-MMM-yy}", DateTime.Today));
- }
- private void ShowAll_Click(object sender, RoutedEventArgs e)
- {
- if (string.Equals(ShowAll.Content as string, "Show All"))
- {
- ShowAll.Content = "Hide Inactive";
- bIncludeInactive = true;
- }
- else
- {
- ShowAll.Content = "Show All";
- bIncludeInactive = false;
- }
- FilterKanbans();
- }
- private void ShowOnInOut_Click(object sender, RoutedEventArgs e)
- {
- var menu = sender as MenuItem;
- var model = menu.Tag as AttendanceKanban;
- UpdateInOutStatus(model, true);
- }
- private void UpdateInOutStatus(AttendanceKanban model, bool include)
- {
- var id = Guid.Parse(model.ID);
- var row = Employees.Rows.FirstOrDefault(r => r.Get<Employee, Guid>(c => c.ID) == id);
- if (row != null)
- {
- var emp = new Employee { ID = id, ShowOnInOutBoard = include };
- new Client<Employee>().Save(emp, include ? "Added To" : "Removed From" + " In/Out Board", (o, e) => { });
- row.Set<Employee, bool>(x => x.ShowOnInOutBoard, include);
- model.Active = include;
- }
- }
- private void RemoveFromInOut_Click(object sender, RoutedEventArgs e)
- {
- var menu = sender as MenuItem;
- var model = menu.Tag as AttendanceKanban;
- UpdateInOutStatus(model, false);
- FilterKanbans();
- }
- }
- }
|