|
@@ -6,163 +6,191 @@ using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
+using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
-using javax.xml.crypto;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+public class SupplierBillPanelSettings : IUserConfigurationSettings
|
|
|
{
|
|
|
- public partial class SupplierBillPanel : UserControl, IPanel<Bill>
|
|
|
+ public SupplierBillPanelSettings()
|
|
|
{
|
|
|
- public SupplierBillPanel()
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- }
|
|
|
-
|
|
|
- public bool IsReady { get; set; }
|
|
|
+ AnchorWidth = 500F;
|
|
|
+ ViewType = ScreenViewType.Combined;
|
|
|
+ }
|
|
|
|
|
|
- public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
+ public ScreenViewType ViewType { get; set; }
|
|
|
+ public double AnchorWidth { get; set; }
|
|
|
+}
|
|
|
|
|
|
- public Dictionary<string, object[]> Selected()
|
|
|
- {
|
|
|
- return new Dictionary<string, object[]> { { typeof(Bill).EntityName(), Bills.SelectedRows } };
|
|
|
- }
|
|
|
+public partial class SupplierBillPanel : UserControl, IPanel<Bill>
|
|
|
+{
|
|
|
+ private SupplierBillPanelSettings settings;
|
|
|
|
|
|
- public void CreateToolbarButtons(IPanelHost host)
|
|
|
- {
|
|
|
- PostUtils.CreateToolbarButtons(host,
|
|
|
- () => (DataModel(Selection.Selected) as IDataModel<Bill>)!,
|
|
|
- () => Bills.Refresh(false, true),
|
|
|
- true);
|
|
|
- }
|
|
|
+ public SupplierBillPanel()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsReady { get; set; }
|
|
|
|
|
|
- public string SectionName => "Supplier Bills";
|
|
|
+ public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
|
|
|
- public DataModel DataModel(Selection selection)
|
|
|
- {
|
|
|
- var ids = Bills.ExtractValues(x => x.ID, selection).ToArray();
|
|
|
- return new BaseDataModel<Bill>(new Filter<Bill>(x => x.ID).InList(ids));
|
|
|
- }
|
|
|
+ public Dictionary<string, object[]> Selected()
|
|
|
+ {
|
|
|
+ return new Dictionary<string, object[]> { { typeof(Bill).EntityName(), Bills.SelectedRows } };
|
|
|
+ }
|
|
|
+
|
|
|
+ public void CreateToolbarButtons(IPanelHost host)
|
|
|
+ {
|
|
|
+ PostUtils.CreateToolbarButtons(host,
|
|
|
+ () => (DataModel(Selection.Selected) as IDataModel<Bill>)!,
|
|
|
+ () => Bills.Refresh(false, true),
|
|
|
+ true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public string SectionName => "Supplier Bills";
|
|
|
+
|
|
|
+ public DataModel DataModel(Selection selection)
|
|
|
+ {
|
|
|
+ var ids = Bills.ExtractValues(x => x.ID, selection).ToArray();
|
|
|
+ return new BaseDataModel<Bill>(new Filter<Bill>(x => x.ID).InList(ids));
|
|
|
+ }
|
|
|
|
|
|
- public void Refresh()
|
|
|
+ public void Refresh()
|
|
|
+ {
|
|
|
+ if (CheckSaved())
|
|
|
{
|
|
|
- if (CheckSaved())
|
|
|
- {
|
|
|
- Bills.Refresh(false, true);
|
|
|
- SetChanged(false);
|
|
|
- }
|
|
|
+ Bills.Refresh(false, true);
|
|
|
+ SetChanged(false);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- public void Setup()
|
|
|
+ public void Setup()
|
|
|
+ {
|
|
|
+ settings = new UserConfiguration<SupplierBillPanelSettings>().Load();
|
|
|
+
|
|
|
+ SplitPanel.View = settings.ViewType == ScreenViewType.Register ? DynamicSplitPanelView.Master :
|
|
|
+ settings.ViewType == ScreenViewType.Details ? DynamicSplitPanelView.Detail : DynamicSplitPanelView.Combined;
|
|
|
+ SplitPanel.AnchorWidth = settings.AnchorWidth;
|
|
|
+
|
|
|
+ Bill.SetLayoutType<VerticalDynamicEditorGridLayout>();
|
|
|
+ Bills.Refresh(true, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CheckSaved(CancelEventArgs cancel)
|
|
|
+ {
|
|
|
+ if (!bChanged)
|
|
|
{
|
|
|
- Bill.SetLayoutType<VerticalDynamicEditorGridLayout>();
|
|
|
- Bills.Refresh(true, false);
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- private void CheckSaved(CancelEventArgs cancel)
|
|
|
+ var result = MessageBox.Show("You have an unsaved Supplier Bill; do you wish to save these changes?", "Save Changes?", MessageBoxButton.YesNoCancel);
|
|
|
+ if (result == MessageBoxResult.Yes)
|
|
|
{
|
|
|
- if (!bChanged)
|
|
|
+ Bill.SaveItem(cancel);
|
|
|
+ if (!cancel.Cancel)
|
|
|
{
|
|
|
- return;
|
|
|
- }
|
|
|
- var result = MessageBox.Show("You have an unsaved Supplier Bill; do you wish to save these changes?", "Save Changes?", MessageBoxButton.YesNoCancel);
|
|
|
- if (result == MessageBoxResult.Yes)
|
|
|
- {
|
|
|
- Bill.SaveItem(cancel);
|
|
|
- if (!cancel.Cancel)
|
|
|
- {
|
|
|
- MessageBox.Show("Purchase Order saved.");
|
|
|
- }
|
|
|
- }
|
|
|
- else if (result == MessageBoxResult.Cancel)
|
|
|
- {
|
|
|
- cancel.Cancel = true;
|
|
|
+ MessageBox.Show("Purchase Order saved.");
|
|
|
}
|
|
|
}
|
|
|
- private bool CheckSaved()
|
|
|
+ else if (result == MessageBoxResult.Cancel)
|
|
|
{
|
|
|
- var cancel = new CancelEventArgs();
|
|
|
- CheckSaved(cancel);
|
|
|
- return !cancel.Cancel;
|
|
|
+ cancel.Cancel = true;
|
|
|
}
|
|
|
+ }
|
|
|
+ private bool CheckSaved()
|
|
|
+ {
|
|
|
+ var cancel = new CancelEventArgs();
|
|
|
+ CheckSaved(cancel);
|
|
|
+ return !cancel.Cancel;
|
|
|
+ }
|
|
|
|
|
|
- public void Shutdown(CancelEventArgs? cancel)
|
|
|
+ public void Shutdown(CancelEventArgs? cancel)
|
|
|
+ {
|
|
|
+ if(cancel is not null)
|
|
|
{
|
|
|
- if(cancel is not null)
|
|
|
- {
|
|
|
- CheckSaved(cancel);
|
|
|
- }
|
|
|
+ CheckSaved(cancel);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- public void Heartbeat(TimeSpan time)
|
|
|
+ public void Heartbeat(TimeSpan time)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public Dictionary<Type, CoreTable> DataEnvironment()
|
|
|
+ {
|
|
|
+ return new Dictionary<Type, CoreTable>
|
|
|
{
|
|
|
- }
|
|
|
-
|
|
|
- public Dictionary<Type, CoreTable> DataEnvironment()
|
|
|
+ { typeof(Bill), Bills.Data }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ private Bill[]? _bills = null;
|
|
|
+
|
|
|
+ private void Bills_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e)
|
|
|
+ {
|
|
|
+ if(SplitPanel.View != DynamicSplitPanelView.Master)
|
|
|
{
|
|
|
- return new Dictionary<Type, CoreTable>
|
|
|
- {
|
|
|
- { typeof(Bill), Bills.Data }
|
|
|
- };
|
|
|
+ ReloadBills();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private Bill[]? _bills = null;
|
|
|
-
|
|
|
- private void Bills_OnOnSelectItem(object sender, DynamicGridSelectionEventArgs e)
|
|
|
+ private void ReloadBills()
|
|
|
+ {
|
|
|
+ if (Bills.SelectedRows?.Any() == true)
|
|
|
{
|
|
|
- if(SplitPanel.View != DynamicSplitPanelView.Master)
|
|
|
- {
|
|
|
- ReloadBills();
|
|
|
- }
|
|
|
+ _bills = Bills.LoadBills(Bills.SelectedRows);
|
|
|
+ Bills.InitialiseEditorForm(Bill, _bills, null, true);
|
|
|
+ Bill.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
-
|
|
|
- private void ReloadBills()
|
|
|
+ else
|
|
|
{
|
|
|
- if (Bills.SelectedRows?.Any() == true)
|
|
|
- {
|
|
|
- _bills = Bills.LoadBills(Bills.SelectedRows);
|
|
|
- Bills.InitialiseEditorForm(Bill, _bills, null, true);
|
|
|
- Bill.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _bills = null;
|
|
|
- Bill.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
+ _bills = null;
|
|
|
+ Bill.Visibility = Visibility.Hidden;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void Bill_OnOnOK()
|
|
|
+ private void Bill_OnOnOK()
|
|
|
+ {
|
|
|
+ using (new WaitCursor())
|
|
|
{
|
|
|
- using (new WaitCursor())
|
|
|
+ var cancel = new System.ComponentModel.CancelEventArgs();
|
|
|
+ Bill.SaveItem(cancel);
|
|
|
+ if (!cancel.Cancel)
|
|
|
{
|
|
|
- var cancel = new System.ComponentModel.CancelEventArgs();
|
|
|
- Bill.SaveItem(cancel);
|
|
|
- if (!cancel.Cancel)
|
|
|
- {
|
|
|
- ReloadBills();
|
|
|
- SetChanged(false);
|
|
|
- }
|
|
|
+ ReloadBills();
|
|
|
+ SetChanged(false);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- private void Bill_OnOnCancel()
|
|
|
- {
|
|
|
- ReloadBills();
|
|
|
- SetChanged(false);
|
|
|
- }
|
|
|
+ private void Bill_OnOnCancel()
|
|
|
+ {
|
|
|
+ ReloadBills();
|
|
|
+ SetChanged(false);
|
|
|
+ }
|
|
|
|
|
|
- private void SetChanged(bool changed)
|
|
|
- {
|
|
|
- bChanged = changed;
|
|
|
- Bills.IsEnabled = !changed;
|
|
|
- Bill.HideButtons = !changed;
|
|
|
- }
|
|
|
+ private void SetChanged(bool changed)
|
|
|
+ {
|
|
|
+ bChanged = changed;
|
|
|
+ Bills.IsEnabled = !changed;
|
|
|
+ Bill.HideButtons = !changed;
|
|
|
+ }
|
|
|
|
|
|
- private bool bChanged = false;
|
|
|
- private void Bill_OnOnChanged(object? sender, EventArgs e)
|
|
|
- {
|
|
|
- SetChanged(true);
|
|
|
- }
|
|
|
+ private bool bChanged = false;
|
|
|
+ private void Bill_OnOnChanged(object? sender, EventArgs e)
|
|
|
+ {
|
|
|
+ SetChanged(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
+ {
|
|
|
+ settings.ViewType = SplitPanel.View == DynamicSplitPanelView.Master ? ScreenViewType.Register :
|
|
|
+ SplitPanel.View == DynamicSplitPanelView.Detail ? ScreenViewType.Details : ScreenViewType.Combined;
|
|
|
+ settings.AnchorWidth = SplitPanel.AnchorWidth;
|
|
|
+
|
|
|
+ new UserConfiguration<SupplierBillPanelSettings>().Save(settings);
|
|
|
}
|
|
|
}
|