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

68 строки
2.1 KiB

  1. using System;
  2. using Microsoft.Toolkit.Mvvm.ComponentModel;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Collections.ObjectModel;
  8. using BPASmart.Model;
  9. using Microsoft.Toolkit.Mvvm.Input;
  10. using BPASmart.RecipeManagement.View;
  11. using System.Windows.Controls;
  12. using BPASmart.RecipeManagement.Globle;
  13. using BPASmartClient.Helper;
  14. namespace BPASmart.RecipeManagement.ViewModel
  15. {
  16. public class MaterialManagerViewModel : ObservableObject
  17. {
  18. /// <summary>
  19. /// 原料集合
  20. /// </summary>
  21. public ObservableCollection<RecipeMaterials> MaterialList { get; set; } = Json<LocalMaterails>.Data.locaMaterails;
  22. public RelayCommand CreateMaterailCommand { get; set; }
  23. public RelayCommand<object> EditMaterailCommand { get; set; }
  24. public RelayCommand<object> DeleteMaterailCommand { get; set; }
  25. private void EditMaterail(object o)
  26. {
  27. if (o == null) return;
  28. if (o is int item && item >= 0)
  29. {
  30. GlobleData.ChangeMaterail = new RecipeMaterials();
  31. GlobleData.ChangeMaterail = MaterialList[item];
  32. MaterialConfigure materialConfigure = new MaterialConfigure();
  33. materialConfigure.ShowDialog();
  34. }
  35. }
  36. private void DeleteMaterail(object o)
  37. {
  38. if (o == null) return;
  39. if (o is int item && item >= 0)
  40. {
  41. MaterialList.RemoveAt(item);
  42. Json<LocalMaterails>.Save();
  43. }
  44. }
  45. public MaterialManagerViewModel()
  46. {
  47. CreateMaterailCommand = new RelayCommand(() =>
  48. {
  49. GlobleData.ChangeMaterail = null;
  50. MaterialConfigure materialConfigure = new MaterialConfigure();
  51. materialConfigure.ShowDialog();
  52. });
  53. EditMaterailCommand = new RelayCommand<object>(EditMaterail);
  54. DeleteMaterailCommand = new RelayCommand<object>(DeleteMaterail);
  55. }
  56. }
  57. }