|
@@ -2,10 +2,13 @@
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
+using InABox.Wpf;
|
|
|
using InABox.WPF;
|
|
|
using Microsoft.Office.Interop.Outlook;
|
|
|
using Syncfusion.Windows.Tools.Controls;
|
|
@@ -17,7 +20,7 @@ namespace PRSDesktop
|
|
|
{
|
|
|
//public int Boxes { get; set; }
|
|
|
|
|
|
- public bool Picked = true;
|
|
|
+ private static readonly BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
|
|
|
|
|
|
public RequisitionItemGrid()
|
|
|
{
|
|
@@ -54,12 +57,75 @@ namespace PRSDesktop
|
|
|
HiddenColumns.Add(x => x.Style.ID);
|
|
|
HiddenColumns.Add(x => x.Style.Code);
|
|
|
HiddenColumns.Add(x => x.Picked);
|
|
|
+ ActionColumns.Add(new DynamicImageColumn(Pick_Image, Pick_Click)
|
|
|
+ {
|
|
|
+ ToolTip = Pick_ToolTip
|
|
|
+ });
|
|
|
ActionColumns.Add(new DynamicMenuColumn(SelectHolding,
|
|
|
(row) => (row.Get<RequisitionItem, Guid>(c => c.Product.ID) == Guid.Empty) || row.Get<RequisitionItem, bool>(c => c.Product.NonStock) == true
|
|
|
? DynamicMenuStatus.Hidden
|
|
|
: DynamicMenuStatus.Enabled)
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ private FrameworkElement? Pick_ToolTip(DynamicActionColumn column, CoreRow? row)
|
|
|
+ {
|
|
|
+ string content;
|
|
|
+ if (row is null)
|
|
|
+ {
|
|
|
+ content = "Has this item been picked?";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!row.Get<RequisitionItem, DateTime>(x => x.Picked).IsEmpty())
|
|
|
+ {
|
|
|
+ content = "This item has been picked";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ content = "This item has not been picked";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return column.TextToolTip(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ private BitmapImage? Pick_Image(CoreRow? row)
|
|
|
+ {
|
|
|
+ return row is null
|
|
|
+ ? tick
|
|
|
+ : (row.Get<RequisitionItem, DateTime>(x => x.Picked).IsEmpty()
|
|
|
+ ? null
|
|
|
+ : tick);
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool Pick_Click(CoreRow? row)
|
|
|
+ {
|
|
|
+ if(row is null)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var reqItem = row.ToObject<RequisitionItem>();
|
|
|
+ ProcessItems(reqItem.Picked.IsEmpty() ? DateTime.Now : DateTime.MinValue, CoreUtils.One(reqItem));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void ProcessItems(DateTime picked, IEnumerable<RequisitionItem> items)
|
|
|
+ {
|
|
|
+ var list = new List<RequisitionItem>();
|
|
|
+ foreach (var item in items)
|
|
|
+ {
|
|
|
+ item.Picked = picked;
|
|
|
+ list.Add(item);
|
|
|
+ }
|
|
|
+ string audittrail;
|
|
|
+ if (picked == DateTime.MinValue)
|
|
|
+ audittrail = "Item unpicked";
|
|
|
+ else
|
|
|
+ audittrail = "Item picked " + picked.ToString("dd MMM yy");
|
|
|
+ Client.Save(list, audittrail);
|
|
|
+ }
|
|
|
+
|
|
|
protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
{
|
|
|
base.DoReconfigure(options);
|
|
@@ -75,14 +141,6 @@ namespace PRSDesktop
|
|
|
.EndUpdate();
|
|
|
}
|
|
|
|
|
|
- protected override void DoBeforeSave(IDynamicEditorForm editor, RequisitionItem[] items)
|
|
|
- {
|
|
|
- base.DoBeforeSave(editor, items);
|
|
|
-
|
|
|
- foreach (var item in items)
|
|
|
- item.Picked = Picked ? DateTime.Now : DateTime.MinValue;
|
|
|
- }
|
|
|
-
|
|
|
private bool CanAddItems() =>
|
|
|
Requisition is not null && Requisition.ID != Guid.Empty && Requisition.Filled.IsEmpty();
|
|
|
|
|
@@ -119,7 +177,7 @@ namespace PRSDesktop
|
|
|
item.Product.ID = product.ID;
|
|
|
item.Product.Synchronise(product);
|
|
|
item.Quantity = quantity;
|
|
|
- item.Picked = Picked ? DateTime.Now : DateTime.MinValue;
|
|
|
+ item.Picked = DateTime.MinValue;
|
|
|
SaveItem(item);
|
|
|
Refresh(false, true);
|
|
|
}
|
|
@@ -130,8 +188,13 @@ namespace PRSDesktop
|
|
|
|
|
|
private void SelectHolding(DynamicMenuColumn column, CoreRow? row)
|
|
|
{
|
|
|
- List<Guid> locations = new List<Guid>();
|
|
|
- var holdings = new Client<StockHolding>().Query(
|
|
|
+ if(row is null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var locations = new List<Guid>();
|
|
|
+ var holdings = Client.Query(
|
|
|
new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(row.Get<RequisitionItem, Guid>(c => c.Product.ID)),
|
|
|
new Columns<StockHolding>(x => x.Location.ID)
|
|
|
.Add(x => x.Units));
|
|
@@ -145,7 +208,7 @@ namespace PRSDesktop
|
|
|
|
|
|
if (locations.Count == 0)
|
|
|
{
|
|
|
- MessageBox.Show("No valid holdings found for product");
|
|
|
+ MessageWindow.ShowMessage("No valid holdings found for product", "No holdings");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -210,22 +273,13 @@ namespace PRSDesktop
|
|
|
criteria.Add(
|
|
|
new Filter<RequisitionItem>(x => x.RequisitionLink.ID).IsEqualTo(Requisition != null ? Requisition.ID : CoreUtils.FullGuid));
|
|
|
|
|
|
- if (Picked)
|
|
|
- criteria.Add(new Filter<RequisitionItem>(x => x.Picked).IsNotEqualTo(DateTime.MinValue));
|
|
|
- else
|
|
|
- criteria.Add(new Filter<RequisitionItem>(x => x.Picked).IsEqualTo(DateTime.MinValue));
|
|
|
-
|
|
|
sort = new SortOrder<RequisitionItem>(x => x.Created);
|
|
|
|
|
|
base.Reload(
|
|
|
criteria,
|
|
|
columns,
|
|
|
ref sort,
|
|
|
- (o, e) =>
|
|
|
- {
|
|
|
- // Update Buttons Here
|
|
|
- action.Invoke(o, e);
|
|
|
- }
|
|
|
+ action
|
|
|
);
|
|
|
}
|
|
|
|