|
@@ -63,133 +63,134 @@ public class ProjectsGrid : DynamicDataGrid<Job>
|
|
|
HiddenColumns.Add(x => x.DefaultScope.ID);
|
|
|
|
|
|
ActionColumns.Add(new DynamicMapColumn<Job>(this, x => x.SiteAddress.Location));
|
|
|
- ActionColumns.Add(new DynamicMenuColumn(BuildMenu));
|
|
|
+ //ActionColumns.Add(new DynamicMenuColumn(BuildMenu));
|
|
|
}
|
|
|
|
|
|
protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
{
|
|
|
base.DoReconfigure(options);
|
|
|
- options.AddRange(
|
|
|
- DynamicGridOption.RecordCount,
|
|
|
- DynamicGridOption.SelectColumns,
|
|
|
- DynamicGridOption.FilterRows
|
|
|
- );
|
|
|
+ options
|
|
|
+ .BeginUpdate()
|
|
|
+ .Add(DynamicGridOption.RecordCount)
|
|
|
+ .Add(DynamicGridOption.SelectColumns)
|
|
|
+ .Add(DynamicGridOption.FilterRows)
|
|
|
+ .EndUpdate();
|
|
|
}
|
|
|
|
|
|
- private void BuildMenu(DynamicMenuColumn column, CoreRow? row)
|
|
|
- {
|
|
|
- if (Security.IsAllowed<CanCancelAllJobRequisitions>())
|
|
|
- {
|
|
|
- column.AddItem("Cancel all active requisitions", null, CancelJobRequisitions_Click);
|
|
|
- }
|
|
|
- if (Security.IsAllowed<CanReleaseJobReserves>())
|
|
|
- {
|
|
|
- column.AddItem("Release Job Reserves", null, ReleaseJobReserves_Click);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void CancelJobRequisitions_Click(CoreRow? obj)
|
|
|
- {
|
|
|
- var job = obj?.ToObject<Job>();
|
|
|
- if (job is null)
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("Please select a job.", "No job selected");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(MessageWindow.ShowYesNoCancel("Are you sure you wish to do this? This will cancel all requisitions for this job.", "Confirm") != MessageWindowResult.Yes)
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("No action taken.", "Process aborted");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var requisitionItems = Client.Query(
|
|
|
- new Filter<JobRequisitionItem>(x => x.Requisition.Job.ID).IsEqualTo(job.ID)
|
|
|
- .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Cancelled)
|
|
|
- .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Issued)
|
|
|
- .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Archived),
|
|
|
- new Columns<JobRequisitionItem>(x => x.ID)
|
|
|
- .Add(x => x.Cancelled))
|
|
|
- .ToList<JobRequisitionItem>();
|
|
|
- foreach(var jri in requisitionItems)
|
|
|
- {
|
|
|
- jri.Cancelled = DateTime.Now;
|
|
|
- }
|
|
|
- Client.Save(requisitionItems, "Cancelled all job requisitions for job");
|
|
|
- MessageWindow.ShowMessage("All job requisitions cancelled.", "Success");
|
|
|
- }
|
|
|
-
|
|
|
- private void ReleaseJobReserves_Click(CoreRow? obj)
|
|
|
- {
|
|
|
- var job = obj?.ToObject<Job>();
|
|
|
- if (job is null)
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("Please select a job.", "No job selected");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(MessageWindow.ShowYesNoCancel("Are you sure you wish to do this? This will release all reserves for this job.", "Confirm") != MessageWindowResult.Yes)
|
|
|
- {
|
|
|
- MessageWindow.ShowMessage("No action taken.", "Process aborted");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var movements = Client.Query<StockMovement>(
|
|
|
- new Filter<StockMovement>(x => x.Job.ID).IsEqualTo(job.ID),
|
|
|
- new Columns<StockMovement>(x => x.Units)
|
|
|
- .Add(x => x.Location.ID)
|
|
|
- .Add(x => x.Product.ID)
|
|
|
- .Add(x => x.Style.ID)
|
|
|
- .AddDimensionsColumns(x => x.Dimensions)
|
|
|
- .Add(x => x.Cost)
|
|
|
- .Add(x => x.OrderItem.ID)
|
|
|
- .Add(x => x.JobRequisitionItem.ID))
|
|
|
- .ToObjects<StockMovement>()
|
|
|
- .GroupBy(x => new
|
|
|
- {
|
|
|
- Location = x.Location.ID,
|
|
|
- Product = x.Product.ID,
|
|
|
- Style = x.Style.ID,
|
|
|
- x.Dimensions,
|
|
|
- x.Cost,
|
|
|
- OrderItem = x.OrderItem.ID,
|
|
|
- JobRequisitionItem = x.JobRequisitionItem.ID
|
|
|
- })
|
|
|
- .Select(x => new { x.Key, Units = x.Sum(x => x.Units) });
|
|
|
-
|
|
|
- var toSave = new List<StockMovement>();
|
|
|
- foreach(var group in movements)
|
|
|
- {
|
|
|
- var from = new StockMovement();
|
|
|
- from.Location.ID = group.Key.Location;
|
|
|
- from.Style.ID = group.Key.Style;
|
|
|
- from.Product.ID = group.Key.Product;
|
|
|
- from.Dimensions.CopyFrom(group.Key.Dimensions);
|
|
|
-
|
|
|
- var to = from.CreateMovement();
|
|
|
-
|
|
|
- from.Job.ID = job.ID;
|
|
|
-
|
|
|
- from.Cost = group.Key.Cost;
|
|
|
- to.Cost = group.Key.Cost;
|
|
|
- from.OrderItem.ID = group.Key.OrderItem;
|
|
|
- to.OrderItem.ID = group.Key.OrderItem;
|
|
|
- from.JobRequisitionItem.ID = group.Key.JobRequisitionItem;
|
|
|
- to.JobRequisitionItem.ID = group.Key.JobRequisitionItem;
|
|
|
-
|
|
|
- from.Type = StockMovementType.TransferOut;
|
|
|
- to.Type = StockMovementType.TransferIn;
|
|
|
- to.Transaction = from.Transaction;
|
|
|
-
|
|
|
- from.Units = -group.Units;
|
|
|
- to.Units = group.Units;
|
|
|
-
|
|
|
- toSave.Add(from);
|
|
|
- toSave.Add(to);
|
|
|
- }
|
|
|
- Client.Save(toSave, "Released all job stock.");
|
|
|
- MessageWindow.ShowMessage("All job stock reserves released.", "Success");
|
|
|
- }
|
|
|
+ // private void BuildMenu(DynamicMenuColumn column, CoreRow? row)
|
|
|
+ // {
|
|
|
+ // if (Security.IsAllowed<CanCancelAllJobRequisitions>())
|
|
|
+ // {
|
|
|
+ // column.AddItem("Cancel all active requisitions", null, CancelJobRequisitions_Click);
|
|
|
+ // }
|
|
|
+ // if (Security.IsAllowed<CanReleaseJobReserves>())
|
|
|
+ // {
|
|
|
+ // column.AddItem("Release Job Reserves", null, ReleaseJobReserves_Click);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private void CancelJobRequisitions_Click(CoreRow? obj)
|
|
|
+ // {
|
|
|
+ // var job = obj?.ToObject<Job>();
|
|
|
+ // if (job is null)
|
|
|
+ // {
|
|
|
+ // MessageWindow.ShowMessage("Please select a job.", "No job selected");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if(MessageWindow.ShowYesNoCancel("Are you sure you wish to do this? This will cancel all requisitions for this job.", "Confirm") != MessageWindowResult.Yes)
|
|
|
+ // {
|
|
|
+ // MessageWindow.ShowMessage("No action taken.", "Process aborted");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // var requisitionItems = Client.Query(
|
|
|
+ // new Filter<JobRequisitionItem>(x => x.Requisition.Job.ID).IsEqualTo(job.ID)
|
|
|
+ // .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Cancelled)
|
|
|
+ // .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Issued)
|
|
|
+ // .And(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Archived),
|
|
|
+ // new Columns<JobRequisitionItem>(x => x.ID)
|
|
|
+ // .Add(x => x.Cancelled))
|
|
|
+ // .ToList<JobRequisitionItem>();
|
|
|
+ // foreach(var jri in requisitionItems)
|
|
|
+ // {
|
|
|
+ // jri.Cancelled = DateTime.Now;
|
|
|
+ // }
|
|
|
+ // Client.Save(requisitionItems, "Cancelled all job requisitions for job");
|
|
|
+ // MessageWindow.ShowMessage("All job requisitions cancelled.", "Success");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private void ReleaseJobReserves_Click(CoreRow? obj)
|
|
|
+ // {
|
|
|
+ // var job = obj?.ToObject<Job>();
|
|
|
+ // if (job is null)
|
|
|
+ // {
|
|
|
+ // MessageWindow.ShowMessage("Please select a job.", "No job selected");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if(MessageWindow.ShowYesNoCancel("Are you sure you wish to do this? This will release all reserves for this job.", "Confirm") != MessageWindowResult.Yes)
|
|
|
+ // {
|
|
|
+ // MessageWindow.ShowMessage("No action taken.", "Process aborted");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // var movements = Client.Query<StockMovement>(
|
|
|
+ // new Filter<StockMovement>(x => x.Job.ID).IsEqualTo(job.ID),
|
|
|
+ // new Columns<StockMovement>(x => x.Units)
|
|
|
+ // .Add(x => x.Location.ID)
|
|
|
+ // .Add(x => x.Product.ID)
|
|
|
+ // .Add(x => x.Style.ID)
|
|
|
+ // .AddDimensionsColumns(x => x.Dimensions)
|
|
|
+ // .Add(x => x.Cost)
|
|
|
+ // .Add(x => x.OrderItem.ID)
|
|
|
+ // .Add(x => x.JobRequisitionItem.ID))
|
|
|
+ // .ToObjects<StockMovement>()
|
|
|
+ // .GroupBy(x => new
|
|
|
+ // {
|
|
|
+ // Location = x.Location.ID,
|
|
|
+ // Product = x.Product.ID,
|
|
|
+ // Style = x.Style.ID,
|
|
|
+ // x.Dimensions,
|
|
|
+ // x.Cost,
|
|
|
+ // OrderItem = x.OrderItem.ID,
|
|
|
+ // JobRequisitionItem = x.JobRequisitionItem.ID
|
|
|
+ // })
|
|
|
+ // .Select(x => new { x.Key, Units = x.Sum(x => x.Units) });
|
|
|
+ //
|
|
|
+ // var toSave = new List<StockMovement>();
|
|
|
+ // foreach(var group in movements)
|
|
|
+ // {
|
|
|
+ // var from = new StockMovement();
|
|
|
+ // from.Location.ID = group.Key.Location;
|
|
|
+ // from.Style.ID = group.Key.Style;
|
|
|
+ // from.Product.ID = group.Key.Product;
|
|
|
+ // from.Dimensions.CopyFrom(group.Key.Dimensions);
|
|
|
+ //
|
|
|
+ // var to = from.CreateMovement();
|
|
|
+ //
|
|
|
+ // from.Job.ID = job.ID;
|
|
|
+ //
|
|
|
+ // from.Cost = group.Key.Cost;
|
|
|
+ // to.Cost = group.Key.Cost;
|
|
|
+ // from.OrderItem.ID = group.Key.OrderItem;
|
|
|
+ // to.OrderItem.ID = group.Key.OrderItem;
|
|
|
+ // from.JobRequisitionItem.ID = group.Key.JobRequisitionItem;
|
|
|
+ // to.JobRequisitionItem.ID = group.Key.JobRequisitionItem;
|
|
|
+ //
|
|
|
+ // from.Type = StockMovementType.TransferOut;
|
|
|
+ // to.Type = StockMovementType.TransferIn;
|
|
|
+ // to.Transaction = from.Transaction;
|
|
|
+ //
|
|
|
+ // from.Units = -group.Units;
|
|
|
+ // to.Units = group.Units;
|
|
|
+ //
|
|
|
+ // toSave.Add(from);
|
|
|
+ // toSave.Add(to);
|
|
|
+ // }
|
|
|
+ // Client.Save(toSave, "Released all job stock.");
|
|
|
+ // MessageWindow.ShowMessage("All job stock reserves released.", "Success");
|
|
|
+ // }
|
|
|
|
|
|
public Guid StatusID
|
|
|
{
|