终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ManualSetItemStorageViewModel.cs 3.6 KiB

преди 1 година
преди 4 месеца
преди 1 година
преди 4 месеца
преди 4 месеца
преди 4 месеца
преди 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.MorkCL.Model.DB;
  3. using BPASmartClient.MorkCL.Model.Json;
  4. using BPASmartClient.MorkCL.Server;
  5. using SqlSugar;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace BPASmartClient.MorkCL.ViewModel
  12. {
  13. public class ManualSetItemStorageViewModel : NotifyBase
  14. {
  15. public ManualSetItemStorageViewModel()
  16. {
  17. ActionManage.GetInstance.Register((object o) =>
  18. {
  19. if (o is not null && o is int storageIndex)
  20. {
  21. if (storageIndex >= 0 && storageIndex <= 11)
  22. {
  23. var storage = Json<ItemStorageInfo>.Data.IngredientsStorage[storageIndex];
  24. if (storage is not null)
  25. {
  26. Storage = new();
  27. StorageIndex = storageIndex;
  28. Storage.Weight = storage.Weight;
  29. Storage.Name = storage.Name;
  30. Storage.IsEmploy = storage.IsEmploy;
  31. Storage.MaterialID = storage.MaterialID;
  32. }
  33. }
  34. }
  35. }, "SendItemStorageInfo", true);
  36. //获取所有主料。
  37. Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());
  38. SaveCommand = new(() =>
  39. {
  40. if (Storage.Weight is float f)
  41. {
  42. if (f > 0)
  43. {
  44. if (StorageIndex >= 0 && StorageIndex <= 11)
  45. {
  46. var storage = Json<ItemStorageInfo>.Data.IngredientsStorage[StorageIndex];
  47. storage.Name = Storage.Name;
  48. storage.Weight = Storage.Weight;
  49. storage.MaterialID = Ingredients.FirstOrDefault(material => material.Name == Storage.Name).Id;
  50. storage.IsEmploy = true;
  51. Json<ItemStorageInfo>.Save();
  52. ActionManage.GetInstance.Send(true, "CloseManualSetStorageView");
  53. }
  54. else
  55. {
  56. }
  57. }
  58. else
  59. MessageNotify.GetInstance.ShowDialog("重量不应小于零,请确认后再试。");
  60. }
  61. else
  62. MessageNotify.GetInstance.ShowDialog("重量因为数字,请确认后再试。");
  63. });
  64. }
  65. private ItemStorage _storage;
  66. /// <summary>
  67. /// 仓位信息
  68. /// </summary>
  69. public ItemStorage Storage
  70. {
  71. get { return _storage; }
  72. set { _storage = value; OnPropertyChanged(); }
  73. }
  74. private int _storageIndex;
  75. /// <summary>
  76. /// 仓位索引。
  77. /// </summary>
  78. public int StorageIndex
  79. {
  80. get { return _storageIndex; }
  81. set { _storageIndex = value; OnPropertyChanged(); }
  82. }
  83. private ObservableCollection<IngredientsTB> _Ingredients;
  84. /// <summary>所有的主料数据。作为ComboBox的数据源。</summary>
  85. public ObservableCollection<IngredientsTB> Ingredients
  86. {
  87. get { return _Ingredients; }
  88. set { _Ingredients = value; OnPropertyChanged(); }
  89. }
  90. public BPARelayCommand SaveCommand { get; set; }
  91. }
  92. }