RequiItems.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using comal.timesheets.CustomControls;
  2. using Comal.Classes;
  3. using InABox.Clients;
  4. using InABox.Core;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. namespace comal.timesheets
  9. {
  10. public static class RequiItems
  11. {
  12. public static List<StoreRequiItem> NewRequisitionRows { get; set; }
  13. public static List<RequisitionItem> OldRequisitionItems { get; set; }
  14. public static List<HoldingsCacheShell> holdingsCache { get; set; }
  15. public static bool HoldingsLoaded { get; set; }
  16. [DoNotPersist]
  17. public class HoldingsCacheShell : Entity
  18. {
  19. public Guid LocationID { get; set; }
  20. public Guid ProductID { get; set; }
  21. public string LocationName { get; set; }
  22. public string Units { get; set; }
  23. public Guid JobID { get; set; }
  24. public string JobNumber { get; set; }
  25. public string JobName { get; set; }
  26. public Guid StyleID { get; set; }
  27. public string StyleCode { get; set; }
  28. public string StyleDescription { get; set; }
  29. public StockDimensions Dimensions { get; set; }
  30. public HoldingsCacheShell()
  31. {
  32. LocationID = Guid.Empty;
  33. ProductID = Guid.Empty;
  34. LocationName = "";
  35. Units = "";
  36. JobID = Guid.Empty;
  37. JobNumber = "";
  38. JobName = "";
  39. StyleID = Guid.Empty;
  40. StyleCode = "";
  41. StyleDescription = "";
  42. Dimensions = new StockDimensions(() => this);
  43. }
  44. /// <summary>
  45. /// For Display Purposes, and save loading time until Dimensions are needed
  46. /// </summary>
  47. public void UpdateDimensionsAndLocationName()
  48. {
  49. if (ProductID != Guid.Empty)
  50. {
  51. CoreTable table = new Client<Product>().Query(new Filter<Product>(x => x.ID).IsEqualTo(ProductID),
  52. new Columns<Product>(
  53. x => x.Dimensions.Unit.ID,
  54. x => x.Dimensions.Unit.HasQuantity,
  55. x => x.Dimensions.Unit.HasLength,
  56. x => x.Dimensions.Unit.HasHeight,
  57. x => x.Dimensions.Unit.HasWeight,
  58. x => x.Dimensions.Unit.HasWidth,
  59. x => x.Dimensions.Quantity,
  60. x => x.Dimensions.Length,
  61. x => x.Dimensions.Height,
  62. x => x.Dimensions.Weight,
  63. x => x.Dimensions.Width,
  64. x => x.Dimensions.Unit.Format,
  65. x => x.Dimensions.Unit.Formula,
  66. x => x.Dimensions.UnitSize
  67. ));
  68. Product product = table.Rows.FirstOrDefault().ToObject<Product>();
  69. Dimensions.Unit.ID = product.Dimensions.Unit.ID;
  70. Dimensions.Unit.HasQuantity = product.Dimensions.Unit.HasQuantity;
  71. Dimensions.Unit.HasLength = product.Dimensions.Unit.HasLength;
  72. Dimensions.Unit.HasHeight = product.Dimensions.Unit.HasHeight;
  73. Dimensions.Unit.HasWeight = product.Dimensions.Unit.HasWeight;
  74. Dimensions.Unit.HasWidth = product.Dimensions.Unit.HasWidth;
  75. Dimensions.Quantity = product.Dimensions.Quantity;
  76. Dimensions.Length = product.Dimensions.Length;
  77. Dimensions.Height = product.Dimensions.Height;
  78. Dimensions.Weight = product.Dimensions.Weight;
  79. Dimensions.Width = product.Dimensions.Width;
  80. Dimensions.Unit.Format = product.Dimensions.Unit.Format;
  81. Dimensions.Unit.Formula = product.Dimensions.Unit.Formula;
  82. Dimensions.UnitSize = product.Dimensions.UnitSize;
  83. }
  84. LocationName = LocationName + " (Units: " + Units + ")" +
  85. Environment.NewLine + "Style: " + StyleDescription
  86. + Environment.NewLine + "Job: " + JobNumber
  87. + Environment.NewLine + "Size: " + Dimensions.UnitSize;
  88. }
  89. }
  90. }
  91. }