| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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; }
- protected override SetoutDocument CreateItem()
- {
- var result = base.CreateItem();
- result.EntityLink.ID = Design.ID;
- result.EntityLink.Synchronise(Design);
- return result;
- }
- protected override void Reload(Filters<SetoutDocument> criteria, Columns<SetoutDocument> columns, ref SortOrder<SetoutDocument>? sort, Action<CoreTable?, Exception?> action)
- {
- criteria.Add(new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(Design.ID));
- 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.PrintAllowed = Security.IsAllowed<CanPrintFactoryFloorDrawings>();
- 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 Design.ID != Guid.Empty;
- }
-
- }
- }
|