| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- namespace PRSDesktop
- {
- public class JobRFIGrid : DynamicDataGrid<JobRFI>
- {
- public Guid ParentID { get; set; }
- public JobRFIGrid()
- {
- Options
- .BeginUpdate()
- .Clear()
- .Add(DynamicGridOption.AddRows)
- .Add(DynamicGridOption.EditRows)
- .Add(DynamicGridOption.DeleteRows)
- .Add(DynamicGridOption.FilterRows)
- .Add(DynamicGridOption.SelectColumns)
- .Add(DynamicGridOption.AddRows)
- .EndUpdate();
- }
-
- protected override void Reload(Filters<JobRFI> criteria, Columns<JobRFI> columns, ref SortOrder<JobRFI>? sort, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(new Filter<JobRFI>(c => c.Job.ID).IsEqualTo(ParentID));
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override JobRFI CreateItem()
- {
- var result = base.CreateItem();
- result.Job.ID = ParentID;
- return result;
- }
-
- public JobRFI[] LoadRFIs(CoreRow[]? rows)
- {
- return LoadItems(rows);
- }
- }
- public partial class JobRFIPanel : UserControl, IPanel<JobRFI>, IJobControl
- {
- public Guid ParentID { get; set; }
- public JobRFIPanel()
- {
- InitializeComponent();
- }
- private void DynamicSplitPanel_OnOnChanged(object sender, DynamicSplitPanelSettings e)
- {
- if (e.View == DynamicSplitPanelView.Master)
- RFIs.Options.Add(DynamicGridOption.MultiSelect);
- else
- RFIs.Options.Remove(DynamicGridOption.MultiSelect);
- }
- private JobRFI[]? _rfis = null;
- private void RFIs_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- ReloadRFIs();
- }
- private void ReloadRFIs()
- {
- if (RFIs.SelectedRows?.Any() == true)
- {
- _rfis = RFIs.LoadRFIs(RFIs.SelectedRows);
- RFIs.InitialiseEditorForm(RFIEditor, _rfis);
- RFIEditor.Visibility = Visibility.Visible;
- }
- else
- {
- _rfis = null;
- RFIEditor.Visibility = Visibility.Hidden;
- }
- }
- private void RFI_OnOnOK()
- {
- using (new WaitCursor())
- {
- var cancel = new System.ComponentModel.CancelEventArgs();
- RFIEditor.SaveItem(cancel);
- if (!cancel.Cancel)
- ReloadRFIs();
- }
- }
- private void RFI_OnOnCancel()
- {
- ReloadRFIs();
- }
- #region IPanel Stuff
- public void Setup()
- {
- RFIs.Refresh(true, false);
- }
- public void Shutdown()
- {
-
- }
- public void Refresh()
- {
- RFIs.Refresh(false, true);
- }
- public string SectionName => "Job RFIs";
- public DataModel DataModel(Selection selection)
- {
- return new BaseDataModel<JobRFI>(new Filter<JobRFI>(x => x.Job.ID).IsEqualTo(ParentID));
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public bool IsReady { get; set; }
- public void CreateToolbarButtons(IPanelHost host)
- {
-
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Heartbeat(TimeSpan time)
- {
-
- }
-
- #endregion
- }
- }
|