| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using RichTextEditor = InABox.Core.RichTextEditor;
- namespace PRSDesktop
- {
- /// <summary>
- /// Interaction logic for QuoteProposalSummary.xaml
- /// </summary>
- public partial class QuoteProposalDetails : UserControl
- {
- private QuoteProposal _proposal;
- private Guid _proposalid;
- private Guid _quoteid;
- public QuoteProposalDetails()
- {
- InitializeComponent();
- }
- public Guid QuoteID
- {
- get => CostSheets.QuoteID;
- set => CostSheets.QuoteID = value;
- }
- public Guid ProposalID
- {
- get => _proposalid;
- set
- {
- _proposalid = value;
- Refresh(false, true);
- }
- }
- public void Refresh(bool columns, bool data)
- {
- if (columns)
- {
- Preamble.EditorDefinition = new RichTextEditor();
- Preamble.ColumnName = "Preamble";
- Preamble.Configure();
- Preamble.OnEditorValueChanged += Preamble_OnEditorValueChanged;
- Preamble.Loaded = true;
- Summary.EditorDefinition = new RichTextEditor();
- Summary.ColumnName = "Summary";
- Summary.Configure();
- Summary.OnEditorValueChanged += Summary_OnEditorValueChanged;
- Summary.Loaded = true;
- ExTax.EditorDefinition = new DoubleEditor();
- ExTax.ColumnName = "ExTax";
- ExTax.Configure();
- ExTax.OnEditorValueChanged += ExTax_OnEditorValueChanged;
- ExTax.Loaded = true;
- ExTax.EditorDefinition = new DoubleEditor();
- ExTax.ColumnName = "Tax";
- ExTax.Configure();
- ExTax.Loaded = true;
- IncTax.EditorDefinition = new DoubleEditor();
- IncTax.ColumnName = "IncTax";
- IncTax.Configure();
- IncTax.OnEditorValueChanged += IncTax_OnEditorValueChanged;
- IncTax.Loaded = true;
- CostSheets.Refresh(true, false);
- }
- if (data)
- {
- new Client<QuoteProposal>().Query(
- new Filter<QuoteProposal>(x => x.ID).IsEqualTo(_proposalid),
- new Columns<QuoteProposal>(x => x.ID, x => x.Preamble, x => x.Summary, x => x.ExTax, x => x.TaxCode.ID, x => x.IncTax),
- null,
- (table, error) =>
- {
- _proposal = table != null && table.Rows.Any() ? table.Rows.First().ToObject<QuoteProposal>() : null;
- Dispatcher.Invoke(() =>
- {
- Preamble.Value = _proposal != null ? _proposal.Preamble : "";
- ExTax.Value = _proposal != null ? _proposal.ExTax : 0.0F;
- TaxCode.Value = _proposal != null ? _proposal.TaxCode.ID : Guid.Empty;
- IncTax.Value = _proposal != null ? _proposal.IncTax : 0.0F;
- Summary.Value = _proposal != null ? _proposal.Summary : "";
- });
- }
- );
- CostSheets.ProposalID = _proposalid;
- }
- }
- private void Preamble_OnEditorValueChanged(IDynamicEditorControl sender, Dictionary<string, object> values)
- {
- if (_proposal != null && _proposal.Preamble != Preamble.Value)
- {
- _proposal.Preamble = Preamble.Value;
- new Client<QuoteProposal>().Save(_proposal, "", (p, e) => { });
- }
- }
- private void ExTax_OnEditorValueChanged(IDynamicEditorControl sender, Dictionary<string, object> values)
- {
- }
- private void IncTax_OnEditorValueChanged(IDynamicEditorControl sender, Dictionary<string, object> values)
- {
- }
- private void Summary_OnEditorValueChanged(IDynamicEditorControl sender, Dictionary<string, object> values)
- {
- if (_proposal != null && _proposal.Summary != Summary.Value)
- {
- _proposal.Summary = Summary.Value;
- new Client<QuoteProposal>().Save(_proposal, "", (p, e) => { });
- }
- }
- }
- }
|