| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for InvoiceGrid.xaml
- /// </summary>
- public partial class InvoiceGrid : UserControl, IPanel<Invoice>, IJobControl
- {
- public InvoiceGrid()
- {
- InitializeComponent();
- Invoices.OnSelectItem += Invoices_OnSelectItem;
- }
- public Guid JobID
- {
- get => Invoices.JobID;
- set
- {
- Invoices.JobID = value;
- Parts.JobID = value;
- Time.JobID = value;
- }
- }
- 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)
- {
- }
- 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)
- {
- var row = e.Rows?.FirstOrDefault();
- var id = row != null ? row.Get<Invoice, Guid>(x => x.ID) : CoreUtils.FullGuid;
- Parts.InvoiceID = id;
- Parts.Refresh(false, true);
- Time.InvoiceID = id;
- Time.Refresh(false, true);
- Lines.InvoiceID = id;
- Lines.Refresh(false, true);
- }
- }
- }
|