|
@@ -10,6 +10,7 @@ using InABox.Configuration;
|
|
|
using InABox.DynamicGrid;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
+using InABox.WPF;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
@@ -49,23 +50,37 @@ namespace PRSDesktop
|
|
|
|
|
|
private void DocumentPreviewer_OnApproved(IEntityDocument stagingsetoutdocument)
|
|
|
{
|
|
|
- string message = "";
|
|
|
+ bool bulkApprove = false;
|
|
|
+ if (_items.Count > 1)
|
|
|
+ {
|
|
|
+ if (MessageBox.Show("Bulk approve? (Skip individual setout approval)", "Continue?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
|
|
+ {
|
|
|
+ bulkApprove = true;
|
|
|
+ Progress.Show("Approving Setouts..");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string message = "Result: " + Environment.NewLine;
|
|
|
|
|
|
foreach (var item in _items)
|
|
|
{
|
|
|
- var returnstring = ApproveSetout(item);
|
|
|
+ if (bulkApprove)
|
|
|
+ Progress.Show("Working on " + item.Number);
|
|
|
+ var returnstring = ApproveSetout(item, bulkApprove);
|
|
|
if (!string.IsNullOrWhiteSpace(returnstring))
|
|
|
message = message + returnstring + Environment.NewLine;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ if(bulkApprove)
|
|
|
+ Progress.Close();
|
|
|
+
|
|
|
foreach (var item in _items)
|
|
|
DeleteAndRefresh(item);
|
|
|
|
|
|
MessageBox.Show(message);
|
|
|
}
|
|
|
|
|
|
- private string ApproveSetout(StagingSetout item)
|
|
|
+ private string ApproveSetout(StagingSetout item, bool bulkapprove)
|
|
|
{
|
|
|
if (item.Group.ID == Guid.Empty)
|
|
|
{
|
|
@@ -89,7 +104,7 @@ namespace PRSDesktop
|
|
|
if (!setoutdoctable.Rows.Any())
|
|
|
return "";
|
|
|
|
|
|
- var stagingsetoutdocument = setoutdoctable.Rows.FirstOrDefault().ToObject<SetoutDocument>();
|
|
|
+ var stagingsetoutdocument = setoutdoctable.Rows.FirstOrDefault().ToObject<StagingSetoutDocument>();
|
|
|
|
|
|
var table = new Client<Setout>().Query(new Filter<Setout>(x => x.Number).IsEqualTo(item.Number),
|
|
|
new Columns<Setout>(x => x.ID));
|
|
@@ -98,8 +113,9 @@ namespace PRSDesktop
|
|
|
//setout already exists - create new setoutdoc and supercede old ones
|
|
|
if (table.Rows.Any())
|
|
|
{
|
|
|
- if (MessageBox.Show("Supercede existing documents?", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
- return "";
|
|
|
+ if (!bulkapprove)
|
|
|
+ if (MessageBox.Show("Supercede existing documents?", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
+ return "";
|
|
|
|
|
|
setout = table.Rows.FirstOrDefault().ToObject<Setout>();
|
|
|
|
|
@@ -145,28 +161,42 @@ namespace PRSDesktop
|
|
|
var editor = new DynamicDataGrid<Setout>();
|
|
|
editor.OnAfterSave += (editor, items) =>
|
|
|
{
|
|
|
- item.Setout.ID = setout.ID;
|
|
|
-
|
|
|
- var setoutdoc = new SetoutDocument();
|
|
|
- setoutdoc.EntityLink.ID = setout.ID;
|
|
|
- setoutdoc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
|
-
|
|
|
- new Client<SetoutDocument>().Save(setoutdoc, "Added from staging screen");
|
|
|
+ CreateSetoutDocument(setout, item, stagingsetoutdocument);
|
|
|
};
|
|
|
|
|
|
- if (!editor.EditItems(new[] { setout }))
|
|
|
+ if (!bulkapprove)
|
|
|
{
|
|
|
- MessageBox.Show("Setout Creation Cancelled");
|
|
|
- return "";
|
|
|
+ if (!editor.EditItems(new[] { setout }))
|
|
|
+ {
|
|
|
+ MessageBox.Show("Setout Creation Cancelled");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return item.Number + " Created";
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
+ new Client<Setout>().Save(setout, "Added from staging screen");
|
|
|
+ CreateSetoutDocument(setout, item, stagingsetoutdocument);
|
|
|
return item.Number + " Created";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//currently not creating packets due to temporary change in requirements - to uncomment and check for validity when required
|
|
|
//CreatePackets(setout);
|
|
|
}
|
|
|
|
|
|
+ private void CreateSetoutDocument(Setout setout, StagingSetout item, StagingSetoutDocument stagingsetoutdocument)
|
|
|
+ {
|
|
|
+ item.Setout.ID = setout.ID;
|
|
|
+
|
|
|
+ var setoutdoc = new SetoutDocument();
|
|
|
+ setoutdoc.EntityLink.ID = setout.ID;
|
|
|
+ setoutdoc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
|
+
|
|
|
+ new Client<SetoutDocument>().Save(setoutdoc, "Added from staging screen");
|
|
|
+ }
|
|
|
+
|
|
|
private void CreatePackets(Setout setout)
|
|
|
{
|
|
|
List<ManufacturingPacket> packets = new List<ManufacturingPacket>();
|
|
@@ -408,6 +438,7 @@ namespace PRSDesktop
|
|
|
{
|
|
|
//stagingSetoutGrid.ScanFiles(_settings.SetoutsFolder);
|
|
|
stagingSetoutGrid.Refresh(false, true);
|
|
|
+ documentPreviewer.Document = new StagingSetoutDocument();
|
|
|
|
|
|
manufacturingControl.StagingSetout = new StagingSetout();
|
|
|
manufacturingControl.Refresh();
|