|
@@ -38,6 +38,8 @@ namespace PRSDesktop
|
|
|
|
|
|
StagingSetout _item = new StagingSetout();
|
|
StagingSetout _item = new StagingSetout();
|
|
|
|
|
|
|
|
+ List<StagingSetout> _items = new List<StagingSetout>();
|
|
|
|
+
|
|
DynamicDataGrid<Document> _materialDocs;
|
|
DynamicDataGrid<Document> _materialDocs;
|
|
public StagingPanel()
|
|
public StagingPanel()
|
|
{
|
|
{
|
|
@@ -47,22 +49,49 @@ namespace PRSDesktop
|
|
|
|
|
|
private void DocumentPreviewer_OnApproved(IEntityDocument stagingsetoutdocument)
|
|
private void DocumentPreviewer_OnApproved(IEntityDocument stagingsetoutdocument)
|
|
{
|
|
{
|
|
- if (_item.Group.ID == Guid.Empty)
|
|
|
|
|
|
+ string message = "";
|
|
|
|
+
|
|
|
|
+ foreach (var item in _items)
|
|
|
|
+ {
|
|
|
|
+ var returnstring = ApproveSetout(item);
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(returnstring))
|
|
|
|
+ message = message + returnstring + Environment.NewLine;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (var item in _items)
|
|
|
|
+ DeleteAndRefresh(item);
|
|
|
|
+
|
|
|
|
+ MessageBox.Show(message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string ApproveSetout(StagingSetout item)
|
|
|
|
+ {
|
|
|
|
+ if (item.Group.ID == Guid.Empty)
|
|
{
|
|
{
|
|
var message = "Setout has no group assigned";
|
|
var message = "Setout has no group assigned";
|
|
if (Security.IsAllowed<CanApproveSetoutsWithoutGroup>())
|
|
if (Security.IsAllowed<CanApproveSetoutsWithoutGroup>())
|
|
{
|
|
{
|
|
if (MessageBox.Show(message + ", continue?", "Continue?", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
|
|
if (MessageBox.Show(message + ", continue?", "Continue?", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
|
|
- return;
|
|
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
MessageBox.Show(message + ", please assign a group!");
|
|
MessageBox.Show(message + ", please assign a group!");
|
|
- return;
|
|
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- var table = new Client<Setout>().Query(new Filter<Setout>(x => x.Number).IsEqualTo(_item.Number),
|
|
|
|
|
|
+ var setoutdoctable = new Client<StagingSetoutDocument>().Query(
|
|
|
|
+ new Filter<StagingSetoutDocument>(x => x.EntityLink.ID).IsEqualTo(item.ID),
|
|
|
|
+ new Columns<StagingSetoutDocument>(x => x.ID, x => x.DocumentLink.ID, x => x.DocumentLink.FileName));
|
|
|
|
+
|
|
|
|
+ if (!setoutdoctable.Rows.Any())
|
|
|
|
+ return "";
|
|
|
|
+
|
|
|
|
+ var stagingsetoutdocument = setoutdoctable.Rows.FirstOrDefault().ToObject<SetoutDocument>();
|
|
|
|
+
|
|
|
|
+ var table = new Client<Setout>().Query(new Filter<Setout>(x => x.Number).IsEqualTo(item.Number),
|
|
new Columns<Setout>(x => x.ID));
|
|
new Columns<Setout>(x => x.ID));
|
|
|
|
|
|
var setout = new Setout();
|
|
var setout = new Setout();
|
|
@@ -70,13 +99,13 @@ namespace PRSDesktop
|
|
if (table.Rows.Any())
|
|
if (table.Rows.Any())
|
|
{
|
|
{
|
|
if (MessageBox.Show("Supercede existing documents?", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
if (MessageBox.Show("Supercede existing documents?", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
- return;
|
|
|
|
|
|
+ return "";
|
|
|
|
|
|
setout = table.Rows.FirstOrDefault().ToObject<Setout>();
|
|
setout = table.Rows.FirstOrDefault().ToObject<Setout>();
|
|
|
|
|
|
- setout.Group.ID = _item.Group.ID;
|
|
|
|
|
|
+ setout.Group.ID = item.Group.ID;
|
|
|
|
|
|
- _item.Setout.ID = setout.ID;
|
|
|
|
|
|
+ item.Setout.ID = setout.ID;
|
|
|
|
|
|
var setoutdoc = new SetoutDocument();
|
|
var setoutdoc = new SetoutDocument();
|
|
setoutdoc.EntityLink.ID = setout.ID;
|
|
setoutdoc.EntityLink.ID = setout.ID;
|
|
@@ -89,7 +118,7 @@ namespace PRSDesktop
|
|
|
|
|
|
CoreTable oldDocsTable = new Client<SetoutDocument>().Query(
|
|
CoreTable oldDocsTable = new Client<SetoutDocument>().Query(
|
|
new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(setout.ID)
|
|
new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(setout.ID)
|
|
- .And(x => x.DocumentLink.ID).IsNotEqualTo(_item.Group.OptimizationDocument.ID)
|
|
|
|
|
|
+ .And(x => x.DocumentLink.ID).IsNotEqualTo(item.Group.OptimizationDocument.ID)
|
|
);
|
|
);
|
|
foreach (var row in oldDocsTable.Rows)
|
|
foreach (var row in oldDocsTable.Rows)
|
|
{
|
|
{
|
|
@@ -103,39 +132,35 @@ namespace PRSDesktop
|
|
new Client<SetoutDocument>().Save(setoutdocs, "Updated from Staging Screen");
|
|
new Client<SetoutDocument>().Save(setoutdocs, "Updated from Staging Screen");
|
|
new Client<Setout>().Save(setout, "Updated from Staging Screen");
|
|
new Client<Setout>().Save(setout, "Updated from Staging Screen");
|
|
|
|
|
|
- MessageBox.Show("Documents for setout " + _item.Number + " superceded.", "Success");
|
|
|
|
-
|
|
|
|
- DeleteAndRefresh(stagingsetoutdocument);
|
|
|
|
|
|
+ return item.Number + " Superceded";
|
|
}
|
|
}
|
|
|
|
|
|
//no setout for this pdf - create new
|
|
//no setout for this pdf - create new
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- setout.Number = _item.Number;
|
|
|
|
- setout.JobLink.ID = _item.JobLink.ID;
|
|
|
|
- setout.Group.ID = _item.Group.ID;
|
|
|
|
|
|
+ setout.Number = item.Number;
|
|
|
|
+ setout.JobLink.ID = item.JobLink.ID;
|
|
|
|
+ setout.Group.ID = item.Group.ID;
|
|
|
|
|
|
var editor = new DynamicDataGrid<Setout>();
|
|
var editor = new DynamicDataGrid<Setout>();
|
|
editor.OnAfterSave += (editor, items) =>
|
|
editor.OnAfterSave += (editor, items) =>
|
|
{
|
|
{
|
|
- _item.Setout.ID = setout.ID;
|
|
|
|
|
|
+ item.Setout.ID = setout.ID;
|
|
|
|
|
|
var setoutdoc = new SetoutDocument();
|
|
var setoutdoc = new SetoutDocument();
|
|
setoutdoc.EntityLink.ID = setout.ID;
|
|
setoutdoc.EntityLink.ID = setout.ID;
|
|
setoutdoc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
setoutdoc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
|
|
|
|
new Client<SetoutDocument>().Save(setoutdoc, "Added from staging screen");
|
|
new Client<SetoutDocument>().Save(setoutdoc, "Added from staging screen");
|
|
-
|
|
|
|
- MessageBox.Show("Setout created for document " + _item.Number, "Success");
|
|
|
|
-
|
|
|
|
- DeleteAndRefresh(stagingsetoutdocument);
|
|
|
|
};
|
|
};
|
|
|
|
|
|
if (!editor.EditItems(new[] { setout }))
|
|
if (!editor.EditItems(new[] { setout }))
|
|
{
|
|
{
|
|
MessageBox.Show("Setout Creation Cancelled");
|
|
MessageBox.Show("Setout Creation Cancelled");
|
|
- return;
|
|
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ return item.Number + " Created";
|
|
}
|
|
}
|
|
|
|
|
|
//currently not creating packets due to temporary change in requirements - to uncomment and check for validity when required
|
|
//currently not creating packets due to temporary change in requirements - to uncomment and check for validity when required
|
|
@@ -254,9 +279,9 @@ namespace PRSDesktop
|
|
return stages;
|
|
return stages;
|
|
}
|
|
}
|
|
|
|
|
|
- private void DeleteAndRefresh(IEntityDocument stagingsetoutdocument)
|
|
|
|
|
|
+ private void DeleteAndRefresh(StagingSetout item)
|
|
{
|
|
{
|
|
- new Client<StagingSetout>().Save(_item, "Updated from staging screen");
|
|
|
|
|
|
+ new Client<StagingSetout>().Save(item, "Updated from staging screen");
|
|
_item = new StagingSetout();
|
|
_item = new StagingSetout();
|
|
|
|
|
|
documentPreviewer.Document = new StagingSetoutDocument();
|
|
documentPreviewer.Document = new StagingSetoutDocument();
|
|
@@ -302,6 +327,11 @@ namespace PRSDesktop
|
|
|
|
|
|
private void StagingSetoutGrid_OnSelectItem(object sender, InABox.DynamicGrid.DynamicGridSelectionEventArgs e)
|
|
private void StagingSetoutGrid_OnSelectItem(object sender, InABox.DynamicGrid.DynamicGridSelectionEventArgs e)
|
|
{
|
|
{
|
|
|
|
+ _items.Clear();
|
|
|
|
+
|
|
|
|
+ foreach (var row in stagingSetoutGrid.SelectedRows)
|
|
|
|
+ _items.Add(row.ToObject<StagingSetout>());
|
|
|
|
+
|
|
_item = stagingSetoutGrid.SelectedRows.FirstOrDefault().ToObject<StagingSetout>();
|
|
_item = stagingSetoutGrid.SelectedRows.FirstOrDefault().ToObject<StagingSetout>();
|
|
|
|
|
|
var doc = new Client<StagingSetoutDocument>().Query(
|
|
var doc = new Client<StagingSetoutDocument>().Query(
|
|
@@ -377,7 +407,7 @@ namespace PRSDesktop
|
|
public void Refresh()
|
|
public void Refresh()
|
|
{
|
|
{
|
|
//stagingSetoutGrid.ScanFiles(_settings.SetoutsFolder);
|
|
//stagingSetoutGrid.ScanFiles(_settings.SetoutsFolder);
|
|
- stagingSetoutGrid.Refresh(false, true);
|
|
|
|
|
|
+ stagingSetoutGrid.Refresh(false, true);
|
|
|
|
|
|
manufacturingControl.StagingSetout = new StagingSetout();
|
|
manufacturingControl.StagingSetout = new StagingSetout();
|
|
manufacturingControl.Refresh();
|
|
manufacturingControl.Refresh();
|