| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using com.sun.corba.se.impl.protocol.giopmsgheaders;
- using com.sun.security.ntlm;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Configuration;
- using InABox.Core;
- using InABox.Core.Postable;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class InvoicePanelSettings : IUserConfigurationSettings
- {
- public bool IncludePaidInvoices { get; set; }
- }
-
- /// <summary>
- /// Interaction logic for InvoiceGrid.xaml
- /// </summary>
- public partial class InvoicePanel : UserControl, IPanel<Invoice>, IJobControl
- {
- private InvoicePanelSettings _settings;
-
- public InvoicePanel()
- {
- _settings = new UserConfiguration<InvoicePanelSettings>().Load();
- InitializeComponent();
- Invoices.IncludePaidInvoices = _settings.IncludePaidInvoices;
- _includePaid.IsChecked = _settings.IncludePaidInvoices;
- Invoices.OnSelectItem += Invoices_OnSelectItem;
-
- }
- public Guid ParentID
- {
- get => Invoices.JobID;
- set
- {
- Invoices.JobID = value;
- Parts.JobID = value;
- Time.JobID = value;
- }
- }
-
- public JobPanelSettings Settings { get; set; }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent OnUpdateDataModel;
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]> { { typeof(Invoice).EntityName(), Invoices.SelectedRows } };
- }
- public void CreateToolbarButtons(IPanelHost host)
- {
- PostUtils.CreateToolbarButtons(
- host,
- () => (DataModel(Selection.Selected) as IDataModel<Invoice>)!,
- () => Invoices.Refresh(false, true),
- true);
- }
- public void Setup()
- {
- Invoices.Refresh(true, false);
- Parts.Refresh(true, false);
- Time.Refresh(true, false);
- Lines.Refresh(true, false);
- }
- public void Shutdown()
- {
- }
- public void Refresh()
- {
- Invoices.Refresh(false, true);
- var bData = Invoices.SelectedRows.Any();
- Parts.Refresh(false, bData);
- Time.Refresh(false, bData);
- Lines.Refresh(false, bData);
- }
- public string SectionName => "Invoice Grid";
- public DataModel DataModel(Selection selection)
- {
- var ids = Invoices.ExtractValues(x => x.ID, selection).ToArray();
- return new InvoiceDataModel(new Filter<Invoice>(x => x.ID).InList(ids));
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- private void Invoices_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- if (!IsReady)
- return;
-
- var row = e.Rows?.FirstOrDefault();
- var jobid = row != null ? row.Get<Invoice, Guid>(x => x.JobLink.ID) : CoreUtils.FullGuid;
- var invoiceid = row != null ? row.Get<Invoice, Guid>(x => x.ID) : CoreUtils.FullGuid;
- Parts.JobID = jobid;
- Parts.InvoiceID = invoiceid;
- Parts.Refresh(false, true);
- Time.JobID = jobid;
- Time.InvoiceID = invoiceid;
- Time.Refresh(false, true);
- Lines.InvoiceID = invoiceid;
- Lines.Refresh(false, true);
- }
-
- private void _includePaid_OnChecked(object sender, RoutedEventArgs e)
- {
- _settings.IncludePaidInvoices = _includePaid.IsChecked == true;
- new UserConfiguration<InvoicePanelSettings>().Save(_settings);
- Invoices.IncludePaidInvoices = _includePaid.IsChecked == true;
- if (IsReady)
- Refresh();
- }
- }
- }
|