终端一体化运控平台
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

78 рядки
3.5 KiB

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