| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Configuration;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- namespace PRSDesktop
- {
-
- public class QuoteContractsSettings : BaseObject, IGlobalConfigurationSettings
- {
- public bool EnableCustomProposalValues { get; set; }
- }
-
- /// <summary>
- /// Interaction logic for QuoteContracts.xaml
- /// </summary>
- public partial class QuoteContracts : UserControl, IMasterDetailControl<Quote>, IPanel<Quote>
- {
-
- public Quote? Master
- {
- get => Contracts.Master;
- set => Contracts.Master = value;
- }
- private readonly QuoteContractsSettings _settings;
-
- public QuoteContracts()
- {
- InitializeComponent();
- _settings = new GlobalConfiguration<QuoteContractsSettings>().Load();
- }
- public bool IsReady { get; set; }
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public void CreateToolbarButtons(IPanelHost host)
- {
- host.CreatePanelAction(new PanelAction("Create Job", PRSDesktop.Resources.tick, CreateJob));
-
- host.CreateSetupAction(new PanelAction()
- {
- Caption = "Contracts Settings",
- Image = PRSDesktop.Resources.specifications,
- OnExecute = action =>
- {
- var grid = new DynamicItemsListGrid<ProjectsSettings>();
- if (grid.EditItems(new QuoteContractsSettings[] { _settings }))
- {
- new GlobalConfiguration<QuoteContractsSettings>().Save(_settings);
- // reload grids?
- }
- }
- });
- }
-
- private void CreateJob(PanelAction action)
- {
- // Scan through
- }
- public string SectionName => "Quote Contracts";
- public DataModel DataModel(Selection selection)
- {
- var ids = Contracts.ExtractValues(x => x.ID, selection).ToArray();
- return new BaseDataModel<QuoteContract>(new Filter<QuoteContract>(x => x.ID).InList(ids));
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- public void Refresh()
- {
- Contracts.Refresh(false, true);
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Setup()
- {
- Contracts.Refresh(true, false);
- Proposals.Refresh(true, false);
- Contracts.OnSelectItem += Contracts_OnSelectItem;
- }
- public void Shutdown(CancelEventArgs? cancel)
- {
- }
- public Dictionary<Type, CoreTable> DataEnvironment()
- {
- return new Dictionary<Type, CoreTable>();
- }
- private void Contracts_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
- {
- var row = e.Rows?.FirstOrDefault();
- Proposals.Master = row?.ToObject<QuoteContract>() ;
- Proposals.Refresh(false,true);
- }
- }
- }
|