12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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);
- }
- 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;
- }
- }
- }
|