|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodSmallStation.Model;
- using BPASmartClient.JXJFoodSmallStation.Model.Bom;
- using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodSmallStation.ViewModel
- {
- public class BomOfMaterialViewModel : ObservableObject
- {
- public BomOfMaterialViewModel()
- {
- RawMaterialInfo = Json<DevicePar>.Data.BomMaterial;
- AddMaterial = new RelayCommand(() =>
- {
- RawMaterialInfo.Add(new BomMaterial()
- {
- Count = Json<DevicePar>.Data.BomMaterial.Count +1 ,
- });
- });
- SaveMaterials = new RelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
- {
- Json<DevicePar>.Save();
- MessageNotify.GetInstance.ShowUserLog($"西门子物料清单保存成功");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
- }
- });
- GetBomMaterialData = new RelayCommand(() =>
- {
- Json<DevicePar>.Data.BomMaterial.Clear();
- ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
- foreach (var item in GVL_SmallStation.GetInstance.RawMaterialsNameCode)
- {
- Json<DevicePar>.Data.BomMaterial.Add(new BomMaterial() { Count = Json<DevicePar>.Data.BomMaterial.Count + 1, MaterialCode = item.Key, MaterialName = item.Value });
- }
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
- });
- DeleteAllMaterial = new RelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否删除所有原料数据!") == true)
- {
- Json<DevicePar>.Data.BomMaterial.Clear();
- MessageNotify.GetInstance.ShowUserLog($"西门子物料清单删除完成");
- }
- });
- RemoveCommand = new RelayCommand<int>((Count) =>
- {
- if (Count is int cnt)
- {
- var res = RawMaterialInfo.FirstOrDefault(p => p.Count == cnt);
- if (res != null)
- {
- if (MessageNotify.GetInstance.ShowDialog($"请确认是否删除[{res.MaterialCode}],[{res.MaterialName}]!") == true)
- {
- RawMaterialInfo.Remove(res);
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
- }
- }
- }
- });
- }
- public ObservableCollection<BomMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<BomMaterial>();
- public RelayCommand AddMaterial { get; set; }
- public RelayCommand SaveMaterials { get; set; }
- public RelayCommand<int> RemoveCommand { get; set; }
- public RelayCommand GetBomMaterialData { get; set; }
- public RelayCommand DeleteAllMaterial { get; set; }
-
- }
- }
|