|
@@ -1,19 +1,15 @@
|
|
|
-using System;
|
|
|
+using Comal.Classes;
|
|
|
+using InABox.Clients;
|
|
|
+using InABox.Core;
|
|
|
+using InABox.DynamicGrid;
|
|
|
+using InABox.WPF;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
-using System.Reflection;
|
|
|
using System.Windows;
|
|
|
-using System.Windows.Controls;
|
|
|
using System.Windows.Media;
|
|
|
-using Comal.Classes;
|
|
|
-using InABox.Clients;
|
|
|
-using InABox.Core;
|
|
|
-using InABox.DynamicGrid;
|
|
|
-using InABox.WPF;
|
|
|
-using PRSDesktop.Panels.Jobs;
|
|
|
-using Syncfusion.UI.Xaml.Charts;
|
|
|
-using Syncfusion.UI.Xaml.Diagram.Theming;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
@@ -23,16 +19,18 @@ namespace PRSDesktop
|
|
|
string empName = "";
|
|
|
|
|
|
public bool IncludeReserves { get; set; }
|
|
|
-
|
|
|
+
|
|
|
public Job Job { get; set; }
|
|
|
-
|
|
|
+
|
|
|
public JobPanelSettings Settings { get; set; }
|
|
|
-
|
|
|
+
|
|
|
public JobSummaryGrid() : base()
|
|
|
{
|
|
|
ColumnsTag = nameof(JobSummaryGrid);
|
|
|
|
|
|
OnCellDoubleClick += JobSummaryGrid_OnCellDoubleClick;
|
|
|
+
|
|
|
+ SetupDetailsColumns();
|
|
|
}
|
|
|
|
|
|
protected override void Init()
|
|
@@ -110,6 +108,11 @@ namespace PRSDesktop
|
|
|
if (row is null) return;
|
|
|
var menu = column.GetMenu();
|
|
|
menu.AddItem("View Stock Movements", PRSDesktop.Resources.forklift, row, ViewStockMovements_Click);
|
|
|
+
|
|
|
+ foreach(var col in DetailsColumns)
|
|
|
+ {
|
|
|
+ menu.AddItem(col.MenuText, null, row, col.Action);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void ViewStockMovements_Click(CoreRow row)
|
|
@@ -166,16 +169,16 @@ namespace PRSDesktop
|
|
|
}
|
|
|
|
|
|
private void ShowDetailGrid<TEntity>(
|
|
|
- String columnname,
|
|
|
- Expression<Func<TEntity,object?>> productcol,
|
|
|
- Guid productid,
|
|
|
- Expression<Func<TEntity,object?>> stylecol,
|
|
|
- Guid? styleid,
|
|
|
- Expression<Func<TEntity,object?>> unitcol,
|
|
|
+ String columnname,
|
|
|
+ Expression<Func<TEntity, object?>> productcol,
|
|
|
+ Guid productid,
|
|
|
+ Expression<Func<TEntity, object?>> stylecol,
|
|
|
+ Guid? styleid,
|
|
|
+ Expression<Func<TEntity, object?>> unitcol,
|
|
|
String unitsize,
|
|
|
- Expression<Func<TEntity,object?>>? jobcol,
|
|
|
+ Expression<Func<TEntity, object?>>? jobcol,
|
|
|
Filter<TEntity>? extrafilter,
|
|
|
- Func<CoreRow,bool>? rowfilter
|
|
|
+ Func<CoreRow, bool>? rowfilter
|
|
|
)
|
|
|
{
|
|
|
var grid = (Activator.CreateInstance(typeof(DynamicDataGrid<>).MakeGenericType(typeof(TEntity))) as IDynamicDataGrid);
|
|
@@ -195,10 +198,10 @@ namespace PRSDesktop
|
|
|
.And(unitcol).IsEqualTo(unitsize);
|
|
|
if (styleid.HasValue)
|
|
|
filter = filter.And(stylecol).IsEqualTo(styleid);
|
|
|
-
|
|
|
+
|
|
|
if (jobcol != null)
|
|
|
filter = filter.And(jobcol).IsEqualTo(Job.ID);
|
|
|
-
|
|
|
+
|
|
|
if (extrafilter != null)
|
|
|
filter = filter.And(extrafilter);
|
|
|
return filter;
|
|
@@ -207,146 +210,188 @@ namespace PRSDesktop
|
|
|
var window = DynamicGridUtils.CreateGridWindow($"Viewing {CoreUtils.Neatify(columnname)} Calculation", (grid as BaseDynamicGrid)!);
|
|
|
window.ShowDialog();
|
|
|
}
|
|
|
-
|
|
|
- private void JobSummaryGrid_OnCellDoubleClick(object sender, DynamicGridCellClickEventArgs args)
|
|
|
+
|
|
|
+ private static readonly Column<JobMaterial> BOMColumn = new Column<JobMaterial>(x => x.BillOfMaterials);
|
|
|
+ private static readonly Column<JobMaterial> RequisitionsColumn = new Column<JobMaterial>(x => x.Requisitions);
|
|
|
+ private static readonly Column<JobMaterial> PickingListsColumn = new Column<JobMaterial>(x => x.PickingLists);
|
|
|
+ private static readonly Column<JobMaterial> IssuedColumn = new Column<JobMaterial>(x => x.Issued);
|
|
|
+ private static readonly Column<JobMaterial> ReservedStockColumn = new Column<JobMaterial>(x => x.ReservedStock);
|
|
|
+ private static readonly Column<JobMaterial> OnOrderColumn = new Column<JobMaterial>(x => x.OnOrder);
|
|
|
+ private static readonly Column<JobMaterial> FreeOnHandColumn = new Column<JobMaterial>(x => x.FreeOnHand);
|
|
|
+ private static readonly Column<JobMaterial> FreeOnOrderColumn = new Column<JobMaterial>(x => x.FreeOnOrder);
|
|
|
+
|
|
|
+ private void ViewBillOfMaterials(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<JobBillOfMaterialsItem>(
|
|
|
+ BOMColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.Job.ID,
|
|
|
+ new Filter<JobBillOfMaterialsItem>(x => x.BillOfMaterials.Approved).IsNotEqualTo(DateTime.MinValue),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewRequisitions(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<JobRequisitionItem>(
|
|
|
+ RequisitionsColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.Job.ID,
|
|
|
+ new Filter<JobRequisitionItem>(x => x.Requisition.Approved).IsNotEqualTo(DateTime.MinValue),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewPickingLists(CoreRow row)
|
|
|
{
|
|
|
- var productid = args.Row.Get<StockSummary, Guid>(c => c.Product.ID);
|
|
|
- Guid? styleid = StyleColumnVisible() ? args.Row.Get<StockSummary, Guid>(c => c.Style.ID) : null;
|
|
|
- var unitsize = args.Row.Get<StockSummary, String>(c => c.Dimensions.UnitSize);
|
|
|
+ ShowDetailGrid<RequisitionItem>(
|
|
|
+ PickingListsColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.JobLink.ID,
|
|
|
+ new Filter<RequisitionItem>(x => x.RequisitionLink.Filled).IsEqualTo(DateTime.MinValue),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewIssued(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<StockMovement>(
|
|
|
+ IssuedColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.Job.ID,
|
|
|
+ new Filter<StockMovement>(x => x.IsTransfer).IsEqualTo(false).And(x => x.Issued).IsNotEqualTo(0.0F),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewReservedStock(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<StockHolding>(
|
|
|
+ ReservedStockColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.Job.ID,
|
|
|
+ new Filter<StockHolding>(x => x.Units).IsGreaterThan(0.1),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewOnOrder(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<PurchaseOrderItem>(
|
|
|
+ OnOrderColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ x => x.Job.ID,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewFreeOnHand(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<StockHolding>(
|
|
|
+ FreeOnHandColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ null,
|
|
|
+ new Filter<StockHolding>(x => x.Units).IsNotEqualTo(0.0F)
|
|
|
+ .And(
|
|
|
+ IncludeReserves
|
|
|
+ ? new Filter<StockHolding>(x => x.Job.ID).IsNotEqualTo(Job.ID)
|
|
|
+ : new Filter<StockHolding>(x => x.Job.JobStatus.Active).IsEqualTo(false)
|
|
|
+ ),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+ private void ViewFreeOnOrder(CoreRow row)
|
|
|
+ {
|
|
|
+ ShowDetailGrid<PurchaseOrderItem>(
|
|
|
+ FreeOnOrderColumn.Property,
|
|
|
+ x => x.Product.ID,
|
|
|
+ row.Get<StockSummary, Guid>(c => c.Product.ID),
|
|
|
+ x => x.Style.ID,
|
|
|
+ StyleColumnVisible() ? row.Get<StockSummary, Guid>(c => c.Style.ID) : null,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
|
|
|
+ null,
|
|
|
|
|
|
- if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.BillOfMaterials, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<JobBillOfMaterialsItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x => x.Job.ID,
|
|
|
- new Filter<JobBillOfMaterialsItem>(x=>x.BillOfMaterials.Approved).IsNotEqualTo(DateTime.MinValue),
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.Requisitions, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<JobRequisitionItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x => x.Job.ID,
|
|
|
- new Filter<JobRequisitionItem>(x=>x.Requisition.Approved).IsNotEqualTo(DateTime.MinValue),
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.PickingLists, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<RequisitionItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x => x.JobLink.ID,
|
|
|
- new Filter<RequisitionItem>(x=>x.RequisitionLink.Filled).IsEqualTo(DateTime.MinValue),
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.Issued, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockMovement>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x => x.Job.ID,
|
|
|
- new Filter<StockMovement>(x=>x.IsTransfer).IsEqualTo(false).And(x=>x.Issued).IsNotEqualTo(0.0F),
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.ReservedStock, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockHolding>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x=>x.Job.ID,
|
|
|
- new Filter<StockHolding>(x => x.Units).IsGreaterThan(0.1),
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.OnOrder, ".")))
|
|
|
+ IncludeReserves
|
|
|
+ ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsNotEqualTo(Job.ID)
|
|
|
+ : new Filter<PurchaseOrderItem>(x => x.Job.JobStatus.Active).IsEqualTo(false),
|
|
|
+ null
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DetailsColumn> DetailsColumns;
|
|
|
+
|
|
|
+ [MemberNotNull(nameof(DetailsColumns))]
|
|
|
+ private void SetupDetailsColumns()
|
|
|
+ {
|
|
|
+ DetailsColumns = new List<DetailsColumn>
|
|
|
{
|
|
|
- ShowDetailGrid<PurchaseOrderItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x=>x.Job.ID,
|
|
|
- null,
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.FreeOnHand, ".")))
|
|
|
+ new(BOMColumn, ViewBillOfMaterials, "View bill of materials"),
|
|
|
+ new(RequisitionsColumn, ViewRequisitions, "View requisitions"),
|
|
|
+ new(PickingListsColumn, ViewPickingLists, "View picking lists"),
|
|
|
+ new(IssuedColumn, ViewIssued, "View issued"),
|
|
|
+ new(ReservedStockColumn, ViewReservedStock, "View reserved stock"),
|
|
|
+ new(OnOrderColumn, ViewOnOrder, "View on order"),
|
|
|
+ new(FreeOnHandColumn, ViewFreeOnHand, "View free on hand"),
|
|
|
+ new(FreeOnOrderColumn, ViewFreeOnOrder, "View free on order"),
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ private class DetailsColumn
|
|
|
+ {
|
|
|
+ public Column<JobMaterial> Column { get; set; }
|
|
|
+
|
|
|
+ public Action<CoreRow> Action { get; set; }
|
|
|
+
|
|
|
+ public string MenuText { get; set; }
|
|
|
+
|
|
|
+ public DetailsColumn(Column<JobMaterial> column, Action<CoreRow> action, string menuText)
|
|
|
{
|
|
|
- ShowDetailGrid<StockHolding>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- null,
|
|
|
- new Filter<StockHolding>(x=>x.Units).IsNotEqualTo(0.0F)
|
|
|
- .And(
|
|
|
- IncludeReserves
|
|
|
- ? new Filter<StockHolding>(x=>x.Job.ID).IsNotEqualTo(Job.ID)
|
|
|
- : new Filter<StockHolding>(x=>x.Job.JobStatus.Active).IsEqualTo(false)
|
|
|
- ),
|
|
|
- null
|
|
|
- );
|
|
|
+ Column = column;
|
|
|
+ Action = action;
|
|
|
+ MenuText = menuText;
|
|
|
}
|
|
|
- else if (string.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.FreeOnOrder, ".")))
|
|
|
+ }
|
|
|
+
|
|
|
+ private void JobSummaryGrid_OnCellDoubleClick(object sender, DynamicGridCellClickEventArgs args)
|
|
|
+ {
|
|
|
+ foreach(var column in DetailsColumns)
|
|
|
{
|
|
|
- ShowDetailGrid<PurchaseOrderItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- null,
|
|
|
-
|
|
|
- IncludeReserves
|
|
|
- ? new Filter<PurchaseOrderItem>(x=>x.Job.ID).IsNotEqualTo(Job.ID)
|
|
|
- : new Filter<PurchaseOrderItem>(x=>x.Job.JobStatus.Active).IsEqualTo(false),
|
|
|
- null
|
|
|
- );
|
|
|
+ if (column.Column.IsEqualTo(args.Column.ColumnName))
|
|
|
+ {
|
|
|
+ column.Action(args.Row);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -367,76 +412,76 @@ namespace PRSDesktop
|
|
|
result.Job.Synchronise(Job);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- private Tuple<Guid,Guid,Guid?,String>[] GetKeys(IEnumerable<CoreRow> rows, Columns<JobMaterial> columns, bool hasstyle)
|
|
|
+
|
|
|
+ private Tuple<Guid, Guid, Guid?, String>[] GetKeys(IEnumerable<CoreRow> rows, Columns<JobMaterial> columns, bool hasstyle)
|
|
|
{
|
|
|
int jobcol = columns.IndexOf(x => x.Job.ID);
|
|
|
int productcol = columns.IndexOf(x => x.Product.ID);
|
|
|
int stylecol = hasstyle ? columns.IndexOf(x => x.Style.ID) : -1;
|
|
|
int unitcol = columns.IndexOf(x => x.Dimensions.UnitSize);
|
|
|
-
|
|
|
+
|
|
|
var result = rows.Select(r => new Tuple<Guid, Guid, Guid?, String>(
|
|
|
(Guid)(r.Values[jobcol] ?? Guid.Empty),
|
|
|
(Guid)(r.Values[productcol] ?? Guid.Empty),
|
|
|
(stylecol != -1) ? (Guid)(r.Values[stylecol] ?? Guid.Empty) : null,
|
|
|
(String)(r.Values[unitcol] ?? ""))
|
|
|
).Distinct().ToArray();
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid? jobid, Guid productid, Guid? styleid, String unitsize, Func<CoreRow,bool>? extrafilter = null) where TSource : IJobMaterial
|
|
|
+ private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid? jobid, Guid productid, Guid? styleid, String unitsize, Func<CoreRow, bool>? extrafilter = null) where TSource : IJobMaterial
|
|
|
{
|
|
|
int jobcol = columns.IndexOf(x => x.Job.ID);
|
|
|
int productcol = columns.IndexOf(x => x.Product.ID);
|
|
|
int stylecol = styleid.HasValue ? columns.IndexOf(x => x.Style.ID) : -1;
|
|
|
- int unitcol = columns.IndexOf(x => x.Dimensions.UnitSize);
|
|
|
-
|
|
|
+ int unitcol = columns.IndexOf(x => x.Dimensions.UnitSize);
|
|
|
+
|
|
|
var subset = rows
|
|
|
- .Where(r=>
|
|
|
+ .Where(r =>
|
|
|
(!jobid.HasValue || Guid.Equals(r.Values[jobcol], jobid))
|
|
|
&& Guid.Equals(r.Values[productcol], productid)
|
|
|
&& (!styleid.HasValue || Guid.Equals(r.Values[stylecol], styleid))
|
|
|
&& String.Equals(r.Values[unitcol], unitsize)
|
|
|
- && ((extrafilter == null) || extrafilter(r) )
|
|
|
+ && ((extrafilter == null) || extrafilter(r))
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
return subset.ToArray();
|
|
|
}
|
|
|
|
|
|
- private double Aggregate<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, bool hasstyle, bool hasjob, Expression<Func<TSource, object>> source, CoreRow target, Expression<Func<JobMaterial, object>> aggregate )
|
|
|
+ private double Aggregate<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, bool hasstyle, bool hasjob, Expression<Func<TSource, object>> source, CoreRow target, Expression<Func<JobMaterial, object>> aggregate)
|
|
|
{
|
|
|
int srcol = columns.IndexOf(source);
|
|
|
-
|
|
|
+
|
|
|
if (srcol == -1)
|
|
|
return 0.00;
|
|
|
|
|
|
- var total = rows.Aggregate(0d, (value, row) => value + (double)(row.Values[srcol] ?? 0.0d));
|
|
|
-
|
|
|
+ var total = rows.Aggregate(0d, (value, row) => value + (double)(row.Values[srcol] ?? 0.0d));
|
|
|
+
|
|
|
target.Set(aggregate, total);
|
|
|
return total;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected override void Reload(Filters<JobMaterial> criteria, Columns<JobMaterial> columns, ref SortOrder<JobMaterial>? sort,
|
|
|
Action<CoreTable?, Exception?> action)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
var filter = Job.ID == Guid.Empty
|
|
|
? new Filter<JobMaterial>().None()
|
|
|
: new Filter<JobMaterial>(x => x.Job.ID).IsEqualTo(Job.ID)
|
|
|
.And(x => x.Product.ID).IsNotEqualTo(Guid.Empty);
|
|
|
|
|
|
var orderby = sort;
|
|
|
-
|
|
|
- Progress.ShowModal("Loading Data",
|
|
|
+
|
|
|
+ Progress.ShowModal("Loading Data",
|
|
|
(progress) =>
|
|
|
{
|
|
|
var table = new CoreTable();
|
|
|
table.LoadColumns(columns);
|
|
|
-
|
|
|
+
|
|
|
var data = new Client<JobMaterial>().Query(filter, columns, orderby);
|
|
|
var pids = data.ExtractValues<JobMaterial, Guid>(x => x.Product.ID).ToArray();
|
|
|
-
|
|
|
+
|
|
|
if (pids.Any())
|
|
|
{
|
|
|
var results = Client.QueryMultiple(
|
|
@@ -494,14 +539,14 @@ namespace PRSDesktop
|
|
|
var shortage = Math.Max(0, Math.Max(0, (requi - issued)) - (reserved + ordered));
|
|
|
newrow.Set<JobMaterial, double>(x => x.JobShortage, shortage);
|
|
|
|
|
|
- var freestockrows = GetRows(freestock.Rows, freestockcolumns, null, key.Item2, key.Item3, key.Item4,
|
|
|
- IncludeReserves ? null : (r) => !r.Get<StockHolding,bool>(x=>x.Job.JobStatus.Active));
|
|
|
+ var freestockrows = GetRows(freestock.Rows, freestockcolumns, null, key.Item2, key.Item3, key.Item4,
|
|
|
+ IncludeReserves ? null : (r) => !r.Get<StockHolding, bool>(x => x.Job.JobStatus.Active));
|
|
|
var freeonhand = Aggregate(freestockrows, freestockcolumns, hasStyle, false, x => x.Units, newrow,
|
|
|
x => x.FreeOnHand);
|
|
|
newrow.Set<JobMaterial, double>(x => x.FreeOnHand, freeonhand);
|
|
|
|
|
|
var freeorderrows = GetRows(freeorders.Rows, freeordercolumns, null, key.Item2, key.Item3, key.Item4,
|
|
|
- IncludeReserves ? null : (r) => !r.Get<PurchaseOrderItem,bool>(x=>x.Job.JobStatus.Active));
|
|
|
+ IncludeReserves ? null : (r) => !r.Get<PurchaseOrderItem, bool>(x => x.Job.JobStatus.Active));
|
|
|
var freeonorder = Aggregate(freeorderrows, freeordercolumns, hasStyle, false, x => x.Qty, newrow,
|
|
|
x => x.FreeOnOrder);
|
|
|
newrow.Set<JobMaterial, double>(x => x.FreeOnOrder, freeonorder);
|
|
@@ -516,11 +561,11 @@ namespace PRSDesktop
|
|
|
}
|
|
|
|
|
|
action?.Invoke(table, null);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected override bool FilterRecord(CoreRow row)
|
|
|
{
|
|
|
var result = base.FilterRecord(row)
|
|
@@ -534,14 +579,14 @@ namespace PRSDesktop
|
|
|
);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private String _jobshortage = CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.JobShortage, ".");
|
|
|
private String _stockshortage = CoreUtils.GetFullPropertyName<JobMaterial, double>(x => x.FreeStockShortage, ".");
|
|
|
|
|
|
protected override Brush? GetCellBackground(CoreRow row, string columnname)
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (String.Equals(columnname, _jobshortage))
|
|
|
return row.Get<JobMaterial, double>(x => x.JobShortage) > 0.0F ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 } : null;
|
|
|
if (String.Equals(columnname, _stockshortage))
|
|
@@ -576,7 +621,7 @@ namespace PRSDesktop
|
|
|
MessageBox.Show("Success - New Purchase Order Created (" + purchaseOrder.PONumber + ")");
|
|
|
};
|
|
|
return page.EditItems(new[] { purchaseOrder }, LoadPurchaseOrderItems, true);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
private CoreTable LoadPurchaseOrderItems(Type arg)
|
|
|
{
|