JobDesignGrid.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Media.Imaging;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using InABox.DynamicGrid;
  7. using InABox.WPF;
  8. namespace PRSDesktop
  9. {
  10. internal class JobDesignGrid : DynamicDataGrid<Setout>, IJobControl
  11. {
  12. private BitmapImage barcode = PRSDesktop.Resources.barcode.AsBitmapImage();
  13. private BitmapImage design = PRSDesktop.Resources.design.AsBitmapImage();
  14. private BitmapImage qacheck = PRSDesktop.Resources.checklist.AsBitmapImage();
  15. private BitmapImage tick = PRSDesktop.Resources.tick.AsBitmapImage();
  16. public JobDesignGrid()
  17. {
  18. Options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.SelectColumns, DynamicGridOption.FilterRows);
  19. //ActionColumns.Add(
  20. // new DynamicTickColumn<Setout>(PRSDesktop.Resources.design.AsBitmapImage(), x => x.Designed)
  21. // {
  22. // Action = DesignedClick
  23. // }
  24. // );
  25. //ActionColumns.Add(new DynamicTickColumn<Setout>(PRSDesktop.Resources.checklist.AsBitmapImage(), x => x.Checked));
  26. //ActionColumns.Add(new DynamicTickColumn<Setout>(PRSDesktop.Resources.factory.AsBitmapImage(), x => x.Issued));
  27. //ActionColumns.Add(new DynamicActionColumn() { Image = DesignedImage, Action = DesignedClick });
  28. //ActionColumns.Add(new DynamicActionColumn() { Image = CheckedImage, Action = CheckedClick });
  29. //ActionColumns.Add(new DynamicActionColumn() { Image = BarcodeImage, Action = BarcodeClick });
  30. //HiddenColumns.Add(x => x.Designed);
  31. //HiddenColumns.Add(x => x.Checked);
  32. //HiddenColumns.Add(x => x.Issued);
  33. //OnAddItem += DoAddItem;
  34. //OnEditItem += DoEditItem;
  35. }
  36. public CoreTable Setouts { get; private set; }
  37. public Guid JobID { get; set; }
  38. protected override void SelectItems(CoreRow[] rows)
  39. {
  40. base.SelectItems(rows);
  41. }
  42. protected override void Reload(Filters<Setout> criteria, Columns<Setout> columns, ref SortOrder<Setout> sort,
  43. Action<CoreTable, Exception> action)
  44. {
  45. criteria.Add(new Filter<Setout>(x => x.JobLink.ID).IsEqualTo(JobID));
  46. sort = new SortOrder<Setout>(x => x.Number, SortDirection.Descending);
  47. base.Reload(criteria, columns, ref sort, action);
  48. }
  49. protected override void DoAdd()
  50. {
  51. if (JobID.Equals(Guid.Empty) || JobID.Equals(CoreUtils.FullGuid))
  52. MessageBox.Show("Please select a Job first!");
  53. else
  54. base.DoAdd();
  55. }
  56. protected override Setout CreateItem()
  57. {
  58. var setout = base.CreateItem();
  59. setout.JobLink.ID = JobID;
  60. //setout.Job = new Client<Job>().Load(new Filter<Job>(x => x.ID).IsEqualTo(CurrentJobID)).FirstOrDefault();
  61. return setout;
  62. }
  63. //public override bool EditItems(Setout[] items)
  64. //{
  65. // Setout item = items.FirstOrDefault();
  66. // if (item == null)
  67. // return false;
  68. // SetoutDetails form = new SetoutDetails(item);
  69. // return form.ShowDialog() == true;
  70. //}
  71. //private BitmapImage DesignedImage(DataRow row)
  72. //{
  73. // if (row == null)
  74. // return design;
  75. // DateTime designed = row.Get<Setout, DateTime>(x => x.Designed);
  76. // //DateTime qachecked = row.Get<Setout, DateTime>(x => x.Checked);
  77. // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
  78. // return designed.IsEmpty() /* && qachecked.IsEmpty() && issued.IsEmpty() */ ? null : tick;
  79. //}
  80. //private bool DesignedClick(CoreRow row)
  81. //{
  82. // Setout setout = LoadItem(row);
  83. // bool designed = setout.Designed.IsEmpty();
  84. // setout.Designed = designed ? DateTime.Now : DateTime.MinValue;
  85. // //setout.Checked = DateTime.MinValue;
  86. // //setout.Issued = DateTime.MinValue;
  87. // //foreach (SetoutStage stage in setout.Stages)
  88. // //{
  89. // // stage.Started = DateTime.MinValue;
  90. // // stage.Completed = DateTime.MinValue;
  91. // //}
  92. // new Client<Setout>().Save(setout,"Setout Designed Flag set to " + (setout.Designed.IsEmpty()? "false" : "true"));
  93. // return true;
  94. //}
  95. //private BitmapImage CheckedImage(DataRow row)
  96. //{
  97. // if (row == null)
  98. // return qacheck;
  99. // DateTime qachecked = row.Get<Setout, DateTime>(x => x.Checked);
  100. // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
  101. // return qachecked.IsEmpty() /* && issued.IsEmpty() */ ? null : tick;
  102. //}
  103. //private bool CheckedClick(DataRow row)
  104. //{
  105. // //Setout setout = LoadItem(row);
  106. // //bool qachecked = setout.Checked.IsEmpty();
  107. // //setout.Designed = qachecked ? setout.Designed.IsEmpty() ? DateTime.Now : setout.Designed : setout.Designed;
  108. // //setout.Checked = qachecked ? DateTime.Now : DateTime.MinValue;
  109. // //setout.Issued = DateTime.MinValue;
  110. // //foreach (SetoutStage stage in setout.Stages)
  111. // //{
  112. // // stage.Started = DateTime.MinValue;
  113. // // stage.Completed = DateTime.MinValue;
  114. // //}
  115. // ////if (issue)
  116. // //// setout.MoveNext();
  117. // //new Client<Setout>().Save(setout, "Setout QA Flag set to " + (setout.Designed.IsEmpty() ? "false" : "true"));
  118. // //return true;
  119. // return false;
  120. //}
  121. //private BitmapImage BarcodeImage(DataRow row)
  122. //{
  123. // if (row == null)
  124. // return barcode;
  125. // DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
  126. // return issued.IsEmpty() ? null : barcode;
  127. //}
  128. //private bool BarcodeClick(DataRow row)
  129. //{
  130. // //DateTime issued = row.Get<Setout, DateTime>(x => x.Issued);
  131. // //if (issued.IsEmpty())
  132. // // return false;
  133. // return false;
  134. //}
  135. }
  136. }