| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 | 
							- using Comal.Classes;
 
- using InABox.DynamicGrid;
 
- using InABox.Wpf;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.ComponentModel;
 
- using System.Linq;
 
- using System.Runtime.CompilerServices;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Data;
 
- using System.Windows.Documents;
 
- using System.Windows.Input;
 
- using System.Windows.Media;
 
- using System.Windows.Media.Imaging;
 
- using System.Windows.Navigation;
 
- using System.Windows.Shapes;
 
- namespace PRSDesktop;
 
- /// <summary>
 
- /// Interaction logic for SupplierBillEditLayout.xaml
 
- /// </summary>
 
- public partial class SupplierBillEditLayout : DynamicEditorGridLayout, INotifyPropertyChanged
 
- {
 
-     public event Action? Approve;
 
-     public override bool TabStripVisible
 
-     {
 
-         get { return Editors.TabStripVisible; }
 
-         set { Editors.TabStripVisible = value; }
 
-     }
 
-     private double _totalWidth;
 
-     public override double TotalWidth => _totalWidth;
 
-     private double _datesHeight;
 
-     private double _editorHeight;
 
-     private double _pageHeight;
 
-     public override double TotalHeight => Math.Max(_datesHeight, _editorHeight) + _pageHeight;
 
-     private double _poAmount;
 
-     public double POAmount
 
-     {
 
-         get => _poAmount;
 
-         set
 
-         {
 
-             _poAmount = value;
 
-             OnPropertyChanged();
 
-             OnPropertyChanged(nameof(BillLessThanPO));
 
-         }
 
-     }
 
-     private double _billAmount;
 
-     public double BillAmount
 
-     {
 
-         get => _billAmount;
 
-         set
 
-         {
 
-             _billAmount = value;
 
-             OnPropertyChanged();
 
-             OnPropertyChanged(nameof(BillLessThanPO));
 
-         }
 
-     }
 
-     private bool _canApprove = false;
 
-     public bool CanApprove
 
-     {
 
-         get => _canApprove;
 
-         set
 
-         {
 
-             _canApprove = value;
 
-             OnPropertyChanged();
 
-         }
 
-     }
 
-     private bool _isApproved = false;
 
-     public bool IsApproved
 
-     {
 
-         get => _isApproved;
 
-         set
 
-         {
 
-             _isApproved = value;
 
-             ApproveButton.Content = value ? "Unapprove" : "Approve";
 
-             OnPropertyChanged();
 
-         }
 
-     }
 
-     public bool BillLessThanPO => BillAmount <= POAmount;
 
-     public SupplierBillEditLayout()
 
-     {
 
-         InitializeComponent();
 
-     }
 
-     public override void LoadPages(IEnumerable<IDynamicEditorPage> pages)
 
-     {
 
-         Editors.Items.Clear();
 
-         OtherPages.Items.Clear();
 
-         Dates.Items.Clear();
 
-         foreach (var page in pages.OrderBy(x => x.PageType).ThenBy(x => x.Order).ThenBy(x => x.Caption()))
 
-         {
 
-             var tab = new DynamicTabItem();
 
-             tab.Header = page.Caption();
 
-             if (page is FrameworkElement element)
 
-                 element.Margin = new Thickness(0, 2, 0, 0);
 
-             tab.Content = page;
 
-             var minSize = page.MinimumSize();
 
-             if(page is DynamicEditorGrid.DynamicEditPage)
 
-             {
 
-                 if (page.Caption() == "Dates")
 
-                 {
 
-                     Dates.Items.Add(tab);
 
-                     _datesHeight = Math.Max(_editorHeight, minSize.Height);
 
-                 }
 
-                 else
 
-                 {
 
-                     Editors.Items.Add(tab);
 
-                     _editorHeight = Math.Max(_editorHeight, minSize.Height);
 
-                     _totalWidth = Math.Max(_totalWidth, minSize.Width);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 OtherPages.Items.Add(tab);
 
-                 _pageHeight = Math.Max(_pageHeight, minSize.Height);
 
-             }
 
-         }
 
-         Dates.Visibility = Dates.Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
 
-         Dates.SelectedIndex = 0;
 
-         Editors.SelectedIndex = 0;
 
-         OtherPages.SelectedIndex = 0;
 
-     }
 
-     private bool bChanging;
 
-     public event PropertyChangedEventHandler? PropertyChanged;
 
-     protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
 
-     {
 
-         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
 
-     }
 
-     private void Editors_SelectionChanged(object sender, SelectionChangedEventArgs e)
 
-     {
 
-         if (bChanging) return;
 
-         if ((e.OriginalSource != Editors && e.OriginalSource != OtherPages) || e.OriginalSource is not DynamicTabControl tabControl) return;
 
-         if (tabControl.SelectedItem is not DynamicTabItem tab) return;
 
-         bChanging = true;
 
-         try
 
-         {
 
-             if (tab is not null && tab.Content is IDynamicEditorPage page)
 
-             {
 
-                 SelectPage(page);
 
-             }
 
-         }
 
-         finally
 
-         {
 
-             bChanging = false;
 
-         }
 
-     }
 
-     private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
 
-     {
 
-         EditorRow.MaxHeight = e.NewSize.Height - 50;
 
-     }
 
-     private void ApproveButton_Click(object sender, RoutedEventArgs e)
 
-     {
 
-         Approve?.Invoke();
 
-     }
 
- }
 
 
  |