终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

59 linhas
2.2 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.Helper;
  5. using FryPot_DosingSystem.Model;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using Microsoft.Toolkit.Mvvm.Input;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace FryPot_DosingSystem.ViewModel
  14. {
  15. internal class NewFryPotMaterialViewModel : ObservableObject
  16. {
  17. public RelayCommand ConfimCommand { get; set; }
  18. private string _materialName;
  19. public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } }
  20. private int _id;
  21. public int Id { get { return _id; } set { _id = value; OnPropertyChanged(); } }
  22. public NewFryPotMaterialViewModel()
  23. {
  24. Json<FlowProcessNames>.Read();
  25. ConfimCommand = new RelayCommand(() =>
  26. {
  27. if (Id > 0 && MaterialName != String.Empty)
  28. {
  29. if (Json<FlowProcessNames>.Data.NameId.ContainsKey(MaterialName))
  30. {
  31. //已存在相同的炒锅工艺物料
  32. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"保存失败,已存在相同工艺项");
  33. }
  34. else
  35. {
  36. if (Json<FlowProcessNames>.Data.NameId.TryAdd(MaterialName, Id))
  37. {
  38. Json<FlowProcessNames>.Save();
  39. MessageNotify.GetInstance.ShowUserLog($"用户新增【{MaterialName}】炒锅工艺项");
  40. ActionManage.GetInstance.Send("CloseNewFryPotMaterial");
  41. }
  42. else
  43. {
  44. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"保存失败,请检查格式是否输入正确");
  45. }
  46. }
  47. }
  48. });
  49. }
  50. }
  51. }