|
@@ -6,454 +6,510 @@ using System.Reflection;
|
|
|
using System.Windows.Media;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
+using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
+using InABox.Wpf;
|
|
|
using PRSDesktop.Utils;
|
|
|
using Syncfusion.Data.Extensions;
|
|
|
using Xceed.Wpf.Toolkit;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+
|
|
|
+public enum StockSummaryMinimumStockBehaviour
|
|
|
{
|
|
|
- public class StockSummaryGrid : DynamicDataGrid<StockSummary>, IDataModelSource
|
|
|
+ Cumulative,
|
|
|
+ Minimum
|
|
|
+}
|
|
|
+
|
|
|
+public class StockSummaryGrid : DynamicDataGrid<StockSummary>, IDataModelSource
|
|
|
+{
|
|
|
+
|
|
|
+ public Guid[] GroupIDs { get; set; }
|
|
|
+ public Guid[] JobIDs { get; set; }
|
|
|
+
|
|
|
+ private StockSummaryMinimumStockBehaviour MinStockBehaviour { get; set; }
|
|
|
+
|
|
|
+ public StockSummaryGrid() : base()
|
|
|
{
|
|
|
+
|
|
|
+ ColumnsTag = "StockSummaryGrid";
|
|
|
+
|
|
|
+ GroupIDs = new Guid[] { };
|
|
|
+ JobIDs = new Guid[] { };
|
|
|
|
|
|
- public Guid[] GroupIDs { get; set; }
|
|
|
- public Guid[] JobIDs { get; set; }
|
|
|
-
|
|
|
- public StockSummaryGrid() : base()
|
|
|
+ HiddenColumns.Add(x => x.Product.ID);
|
|
|
+ HiddenColumns.Add(x => x.Product.Issues);
|
|
|
+ HiddenColumns.Add(x => x.Style.ID);
|
|
|
+ HiddenColumns.Add(x => x.Job.ID);
|
|
|
+ HiddenColumns.Add(x => x.Dimensions.UnitSize);
|
|
|
+ HiddenColumns.Add(x => x.Product.DefaultInstance.MinimumStockLevel);
|
|
|
+ HiddenColumns.Add(x => x.Issued);
|
|
|
+ HiddenColumns.Add(x => x.TotalRequired);
|
|
|
+ HiddenColumns.Add(x => x.NettRequired);
|
|
|
+ HiddenColumns.Add(x => x.AllStock);
|
|
|
+ HiddenColumns.Add(x => x.OnOrder);
|
|
|
+ HiddenColumns.Add(x => x.TotalStock);
|
|
|
+ HiddenColumns.Add(x => x.BalanceAvailable);
|
|
|
+
|
|
|
+ HiddenColumns.Add(x => x.Product.Image.ID);
|
|
|
+ HiddenColumns.Add(x => x.Product.Image.FileName);
|
|
|
+ ActionColumns.Add(new DynamicIssuesColumn<Product>(this, CoreUtils.GetFullPropertyName<StockSummary, string>(x => x.Product.Issues, "."), LoadProducts));
|
|
|
+ ActionColumns.Add(new DynamicImagePreviewColumn<StockSummary>(x => x.Product.Image)
|
|
|
+ { Position = DynamicActionColumnPosition.Start });
|
|
|
+
|
|
|
+ OnCellDoubleClick += StockSummaryGrid_OnCellDoubleClick;
|
|
|
+
|
|
|
+ MinStockBehaviour = new GlobalConfiguration<StockSummaryPanelSettings>().Load().MinimumStockBehaviour;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Product[] LoadProducts(CoreRow[] arg)
|
|
|
+ {
|
|
|
+ return Client.Query(
|
|
|
+ new Filter<Product>(x => x.ID).InList(arg.Select(x => x.Get<StockSummary, Guid>(x => x.Product.ID)).ToArray()),
|
|
|
+ new Columns<Product>(x => x.ID, x => x.Issues))
|
|
|
+ .ToObjects<Product>().ToArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
+ {
|
|
|
+ base.DoReconfigure(options);
|
|
|
+
|
|
|
+ options.AddRange(
|
|
|
+ DynamicGridOption.RecordCount,
|
|
|
+ DynamicGridOption.SelectColumns,
|
|
|
+ DynamicGridOption.FilterRows,
|
|
|
+ DynamicGridOption.ExportData,
|
|
|
+ DynamicGridOption.MultiSelect
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public override DynamicGridColumns GenerateColumns()
|
|
|
+ {
|
|
|
+ var columns = new DynamicGridColumns();
|
|
|
+ columns.Add<StockSummary, string>(x => x.Product.Code, 120, "Product Code", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, string>(x => x.Style.Code, 120, "Style Code", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, string>(x => x.Dimensions.UnitSize, 120, "Unit Size", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, int>(x => x.MinimumStockLevel, 120, "Minimum Stock Level", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, double>(x => x.BillOfMaterials, 120, "BOM", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, double>(x => x.Issued, 120, "Issued", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, double>(x => x.AllStock, 120, "Stock", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, double>(x => x.OnOrder, 120, "On Order", "", Alignment.MiddleCenter);
|
|
|
+ columns.Add<StockSummary, double>(x => x.BalanceAvailable, 120, "Balance Available", "", Alignment.MiddleCenter);
|
|
|
+ return columns;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 unitsize,
|
|
|
+ Expression<Func<TEntity,object?>>? jobcol,
|
|
|
+ Filter<TEntity>? extrafilter,
|
|
|
+ Func<CoreRow,bool>? rowfilter
|
|
|
+ )
|
|
|
+ {
|
|
|
+ var grid = (Activator.CreateInstance(typeof(DynamicDataGrid<>).MakeGenericType(typeof(TEntity))) as IDynamicDataGrid);
|
|
|
+ if (grid == null)
|
|
|
{
|
|
|
+ MessageBox.Show($"Cannot create Grid for [{typeof(TEntity).Name}]");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ grid.ColumnsTag = $"{ColumnsTag}.{columnname}";
|
|
|
+ grid.Reconfigure(options => { options.BeginUpdate().Clear().AddRange(DynamicGridOption.FilterRows, DynamicGridOption.SelectColumns).EndUpdate(); });
|
|
|
+ grid.OnDefineFilter += t =>
|
|
|
+ {
|
|
|
+ var filter = new Filter<TEntity>(productcol).IsEqualTo(productid)
|
|
|
+ .And(unitcol).IsEqualTo(unitsize);
|
|
|
+ if (styleid.HasValue)
|
|
|
+ filter = filter.And(stylecol).IsEqualTo(styleid);
|
|
|
+
|
|
|
+ if (jobcol != null)
|
|
|
+ filter = filter.And(new Filter<TEntity>(jobcol).InList(JobIDs).Or(jobcol).IsEqualTo(Guid.Empty));
|
|
|
+
|
|
|
+ if (extrafilter != null)
|
|
|
+ filter = filter.And(extrafilter);
|
|
|
+ return filter;
|
|
|
+ };
|
|
|
+ grid.OnFilterRecord += row => rowfilter?.Invoke(row) ?? true;
|
|
|
+ var window = DynamicGridUtils.CreateGridWindow($"Viewing {CoreUtils.Neatify(columnname)} Calculation", (grid as BaseDynamicGrid)!);
|
|
|
+ window.ShowDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void StockSummaryGrid_OnCellDoubleClick(object sender, DynamicGridCellClickEventArgs args)
|
|
|
+ {
|
|
|
|
|
|
- ColumnsTag = "StockSummaryGrid";
|
|
|
+
|
|
|
+
|
|
|
+ Guid productid = args.Row.Get<StockSummary, Guid>(c => c.Product.ID);
|
|
|
+ Guid? styleid = HasStyle() ? args.Row.Get<StockSummary, Guid>(c => c.Style.ID) : null;
|
|
|
+ String unitsize = args.Row.Get<StockSummary, String>(c => c.Dimensions.UnitSize);
|
|
|
|
|
|
- GroupIDs = new Guid[] { };
|
|
|
- JobIDs = new Guid[] { };
|
|
|
-
|
|
|
- HiddenColumns.Add(x => x.Product.ID);
|
|
|
- HiddenColumns.Add(x => x.Style.ID);
|
|
|
- HiddenColumns.Add(x => x.Job.ID);
|
|
|
- HiddenColumns.Add(x => x.Dimensions.UnitSize);
|
|
|
- HiddenColumns.Add(x => x.Product.DefaultInstance.MinimumStockLevel);
|
|
|
- HiddenColumns.Add(x => x.Issued);
|
|
|
- HiddenColumns.Add(x => x.TotalRequired);
|
|
|
- HiddenColumns.Add(x => x.NettRequired);
|
|
|
- HiddenColumns.Add(x => x.AllStock);
|
|
|
- HiddenColumns.Add(x => x.OnOrder);
|
|
|
- HiddenColumns.Add(x => x.TotalStock);
|
|
|
- HiddenColumns.Add(x => x.BalanceAvailable);
|
|
|
-
|
|
|
- HiddenColumns.Add(x => x.Product.Image.ID);
|
|
|
- HiddenColumns.Add(x => x.Product.Image.FileName);
|
|
|
- ActionColumns.Add(new DynamicImagePreviewColumn<StockSummary>(x => x.Product.Image)
|
|
|
- { Position = DynamicActionColumnPosition.Start });
|
|
|
-
|
|
|
- OnCellDoubleClick += StockSummaryGrid_OnCellDoubleClick;
|
|
|
+ if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, 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
|
|
|
+ );
|
|
|
}
|
|
|
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, int>(x => x.MinimumStockLevel, ".")))
|
|
|
{
|
|
|
- base.DoReconfigure(options);
|
|
|
-
|
|
|
- options.AddRange(
|
|
|
- DynamicGridOption.RecordCount,
|
|
|
- DynamicGridOption.SelectColumns,
|
|
|
- DynamicGridOption.FilterRows,
|
|
|
- DynamicGridOption.ExportData,
|
|
|
- DynamicGridOption.MultiSelect
|
|
|
+ ShowDetailGrid<ProductInstance>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x => x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- public override DynamicGridColumns GenerateColumns()
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.Issued, ".")))
|
|
|
{
|
|
|
- var columns = new DynamicGridColumns();
|
|
|
- columns.Add<StockSummary, string>(x => x.Product.Code, 120, "Product Code", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, string>(x => x.Style.Code, 120, "Style Code", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, string>(x => x.Dimensions.UnitSize, 120, "Unit Size", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, int>(x => x.Product.DefaultInstance.MinimumStockLevel, 120, "Minimum Stock Level", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, double>(x => x.BillOfMaterials, 120, "BOM", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, double>(x => x.Issued, 120, "Issued", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, double>(x => x.AllStock, 120, "Stock", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, double>(x => x.OnOrder, 120, "On Order", "", Alignment.MiddleCenter);
|
|
|
- columns.Add<StockSummary, double>(x => x.BalanceAvailable, 120, "Balance Available", "", Alignment.MiddleCenter);
|
|
|
- return columns;
|
|
|
+ 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
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- 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 unitsize,
|
|
|
- Expression<Func<TEntity,object?>>? jobcol,
|
|
|
- Filter<TEntity>? extrafilter,
|
|
|
- Func<CoreRow,bool>? rowfilter
|
|
|
- )
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.TotalRequired, ".")))
|
|
|
{
|
|
|
- var grid = (Activator.CreateInstance(typeof(DynamicDataGrid<>).MakeGenericType(typeof(TEntity))) as IDynamicDataGrid);
|
|
|
- if (grid == null)
|
|
|
- {
|
|
|
- MessageBox.Show($"Cannot create Grid for [{typeof(TEntity).Name}]");
|
|
|
- return;
|
|
|
- }
|
|
|
- grid.ColumnsTag = $"{ColumnsTag}.{columnname}";
|
|
|
- grid.Reconfigure(options => { options.BeginUpdate().Clear().AddRange(DynamicGridOption.FilterRows, DynamicGridOption.SelectColumns).EndUpdate(); });
|
|
|
- grid.OnDefineFilter += t =>
|
|
|
- {
|
|
|
- var filter = new Filter<TEntity>(productcol).IsEqualTo(productid)
|
|
|
- .And(unitcol).IsEqualTo(unitsize);
|
|
|
- if (styleid.HasValue)
|
|
|
- filter = filter.And(stylecol).IsEqualTo(styleid);
|
|
|
-
|
|
|
- if (jobcol != null)
|
|
|
- filter = filter.And(jobcol).InList(JobIDs);
|
|
|
-
|
|
|
- if (extrafilter != null)
|
|
|
- filter = filter.And(extrafilter);
|
|
|
- return filter;
|
|
|
- };
|
|
|
- grid.OnFilterRecord += row => rowfilter?.Invoke(row) ?? true;
|
|
|
- var window = DynamicGridUtils.CreateGridWindow($"Viewing {CoreUtils.Neatify(columnname)} Calculation", (grid as BaseDynamicGrid)!);
|
|
|
- window.ShowDialog();
|
|
|
+ ShowDetailGrid<StockSummary>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ x => x.Job.ID,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- private void StockSummaryGrid_OnCellDoubleClick(object sender, DynamicGridCellClickEventArgs args)
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.NettRequired, ".")))
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Guid productid = args.Row.Get<StockSummary, Guid>(c => c.Product.ID);
|
|
|
- Guid? styleid = HasStyle() ? args.Row.Get<StockSummary, Guid>(c => c.Style.ID) : null;
|
|
|
- String unitsize = args.Row.Get<StockSummary, String>(c => c.Dimensions.UnitSize);
|
|
|
-
|
|
|
- if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, 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<StockSummary, 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<StockSummary, double>(x => x.TotalRequired, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockSummary>(
|
|
|
- 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<StockSummary, double>(x => x.NettRequired, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockSummary>(
|
|
|
- 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<StockSummary, double>(x => x.AllStock, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockHolding>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- null,
|
|
|
- null,
|
|
|
- (row) => row.Get<StockHolding,double>(x=>x.Units) != 0.0F
|
|
|
- );
|
|
|
- }
|
|
|
- else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.OnOrder, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<PurchaseOrderItem>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- null,
|
|
|
- null,
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
- else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.TotalStock, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockSummary>(
|
|
|
- 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<StockSummary, double>(x => x.BalanceAvailable, ".")))
|
|
|
- {
|
|
|
- ShowDetailGrid<StockSummary>(
|
|
|
- args.Column.ColumnName,
|
|
|
- x => x.Product.ID,
|
|
|
- productid,
|
|
|
- x => x.Style.ID,
|
|
|
- styleid,
|
|
|
- x=>x.Dimensions.UnitSize,
|
|
|
- unitsize,
|
|
|
- x => x.Job.ID,
|
|
|
- null,
|
|
|
- null
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
+ ShowDetailGrid<StockSummary>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ x => x.Job.ID,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- private bool HasStyle()
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.AllStock, ".")))
|
|
|
{
|
|
|
- return DataColumns().ColumnNames().Any(x => x.StartsWith("Style.") && !x.Equals("Style.ID"));
|
|
|
+ ShowDetailGrid<StockHolding>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ (row) => row.Get<StockHolding,double>(x=>x.Units) != 0.0F
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- private Filters<StockSummary> GetFilters()
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.OnOrder, ".")))
|
|
|
{
|
|
|
- var filters = new Filters<StockSummary>();
|
|
|
- filters.Add(FilterComponent.GetFilter());
|
|
|
-
|
|
|
- Filter<StockSummary>? _groupfilter = !GroupIDs.Any()
|
|
|
- ? new Filter<StockSummary>().None()
|
|
|
- : !GroupIDs.Contains(CoreUtils.FullGuid)
|
|
|
- ? new Filter<StockSummary>(x => x.Product.Group.ID).InList(GroupIDs)
|
|
|
- : null;
|
|
|
- filters.Add(_groupfilter);
|
|
|
-
|
|
|
- var jobFilter = !JobIDs.Any()
|
|
|
- ? new Filter<StockSummary>().None()
|
|
|
- : new Filter<StockSummary>(x => x.Job.ID).InList(JobIDs);
|
|
|
- filters.Add(jobFilter);
|
|
|
-
|
|
|
- //Filter<StockSummary> _productfilter = new Filter<StockSummary>(x => x.Product.ID).IsNotEqualTo(Guid.Empty);
|
|
|
- //filters.Add(_productfilter);
|
|
|
-
|
|
|
- return filters;
|
|
|
+ ShowDetailGrid<PurchaseOrderItem>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- private Tuple<Guid,Guid?,String>[] GetKeys(IEnumerable<CoreRow> rows, Columns<StockSummary> columns, bool hasstyle)
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.TotalStock, ".")))
|
|
|
{
|
|
|
- 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?, String>(
|
|
|
- (Guid)(r.Values[productcol] ?? Guid.Empty),
|
|
|
- (stylecol != -1) ? (Guid)(r.Values[stylecol] ?? Guid.Empty) : null,
|
|
|
- (String)(r.Values[unitcol] ?? ""))
|
|
|
- ).Distinct().ToArray();
|
|
|
-
|
|
|
- return result;
|
|
|
+ ShowDetailGrid<StockSummary>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ x => x.Job.ID,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid productid, Guid? styleid, String unitsize) where TSource : IJobMaterial
|
|
|
+ else if (String.Equals(args.Column.ColumnName, CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.BalanceAvailable, ".")))
|
|
|
{
|
|
|
- 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);
|
|
|
-
|
|
|
- var subset = rows
|
|
|
- .Where(r=>
|
|
|
- Guid.Equals(r.Values[productcol], productid)
|
|
|
- && (!styleid.HasValue || Guid.Equals(r.Values[stylecol], styleid))
|
|
|
- && String.Equals(r.Values[unitcol], unitsize)
|
|
|
- );
|
|
|
-
|
|
|
- return subset.ToArray();
|
|
|
+ ShowDetailGrid<StockSummary>(
|
|
|
+ args.Column.ColumnName,
|
|
|
+ x => x.Product.ID,
|
|
|
+ productid,
|
|
|
+ x => x.Style.ID,
|
|
|
+ styleid,
|
|
|
+ x=>x.Dimensions.UnitSize,
|
|
|
+ unitsize,
|
|
|
+ x => x.Job.ID,
|
|
|
+ null,
|
|
|
+ null
|
|
|
+ );
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool HasStyle()
|
|
|
+ {
|
|
|
+ return DataColumns().ColumnNames().Any(x => x.StartsWith("Style.") && !x.Equals("Style.ID"));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Filters<StockSummary> GetFilters()
|
|
|
+ {
|
|
|
+ var filters = new Filters<StockSummary>();
|
|
|
+ filters.Add(FilterComponent.GetFilter());
|
|
|
+
|
|
|
+ Filter<StockSummary>? _groupfilter = !GroupIDs.Any()
|
|
|
+ ? new Filter<StockSummary>().None()
|
|
|
+ : !GroupIDs.Contains(CoreUtils.FullGuid)
|
|
|
+ ? new Filter<StockSummary>(x => x.Product.Group.ID).InList(GroupIDs)
|
|
|
+ : null;
|
|
|
+ filters.Add(_groupfilter);
|
|
|
+
|
|
|
+ var jobFilter = !JobIDs.Any()
|
|
|
+ ? new Filter<StockSummary>().None()
|
|
|
+ : new Filter<StockSummary>(x => x.Job.ID).InList(JobIDs);
|
|
|
+ filters.Add(jobFilter.Or(x => x.Job.ID).IsEqualTo(Guid.Empty));
|
|
|
+
|
|
|
+ //Filter<StockSummary> _productfilter = new Filter<StockSummary>(x => x.Product.ID).IsNotEqualTo(Guid.Empty);
|
|
|
+ //filters.Add(_productfilter);
|
|
|
+
|
|
|
+ return filters;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Tuple<Guid,Guid?,String>[] GetKeys(IEnumerable<CoreRow> rows, Columns<StockSummary> columns, bool hasstyle)
|
|
|
+ {
|
|
|
+ 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?, String>(
|
|
|
+ (Guid)(r.Values[productcol] ?? Guid.Empty),
|
|
|
+ (stylecol != -1) ? (Guid)(r.Values[stylecol] ?? Guid.Empty) : null,
|
|
|
+ (String)(r.Values[unitcol] ?? ""))
|
|
|
+ ).Distinct().ToArray();
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- private double Aggregate<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, bool hasstyle, bool hasjob, Expression<Func<TSource, object>> source, CoreRow target, Expression<Func<StockSummary, object>> aggregate )
|
|
|
+ private CoreRow[] GetRows<TSource>(IEnumerable<CoreRow> rows, Columns<TSource> columns, Guid productid, Guid? styleid, String unitsize) where TSource : IJobMaterial
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ var subset = rows
|
|
|
+ .Where(r=>
|
|
|
+ Guid.Equals(r.Values[productcol], productid)
|
|
|
+ && (!styleid.HasValue || Guid.Equals(r.Values[stylecol], styleid))
|
|
|
+ && String.Equals(r.Values[unitcol], unitsize)
|
|
|
+ );
|
|
|
+
|
|
|
+ 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<StockSummary, 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));
|
|
|
+
|
|
|
+ // int productcol = columns.IndexOf(x => x.Product.ID);
|
|
|
+ // int stylecol = hasstyle ? columns.IndexOf(x => x.Style.ID) : -1;
|
|
|
+ // int jobcol = hasjob ? columns.IndexOf(x => x.Job.ID) : -1;
|
|
|
+ // int unitcol = columns.IndexOf(x => x.Dimensions.UnitSize);
|
|
|
+ //
|
|
|
+ // var tuples = rows.Select(r => new Tuple<Guid, Guid?, Guid?, String, double>(
|
|
|
+ // (Guid)(r.Values[productcol] ?? Guid.Empty),
|
|
|
+ // (hasstyle ? (Guid)(r.Values[stylecol] ?? Guid.Empty) : null),
|
|
|
+ // (hasjob ? (Guid)(r.Values[jobcol] ?? Guid.Empty) : null),
|
|
|
+ // (String)(r.Values[unitcol] ?? ""),
|
|
|
+ // (double)(r.Values[aggcol] ?? 0.0d))
|
|
|
+ // ).ToArray();
|
|
|
+ //
|
|
|
+ // var total = tuples.Aggregate(0d, (value, tuple) => value + tuple.Item5);
|
|
|
+
|
|
|
+ target.Set(aggregate, total);
|
|
|
+ return total;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Reload(Filters<StockSummary> criteria, Columns<StockSummary> columns, ref SortOrder<StockSummary>? sort,
|
|
|
+ Action<CoreTable?, Exception?> action)
|
|
|
+ {
|
|
|
+ var filter = GetFilters().Combine();
|
|
|
+
|
|
|
+ new Client<StockSummary>().Query(filter,columns,sort, (o,e) =>
|
|
|
{
|
|
|
- int srcol = columns.IndexOf(source);
|
|
|
+ if(o is null)
|
|
|
+ {
|
|
|
+ Dispatcher.BeginInvoke(() =>
|
|
|
+ {
|
|
|
+ MessageWindow.ShowError("Failed to load data", e);
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var pids = o.ExtractValues<StockSummary, Guid>(x => x.Product.ID).ToArray();
|
|
|
|
|
|
- if (srcol == -1)
|
|
|
- return 0.00;
|
|
|
+ MultiQuery query = new MultiQuery();
|
|
|
+ query.Add<StockHolding>(
|
|
|
+ new Filter<StockHolding>(x => x.Product.ID).InList(pids)
|
|
|
+ .And(x => x.Units).IsNotEqualTo(0.0),
|
|
|
+ new Columns<StockHolding>(x => x.Product.ID)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .Add(x => x.Dimensions.UnitSize)
|
|
|
+ .Add(x => x.Units)
|
|
|
+ );
|
|
|
+ query.Add<PurchaseOrderItem>(
|
|
|
+ new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
|
|
|
+ .And(x => x.Product.ID).InList(pids),
|
|
|
+ new Columns<PurchaseOrderItem>(x => x.Product.ID)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .Add(x => x.Dimensions.UnitSize)
|
|
|
+ .Add(x => x.Qty)
|
|
|
+ );
|
|
|
+ query.Query();
|
|
|
+ var holdings = query.Get<StockHolding>();
|
|
|
+ Columns<StockHolding> holdingcolumns = new Columns<StockHolding>(holdings.Columns.Select(x => x.ColumnName));
|
|
|
+
|
|
|
+ var orders = query.Get<PurchaseOrderItem>();
|
|
|
+ Columns<PurchaseOrderItem> ordercolumns = new Columns<PurchaseOrderItem>(orders.Columns.Select(x => x.ColumnName));
|
|
|
|
|
|
- var total = rows.Aggregate(0d, (value, row) => value + (double)(row.Values[srcol] ?? 0.0d));
|
|
|
|
|
|
- // int productcol = columns.IndexOf(x => x.Product.ID);
|
|
|
- // int stylecol = hasstyle ? columns.IndexOf(x => x.Style.ID) : -1;
|
|
|
- // int jobcol = hasjob ? columns.IndexOf(x => x.Job.ID) : -1;
|
|
|
- // int unitcol = columns.IndexOf(x => x.Dimensions.UnitSize);
|
|
|
- //
|
|
|
- // var tuples = rows.Select(r => new Tuple<Guid, Guid?, Guid?, String, double>(
|
|
|
- // (Guid)(r.Values[productcol] ?? Guid.Empty),
|
|
|
- // (hasstyle ? (Guid)(r.Values[stylecol] ?? Guid.Empty) : null),
|
|
|
- // (hasjob ? (Guid)(r.Values[jobcol] ?? Guid.Empty) : null),
|
|
|
- // (String)(r.Values[unitcol] ?? ""),
|
|
|
- // (double)(r.Values[aggcol] ?? 0.0d))
|
|
|
- // ).ToArray();
|
|
|
- //
|
|
|
- // var total = tuples.Aggregate(0d, (value, tuple) => value + tuple.Item5);
|
|
|
-
|
|
|
- target.Set(aggregate, total);
|
|
|
- return total;
|
|
|
- }
|
|
|
-
|
|
|
- protected override void Reload(Filters<StockSummary> criteria, Columns<StockSummary> columns, ref SortOrder<StockSummary>? sort,
|
|
|
- Action<CoreTable?, Exception?> action)
|
|
|
- {
|
|
|
- var filter = GetFilters().Combine();
|
|
|
+ CoreTable table = new CoreTable();
|
|
|
+ table.LoadColumns(columns);
|
|
|
|
|
|
- new Client<StockSummary>().Query(filter,columns,sort, (o,e) =>
|
|
|
+ if (o != null)
|
|
|
{
|
|
|
|
|
|
- var pids = o.ExtractValues<StockSummary, Guid>(x => x.Product.ID).ToArray();
|
|
|
-
|
|
|
- MultiQuery query = new MultiQuery();
|
|
|
- query.Add<StockHolding>(
|
|
|
- new Filter<StockHolding>(x => x.Product.ID).InList(pids),
|
|
|
- new Columns<StockHolding>(x => x.Product.ID)
|
|
|
- .Add(x => x.Style.ID)
|
|
|
- .Add(x => x.Dimensions.UnitSize)
|
|
|
- .Add(x => x.Units)
|
|
|
- );
|
|
|
- query.Add<PurchaseOrderItem>(
|
|
|
- new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
|
|
|
- .And(x => x.Product.ID).InList(pids),
|
|
|
- new Columns<PurchaseOrderItem>(x => x.Product.ID)
|
|
|
- .Add(x => x.Style.ID)
|
|
|
- .Add(x => x.Dimensions.UnitSize)
|
|
|
- .Add(x => x.Qty)
|
|
|
- );
|
|
|
- query.Query();
|
|
|
- var holdings = query.Get<StockHolding>();
|
|
|
- Columns<StockHolding> holdingcolumns = new Columns<StockHolding>(holdings.Columns.Select(x => x.ColumnName));
|
|
|
-
|
|
|
- var orders = query.Get<PurchaseOrderItem>();
|
|
|
- Columns<PurchaseOrderItem> ordercolumns = new Columns<PurchaseOrderItem>(orders.Columns.Select(x => x.ColumnName));
|
|
|
+ bool bHasStyle = HasStyle();
|
|
|
|
|
|
+ var keys = GetKeys(o.Rows, columns, bHasStyle);
|
|
|
|
|
|
- CoreTable table = new CoreTable();
|
|
|
- table.LoadColumns(columns);
|
|
|
-
|
|
|
- if (o != null)
|
|
|
+ foreach (var key in keys)
|
|
|
{
|
|
|
|
|
|
- bool bHasStyle = HasStyle();
|
|
|
-
|
|
|
- var keys = GetKeys(o.Rows, columns, bHasStyle);
|
|
|
-
|
|
|
- foreach (var key in keys)
|
|
|
+ var rows = GetRows(o.Rows, columns, key.Item1, key.Item2, key.Item3);
|
|
|
+ if (rows.Any())
|
|
|
{
|
|
|
|
|
|
- var rows = GetRows(o.Rows, columns, key.Item1, key.Item2, key.Item3);
|
|
|
- if (rows.Any())
|
|
|
+ CoreRow newrow = table.NewRow();
|
|
|
+ newrow.LoadValues(rows.First().Values);
|
|
|
+ Aggregate(rows, columns, bHasStyle, true, x => x.BillOfMaterials, newrow, x => x.BillOfMaterials);
|
|
|
+ Aggregate(rows, columns, bHasStyle, true, x => x.Issued, newrow, x => x.Issued);
|
|
|
+ Aggregate(rows, columns, bHasStyle, true, x => x.TotalRequired, newrow, x => x.TotalRequired);
|
|
|
+ var nettrequired = Aggregate(rows, columns, bHasStyle, true, x => x.NettRequired, newrow, x => x.NettRequired);
|
|
|
+ var holdingrows = GetRows(holdings.Rows, holdingcolumns, key.Item1, key.Item2, key.Item3);
|
|
|
+ var allstock = Aggregate(holdingrows, holdingcolumns, bHasStyle, false, x => x.Units, newrow, x => x.AllStock);
|
|
|
+ var orderrows = GetRows(orders.Rows, ordercolumns, key.Item1, key.Item2, key.Item3);
|
|
|
+ var onorder = Aggregate(orderrows, ordercolumns, bHasStyle, false, x => x.Qty, newrow, x => x.OnOrder);
|
|
|
+ newrow.Set<StockSummary, double>(x => x.TotalStock, allstock + onorder);
|
|
|
+
|
|
|
+ var minStock = newrow.Get<StockSummary, double>(c => c.MinimumStockLevel);
|
|
|
+ var balance = MinStockBehaviour switch
|
|
|
{
|
|
|
-
|
|
|
- CoreRow newrow = table.NewRow();
|
|
|
- newrow.LoadValues(rows.First().Values);
|
|
|
- Aggregate(rows, columns, bHasStyle, true, x => x.BillOfMaterials, newrow, x => x.BillOfMaterials);
|
|
|
- Aggregate(rows, columns, bHasStyle, true, x => x.Issued, newrow, x => x.Issued);
|
|
|
- Aggregate(rows, columns, bHasStyle, true, x => x.TotalRequired, newrow, x => x.TotalRequired);
|
|
|
- var nettrequired = Aggregate(rows, columns, bHasStyle, true, x => x.NettRequired, newrow, x => x.NettRequired);
|
|
|
- var holdingrows = GetRows(holdings.Rows, holdingcolumns, key.Item1, key.Item2, key.Item3);
|
|
|
- var allstock = Aggregate(holdingrows, holdingcolumns, bHasStyle, false, x => x.Units, newrow, x => x.AllStock);
|
|
|
- var orderrows = GetRows(orders.Rows, ordercolumns, key.Item1, key.Item2, key.Item3);
|
|
|
- var onorder = Aggregate(orderrows, ordercolumns, bHasStyle, false, x => x.Qty, newrow, x => x.OnOrder);
|
|
|
- newrow.Set<StockSummary, double>(x => x.TotalStock, allstock + onorder);
|
|
|
- newrow.Set<StockSummary, double>(x => x.BalanceAvailable, allstock + onorder - (newrow.Get<StockSummary,double>(c=>c.Product.DefaultInstance.MinimumStockLevel) + nettrequired));
|
|
|
- table.Rows.Add(newrow);
|
|
|
- }
|
|
|
-
|
|
|
+ StockSummaryMinimumStockBehaviour.Cumulative => allstock + onorder -
|
|
|
+ (minStock + nettrequired),
|
|
|
+ StockSummaryMinimumStockBehaviour.Minimum or _ => allstock + onorder -
|
|
|
+ Math.Max(minStock, nettrequired),
|
|
|
+ };
|
|
|
+
|
|
|
+ newrow.Set<StockSummary, double>(x => x.BalanceAvailable, balance);
|
|
|
+ table.Rows.Add(newrow);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- action?.Invoke(table, e);
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
+ action?.Invoke(table, e);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- protected override bool FilterRecord(CoreRow row)
|
|
|
- {
|
|
|
- var result = base.FilterRecord(row);
|
|
|
- if (result)
|
|
|
- result = (result && (
|
|
|
- row.Get<StockSummary, double>(x => x.BillOfMaterials) != 0.0F
|
|
|
- || row.Get<StockSummary, double>(x => x.Product.DefaultInstance.MinimumStockLevel) != 0.0F
|
|
|
- || row.Get<StockSummary, double>(x => x.Issued) != 0.0F
|
|
|
- || row.Get<StockSummary, double>(x => x.AllStock) != 0.0F
|
|
|
- || row.Get<StockSummary, double>(x => x.OnOrder) != 0.0F
|
|
|
- )
|
|
|
- );
|
|
|
- return result;
|
|
|
- }
|
|
|
+ protected override bool FilterRecord(CoreRow row)
|
|
|
+ {
|
|
|
+ var result = base.FilterRecord(row);
|
|
|
+ if (result)
|
|
|
+ result = (result && (
|
|
|
+ row.Get<StockSummary, double>(x => x.BillOfMaterials) != 0.0F
|
|
|
+ || row.Get<StockSummary, double>(x => x.MinimumStockLevel) != 0.0F
|
|
|
+ || row.Get<StockSummary, double>(x => x.Issued) != 0.0F
|
|
|
+ || row.Get<StockSummary, double>(x => x.AllStock) != 0.0F
|
|
|
+ || row.Get<StockSummary, double>(x => x.OnOrder) != 0.0F
|
|
|
+ )
|
|
|
+ );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- // private String _minstock = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.Product.MinimumStockLevel, ".");
|
|
|
- // private String _bom = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.BillOfMaterials, ".");
|
|
|
- // private String _issued = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.Issued, ".");
|
|
|
- // private String _nettrequired = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.NettRequired, ".");
|
|
|
- // private String _stock = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.AllStock, ".");
|
|
|
- // private String _ordered = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.OnOrder, ".");
|
|
|
- private string _balance = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.BalanceAvailable, ".");
|
|
|
+ // private String _minstock = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.Product.MinimumStockLevel, ".");
|
|
|
+ // private String _bom = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.BillOfMaterials, ".");
|
|
|
+ // private String _issued = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.Issued, ".");
|
|
|
+ // private String _nettrequired = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.NettRequired, ".");
|
|
|
+ // private String _stock = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.AllStock, ".");
|
|
|
+ // private String _ordered = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.OnOrder, ".");
|
|
|
+ private string _balance = CoreUtils.GetFullPropertyName<StockSummary, double>(x => x.BalanceAvailable, ".");
|
|
|
|
|
|
- protected override Brush? GetCellBackground(CoreRow row, string columnname)
|
|
|
+ protected override Brush? GetCellBackground(CoreRow row, string columnname)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (String.Equals(columnname, _balance))
|
|
|
{
|
|
|
-
|
|
|
- if (String.Equals(columnname, _balance))
|
|
|
- {
|
|
|
- return row.Get<StockSummary, double>(x => x.BalanceAvailable) < 0.0F
|
|
|
- ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 }
|
|
|
- : null;
|
|
|
- }
|
|
|
- return null;
|
|
|
+ return row.Get<StockSummary, double>(x => x.BalanceAvailable) < 0.0F
|
|
|
+ ? new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.5 }
|
|
|
+ : null;
|
|
|
}
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- #region IDataModelSource
|
|
|
-
|
|
|
- public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
+ #region IDataModelSource
|
|
|
+
|
|
|
+ public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
|
|
|
- public string SectionName => "Stock Summary";
|
|
|
+ public string SectionName => "Stock Summary";
|
|
|
|
|
|
- public DataModel DataModel(Selection selection)
|
|
|
- {
|
|
|
- return new AutoDataModel<StockSummary>(null);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
+ public DataModel DataModel(Selection selection)
|
|
|
+ {
|
|
|
+ return new AutoDataModel<StockSummary>(null);
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|