| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Threading;
- 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(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.RecordCount = true;
- options.SelectColumns = true;
- options.ImportData = false;
- options.ExportData = false;
- }
- 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,
- CancellationToken token, 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, token, 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;
- }
-
- }
- }
|