1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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()
- {
- Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns);
- 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
- ));
- Options.Remove(DynamicGridOption.AddRows);
- Options.Remove(DynamicGridOption.DeleteRows);
- Options.Remove(DynamicGridOption.ImportData);
- Options.Remove(DynamicGridOption.ExportData);
- Options.Remove(DynamicGridOption.EditRows);
- }
- public Guid SetoutID { get; set; }
- protected override SetoutDocument CreateItem()
- {
- var result = base.CreateItem();
- result.EntityLink.ID = SetoutID;
- 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(SetoutID));
- 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;
- }
- }
- }
|