QAFormQuestionGrid.cs 3.6 KB

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