| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Windows.Media.Imaging;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- namespace PRSDesktop
- {
- public class JobDesignDocumentGrid : DynamicDataGrid<SetoutDocument>
- {
- public JobDesignDocumentGrid()
- {
- HiddenColumns.Add(x => x.DocumentLink.ID);
- HiddenColumns.Add(x => x.EntityLink.ID);
- HiddenColumns.Add(x => x.Superceded);
- HiddenColumns.Add(x => x.DocumentLink.FileName);
- ActionColumns.Add(new DynamicImageColumn(DocumentImage, ViewDocument) { Position = DynamicActionColumnPosition.Start });
- ActionColumns.Add(new DynamicTickColumn<SetoutDocument, DateTime>(
- x => x.Superceded,
- PRSDesktop.Resources.tick.AsBitmapImage(),
- PRSDesktop.Resources.warning.AsBitmapImage(),
- PRSDesktop.Resources.tick.AsBitmapImage(),
- SupercedeDocument
- ));
- }
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
- base.DoReconfigure(options);
- options.BeginUpdate()
- .Add(DynamicGridOption.RecordCount)
- .Add(DynamicGridOption.SelectColumns)
- .Remove(DynamicGridOption.ImportData)
- .Remove(DynamicGridOption.ExportData)
- .EndUpdate();
- }
- public Setout? Design { get; set; }
- public override SetoutDocument CreateItem()
- {
- var result = base.CreateItem();
- result.EntityLink.ID = Design?.ID ?? Guid.Empty;
- result.EntityLink.Synchronise(Design ?? new Setout());
- return result;
- }
- protected override void Reload(Filters<SetoutDocument> criteria, Columns<SetoutDocument> columns, ref SortOrder<SetoutDocument>? sort, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(Design != null
- ? new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(Design.ID)
- : new Filter<SetoutDocument>().None());
- base.Reload(criteria, columns, ref sort, action);
- }
- private BitmapImage DocumentImage(CoreRow arg)
- {
- return PRSDesktop.Resources.view.AsBitmapImage();
- }
- private bool ViewDocument(CoreRow row)
- {
- var doc = row.ToObject<SetoutDocument>();
- var viewer = new DocumentEditor(doc);
- viewer.SaveAllowed = Security.IsAllowed<CanSaveFactoryFloorDrawings>();
- viewer.ShowDialog();
- return false;
- }
- private bool SupercedeDocument(CoreRow row)
- {
- var sd = row.ToObject<SetoutDocument>();
- sd.Superceded = sd.Superceded.IsEmpty() ? DateTime.Now : DateTime.MinValue;
- new Client<SetoutDocument>().Save(sd, string.Format("{0} Superceded Flag", sd.Superceded.IsEmpty() ? "Cleared" : "Set"));
- return true;
- }
- protected override bool CanCreateItems()
- {
- return base.CanCreateItems() && (Design?.ID ?? Guid.Empty) != Guid.Empty;
- }
-
- }
- }
|