StockHoldingShell.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System;
  2. using System.Linq;
  3. using Comal.Classes;
  4. using InABox.Mobile;
  5. using Syncfusion.XForms.Core;
  6. using Xamarin.CommunityToolkit.ObjectModel;
  7. using Xamarin.Forms;
  8. namespace PRS.Mobile
  9. {
  10. public class StockHoldingShell : Shell<StockHoldingModel, StockHolding>
  11. {
  12. public StockHoldingShell()
  13. {
  14. Transactions = new ObservableRangeCollection<StockTransaction>();
  15. Transactions.CollectionChanged += (sender, args) =>
  16. {
  17. OnPropertyChanged(nameof(Transactions));
  18. };
  19. }
  20. protected override void ConfigureColumns(ShellColumns<StockHoldingModel, StockHolding> columns)
  21. {
  22. columns
  23. .Map(nameof(ProductID), x => x.Product.ID)
  24. .Map(nameof(ProductCode), x => x.Product.Code)
  25. .Map(nameof(ProductName), x => x.Product.Name)
  26. .Map(nameof(JobID), x => x.Job.ID)
  27. .Map(nameof(JobNumber), x => x.Job.JobNumber)
  28. .Map(nameof(JobName), x => x.Job.Name)
  29. .Map(nameof(LocationID), x => x.Location.ID)
  30. .Map(nameof(LocationCode), x => x.Location.Code)
  31. .Map(nameof(LocationDescription), x => x.Location.Description)
  32. .Map(nameof(LocationAreaID), x => x.Location.Area.ID)
  33. .Map(nameof(LocationAreaCode), x => x.Location.Area.Code)
  34. .Map(nameof(LocationAreaDescription), x => x.Location.Area.Description)
  35. .Map(nameof(StyleID), x => x.Style.ID)
  36. .Map(nameof(StyleCode), x => x.Style.Code)
  37. .Map(nameof(StyleDescription), x => x.Style.Description)
  38. .Map(nameof(DimensionsUnitID), x => x.Dimensions.Unit.ID)
  39. .Map(nameof(DimensionsHasQuantity), x => x.Dimensions.Unit.HasQuantity)
  40. .Map(nameof(DimensionsHasLength), x => x.Dimensions.Unit.HasLength)
  41. .Map(nameof(DimensionsHasHeight), x => x.Dimensions.Unit.HasHeight)
  42. .Map(nameof(DimensionsHasWeight), x => x.Dimensions.Unit.HasWeight)
  43. .Map(nameof(DimensionsHasWidth), x => x.Dimensions.Unit.HasWidth)
  44. .Map(nameof(DimensionsQuantity), x => x.Dimensions.Quantity)
  45. .Map(nameof(DimensionsLength), x => x.Dimensions.Length)
  46. .Map(nameof(DimensionsHeight), x => x.Dimensions.Height)
  47. .Map(nameof(DimensionsWeight), x => x.Dimensions.Weight)
  48. .Map(nameof(DimensionsWidth), x => x.Dimensions.Width)
  49. .Map(nameof(DimensionsUnitFormat), x => x.Dimensions.Unit.Format)
  50. .Map(nameof(DimensionsUnitFormula), x => x.Dimensions.Unit.Formula)
  51. .Map(nameof(DimensionsUnitSize), x => x.Dimensions.UnitSize)
  52. .Map(nameof(DimensionsValue), x => x.Dimensions.Value)
  53. .Map(nameof(ImageID), x => x.Product.Image.ID)
  54. .Map(nameof(Units), x => x.Units)
  55. .Map(nameof(Available), x => x.Available)
  56. .Map(nameof(AverageCost), x=>x.AverageValue)
  57. .Map(nameof(LastStocktake), x=>x.LastStockTake)
  58. ;
  59. }
  60. public Guid ProductID
  61. {
  62. get => Get<Guid>();
  63. set => Set(value);
  64. }
  65. public String ProductCode
  66. {
  67. get => Get<String>();
  68. set => Set(value);
  69. }
  70. public String ProductName
  71. {
  72. get => Get<String>();
  73. set => Set(value);
  74. }
  75. public String ProductDisplay => ProductID == Guid.Empty ? "" : $"{ProductCode}: {ProductName}";
  76. public Guid JobID
  77. {
  78. get => Get<Guid>();
  79. set
  80. {
  81. Set(value);
  82. Parent?.UpdateShells(new StockHoldingShell[] { this });
  83. }
  84. }
  85. public String JobNumber
  86. {
  87. get => Get<String>();
  88. set => Set(value);
  89. }
  90. public String JobName
  91. {
  92. get => Get<String>();
  93. set => Set(value);
  94. }
  95. public String JobDisplay => JobID == Guid.Empty ? "" : $"{JobNumber}: {JobName}";
  96. public Guid LocationID
  97. {
  98. get => Get<Guid>();
  99. set
  100. {
  101. Set(value);
  102. Parent?.UpdateShells(new StockHoldingShell[] { this });
  103. }
  104. }
  105. public String LocationCode
  106. {
  107. get => Get<String>();
  108. set => Set(value);
  109. }
  110. public String LocationDescription
  111. {
  112. get => Get<String>();
  113. set => Set(value);
  114. }
  115. public Guid LocationAreaID
  116. {
  117. get => Get<Guid>();
  118. set => Set(value);
  119. }
  120. public String LocationAreaCode
  121. {
  122. get => Get<String>();
  123. set => Set(value);
  124. }
  125. public String LocationAreaDescription
  126. {
  127. get => Get<String>();
  128. set => Set(value);
  129. }
  130. public Guid StyleID
  131. {
  132. get => Get<Guid>();
  133. set
  134. {
  135. Set(value);
  136. Parent?.UpdateShells(new StockHoldingShell[] { this });
  137. }
  138. }
  139. public String StyleCode
  140. {
  141. get => Get<String>();
  142. set => Set(value);
  143. }
  144. public String StyleDescription
  145. {
  146. get => Get<String>();
  147. set => Set(value);
  148. }
  149. public String StyleDisplay => StyleID == Guid.Empty ? "" : $"{StyleCode}: {StyleDescription}";
  150. public Guid DimensionsUnitID
  151. {
  152. get => Get<Guid>();
  153. set => Set(value);
  154. }
  155. public string DimensionsUnitCode
  156. {
  157. get => Get<String>();
  158. set => Set(value);
  159. }
  160. public string DimensionsUnitDescription
  161. {
  162. get => Get<String>();
  163. set => Set(value);
  164. }
  165. public bool DimensionsHasQuantity
  166. {
  167. get => Get<bool>();
  168. set => Set(value);
  169. }
  170. public double DimensionsQuantity
  171. {
  172. get => Get<double>();
  173. set => Set(value);
  174. }
  175. public bool DimensionsHasLength
  176. {
  177. get => Get<bool>();
  178. set => Set(value);
  179. }
  180. public double DimensionsLength
  181. {
  182. get => Get<double>();
  183. set => Set(value);
  184. }
  185. public bool DimensionsHasWidth
  186. {
  187. get => Get<bool>();
  188. set => Set(value);
  189. }
  190. public double DimensionsWidth
  191. {
  192. get => Get<double>();
  193. set => Set(value);
  194. }
  195. public bool DimensionsHasHeight
  196. {
  197. get => Get<bool>();
  198. set => Set(value);
  199. }
  200. public double DimensionsHeight
  201. {
  202. get => Get<double>();
  203. set => Set(value);
  204. }
  205. public bool DimensionsHasWeight
  206. {
  207. get => Get<bool>();
  208. set => Set(value);
  209. }
  210. public double DimensionsWeight
  211. {
  212. get => Get<double>();
  213. set => Set(value);
  214. }
  215. public double DimensionsValue
  216. {
  217. get => Get<double>();
  218. set => Set(value);
  219. }
  220. public string DimensionsUnitFormula
  221. {
  222. get => Get<string>();
  223. set => Set(value);
  224. }
  225. public string DimensionsUnitFormat
  226. {
  227. get => Get<string>();
  228. set => Set(value);
  229. }
  230. public string DimensionsUnitSize
  231. {
  232. get => Get<string>();
  233. set
  234. {
  235. Set(value);
  236. Parent?.UpdateShells(new StockHoldingShell[] { this });
  237. }
  238. }
  239. public Guid ImageID
  240. {
  241. get => Get<Guid>();
  242. set
  243. {
  244. Set(value);
  245. OnPropertyChanged(nameof(Image));
  246. }
  247. }
  248. public byte[]? Image
  249. {
  250. get
  251. {
  252. if (Parent != null && Parent.Images.TryGetValue(ImageID, out byte[] data))
  253. return data;
  254. return new byte[] { };
  255. }
  256. }
  257. public double Units
  258. {
  259. get => Get<double>();
  260. set => Set(value);
  261. }
  262. public double Available
  263. {
  264. get => Get<double>();
  265. set => Set(value);
  266. }
  267. public double AverageCost
  268. {
  269. get => Get<double>();
  270. set => Set(value);
  271. }
  272. public DateTime LastStocktake
  273. {
  274. get => Get<DateTime>();
  275. }
  276. public ObservableRangeCollection<StockTransaction> Transactions { get; private set; }
  277. public StockTransactionAllocation[] Allocations => Parent.GetAllocations(this);
  278. }
  279. }