终端一体化运控平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

135 lignes
5.6 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls.MessageShow;
  3. using BPASmartClient.MorkCL.Model.DB;
  4. using BPASmartClient.MorkCL.Server;
  5. namespace BPASmartClient.MorkCL.ViewModel
  6. {
  7. public class AddRawMaterialViewModel : NotifyBase
  8. {
  9. private ObservableCollection<AccessoriesTB> accessories;
  10. private ObservableCollection<IngredientsTB> ingredients;
  11. private ObservableCollection<SeasoningTB> seasonings;
  12. public AddRawMaterialViewModel()
  13. {
  14. //InitialTestData();
  15. RefreshData();
  16. RemoveAccessoryCommand = new BPARelayCommand<string>((Id) =>
  17. {
  18. if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
  19. {
  20. return;
  21. }
  22. var result = SqliteHelper.GetInstance.DelAccessories(Id);
  23. if (result)
  24. {
  25. RefreshData();
  26. NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除辅料信息成功!");
  27. }
  28. });
  29. RemoveIngreditentCommand = new BPARelayCommand<string>((Id) =>
  30. {
  31. if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
  32. {
  33. return;
  34. }
  35. var result = SqliteHelper.GetInstance.DelIngredients(Id);
  36. if (result)
  37. {
  38. RefreshData();
  39. NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除主料信息成功!");
  40. }
  41. });
  42. RemoveSeasoningCommand = new BPARelayCommand<string>((Id) =>
  43. {
  44. if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
  45. {
  46. return;
  47. }
  48. var result = SqliteHelper.GetInstance.DelSeasoning(Id);
  49. if (result)
  50. {
  51. RefreshData();
  52. NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除调料信息成功!");
  53. }
  54. });
  55. AddMaterialCommand = new BPARelayCommand<string>((materialType) =>
  56. {
  57. EditRawMaterialView editRawMaterialView = new EditRawMaterialView();
  58. ActionManage.GetInstance.Send(new MaterialBase(), "OpenEditRawMaterialView");
  59. ActionManage.GetInstance.Send(materialType, "ChangeMaterialType");
  60. if (editRawMaterialView.ShowDialog() == true)
  61. {
  62. RefreshData();
  63. }
  64. });
  65. EditCommand = new BPARelayCommand<object>((o) =>
  66. {
  67. EditRawMaterialView editRawMaterialView = new EditRawMaterialView();
  68. ActionManage.GetInstance.Send(o, "OpenEditRawMaterialView");
  69. if (editRawMaterialView.ShowDialog() == true)
  70. {
  71. RefreshData();
  72. }
  73. });
  74. }
  75. private void InitialTestData()
  76. {
  77. Accessories = new ObservableCollection<AccessoriesTB>();
  78. for (int i = 0; i < 8; i++)
  79. {
  80. Accessories.Add(new AccessoriesTB() { Id = i.ToString(), Name = $"第{i}样", Loc = i });
  81. }
  82. Ingredients = new();
  83. for (int i = 0; i < 12; i++)
  84. {
  85. Ingredients.Add(new IngredientsTB() { Id = i.ToString(), Name = $"第{i}样" });
  86. }
  87. Seasonings = new();
  88. for (int i = 0; i < 3; i++)
  89. {
  90. Seasonings.Add(new SeasoningTB() { Id = i.ToString(), Name = $"第{i}样", Loc = i });
  91. }
  92. }
  93. private void RefreshData()
  94. {
  95. Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());
  96. Accessories = new ObservableCollection<AccessoriesTB>(SqliteHelper.GetInstance.GetAccessories().OrderBy(tb => tb.Loc));
  97. Seasonings = new ObservableCollection<SeasoningTB>(SqliteHelper.GetInstance.GetSeasoning().OrderBy(tb => tb.Loc));
  98. }
  99. /// <summary>辅料信息集合</summary>
  100. public ObservableCollection<AccessoriesTB> Accessories
  101. { get => accessories; set { accessories = value; OnPropertyChanged(); } }
  102. /// <summary>主料信息集合</summary>
  103. public ObservableCollection<IngredientsTB> Ingredients
  104. { get => ingredients; set { ingredients = value; OnPropertyChanged(); } }
  105. /// <summary>调料信息集合</summary>
  106. public ObservableCollection<SeasoningTB> Seasonings
  107. { get => seasonings; set { seasonings = value; OnPropertyChanged(); } }
  108. /// <summary>删除辅料信息</summary>
  109. public BPARelayCommand<string> RemoveAccessoryCommand { get; set; }
  110. /// <summary>删除主料信息</summary>
  111. public BPARelayCommand<string> RemoveIngreditentCommand { get; set; }
  112. /// <summary>删除调料信息</summary>
  113. public BPARelayCommand<string> RemoveSeasoningCommand { get; set; }
  114. /// <summary>添加物料信息。</summary>
  115. public BPARelayCommand<string> AddMaterialCommand { get; set; }
  116. /// <summary>编辑物料信息。</summary>
  117. public BPARelayCommand<object> EditCommand { get; set; }
  118. }
  119. }