|
@@ -11,197 +11,196 @@ using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
using InABox.Wpf;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
+namespace PRSDesktop;
|
|
|
+
|
|
|
+public class ManufacturingGrid : DynamicDataGrid<ManufacturingPacket>, IMasterDetailControl<Job, ManufacturingPacket>, IDataModelSource
|
|
|
{
|
|
|
- public class ManufacturingGrid : DynamicDataGrid<ManufacturingPacket>, IMasterDetailControl<Job, ManufacturingPacket>, IDataModelSource
|
|
|
- {
|
|
|
- private readonly BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
|
|
|
+ private readonly BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
|
|
|
|
|
|
- private readonly ManufacturingSection[] Sections = new Client<ManufacturingSection>().Load();
|
|
|
- //private BitmapImage Tick = PRSDesktop.Resources.tick.AsBitmapImage();
|
|
|
+ private readonly ManufacturingSection[] Sections = new Client<ManufacturingSection>().Load();
|
|
|
+ //private BitmapImage Tick = PRSDesktop.Resources.tick.AsBitmapImage();
|
|
|
|
|
|
- private readonly ManufacturingTemplateStage[] Stages = new Client<ManufacturingTemplateStage>().Load();
|
|
|
-
|
|
|
- public Job? Master { get; set; }
|
|
|
+ private readonly ManufacturingTemplateStage[] Stages = new Client<ManufacturingTemplateStage>().Load();
|
|
|
+
|
|
|
+ public Job? Master { get; set; }
|
|
|
|
|
|
- public Filter<ManufacturingPacket> MasterDetailFilter => Master != null
|
|
|
- ? Master.ID != Guid.Empty
|
|
|
- ? new Filter<ManufacturingPacket>(x => x.JobLink.ID).IsEqualTo(Master.ID)
|
|
|
- : new Filter<ManufacturingPacket>().None()
|
|
|
- : new Filter<ManufacturingPacket>().All();
|
|
|
-
|
|
|
- public Setout? Design { get; set; }
|
|
|
+ public Filter<ManufacturingPacket> MasterDetailFilter => Master != null
|
|
|
+ ? Master.ID != Guid.Empty
|
|
|
+ ? new Filter<ManufacturingPacket>(x => x.JobLink.ID).IsEqualTo(Master.ID)
|
|
|
+ : new Filter<ManufacturingPacket>().None()
|
|
|
+ : new Filter<ManufacturingPacket>().All();
|
|
|
+
|
|
|
+ public Setout? Design { get; set; }
|
|
|
|
|
|
- public CoreTable Packets { get; private set; }
|
|
|
+ public CoreTable Packets { get; private set; }
|
|
|
|
|
|
- public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
+ public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
|
|
|
- public string SectionName => "Manufacturing Grid";
|
|
|
+ public string SectionName => "Manufacturing Grid";
|
|
|
|
|
|
- public ManufacturingGrid()
|
|
|
- {
|
|
|
- Design = new Setout();
|
|
|
- }
|
|
|
+ public ManufacturingGrid()
|
|
|
+ {
|
|
|
+ Design = new Setout();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Init()
|
|
|
+ {
|
|
|
|
|
|
- protected override void Init()
|
|
|
- {
|
|
|
-
|
|
|
- base.Init();
|
|
|
-
|
|
|
- ActionColumns.Add(new DynamicImageColumn(BarCodeImage, BarcodeClick) { AllowHeaderClick = true });
|
|
|
- HiddenColumns.Add(x => x.BarcodePrinted);
|
|
|
-
|
|
|
- HiddenColumns.Add(x => x.SetoutLink.JobLink.ID);
|
|
|
- AddButton("Complete Item", PRSDesktop.Resources.wrench.AsBitmapImage(), CompleteItems);
|
|
|
- }
|
|
|
+ base.Init();
|
|
|
|
|
|
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
- {
|
|
|
- base.DoReconfigure(options);
|
|
|
+ ActionColumns.Add(new DynamicImageColumn(BarCodeImage, BarcodeClick) { AllowHeaderClick = true });
|
|
|
+ HiddenColumns.Add(x => x.BarcodePrinted);
|
|
|
+
|
|
|
+ HiddenColumns.Add(x => x.SetoutLink.JobLink.ID);
|
|
|
+ AddButton("Complete Item", PRSDesktop.Resources.wrench.AsBitmapImage(), CompleteItems);
|
|
|
+ }
|
|
|
|
|
|
- options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns, DynamicGridOption.AddRows, DynamicGridOption.EditRows,
|
|
|
- DynamicGridOption.FilterRows, DynamicGridOption.DeleteRows, DynamicGridOption.MultiSelect, DynamicGridOption.ExportData);
|
|
|
- }
|
|
|
+ protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
+ {
|
|
|
+ base.DoReconfigure(options);
|
|
|
|
|
|
+ options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns, DynamicGridOption.AddRows, DynamicGridOption.EditRows,
|
|
|
+ DynamicGridOption.FilterRows, DynamicGridOption.DeleteRows, DynamicGridOption.MultiSelect, DynamicGridOption.ExportData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public DataModel DataModel(Selection selection)
|
|
|
+ {
|
|
|
+ var ids = ExtractValues(x => x.ID, selection).ToArray();
|
|
|
+ return new ManufacturingPacketDataModel(new Filter<ManufacturingPacket>(x => x.ID).InList(ids));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- public DataModel DataModel(Selection selection)
|
|
|
+
|
|
|
+ private bool CompleteItems(Button sender, CoreRow[] rows)
|
|
|
+ {
|
|
|
+ if (rows == null || !rows.Any())
|
|
|
{
|
|
|
- var ids = ExtractValues(x => x.ID, selection).ToArray();
|
|
|
- return new ManufacturingPacketDataModel(new Filter<ManufacturingPacket>(x => x.ID).InList(ids));
|
|
|
+ MessageBox.Show("Please select at least one item to complete!");
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- private bool CompleteItems(Button sender, CoreRow[] rows)
|
|
|
+ if (MessageBox.Show("Are you sue you wish to complete these items?", "Confirm Complete", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
{
|
|
|
- if (rows == null || !rows.Any())
|
|
|
- {
|
|
|
- MessageBox.Show("Please select at least one item to complete!");
|
|
|
- return false;
|
|
|
- }
|
|
|
+ Progress.Show("Loading Stages");
|
|
|
|
|
|
- if (MessageBox.Show("Are you sue you wish to complete these items?", "Confirm Complete", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
+ Filter<ManufacturingPacket> pktflt = null;
|
|
|
+ Filter<ManufacturingPacketStage> stgflt = null;
|
|
|
+ foreach (var row in rows)
|
|
|
{
|
|
|
- Progress.Show("Loading Stages");
|
|
|
-
|
|
|
- Filter<ManufacturingPacket> pktflt = null;
|
|
|
- Filter<ManufacturingPacketStage> stgflt = null;
|
|
|
- foreach (var row in rows)
|
|
|
- {
|
|
|
- var id = row.Get<ManufacturingPacket, Guid>(x => x.ID);
|
|
|
- pktflt = stgflt == null ? new Filter<ManufacturingPacket>(x => x.ID).IsEqualTo(id) : pktflt.Or(x => x.ID).IsEqualTo(id);
|
|
|
- stgflt = stgflt == null
|
|
|
- ? new Filter<ManufacturingPacketStage>(x => x.Parent.ID).IsEqualTo(id)
|
|
|
- : stgflt.Or(x => x.Parent.ID).IsEqualTo(id);
|
|
|
- }
|
|
|
-
|
|
|
- var pkts = new Client<ManufacturingPacket>().Load(pktflt);
|
|
|
- var stgs = new Client<ManufacturingPacketStage>().Load(stgflt, new SortOrder<ManufacturingPacketStage>(x => x.Sequence));
|
|
|
+ var id = row.Get<ManufacturingPacket, Guid>(x => x.ID);
|
|
|
+ pktflt = stgflt == null ? new Filter<ManufacturingPacket>(x => x.ID).IsEqualTo(id) : pktflt.Or(x => x.ID).IsEqualTo(id);
|
|
|
+ stgflt = stgflt == null
|
|
|
+ ? new Filter<ManufacturingPacketStage>(x => x.Parent.ID).IsEqualTo(id)
|
|
|
+ : stgflt.Or(x => x.Parent.ID).IsEqualTo(id);
|
|
|
+ }
|
|
|
|
|
|
- while (pkts.Any(x => x.Completed.IsEmpty())) ManufacturingPacket.Progress(pkts, stgs);
|
|
|
+ var pkts = new Client<ManufacturingPacket>().Load(pktflt);
|
|
|
+ var stgs = new Client<ManufacturingPacketStage>().Load(stgflt, new SortOrder<ManufacturingPacketStage>(x => x.Sequence));
|
|
|
|
|
|
- Progress.SetMessage("Progressing Items");
|
|
|
- new Client<ManufacturingPacketStage>().Save(stgs.Where(x => x.IsChanged()), "ManufacturingPacket Marked as Complete by User");
|
|
|
- new Client<ManufacturingPacket>().Save(pkts.Where(x => x.IsChanged()), "ManufacturingPacket Marked as Complete by User");
|
|
|
- Progress.Close();
|
|
|
- return true;
|
|
|
- }
|
|
|
+ while (pkts.Any(x => x.Completed.IsEmpty())) ManufacturingPacket.Progress(pkts, stgs);
|
|
|
|
|
|
- return false;
|
|
|
+ Progress.SetMessage("Progressing Items");
|
|
|
+ new Client<ManufacturingPacketStage>().Save(stgs.Where(x => x.IsChanged()), "ManufacturingPacket Marked as Complete by User");
|
|
|
+ new Client<ManufacturingPacket>().Save(pkts.Where(x => x.IsChanged()), "ManufacturingPacket Marked as Complete by User");
|
|
|
+ Progress.Close();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- private BitmapImage BarCodeImage(CoreRow arg)
|
|
|
- {
|
|
|
- if (arg == null)
|
|
|
- return barcode;
|
|
|
- return arg.Get<ManufacturingPacket, DateTime>(x => x.BarcodePrinted).IsEmpty() ? null : barcode;
|
|
|
- }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- private bool BarcodeClick(CoreRow arg)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ private BitmapImage BarCodeImage(CoreRow arg)
|
|
|
+ {
|
|
|
+ if (arg == null)
|
|
|
+ return barcode;
|
|
|
+ return arg.Get<ManufacturingPacket, DateTime>(x => x.BarcodePrinted).IsEmpty() ? null : barcode;
|
|
|
+ }
|
|
|
|
|
|
+ private bool BarcodeClick(CoreRow arg)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- protected override void Reload(Filters<ManufacturingPacket> criteria, Columns<ManufacturingPacket> columns,
|
|
|
- ref SortOrder<ManufacturingPacket>? sort, Action<CoreTable?, Exception?> action)
|
|
|
- {
|
|
|
- criteria.Add(MasterDetailFilter);
|
|
|
- if ((Design?.ID ?? Guid.Empty) != Guid.Empty)
|
|
|
- criteria.Add(new Filter<ManufacturingPacket>(x => x.SetoutLink.ID).IsEqualTo(Design.ID));
|
|
|
- sort = new SortOrder<ManufacturingPacket>(x => x.SetoutLink.Number);
|
|
|
- base.Reload(criteria, columns, ref sort, action);
|
|
|
- }
|
|
|
|
|
|
- protected override ManufacturingPacket CreateItem()
|
|
|
- {
|
|
|
- var result = base.CreateItem();
|
|
|
- result.SetoutLink.ID = Design.ID;
|
|
|
- result.SetoutLink.Synchronise(Design);
|
|
|
- return result;
|
|
|
- }
|
|
|
+ protected override void Reload(Filters<ManufacturingPacket> criteria, Columns<ManufacturingPacket> columns,
|
|
|
+ ref SortOrder<ManufacturingPacket>? sort, Action<CoreTable?, Exception?> action)
|
|
|
+ {
|
|
|
+ criteria.Add(MasterDetailFilter);
|
|
|
+ if ((Design?.ID ?? Guid.Empty) != Guid.Empty)
|
|
|
+ criteria.Add(new Filter<ManufacturingPacket>(x => x.SetoutLink.ID).IsEqualTo(Design.ID));
|
|
|
+ sort = new SortOrder<ManufacturingPacket>(x => x.SetoutLink.Number);
|
|
|
+ base.Reload(criteria, columns, ref sort, action);
|
|
|
+ }
|
|
|
|
|
|
- protected override Dictionary<string, object?> EditorValueChanged(IDynamicEditorForm editor, ManufacturingPacket[] items, string name,
|
|
|
- object value)
|
|
|
+ protected override ManufacturingPacket CreateItem()
|
|
|
+ {
|
|
|
+ var result = base.CreateItem();
|
|
|
+ result.SetoutLink.ID = Design.ID;
|
|
|
+ result.SetoutLink.Synchronise(Design);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override Dictionary<string, object?> EditorValueChanged(IDynamicEditorForm editor, ManufacturingPacket[] items, string name,
|
|
|
+ object value)
|
|
|
+ {
|
|
|
+ var result = base.EditorValueChanged(editor, items, name, value);
|
|
|
+ if (name == "ManufacturingTemplateLink.ID")
|
|
|
{
|
|
|
- var result = base.EditorValueChanged(editor, items, name, value);
|
|
|
- if (name == "ManufacturingTemplateLink.ID")
|
|
|
+ var template = new Client<ManufacturingTemplate>().Load(new Filter<ManufacturingTemplate>(x => x.ID).IsEqualTo(value))
|
|
|
+ .FirstOrDefault();
|
|
|
+ if (template != null)
|
|
|
{
|
|
|
- var template = new Client<ManufacturingTemplate>().Load(new Filter<ManufacturingTemplate>(x => x.ID).IsEqualTo(value))
|
|
|
- .FirstOrDefault();
|
|
|
- if (template != null)
|
|
|
- {
|
|
|
- foreach (var item in items) item.Group = template.Factory.Name;
|
|
|
- result["Group"] = template.Factory.Name;
|
|
|
- }
|
|
|
+ foreach (var item in items) item.Group = template.Factory.Name;
|
|
|
+ result["Group"] = template.Factory.Name;
|
|
|
+ }
|
|
|
|
|
|
- //Type attrtype = typeof(IDynamicEnclosedListGrid<,>).MakeGenericType(typeof(ManufacturingPacket),typeof(CoreAttribute));
|
|
|
- //var attrpage = editor.Pages.FirstOrDefault(x => x.GetType().GetInterface(attrtype.Name) != null);
|
|
|
- //if (attrpage != null)
|
|
|
- //{
|
|
|
- // if (!attrpage.Ready)
|
|
|
- // attrpage.Load(items.First(), null);
|
|
|
- // MethodInfo load = attrpage.GetType().GetMethod("LoadItems");
|
|
|
- // load.Invoke(attrpage, new object[] { template.CustomAttributes });
|
|
|
- //}
|
|
|
-
|
|
|
- var stagetype = typeof(IDynamicOneToManyGrid<,>).MakeGenericType(typeof(ManufacturingPacket), typeof(ManufacturingPacketStage));
|
|
|
- var stagepage = editor.Pages.FirstOrDefault(x => x.GetType().GetInterface(stagetype.Name) != null);
|
|
|
- if (stagepage != null)
|
|
|
+ //Type attrtype = typeof(IDynamicEnclosedListGrid<,>).MakeGenericType(typeof(ManufacturingPacket),typeof(CoreAttribute));
|
|
|
+ //var attrpage = editor.Pages.FirstOrDefault(x => x.GetType().GetInterface(attrtype.Name) != null);
|
|
|
+ //if (attrpage != null)
|
|
|
+ //{
|
|
|
+ // if (!attrpage.Ready)
|
|
|
+ // attrpage.Load(items.First(), null);
|
|
|
+ // MethodInfo load = attrpage.GetType().GetMethod("LoadItems");
|
|
|
+ // load.Invoke(attrpage, new object[] { template.CustomAttributes });
|
|
|
+ //}
|
|
|
+
|
|
|
+ var stagetype = typeof(IDynamicOneToManyGrid<,>).MakeGenericType(typeof(ManufacturingPacket), typeof(ManufacturingPacketStage));
|
|
|
+ var stagepage = editor.Pages.FirstOrDefault(x => x.GetType().GetInterface(stagetype.Name) != null);
|
|
|
+ if (stagepage != null)
|
|
|
+ {
|
|
|
+ var tstages = Stages.Where(x => x.Template.ID.Equals(value)).OrderBy(x => x.Sequence);
|
|
|
+ var pstages = new List<ManufacturingPacketStage>();
|
|
|
+ foreach (var tstage in tstages)
|
|
|
{
|
|
|
- var tstages = Stages.Where(x => x.Template.ID.Equals(value)).OrderBy(x => x.Sequence);
|
|
|
- var pstages = new List<ManufacturingPacketStage>();
|
|
|
- foreach (var tstage in tstages)
|
|
|
+ var pstage = new ManufacturingPacketStage
|
|
|
{
|
|
|
- var pstage = new ManufacturingPacketStage
|
|
|
- {
|
|
|
- Time = tstage.Time,
|
|
|
- Sequence = tstage.Sequence,
|
|
|
- SequenceType = tstage.SequenceType,
|
|
|
- Started = DateTime.MinValue,
|
|
|
- PercentageComplete = 0.0F,
|
|
|
- Completed = DateTime.MinValue,
|
|
|
- QualityChecks = tstage.QualityChecks,
|
|
|
- QualityStatus = QualityStatus.NotChecked,
|
|
|
- QualityNotes = ""
|
|
|
- };
|
|
|
- var section = Sections.Where(x => x.ID.Equals(tstage.Section.ID));
|
|
|
-
|
|
|
- //pstage.QAChecks.AddRange(tstage.QAChecks);
|
|
|
- pstage.ManufacturingSectionLink.ID = tstage.Section.ID;
|
|
|
- pstage.ManufacturingSectionLink.Name = tstage.Section.Name;
|
|
|
- pstages.Add(pstage);
|
|
|
- }
|
|
|
-
|
|
|
- if (!stagepage.Ready)
|
|
|
- stagepage.Load(items.First(), null);
|
|
|
- var load = stagepage.GetType().GetMethod("LoadItems");
|
|
|
- load.Invoke(stagepage, new object[] { pstages.ToArray() });
|
|
|
+ Time = tstage.Time,
|
|
|
+ Sequence = tstage.Sequence,
|
|
|
+ SequenceType = tstage.SequenceType,
|
|
|
+ Started = DateTime.MinValue,
|
|
|
+ PercentageComplete = 0.0F,
|
|
|
+ Completed = DateTime.MinValue,
|
|
|
+ QualityChecks = tstage.QualityChecks,
|
|
|
+ QualityStatus = QualityStatus.NotChecked,
|
|
|
+ QualityNotes = ""
|
|
|
+ };
|
|
|
+ var section = Sections.Where(x => x.ID.Equals(tstage.Section.ID));
|
|
|
+
|
|
|
+ //pstage.QAChecks.AddRange(tstage.QAChecks);
|
|
|
+ pstage.ManufacturingSectionLink.ID = tstage.Section.ID;
|
|
|
+ pstage.ManufacturingSectionLink.Name = tstage.Section.Name;
|
|
|
+ pstages.Add(pstage);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- return result;
|
|
|
+ if (!stagepage.Ready)
|
|
|
+ stagepage.Load(items.First(), null);
|
|
|
+ var load = stagepage.GetType().GetMethod("LoadItems");
|
|
|
+ load.Invoke(stagepage, new object[] { pstages.ToArray() });
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|