|
@@ -7,14 +7,10 @@ using InABox.Clients;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
-using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
-using org.apache.logging.log4j.message;
|
|
|
-using static com.sun.tools.javap.TypeAnnotationWriter;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Media;
|
|
|
-using org.omg.PortableInterceptor;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
@@ -111,6 +107,9 @@ namespace PRSDesktop
|
|
|
List<Guid> filterProductIDs = new List<Guid>();
|
|
|
Guid empID = new Guid();
|
|
|
string empName = "";
|
|
|
+ bool bIncludeArchived = false;
|
|
|
+ bool bViewCancelled = false;
|
|
|
+
|
|
|
public JobRequisitionReviewGrid()
|
|
|
{
|
|
|
Options.AddRange(
|
|
@@ -146,6 +145,9 @@ namespace PRSDesktop
|
|
|
if (Security.CanEdit<PurchaseOrder>())
|
|
|
AddButton("Create Treatment PO", null, CreateTreatmentPO);
|
|
|
|
|
|
+ AddButton("Include Archived", null, ViewArchived);
|
|
|
+ AddButton("Include Cancelled", null, ViewCancelled);
|
|
|
+
|
|
|
ActionColumns.Add(new DynamicActionColumn(ViewStockImage, null) { ToolTip = ShowStockToolTip });
|
|
|
|
|
|
ColumnsTag = "JobRequisitionReview";
|
|
@@ -158,9 +160,51 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private bool ViewCancelled(Button button, CoreRow[] rows)
|
|
|
+ {
|
|
|
+ if (bViewCancelled)
|
|
|
+ {
|
|
|
+ bViewCancelled = false;
|
|
|
+ button.Content = "Includ Cancelled";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bViewCancelled = true;
|
|
|
+ button.Content = "Exclude Cancelled";
|
|
|
+ }
|
|
|
+
|
|
|
+ Dispatcher.BeginInvoke(() =>
|
|
|
+ {
|
|
|
+ Refresh(true, true);
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool ViewArchived(Button button, CoreRow[] rows)
|
|
|
+ {
|
|
|
+ if (bIncludeArchived)
|
|
|
+ {
|
|
|
+ bIncludeArchived = false;
|
|
|
+ button.Content = "Include Archived";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bIncludeArchived = true;
|
|
|
+ button.Content = "Exclude Archived";
|
|
|
+ }
|
|
|
+
|
|
|
+ Dispatcher.BeginInvoke(() =>
|
|
|
+ {
|
|
|
+ Refresh(true, true);
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
private FrameworkElement ShowStockToolTip(DynamicActionColumn arg1, CoreRow row)
|
|
|
{
|
|
|
- JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
|
+ JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
|
var holdings = new StockHoldingToolTipGrid(item.Product.ID, item.Job.ID, item.ID, item.Requisition.Number.ToString());
|
|
|
holdings.Refresh(true, true);
|
|
|
|
|
@@ -228,6 +272,7 @@ namespace PRSDesktop
|
|
|
}
|
|
|
return valid;
|
|
|
}
|
|
|
+
|
|
|
private void Reserve_Clicked(CoreRow row)
|
|
|
{
|
|
|
JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
@@ -333,6 +378,13 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void Archive_Clicked(CoreRow row)
|
|
|
+ {
|
|
|
+ JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
|
+
|
|
|
+ SaveRow(row, JobRequisitionItemStatus.Archived, "Line marked as Archived by " + empName + " on " + DateTime.Now.ToString("dd MMM yy"));
|
|
|
+ }
|
|
|
+
|
|
|
private void OrderRequired_Clicked(CoreRow row)
|
|
|
{
|
|
|
JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
@@ -409,46 +461,102 @@ namespace PRSDesktop
|
|
|
private void PurchaseOrderOnSave(DynamicEditorForm form, PurchaseOrder[] items)
|
|
|
{
|
|
|
Progress.Show("Working");
|
|
|
+
|
|
|
Guid POID = items[0].ID;
|
|
|
+
|
|
|
CoreTable table = new Client<PurchaseOrderItem>().Query(new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.ID).IsEqualTo(POID),
|
|
|
new Columns<PurchaseOrderItem>(x => x.ID, x => x.Product.ID, x => x.Qty, x => x.Dimensions.UnitSize, x => x.DueDate, x => x.Job.ID));
|
|
|
if (table.Rows.Any())
|
|
|
{
|
|
|
- List<JobRequisitionItem> requiItems = new List<JobRequisitionItem>();
|
|
|
- List<PurchaseOrderItem> poItems = new List<PurchaseOrderItem>();
|
|
|
- foreach (CoreRow row in table.Rows)
|
|
|
- {
|
|
|
- PurchaseOrderItem poItem = row.ToObject<PurchaseOrderItem>();
|
|
|
- poItems.Add(poItem);
|
|
|
- }
|
|
|
- foreach (CoreRow row in SelectedRows)
|
|
|
- {
|
|
|
- JobRequisitionItem JobReqItem = row.ToObject<JobRequisitionItem>();
|
|
|
- foreach (var item in poItems)
|
|
|
- {
|
|
|
- if (JobReqItem.Product.ID == item.Product.ID &&
|
|
|
- JobReqItem.Qty == item.Qty &&
|
|
|
- JobReqItem.Dimensions.UnitSize == item.Dimensions.UnitSize &&
|
|
|
- JobReqItem.Job.ID == item.Job.ID)
|
|
|
- {
|
|
|
- JobReqItem.PurchaseOrderItem.ID = item.ID;
|
|
|
- JobReqItem.PurchaseOrderItem.DueDate = item.DueDate;
|
|
|
- JobReqItem.Status = JobRequisitionItemStatus.OnOrder;
|
|
|
- JobReqItem.Notes = JobReqItem.Notes + Environment.NewLine + "Line marked as On Order by " + empName + " on " + DateTime.Now.ToString("dd MMM yy");
|
|
|
- requiItems.Add(JobReqItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ var poItems = AddPOItems(table, new List<PurchaseOrderItem>());
|
|
|
+
|
|
|
+ var requiItems = MatchRequiItems(poItems, new List<JobRequisitionItem>());
|
|
|
+
|
|
|
if (requiItems.Count > 0)
|
|
|
+ SaveAndRefreshScreen(requiItems);
|
|
|
+ }
|
|
|
+ Progress.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SaveAndRefreshScreen(List<JobRequisitionItem> requiItems)
|
|
|
+ {
|
|
|
+ new Client<JobRequisitionItem>().Save(requiItems, "Updated on Create Purchase Order from Job Requi Dashboard");
|
|
|
+ Dispatcher.BeginInvoke(() =>
|
|
|
+ {
|
|
|
+ Refresh(false, true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<PurchaseOrderItem> AddPOItems(CoreTable table, List<PurchaseOrderItem> poItems)
|
|
|
+ {
|
|
|
+ foreach (CoreRow row in table.Rows)
|
|
|
+ {
|
|
|
+ PurchaseOrderItem poItem = row.ToObject<PurchaseOrderItem>();
|
|
|
+ poItems.Add(poItem);
|
|
|
+ }
|
|
|
+ return poItems;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<JobRequisitionItem> MatchRequiItems(List<PurchaseOrderItem> poItems, List<JobRequisitionItem> requiItems)
|
|
|
+ {
|
|
|
+ foreach (CoreRow row in SelectedRows)
|
|
|
+ {
|
|
|
+ JobRequisitionItem JobReqItem = row.ToObject<JobRequisitionItem>();
|
|
|
+ foreach (var item in poItems)
|
|
|
{
|
|
|
- new Client<JobRequisitionItem>().Save(requiItems, "Updated on Create Purchase Order from Job Requi Dashboard");
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(false, true);
|
|
|
- });
|
|
|
+ if (string.IsNullOrWhiteSpace(JobReqItem.Dimensions.UnitSize))
|
|
|
+ JobReqItem.Dimensions.UnitSize = QueryUnitSize(JobReqItem.Product.ID);
|
|
|
+
|
|
|
+ if (string.IsNullOrWhiteSpace(item.Dimensions.UnitSize))
|
|
|
+ item.Dimensions.UnitSize = QueryUnitSize(item.Product.ID);
|
|
|
+
|
|
|
+ if (JobReqItem.Job.ID == Guid.Empty)
|
|
|
+ JobReqItem.Job.ID = QueryJobID(JobReqItem.Requisition.ID);
|
|
|
+
|
|
|
+ if (item.Job.ID == Guid.Empty)
|
|
|
+ item.Job.ID = QueryJobID(JobReqItem.Requisition.ID);
|
|
|
+
|
|
|
+ if (MatchReqItemToPOItem(JobReqItem, item))
|
|
|
+ requiItems.Add(UpdateJobReqItemWithPODetails(JobReqItem, item));
|
|
|
}
|
|
|
}
|
|
|
- Progress.Close();
|
|
|
+ return requiItems;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private JobRequisitionItem UpdateJobReqItemWithPODetails(JobRequisitionItem JobReqItem, PurchaseOrderItem item)
|
|
|
+ {
|
|
|
+ JobReqItem.PurchaseOrderItem.ID = item.ID;
|
|
|
+ JobReqItem.PurchaseOrderItem.DueDate = item.DueDate;
|
|
|
+ JobReqItem.Status = JobRequisitionItemStatus.OnOrder;
|
|
|
+ JobReqItem.Notes = JobReqItem.Notes + Environment.NewLine + "Line marked as On Order by " + empName + " on " + DateTime.Now.ToString("dd MMM yy");
|
|
|
+ return JobReqItem;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool MatchReqItemToPOItem(JobRequisitionItem JobReqItem, PurchaseOrderItem item)
|
|
|
+ {
|
|
|
+ if (JobReqItem.Product.ID == item.Product.ID &&
|
|
|
+ JobReqItem.Qty == item.Qty &&
|
|
|
+ JobReqItem.Dimensions.UnitSize == item.Dimensions.UnitSize &&
|
|
|
+ JobReqItem.Job.ID == item.Job.ID)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private string QueryUnitSize(Guid productID)
|
|
|
+ {
|
|
|
+ CoreTable table = new Client<Product>().Query(new Filter<Product>(x => x.ID).IsEqualTo(productID),
|
|
|
+ new Columns<Product>(x => x.Dimensions.UnitSize));
|
|
|
+ return table.Rows.FirstOrDefault().Get<string>("Dimensions.UnitSize");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Guid QueryJobID(Guid iD)
|
|
|
+ {
|
|
|
+ CoreTable table = new Client<JobRequisition>().Query(new Filter<JobRequisition>(x => x.ID).IsEqualTo(iD),
|
|
|
+ new Columns<JobRequisition>(x => x.Job.ID));
|
|
|
+ return table.Rows.FirstOrDefault().Get<Guid>("Job.ID");
|
|
|
}
|
|
|
|
|
|
private CoreTable LoadPurchaseOrderItems(Type arg)
|
|
@@ -529,6 +637,14 @@ namespace PRSDesktop
|
|
|
protected override void Reload(Filters<JobRequisitionItem> criteria, Columns<JobRequisitionItem> columns, ref SortOrder<JobRequisitionItem> sort,
|
|
|
Action<CoreTable, Exception> action)
|
|
|
{
|
|
|
+ criteria.Add(new Filter<JobRequisitionItem>(x => x.Requisition.Approved).IsNotEqualTo(DateTime.MinValue));
|
|
|
+
|
|
|
+ if (!bViewCancelled)
|
|
|
+ criteria.Add(new Filter<JobRequisitionItem>(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Cancelled));
|
|
|
+
|
|
|
+ if (!bIncludeArchived)
|
|
|
+ criteria.Add(new Filter<JobRequisitionItem>(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Archived));
|
|
|
+
|
|
|
if (filterProductIDs.Count > 0)
|
|
|
{
|
|
|
Filter<JobRequisitionItem> filter = new Filter<JobRequisitionItem>(x => x.Product.ID).IsEqualTo(filterProductIDs.FirstOrDefault());
|
|
@@ -573,7 +689,10 @@ namespace PRSDesktop
|
|
|
column.AddItem("Order Required", PRSDesktop.Resources.purchase, OrderRequired_Clicked);
|
|
|
column.AddItem("Mark as Not Checked", PRSDesktop.Resources.disabled, Uncheck_Clicked);
|
|
|
column.AddItem("Split Line", PRSDesktop.Resources.split, SplitLine_Clicked);
|
|
|
+ column.AddItem("Archive", PRSDesktop.Resources.archive, Archive_Clicked);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
|