using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.Helper; using FryPot_DosingSystem.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FryPot_DosingSystem.ViewModel { internal class NewFryPotMaterialViewModel : ObservableObject { public RelayCommand ConfimCommand { get; set; } private string _materialName; public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } private int _id; public int Id { get { return _id; } set { _id = value; OnPropertyChanged(); } } public NewFryPotMaterialViewModel() { Json.Read(); ConfimCommand = new RelayCommand(() => { if (Id > 0 && MaterialName != String.Empty) { if (Json.Data.NameId.ContainsKey(MaterialName)) { //已存在相同的炒锅工艺物料 NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"保存失败,已存在相同工艺项"); } else { if (Json.Data.NameId.TryAdd(MaterialName, Id)) { Json.Save(); MessageNotify.GetInstance.ShowUserLog($"用户新增【{MaterialName}】炒锅工艺项"); ActionManage.GetInstance.Send("CloseNewFryPotMaterial"); } else { NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"保存失败,请检查格式是否输入正确"); } } } }); } } }