终端一体化运控平台
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.

BomOfMaterialViewModel.cs 4.2 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPA.Helper;
  5. using BPASmartClient.JXJFoodSmallStation.Model;
  6. using BPASmartClient.JXJFoodSmallStation.Model.Bom;
  7. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  8. using BPA.Helper;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.ComponentModel;
  13. using System.Linq;
  14. using System.Reflection;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  19. {
  20. public class BomOfMaterialViewModel : NotifyBase
  21. {
  22. public BomOfMaterialViewModel()
  23. {
  24. RawMaterialInfo = Json<DevicePar>.Data.BomMaterial;
  25. AddMaterial = new BPARelayCommand(() =>
  26. {
  27. RawMaterialInfo.Add(new BomMaterial()
  28. {
  29. Count = Json<DevicePar>.Data.BomMaterial.Count +1 ,
  30. });
  31. MessageNotify.GetInstance.ShowUserLog("新增一条物料数据。");
  32. });
  33. SaveMaterials = new BPARelayCommand(() =>
  34. {
  35. if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
  36. {
  37. Json<DevicePar>.Save();
  38. MessageNotify.GetInstance.ShowUserLog($"西门子物料清单保存成功");
  39. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  40. }
  41. });
  42. GetBomMaterialData = new BPARelayCommand(() =>
  43. {
  44. Json<DevicePar>.Data.BomMaterial.Clear();
  45. ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
  46. foreach (var item in GVL_SmallStation.GetInstance.RawMaterialsNameCode)
  47. {
  48. Json<DevicePar>.Data.BomMaterial.Add(new BomMaterial() { Count = Json<DevicePar>.Data.BomMaterial.Count + 1, MaterialCode = item.Key, MaterialName = item.Value });
  49. }
  50. MessageNotify.GetInstance.ShowUserLog("西门子物料数据拉取了本地数据。");
  51. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
  52. });
  53. DeleteAllMaterial = new BPARelayCommand(() =>
  54. {
  55. if (MessageNotify.GetInstance.ShowDialog("请确认,是否删除所有原料数据!") == true)
  56. {
  57. Json<DevicePar>.Data.BomMaterial.Clear();
  58. MessageNotify.GetInstance.ShowUserLog($"手动点击西门子物料清单全部清除。");
  59. }
  60. });
  61. RemoveCommand = new BPARelayCommand<int>((Count) =>
  62. {
  63. if (Count is int cnt)
  64. {
  65. var res = RawMaterialInfo.FirstOrDefault(p => p.Count == cnt);
  66. if (res != null)
  67. {
  68. if (MessageNotify.GetInstance.ShowDialog($"请确认是否删除物料编码:【{res.MaterialCode}】,物料名称:【{res.MaterialName}】的信息?") == true)
  69. {
  70. RawMaterialInfo.Remove(res);
  71. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
  72. MessageNotify.GetInstance.ShowUserLog($"删除一条物料数据,物料编码:【{res.MaterialCode}】,物料名称:{res.MaterialName}。");
  73. }
  74. }
  75. }
  76. });
  77. }
  78. public ObservableCollection<BomMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<BomMaterial>();
  79. public BPARelayCommand AddMaterial { get; set; }
  80. public BPARelayCommand SaveMaterials { get; set; }
  81. public BPARelayCommand<int> RemoveCommand { get; set; }
  82. public BPARelayCommand GetBomMaterialData { get; set; }
  83. public BPARelayCommand DeleteAllMaterial { get; set; }
  84. }
  85. }