StoreRequiScannerPage.xaml.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. using comal.timesheets.StoreRequis;
  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. using System.Threading;
  9. using System.Threading.Tasks;
  10. using Xamarin.Essentials;
  11. using Xamarin.Forms;
  12. using Xamarin.Forms.Xaml;
  13. using XF.Material.Forms.UI.Dialogs;
  14. using static comal.timesheets.RequiItems;
  15. namespace comal.timesheets
  16. {
  17. [XamlCompilation(XamlCompilationOptions.Compile)]
  18. public partial class StoreRequiScannerPage : ContentPage
  19. {
  20. #region Fields / Constructor
  21. public delegate bool OnScanEvent(object sender, string barcode);
  22. public event OnScanEvent OnScan;
  23. List<StoreRequiItemShell> shells = new List<StoreRequiItemShell>();
  24. List<StoreRequiItemShell> oldShells = new List<StoreRequiItemShell>();
  25. Requisition requisition = new Requisition();
  26. bool loading = false;
  27. Dictionary<StoreRequiItemShell, string> itemRowScannerRawResultPairs = new Dictionary<StoreRequiItemShell, string>();
  28. Dictionary<StoreRequiItemShell, string> itemRowScannerProcessedResultPairs = new Dictionary<StoreRequiItemShell, string>();
  29. bool firstLoad = true;
  30. bool containsNotes = false;
  31. public StoreRequiScannerPage(Guid requiID)
  32. {
  33. InitializeComponent();
  34. ConfigAll(requiID);
  35. }
  36. #endregion
  37. #region Config
  38. void ConfigAll(Guid requiID)
  39. {
  40. NavigationPage.SetHasBackButton(this, false);
  41. SetScannerOptions();
  42. if (requiID != Guid.Empty)
  43. {
  44. requisition.ID = requiID;
  45. LoadExistingRequi();
  46. }
  47. if (!HoldingsLoaded)
  48. {
  49. Timer t = null;
  50. t = new Timer(new TimerCallback((object o) =>
  51. {
  52. if (HoldingsLoaded)
  53. {
  54. Device.BeginInvokeOnMainThread(() =>
  55. {
  56. ConfigDisplay();
  57. });
  58. t.Dispose();
  59. }
  60. }), null, 0, 500);
  61. }
  62. else
  63. {
  64. loadingLbl.IsVisible = false;
  65. addBtn.IsEnabled = true;
  66. Task.Run(() =>
  67. {
  68. Thread.Sleep(1500);
  69. Device.BeginInvokeOnMainThread(() => { ConfigDisplay(); });
  70. });
  71. }
  72. }
  73. void SetScannerOptions()
  74. {
  75. var options = new ZXing.Mobile.MobileBarcodeScanningOptions()
  76. {
  77. PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE },
  78. AutoRotate = false,
  79. TryInverted = true,
  80. TryHarder = true,
  81. };
  82. _scanView.Options = options;
  83. _scanView.IsAnalyzing = true;
  84. _scanView.IsScanning = true;
  85. _scanView.AutoFocus();
  86. _scanView.OnScanResult += ScanView_OnScanResult;
  87. }
  88. protected override void OnAppearing()
  89. {
  90. base.OnAppearing();
  91. if (!firstLoad)
  92. _scanView.IsAnalyzing = true;
  93. }
  94. protected override void OnDisappearing()
  95. {
  96. _scanView.IsAnalyzing = false;
  97. base.OnDisappearing();
  98. }
  99. async void LoadExistingRequi()
  100. {
  101. await Task.Run(() =>
  102. {
  103. requisition = new Client<Requisition>().Query(
  104. new Filter<Requisition>(x => x.ID).IsEqualTo(requisition.ID)
  105. ).Rows.FirstOrDefault().ToObject<Requisition>();
  106. if (!string.IsNullOrWhiteSpace(requisition.Request))
  107. {
  108. StoreRequiItemShell shell1 = new StoreRequiItemShell()
  109. {
  110. IsNotes = true,
  111. IsNotNotes = false,
  112. Summary = requisition.Request,
  113. BorderColor = Color.FromHex("#9f4576")
  114. };
  115. shells.Insert(0, shell1);
  116. containsNotes = true;
  117. }
  118. });
  119. await Task.Run(() =>
  120. {
  121. CoreTable table = new Client<RequisitionItem>().Query
  122. (
  123. new Filter<RequisitionItem>(x => x.RequisitionLink.ID).IsEqualTo(requisition.ID),
  124. new Columns<RequisitionItem>(
  125. x => x.ID,
  126. x => x.Product.ID,
  127. x => x.Product.Name,
  128. x => x.Product.Code,
  129. x => x.Quantity,
  130. x => x.Location.ID,
  131. x => x.Location.Description,
  132. x => x.Picked
  133. )
  134. );
  135. if (table.Rows.Any())
  136. {
  137. Device.BeginInvokeOnMainThread(() => { saveBtn.IsVisible = true; });
  138. foreach (CoreRow row in table.Rows)
  139. {
  140. StoreRequiItemShell shell = new StoreRequiItemShell()
  141. {
  142. ID = row.Get<RequisitionItem, Guid>(x => x.ID),
  143. ProductID = row.Get<RequisitionItem, Guid>(x => x.Product.ID),
  144. ProductName = row.Get<RequisitionItem, string>(x => x.Product.Name),
  145. ProductCode = row.Get<RequisitionItem, string>(x => x.Product.Code),
  146. Quantity = row.Get<RequisitionItem, double>(x => x.Quantity),
  147. LocationID = row.Get<RequisitionItem, Guid>(x => x.Location.ID),
  148. LocationName = row.Get<RequisitionItem, string>(x => x.Location.Description),
  149. Picked = row.Get<RequisitionItem, DateTime>(x => x.Picked),
  150. };
  151. shells.Add(shell);
  152. oldShells.Add(shell);
  153. }
  154. }
  155. Device.BeginInvokeOnMainThread(() =>
  156. {
  157. requiItemListView.ItemsSource = shells;
  158. if (containsNotes)
  159. {
  160. countLbl.Text = "Number of items: " + (shells.Count - 1);
  161. }
  162. else
  163. {
  164. countLbl.Text = "Number of items: " + shells.Count;
  165. }
  166. });
  167. });
  168. }
  169. void ConfigDisplay()
  170. {
  171. loadingLbl.IsVisible = false;
  172. addBtn.IsEnabled = true;
  173. double width = scannerGrid.Width / 6;
  174. double height = scannerGrid.Height / 6;
  175. lblv1.WidthRequest = height / 2;
  176. lblh1.IsVisible = true;
  177. lblv1.IsVisible = true;
  178. lblv2.WidthRequest = height / 2;
  179. lblh2.IsVisible = true;
  180. lblv2.IsVisible = true;
  181. lblv3.WidthRequest = height / 2;
  182. lblh3.IsVisible = true;
  183. lblv3.IsVisible = true;
  184. lblv4.WidthRequest = height / 2;
  185. lblh4.IsVisible = true;
  186. lblv4.IsVisible = true;
  187. scannerGrid.RaiseChild(lblv1);
  188. scannerGrid.RaiseChild(lblh1);
  189. scannerGrid.RaiseChild(lblv2);
  190. scannerGrid.RaiseChild(lblh2);
  191. scannerGrid.RaiseChild(lblv3);
  192. scannerGrid.RaiseChild(lblh3);
  193. scannerGrid.RaiseChild(lblv4);
  194. scannerGrid.RaiseChild(lblh4);
  195. firstLoad = false;
  196. }
  197. #endregion
  198. #region Scanning
  199. private void ScanView_OnScanResult(ZXing.Result result)
  200. {
  201. Device.BeginInvokeOnMainThread(async () =>
  202. {
  203. if (!loading)
  204. {
  205. loading = true;
  206. if (RequiItems.HoldingsLoaded)
  207. {
  208. bool bOK = true;
  209. if (OnScan != null)
  210. bOK = OnScan(this, result.Text);
  211. if (bOK)
  212. {
  213. if (!itemRowScannerRawResultPairs.Values.Contains(result.Text))
  214. {
  215. if (!itemRowScannerProcessedResultPairs.Values.Contains(result.Text))
  216. {
  217. Vibration.Vibrate();
  218. var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
  219. player.Load("requiitemadded.mp3");
  220. player.Play();
  221. using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Adding"))
  222. {
  223. string rawResult = result.Text;
  224. Tuple<string, double> tuple = ProcessResult(result.Text);
  225. LoadProduct(tuple, rawResult);
  226. }
  227. }
  228. else
  229. {
  230. loading = false;
  231. }
  232. }
  233. else
  234. {
  235. loading = false;
  236. }
  237. }
  238. else
  239. {
  240. loading = false;
  241. }
  242. }
  243. else
  244. {
  245. loading = false;
  246. }
  247. }
  248. });
  249. }
  250. private Tuple<string, double> ProcessResult(string result)
  251. {
  252. double qty = 1;
  253. if (result.Contains("*"))
  254. {
  255. try
  256. {
  257. int i = result.IndexOf("*");
  258. string remainder = result.Substring(i);
  259. result = result.Remove(i);
  260. string s1 = remainder.Substring(1);
  261. qty = Convert.ToDouble(s1);
  262. }
  263. catch
  264. {
  265. loading = false;
  266. }
  267. }
  268. Tuple<string, double> tuple = new Tuple<string, double>(result, qty);
  269. return tuple;
  270. }
  271. private void LoadProduct(Tuple<string, double> processedResultQtyTuple, string rawResult)
  272. {
  273. Device.BeginInvokeOnMainThread(async () =>
  274. {
  275. //lookup product in productshells cache
  276. ProductShell product = GlobalVariables.ProductShells.Find(x => x.Code.Equals(processedResultQtyTuple.Item1));
  277. //lookup holding for product in holdings cache
  278. try
  279. {
  280. var list = CreateHoldingsList(product.ID);
  281. if (list.Count == 1) //one stockholding - auto choose holding
  282. AddStoreRequiItemShell(list.First(), product, rawResult, processedResultQtyTuple);
  283. else if (list.Count > 1) //more than one stockholding - user choose shelf
  284. UserSelectFromList(list, product, rawResult, processedResultQtyTuple);
  285. else if (list.Count == 0)
  286. DisplayAlert("No Holdings Found for Product", "", "OK");
  287. loading = false;
  288. }
  289. catch (Exception e)
  290. {
  291. DisplayAlert("Error", e.Message, "OK");
  292. loading = false;
  293. return;
  294. }
  295. });
  296. }
  297. private void UserSelectFromList(List<StoreRequiIHoldingShell> list, ProductShell product, string rawResult, Tuple<string, double> processedResultQtyTuple)
  298. {
  299. Dictionary<string, Guid> holdingLocationIDs = new Dictionary<string, Guid>();
  300. foreach (StoreRequiIHoldingShell holding in list)
  301. {
  302. if (!holdingLocationIDs.ContainsKey(holding.LocationName))
  303. holdingLocationIDs.Add(holding.LocationName, holding.LocationID);
  304. }
  305. List<string> options = holdingLocationIDs.Keys.ToList();
  306. ListSelectionPage page = new ListSelectionPage(options);
  307. page.OnSimpleListTapped += (locationName) =>
  308. {
  309. AddStoreRequiItemShell(list.Find(x => x.LocationName == locationName), product, rawResult, processedResultQtyTuple);
  310. };
  311. Navigation.PushAsync(page);
  312. }
  313. private List<StoreRequiIHoldingShell> CreateHoldingsList(Guid productID)
  314. {
  315. List<StoreRequiIHoldingShell> list = new List<StoreRequiIHoldingShell>();
  316. CoreTable table = DoHoldingsQuery(productID);
  317. foreach (CoreRow row in table.Rows)
  318. {
  319. if (row.Get<StockHolding, double>(x => x.Units) == 0.0)
  320. continue;
  321. list.Add(CreateHoldingShell(row));
  322. }
  323. return list;
  324. }
  325. private CoreTable DoHoldingsQuery(Guid productID)
  326. {
  327. return new Client<StockHolding>().Query(
  328. new Filter<StockHolding>(x => x.Product.ID).IsEqualTo(productID),
  329. new Columns<StockHolding>(
  330. x => x.ID,
  331. x => x.Product.ID,
  332. x => x.Location.ID,
  333. x => x.Location.Description,
  334. x => x.Units,
  335. x => x.Job.ID,
  336. x => x.Job.JobNumber,
  337. x => x.Job.Name,
  338. x => x.Style.ID,
  339. x => x.Style.Code,
  340. x => x.Style.Description,
  341. x => x.Dimensions.Unit.ID,
  342. x => x.Dimensions.Unit.HasQuantity,
  343. x => x.Dimensions.Unit.HasLength,
  344. x => x.Dimensions.Unit.HasHeight,
  345. x => x.Dimensions.Unit.HasWeight,
  346. x => x.Dimensions.Unit.HasWidth,
  347. x => x.Dimensions.Quantity,
  348. x => x.Dimensions.Length,
  349. x => x.Dimensions.Height,
  350. x => x.Dimensions.Weight,
  351. x => x.Dimensions.Width,
  352. x => x.Dimensions.Unit.Format,
  353. x => x.Dimensions.Unit.Formula,
  354. x => x.Dimensions.UnitSize
  355. )
  356. );
  357. }
  358. private StoreRequiIHoldingShell CreateHoldingShell(CoreRow row)
  359. {
  360. StoreRequiIHoldingShell holding = new StoreRequiIHoldingShell()
  361. {
  362. ProductID = row.Get<StockHolding, Guid>(x => x.Product.ID),
  363. LocationID = row.Get<StockHolding, Guid>(x => x.Location.ID),
  364. LocationName = row.Get<StockHolding, string>(x => x.Location.Description),
  365. Units = row.Get<StockHolding, double>(x => x.Units).ToString(),
  366. JobID = row.Get<StockHolding, Guid>(x => x.Job.ID),
  367. JobNumber = row.Get<StockHolding, string>(x => x.Job.JobNumber),
  368. JobName = row.Get<StockHolding, string>(x => x.Job.Name),
  369. StyleID = row.Get<StockHolding, Guid>(x => x.Style.ID),
  370. StyleCode = row.Get<StockHolding, string>(x => x.Style.Code),
  371. StyleDescription = row.Get<StockHolding, string>(x => x.Style.Description)
  372. };
  373. holding.Dimensions.Unit.ID = row.Get<StockHolding, Guid>(x => x.Dimensions.Unit.ID);
  374. holding.Dimensions.Unit.HasQuantity = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasQuantity);
  375. holding.Dimensions.Unit.HasLength = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasLength);
  376. holding.Dimensions.Unit.HasHeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasHeight);
  377. holding.Dimensions.Unit.HasWeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWeight);
  378. holding.Dimensions.Unit.HasWidth = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWidth);
  379. holding.Dimensions.Quantity = row.Get<StockHolding, double>(x => x.Dimensions.Quantity);
  380. holding.Dimensions.Length = row.Get<StockHolding, double>(x => x.Dimensions.Length);
  381. holding.Dimensions.Height = row.Get<StockHolding, double>(x => x.Dimensions.Height);
  382. holding.Dimensions.Weight = row.Get<StockHolding, double>(x => x.Dimensions.Weight);
  383. holding.Dimensions.Width = row.Get<StockHolding, double>(x => x.Dimensions.Width);
  384. holding.Dimensions.Unit.Format = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Format);
  385. holding.Dimensions.Unit.Formula = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Formula);
  386. holding.Dimensions.UnitSize = row.Get<StockHolding, string>(x => x.Dimensions.UnitSize);
  387. holding.LocationName = holding.LocationName + " (Units: " + holding.Units + ")" +
  388. Environment.NewLine + "Style: " + holding.StyleDescription
  389. + Environment.NewLine + "Job: " + holding.JobNumber
  390. + Environment.NewLine + "Size: " + holding.Dimensions.UnitSize;
  391. return holding;
  392. }
  393. private void AddStoreRequiItemShell(StoreRequiIHoldingShell holding, ProductShell product, string rawResult, Tuple<string, double> processedResultQtyTuple)
  394. {
  395. StoreRequiItemShell shell = new StoreRequiItemShell
  396. {
  397. ProductID = product.ID,
  398. ProductName = product.Name,
  399. ProductCode = product.Code,
  400. Quantity = 1,
  401. LocationID = holding.LocationID,
  402. LocationName = holding.LocationName,
  403. StyleID = holding.StyleID,
  404. JobID = holding.StyleID
  405. };
  406. shell.Dimensions.Unit.ID = holding.Dimensions.Unit.ID;
  407. shell.Dimensions.Unit.HasQuantity = holding.Dimensions.Unit.HasQuantity;
  408. shell.Dimensions.Unit.HasLength = holding.Dimensions.Unit.HasLength;
  409. shell.Dimensions.Unit.HasHeight = holding.Dimensions.Unit.HasHeight;
  410. shell.Dimensions.Unit.HasWeight = holding.Dimensions.Unit.HasWeight;
  411. shell.Dimensions.Unit.HasWidth = holding.Dimensions.Unit.HasWidth;
  412. shell.Dimensions.Quantity = holding.Dimensions.Quantity;
  413. shell.Dimensions.Length = holding.Dimensions.Length;
  414. shell.Dimensions.Height = holding.Dimensions.Height;
  415. shell.Dimensions.Weight = holding.Dimensions.Weight;
  416. shell.Dimensions.Width = holding.Dimensions.Width;
  417. shell.Dimensions.Unit.Format = holding.Dimensions.Unit.Format;
  418. shell.Dimensions.Unit.Formula = holding.Dimensions.Unit.Formula;
  419. shell.Dimensions.UnitSize = holding.Dimensions.UnitSize;
  420. shells.Add(shell);
  421. itemRowScannerRawResultPairs.Add(shell, rawResult);
  422. itemRowScannerProcessedResultPairs.Add(shell, processedResultQtyTuple.Item1);
  423. requiItemListView.ItemsSource = null;
  424. requiItemListView.ItemsSource = shells;
  425. countLbl.IsVisible = true;
  426. if (containsNotes)
  427. {
  428. countLbl.Text = "Number of items: " + (shells.Count - 1);
  429. }
  430. else
  431. {
  432. countLbl.Text = "Number of items: " + shells.Count;
  433. }
  434. saveBtn.IsVisible = true;
  435. loading = false;
  436. }
  437. #endregion
  438. #region Button Presses
  439. private async void ExitBtn_Clicked(object sender, EventArgs e)
  440. {
  441. if (shells.Count > 0)
  442. {
  443. if (containsNotes && shells.Count > 1)
  444. {
  445. string chosenOption = await DisplayActionSheet("Leave without saving?", "Cancel", null, "Yes", "No");
  446. switch (chosenOption)
  447. {
  448. case "Cancel":
  449. return;
  450. case "Yes":
  451. Navigation.PopAsync();
  452. break;
  453. case "No":
  454. return;
  455. default:
  456. return;
  457. }
  458. }
  459. else if (containsNotes && shells.Count == 1)
  460. {
  461. Navigation.PopAsync();
  462. }
  463. else
  464. {
  465. string chosenOption = await DisplayActionSheet("Leave without saving?", "Cancel", null, "Yes", "No");
  466. switch (chosenOption)
  467. {
  468. case "Cancel":
  469. return;
  470. case "Yes":
  471. Navigation.PopAsync();
  472. break;
  473. case "No":
  474. return;
  475. default:
  476. return;
  477. }
  478. }
  479. }
  480. else
  481. Navigation.PopAsync();
  482. }
  483. void SaveBtn_Clicked(object sender, EventArgs e)
  484. {
  485. StoreRequiConfirmationPage page = new StoreRequiConfirmationPage(requisition, shells, oldShells);
  486. page.OnSaveSelected += () => { Navigation.PopAsync(); };
  487. Navigation.PushAsync(page);
  488. }
  489. private async void RequiItem_Tapped(object sender, EventArgs e)
  490. {
  491. var shell = requiItemListView.SelectedItem as StoreRequiItemShell;
  492. if (shell == null) return;
  493. await RequiItemTappedAsync(shell);
  494. }
  495. private async Task RequiItemTappedAsync(StoreRequiItemShell shell)
  496. {
  497. string pickstatus = shell.Picked == DateTime.MinValue ? "not picked" : "picked (" + shell.Picked.ToString("dd MMM yy") + ")";
  498. string options = shell.Picked == DateTime.MinValue ? ". Mark as Picked?" : ". Remove Picked status?";
  499. string chosenOption = await DisplayActionSheet("Line is " + pickstatus + options, "Cancel", null, "Yes", "No");
  500. if (chosenOption != "Yes")
  501. return;
  502. shell.Picked = shell.Picked == DateTime.MinValue ? DateTime.Today : DateTime.MinValue;
  503. shell.Colour = shell.Picked == DateTime.MinValue ? Color.Default : Color.FromHex("#8fbc8f");
  504. requiItemListView.ItemsSource = null;
  505. requiItemListView.ItemsSource = shells;
  506. }
  507. void ReduceQtyBtn_Clicked(object sender, EventArgs e)
  508. {
  509. var shell = ((TappedEventArgs)e).Parameter as StoreRequiItemShell;
  510. if (shell == null) return;
  511. if (shell.Quantity <= 1)
  512. {
  513. shells.Remove(shell);
  514. itemRowScannerRawResultPairs.Remove(shell);
  515. itemRowScannerProcessedResultPairs.Remove(shell);
  516. if (containsNotes)
  517. {
  518. countLbl.Text = "Number of items: " + (shells.Count - 1);
  519. if (shells.Count == 1)
  520. {
  521. saveBtn.IsVisible = false;
  522. }
  523. }
  524. else
  525. {
  526. countLbl.Text = "Number of items: " + shells.Count;
  527. if (shells.Count == 0)
  528. {
  529. saveBtn.IsVisible = false;
  530. }
  531. }
  532. }
  533. else
  534. {
  535. shell.Quantity--;
  536. }
  537. requiItemListView.ItemsSource = null;
  538. requiItemListView.ItemsSource = shells;
  539. }
  540. void IncreaseQtyBtn_Clicked(object sender, EventArgs e)
  541. {
  542. var shell = ((TappedEventArgs)e).Parameter as StoreRequiItemShell;
  543. if (shell == null)
  544. return;
  545. shell.Quantity++;
  546. requiItemListView.ItemsSource = null;
  547. requiItemListView.ItemsSource = shells;
  548. }
  549. void AddItem_Clicked(object sender, EventArgs e)
  550. {
  551. if (GlobalVariables.ProductsLoaded)
  552. {
  553. if (loading)
  554. return;
  555. loading = true;
  556. ProductList products = new ProductList(GlobalVariables.ProductShells, true);
  557. products.OnProductSelected += () =>
  558. {
  559. Tuple<string, double> tuple = new Tuple<string, double>(products.SelectedProduct.Code, 1);
  560. LoadProduct(new Tuple<string, double>(products.SelectedProduct.Code, 1), products.SelectedProduct.Code);
  561. };
  562. Navigation.PushAsync(products);
  563. }
  564. }
  565. void Qty_Changed(object sender, EventArgs e)
  566. {
  567. }
  568. #endregion
  569. }
  570. [DoNotPersist]
  571. public class StoreRequiItemShell : Entity
  572. {
  573. public Guid ProductID { get; set; }
  574. public string ProductCode { get; set; }
  575. public string ProductName { get; set; }
  576. public string LocationName { get; set; }
  577. public double Quantity { get; set; }
  578. public Guid LocationID { get; set; }
  579. public Color BorderColor { get; set; }
  580. public bool IsNotes { get; set; }
  581. public bool IsNotNotes { get; set; }
  582. public string Summary { get; set; }
  583. public DateTime Picked { get; set; }
  584. public Color Colour { get; set; }
  585. public Guid JobID { get; set; }
  586. public Guid StyleID { get; set; }
  587. public StockDimensions Dimensions { get; set; }
  588. public StoreRequiItemShell()
  589. {
  590. ProductID = Guid.Empty;
  591. ProductCode = "";
  592. ProductName = "";
  593. LocationName = "";
  594. Quantity = 0;
  595. ID = Guid.Empty;
  596. LocationID = Guid.Empty;
  597. BorderColor = Color.FromHex("#15C7C1");
  598. IsNotes = false;
  599. IsNotNotes = true;
  600. Picked = DateTime.MinValue;
  601. Colour = Color.Default;
  602. JobID = Guid.Empty;
  603. StyleID = Guid.Empty;
  604. Dimensions = new StockDimensions(() => this);
  605. }
  606. }
  607. }