QAFormQuestionGrid.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. using InABox.WPF;
  10. namespace PRSDesktop.Configuration;
  11. public abstract class QAFormQuestionGrid<T> : DynamicOneToManyGrid<DigitalForm, QAQuestion> where T : Entity, IRemotable, IPersistent, new()
  12. {
  13. protected bool Preview = false;
  14. public QAFormQuestionGrid()
  15. {
  16. AddButton("Fill", PRSDesktop.Resources.quality.AsBitmapImage(), PreviewForm);
  17. //AddButton("Design", PRSDesktop.Resources.edit.AsBitmapImage(true), DesignForm);
  18. }
  19. public virtual string Description()
  20. {
  21. return "QA Checks";
  22. }
  23. //private bool DesignForm(Button arg1, CoreRow[] arg2)
  24. //{
  25. // var form = new DynamicFormWindow();
  26. // bool result = form.ShowDialog() == true;
  27. // return false;
  28. //}
  29. private bool PreviewForm(Button sender, CoreRow[] rows)
  30. {
  31. var window = new Window { Title = "Quality Assurance Form", Width = 700 };
  32. window.Background = new SolidColorBrush(Colors.WhiteSmoke);
  33. var layout = new Grid();
  34. layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1.0F, GridUnitType.Star) });
  35. layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100.0F) });
  36. layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100.0F) });
  37. layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1.0F, GridUnitType.Star) });
  38. layout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50.0F) });
  39. var qagrid = new QAGrid();
  40. var values = new Dictionary<Guid, object>();
  41. qagrid.LoadChecks(Description(), Items, values);
  42. qagrid.CollapseMargins();
  43. qagrid.SetValue(Grid.RowProperty, 0);
  44. qagrid.SetValue(Grid.ColumnProperty, 0);
  45. qagrid.SetValue(Grid.ColumnSpanProperty, 3);
  46. layout.Children.Add(qagrid);
  47. var ok = new Button();
  48. ok.SetValue(Grid.RowProperty, 1);
  49. ok.SetValue(Grid.ColumnProperty, 1);
  50. ok.Content = "OK";
  51. ok.Margin = new Thickness(0, 0, 10, 10);
  52. ok.Click += (o, e) =>
  53. {
  54. values.Clear();
  55. window.DialogResult = true;
  56. window.Close();
  57. };
  58. layout.Children.Add(ok);
  59. var cancel = new Button();
  60. cancel.SetValue(Grid.RowProperty, 1);
  61. cancel.SetValue(Grid.ColumnProperty, 2);
  62. cancel.Content = "Cancel";
  63. cancel.Margin = new Thickness(0, 0, 10, 10);
  64. cancel.Click += (o, e) =>
  65. {
  66. window.DialogResult = false;
  67. window.Close();
  68. };
  69. layout.Children.Add(cancel);
  70. window.Content = layout;
  71. window.ShowDialog();
  72. return false;
  73. }
  74. }
  75. public class QAFormQuestionGrid : QAFormQuestionGrid<DigitalForm>
  76. {
  77. }
  78. public class KanbanQAQuestionGrid : QAFormQuestionGrid<Kanban>
  79. {
  80. }
  81. public class ITPQAQuestionGrid : QAFormQuestionGrid<JobITP>
  82. {
  83. }
  84. public class AssignmentQAQuestionGrid : QAFormQuestionGrid<Assignment>
  85. {
  86. }
  87. public class ManufacturingSectionQAQuestionGrid : QAFormQuestionGrid<ManufacturingSection>
  88. {
  89. }
  90. public class ManufacturingPacketStageQAQuestionGrid : QAFormQuestionGrid<ManufacturingPacketStage>
  91. {
  92. }