|
@@ -14,10 +14,14 @@ using System.Windows.Media;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
|
+ public delegate void JobRequiItemSelect(JobRequisitionItem item);
|
|
|
+ public delegate void GridRefresh();
|
|
|
public class JobRequisitionReviewGrid : DynamicDataGrid<JobRequisitionItem>
|
|
|
{
|
|
|
+ public event JobRequiItemSelect OnJobRequiItemSelected;
|
|
|
+ public event GridRefresh OnGridRefresh;
|
|
|
List<Guid> filterProductIDs = new List<Guid>();
|
|
|
- Guid empID = new Guid();
|
|
|
+ public Guid empID = new Guid();
|
|
|
string empName = "";
|
|
|
bool bIncludeArchived = false;
|
|
|
bool bViewCancelled = false;
|
|
@@ -75,8 +79,8 @@ namespace PRSDesktop
|
|
|
|
|
|
AddButton("Include Archived", null, ViewArchived);
|
|
|
AddButton("Include Cancelled", null, ViewCancelled);
|
|
|
-
|
|
|
- ActionColumns.Add(new DynamicImageColumn(PRSDesktop.Resources.rack.AsBitmapImage(), null) { ToolTip = ShowStockToolTip });
|
|
|
+
|
|
|
+ OnSelectItem += JobRequisitionReviewGrid_OnSelectItem;
|
|
|
|
|
|
ColumnsTag = "JobRequisitionReview";
|
|
|
|
|
@@ -88,13 +92,17 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void JobRequisitionReviewGrid_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
|
|
|
+ {
|
|
|
+ OnJobRequiItemSelected?.Invoke(SelectedRows[0].ToObject<JobRequisitionItem>());
|
|
|
+ }
|
|
|
|
|
|
private bool ViewCancelled(Button button, CoreRow[] rows)
|
|
|
{
|
|
|
if (bViewCancelled)
|
|
|
{
|
|
|
bViewCancelled = false;
|
|
|
- button.Content = "Includ Cancelled";
|
|
|
+ button.Content = "Include Cancelled";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -102,10 +110,7 @@ namespace PRSDesktop
|
|
|
button.Content = "Exclude Cancelled";
|
|
|
}
|
|
|
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -123,30 +128,11 @@ namespace PRSDesktop
|
|
|
button.Content = "Exclude Archived";
|
|
|
}
|
|
|
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private FrameworkElement ShowStockToolTip(DynamicActionColumn arg1, CoreRow row)
|
|
|
- {
|
|
|
- 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);
|
|
|
-
|
|
|
- Frame frame = new Frame();
|
|
|
- frame.Background = new SolidColorBrush(Colors.LightYellow);
|
|
|
- frame.Padding = new Thickness(10);
|
|
|
- frame.BorderBrush = new SolidColorBrush(Colors.DarkGray);
|
|
|
- frame.BorderThickness = new Thickness(1);
|
|
|
- frame.Content = holdings;
|
|
|
-
|
|
|
- return frame;
|
|
|
- }
|
|
|
-
|
|
|
private bool CreateTreatmentPO(Button button, CoreRow[] rows)
|
|
|
{
|
|
|
return true;
|
|
@@ -197,65 +183,6 @@ namespace PRSDesktop
|
|
|
return valid;
|
|
|
}
|
|
|
|
|
|
- private void Reserve_Clicked(CoreRow row)
|
|
|
- {
|
|
|
- JobRequisitionItem item = row.ToObject<JobRequisitionItem>();
|
|
|
-
|
|
|
- CoreTable table = new Client<StockHolding>().Query
|
|
|
- (
|
|
|
- new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(item.Product.ID)
|
|
|
- .And(x => x.Job).NotLinkValid(),
|
|
|
- new Columns<StockHolding>(x => x.Units)
|
|
|
- );
|
|
|
- if (table.Rows.Count == 0)
|
|
|
- {
|
|
|
- MessageBox.Show("No free stock found for this product.");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- double units = 0.0;
|
|
|
- foreach (CoreRow corerow in table.Rows)
|
|
|
- {
|
|
|
- List<Object> list = corerow.Values;
|
|
|
- if (list[0] == null) list[0] = 0;
|
|
|
- double holdingUnits = double.Parse(list[0].ToString());
|
|
|
- units = units + holdingUnits;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (item.Qty > units)
|
|
|
- {
|
|
|
- var result = MessageBox.Show("Current free stock for this product is " + units + ". Amount required for this requisition line is " + item.Qty +
|
|
|
- ". Do you want to split this requisition line?", "Alert", MessageBoxButton.YesNo);
|
|
|
- switch (result)
|
|
|
- {
|
|
|
- case MessageBoxResult.Yes:
|
|
|
- SplitLine(item, units, item.Qty - units, "line split due to insufficient stock holdings");
|
|
|
- return;
|
|
|
- case MessageBoxResult.No:
|
|
|
- break;
|
|
|
- default:
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- JobRequisitionReserveWindow window = new JobRequisitionReserveWindow();
|
|
|
- JobRequisitionItemStockHoldingReserverGrid holdings = new JobRequisitionItemStockHoldingReserverGrid
|
|
|
- (
|
|
|
- item.Product.ID, item.Requisition.Job.ID, item.ID, item.Requisition.Job.JobNumber + " (" + item.Requisition.Number + ")"
|
|
|
- );
|
|
|
- holdings.Refresh(true, true);
|
|
|
- window.grid.Children.Add(holdings);
|
|
|
- window.SizeToContent = SizeToContent.WidthAndHeight;
|
|
|
-
|
|
|
- window.ShowDialog();
|
|
|
- if (holdings.StockReserved || window.StockReserved)
|
|
|
- SaveRow(row, JobRequisitionItemStatus.Reserved, "Line marked reserved by " + empName + " on " + DateTime.Now.ToString("dd MMM yy"));
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
private void SplitLine(JobRequisitionItem item, double oldItemQty, double newItemQty, string notes)
|
|
|
{
|
|
|
List<JobRequisitionItem> items = new List<JobRequisitionItem>();
|
|
@@ -283,10 +210,7 @@ namespace PRSDesktop
|
|
|
items.Add(item);
|
|
|
new Client<JobRequisitionItem>().Save(items, "Split lines from Job Requi Item Review Dashboard");
|
|
|
MessageBox.Show("Line split - original line Qty is now " + item.Qty + ". New line Qty is " + newItem.Qty, "Success");
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
}
|
|
|
|
|
|
private void SplitLine_Clicked(CoreRow row)
|
|
@@ -405,10 +329,7 @@ namespace PRSDesktop
|
|
|
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);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
}
|
|
|
|
|
|
private List<PurchaseOrderItem> AddPOItems(CoreTable table, List<PurchaseOrderItem> poItems)
|
|
@@ -453,8 +374,11 @@ namespace PRSDesktop
|
|
|
{
|
|
|
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");
|
|
|
+ if (JobReqItem.Status != JobRequisitionItemStatus.OnOrder)
|
|
|
+ {
|
|
|
+ JobReqItem.Notes = JobReqItem.Notes + Environment.NewLine + "Line marked as On Order by " + empName + " on " + DateTime.Now.ToString("dd MMM yy");
|
|
|
+ JobReqItem.Status = JobRequisitionItemStatus.OnOrder;
|
|
|
+ }
|
|
|
return JobReqItem;
|
|
|
}
|
|
|
|
|
@@ -521,10 +445,9 @@ namespace PRSDesktop
|
|
|
item.Status = status;
|
|
|
item.Notes = item.Notes + Environment.NewLine + note;
|
|
|
new Client<JobRequisitionItem>().Save(item, "Updated From Job Requisition Review Dashboard");
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void SaveItem(JobRequisitionItem item, JobRequisitionItemStatus status, string note)
|
|
@@ -532,10 +455,7 @@ namespace PRSDesktop
|
|
|
item.Status = status;
|
|
|
item.Notes = item.Notes + Environment.NewLine + note;
|
|
|
new Client<JobRequisitionItem>().Save(item, "Updated From Job Requisition Review Dashboard");
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
}
|
|
|
|
|
|
private void MultiSaveRows(CoreRow[] rows, JobRequisitionItemStatus status, string note)
|
|
@@ -550,10 +470,7 @@ namespace PRSDesktop
|
|
|
items.Add(item);
|
|
|
}
|
|
|
new Client<JobRequisitionItem>().Save(items, "Updated From Job Requisition Review Dashboard");
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -599,15 +516,11 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Dispatcher.BeginInvoke(() =>
|
|
|
- {
|
|
|
- Refresh(true, true);
|
|
|
- });
|
|
|
+ OnGridRefresh?.Invoke();
|
|
|
}
|
|
|
|
|
|
private void BuildMenu(DynamicMenuColumn column, CoreRow row)
|
|
|
{
|
|
|
- column.AddItem("Reserve", PRSDesktop.Resources.project, Reserve_Clicked);
|
|
|
column.AddItem("Treatment Required", PRSDesktop.Resources.palette, TreatmentRequired_Clicked);
|
|
|
column.AddItem("Order Required", PRSDesktop.Resources.purchase, OrderRequired_Clicked);
|
|
|
column.AddItem("Mark as Not Checked", PRSDesktop.Resources.disabled, Uncheck_Clicked);
|