123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.Wpf;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for WidgetDashboard.xaml
- /// </summary>
- public partial class WidgetDashboard : UserControl, IBasePanel
- {
- private Dictionary<Guid, string> groups;
- public WidgetDashboard()
- {
- InitializeComponent();
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public bool IsReady { get; set; } = false;
- public void CreateToolbarButtons(IPanelHost host)
- {
- }
- public string SectionName => "Widget Dashboard";
- public DataModel DataModel(Selection selection)
- {
- return new WidgetDashboardDataModel();
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- public void Refresh()
- {
- Timesheets.Refresh();
- Tasks.Refresh();
- Manufacturing.Refresh();
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Setup()
- {
- LoadGroups();
- Timesheets.Setup();
- Tasks.Setup();
- Manufacturing.Setup();
- }
- public void Shutdown(CancelEventArgs? cancel)
- {
- Timesheets.Shutdown(cancel);
- if (cancel?.Cancel == true) return;
- Tasks.Shutdown(cancel);
- if (cancel?.Cancel == true) return;
- Manufacturing.Shutdown(cancel);
- }
- private void LoadGroups()
- {
- groups = null;
- new Client<EmployeeGroup>().Query(
- null,
- Columns.None<EmployeeGroup>().Add(
- x => x.ID,
- x => x.Description
- ),
- new SortOrder<EmployeeGroup>(x => x.Description),
- CoreRange.All,
- (o, e) =>
- {
- groups = new Dictionary<Guid, string>
- {
- { CoreUtils.FullGuid, "All Employees" },
- { Guid.Empty, "(No Group Assigned)" }
- };
- o.LoadDictionary<EmployeeGroup, Guid, string>(groups, x => x.ID, x => x.Description);
- Dispatcher.Invoke(
- () =>
- {
- SelectEmployees.SelectedValue = null;
- SelectEmployees.ItemsSource = groups;
- SelectEmployees.SelectedIndex = 0;
- }
- );
- }
- );
- }
- private void PrevDay_Click(object sender, RoutedEventArgs e)
- {
- SelectDate.DateTime = SelectDate.DateTime.Value.AddDays(-1);
- }
- private void NextDay_Click(object sender, RoutedEventArgs e)
- {
- SelectDate.DateTime = SelectDate.DateTime.Value.AddDays(1);
- }
- private void SelectDate_DateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (IsReady)
- {
- Timesheets.Date = SelectDate.DateTime.Value;
- Tasks.Date = SelectDate.DateTime.Value;
- Manufacturing.Date = SelectDate.DateTime.Value;
- }
- }
- private void SelectEmployees_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!IsReady || SelectEmployees.SelectedValue == null)
- return;
- Timesheets.GroupID = (Guid)SelectEmployees.SelectedValue;
- Tasks.GroupID = (Guid)SelectEmployees.SelectedValue;
- Manufacturing.GroupID = (Guid)SelectEmployees.SelectedValue;
- }
- }
- }
|