|
|
@@ -361,22 +361,8 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
|
|
|
}
|
|
|
|
|
|
- private bool HasPurchaseOrders()
|
|
|
- {
|
|
|
- var ids = SelectedRows.Select(r => r.Get<JobRequisitionItem, Guid>(x => x.ID)).ToArray();
|
|
|
- return Client.Query(
|
|
|
- new Filter<PurchaseOrderItemAllocation>(x => x.JobRequisitionItem.ID).InList(ids),
|
|
|
- Columns.None<PurchaseOrderItemAllocation>().Add(x => x.ID)
|
|
|
- ).Rows.Any();
|
|
|
- }
|
|
|
-
|
|
|
private void CreatePurchaseOrder()
|
|
|
{
|
|
|
- if (HasPurchaseOrders())
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("You cannot do this when Purchase Orders already exist!","Error");
|
|
|
- return;
|
|
|
- }
|
|
|
var mr = MessageWindow.ShowYesNoCancel("Include Style in Order?", "Confirm");
|
|
|
if (mr == MessageWindowResult.Cancel)
|
|
|
return;
|
|
|
@@ -386,7 +372,9 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
{
|
|
|
var jri = row.ToObject<JobRequisitionItem>();
|
|
|
if (mr != MessageWindowResult.Yes)
|
|
|
+ {
|
|
|
jri.Style.CopyFrom(new ProductStyle());
|
|
|
+ }
|
|
|
|
|
|
var qtyrequired = row.Get<JobRequisitionItem, double>(c => c.Qty) - row.Get<JobRequisitionItem, double>(c => c.InStock);
|
|
|
|
|
|
@@ -440,12 +428,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
|
|
|
private void AddToExistingOrder()
|
|
|
{
|
|
|
- if (HasPurchaseOrders())
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("You cannot do this when Purchase Orders already exist!", "Error");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
var dlg = new MultiSelectDialog<PurchaseOrder>(
|
|
|
new Filter<PurchaseOrder>(x => x.ClosedDate).IsEqualTo(DateTime.MinValue),
|
|
|
Columns.None<PurchaseOrder>().Add(x => x.ID),
|
|
|
@@ -663,7 +645,12 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
x => x.Item.PurchaseOrderLink.SupplierLink.Name)
|
|
|
.ToArray();
|
|
|
foreach (var tuple in orders)
|
|
|
- column.AddItem($"{tuple.Item2}: {tuple.Item3}", PRSDesktop.Resources.purchase, (r) => ViewPurchaseOrder(tuple.Item1), viewOrder);
|
|
|
+ {
|
|
|
+ if(tuple.Item1 != Guid.Empty)
|
|
|
+ {
|
|
|
+ column.AddItem($"{tuple.Item2}: {tuple.Item3}", PRSDesktop.Resources.purchase, (r) => ViewPurchaseOrder(tuple.Item1), viewOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -859,92 +846,44 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
|
|
|
private void ViewPurchaseOrder(Guid id)
|
|
|
{
|
|
|
-
|
|
|
- if (Guid.Equals(id, Guid.Empty)) return;
|
|
|
-
|
|
|
var _entity = Client.Query(
|
|
|
new Filter<PurchaseOrder>(x => x.ID).IsEqualTo(id),
|
|
|
- DynamicGridUtils.LoadEditorColumns(Columns.None<PurchaseOrder>())
|
|
|
- ).Rows
|
|
|
- .FirstOrDefault()?
|
|
|
- .ToObject<PurchaseOrder>();
|
|
|
+ DynamicGridUtils.LoadEditorColumns(Columns.None<PurchaseOrder>()))
|
|
|
+ .ToObjects<PurchaseOrder>().FirstOrDefault();
|
|
|
|
|
|
if (_entity is null) return;
|
|
|
|
|
|
- var _window = new Window() { Title = "View Purchase Order Details" };
|
|
|
-
|
|
|
- var _editor = new EmbeddedDynamicEditorForm
|
|
|
+ var window = new DynamicEditorForm()
|
|
|
{
|
|
|
- HighlightButtons = true,
|
|
|
- DisableButtons = true,
|
|
|
- HideButtons = false,
|
|
|
- Margin = new Thickness(5)
|
|
|
+ Title = "View Purchase Order Details"
|
|
|
};
|
|
|
- _editor.SetValue(Grid.RowProperty, 1);
|
|
|
- _editor.SetLayoutType<VerticalDynamicEditorGridLayout>();
|
|
|
- _window.Content = _editor;
|
|
|
+ window.Form.HighlightButtons = true;
|
|
|
+ window.Form.DisableOKIfUnchanged = true;
|
|
|
+ window.Form.SetLayoutType<VerticalDynamicEditorGridLayout>();
|
|
|
|
|
|
- new SupplierPurchaseOrders().InitialiseEditorForm(_editor, new PurchaseOrder[] { _entity }, null, true);
|
|
|
+ new SupplierPurchaseOrders().InitialiseEditorForm(window, new PurchaseOrder[] { _entity }, null, true);
|
|
|
|
|
|
- _editor.AddButton(new Button()
|
|
|
+ window.Form.AddButton(new Button()
|
|
|
{
|
|
|
Content = new System.Windows.Controls.Image() { Source = PRSDesktop.Resources.printer.AsBitmapImage(32,32) },
|
|
|
- Command = new ActionCommand(() => ShowReports(_editor, id)),
|
|
|
+ Command = new ActionCommand(() => ShowReports(id)),
|
|
|
Width = 40
|
|
|
});
|
|
|
- _editor.OnAfterEditorValueChanged += (sender, args) =>
|
|
|
- {
|
|
|
- _editor.DisableButtons = false;
|
|
|
- return null;
|
|
|
- };
|
|
|
-
|
|
|
- _editor.OnOK += () =>
|
|
|
- {
|
|
|
- _editor.SaveItem(new CancelEventArgs());
|
|
|
- _window.DialogResult = true;
|
|
|
- Refresh(false,true);
|
|
|
- };
|
|
|
- _editor.OnCancel += () =>
|
|
|
+ if (window.ShowDialog() == true)
|
|
|
{
|
|
|
- _window.DialogResult = false;
|
|
|
- };
|
|
|
- _editor.OnChanged += (sender, args) =>
|
|
|
- {
|
|
|
- _editor.DisableButtons = false;
|
|
|
- };
|
|
|
-
|
|
|
- _window.ShowDialog();
|
|
|
-
|
|
|
+ Refresh(false, true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void ShowReports(EmbeddedDynamicEditorForm editor, Guid id)
|
|
|
+ private static void ShowReports(Guid id)
|
|
|
{
|
|
|
var _model = new AutoDataModel<PurchaseOrder>(new Filter<PurchaseOrder>(x => x.ID).IsEqualTo(id));
|
|
|
var menu = new ContextMenu();
|
|
|
var templates = ReportUtils.LoadReports("Purchase Orders", _model, Columns.None<ReportTemplate>().Add(x => x.ID, x => x.Name));
|
|
|
-
|
|
|
- foreach (var template in templates)
|
|
|
- {
|
|
|
- var item = new MenuItem
|
|
|
- {
|
|
|
- Header = template.Name,
|
|
|
- Icon = new System.Windows.Controls.Image() { Source = PRSDesktop.Resources.printer.AsBitmapImage(24,24) },
|
|
|
- Command = new ActionCommand(() =>
|
|
|
- ReportUtils.PreviewReport(
|
|
|
- template,
|
|
|
- _model,
|
|
|
- false,
|
|
|
- Security.IsAllowed<CanDesignReports>()
|
|
|
- )
|
|
|
- ),
|
|
|
- IsEnabled = editor.DisableButtons
|
|
|
- };
|
|
|
- menu.Items.Add(item);
|
|
|
-
|
|
|
- }
|
|
|
+ ReportUtils.PopulateMenu(menu, "Purchase Orders", _model, Security.IsAllowed<CanDesignReports>(), true);
|
|
|
|
|
|
if (menu.Items.Count == 0)
|
|
|
- menu.Items.Add(new MenuItem() { Header = "No Reports Available!" });
|
|
|
+ menu.AddItem("No reports", null, null, enabled: false);
|
|
|
menu.IsOpen = true;
|
|
|
}
|
|
|
|
|
|
@@ -953,7 +892,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
{
|
|
|
if (row is null) return;
|
|
|
|
|
|
- List<StockHolding> _holdings = new();
|
|
|
var _movements = Client.Query(
|
|
|
new Filter<StockMovement>(x => x.JobRequisitionItem.ID)
|
|
|
.IsEqualTo(row.Get<JobRequisitionItem, Guid>(x => x.ID)),
|
|
|
@@ -968,30 +906,11 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
.Add(x=>x.Units)
|
|
|
.Add(x=>x.Cost)
|
|
|
).ToObjects<StockMovement>();
|
|
|
- foreach (var _movement in _movements)
|
|
|
- {
|
|
|
- var _holding = _holdings.FirstOrDefault(x =>
|
|
|
- Guid.Equals(x.Location.ID, _movement.Location.ID)
|
|
|
- && Guid.Equals(x.Style.ID, _movement.Style.ID)
|
|
|
- && x.Dimensions.Equals(_movement.Dimensions)
|
|
|
- );
|
|
|
- if (_holding == null)
|
|
|
- {
|
|
|
- _holding = new StockHolding();
|
|
|
- _holding.Location.CopyFrom(_movement.Location);
|
|
|
- _holding.Style.CopyFrom(_movement.Style);
|
|
|
- _holding.Dimensions.CopyFrom(_movement.Dimensions);
|
|
|
- _holding.Units += _movement.Units;
|
|
|
- _holding.Value += _movement.Units * _movement.Cost;
|
|
|
- if (!_holding.Units.IsEffectivelyEqual(0.0))
|
|
|
- _holding.AverageValue = _holding.Value / _holding.Units;
|
|
|
- }
|
|
|
- _holdings.Add(_holding);
|
|
|
- }
|
|
|
|
|
|
- DynamicItemsListGrid<StockHolding> grid = new()
|
|
|
+ var holdings = StockHoldingExtensions.GroupMovements(_movements);
|
|
|
+ var grid = new DynamicItemsListGrid<StockHolding>()
|
|
|
{
|
|
|
- Items = _holdings
|
|
|
+ Items = holdings
|
|
|
};
|
|
|
grid.ColumnsLoaded += (sender, args) =>
|
|
|
{
|
|
|
@@ -1008,7 +927,6 @@ public class ReservationManagementItemGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
|
|
|
var window = DynamicGridUtils.CreateGridWindow("Stock Holdings", grid);
|
|
|
window.ShowDialog();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void ViewStockMovements(CoreRow? row)
|