|
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPA.Helper;
- using BPASmartClient.JXJFoodBigStation.Model;
- using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
- using BPA.Helper;
-
- 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.JXJFoodBigStation.ViewModel
- {
- public class BomOfMaterialViewModel : NotifyBase
- {
- public BomOfMaterialViewModel()
- {
- RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
- /*if (RawMaterialInfo.Count ==0)
- {
- Json<BomMaterial>.Data.RawMaterials.Clear();
- ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
- foreach (var item in GVL_BigStation.RawMaterialsNameCode)
- {
- Json<BomMaterial>.Data.RawMaterials.Add(new RawMaterial() { RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count + 1, RawMaterialName = item.Key, RawMaterialChineseName = item.Value });
- }
- RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
- }*/
- AddMaterial = new BPARelayCommand(() =>
- {
- RawMaterialInfo.Add(new RawMaterial()
- {
- RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count +1 ,
- });
- MessageNotify.GetInstance.ShowUserLog("新增一条物料数据。");
- });
- SaveMaterials = new BPARelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
- {
- Json<BomMaterial>.Save();
- MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
- }
- });
- RemoveCommand = new BPARelayCommand<int>((Count) =>
- {
- if (Count is int cnt)
- {
- var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt);
- if (res != null)
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true)
- {
- RawMaterialInfo.Remove(res);
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
- MessageNotify.GetInstance.ShowUserLog($"删除一条物料数据,物料为:【{res.RawMaterialName}】:{res.RawMaterialChineseName}。");
- }
- }
- }
- });
- }
- public ObservableCollection<RawMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<RawMaterial>();
- public BPARelayCommand AddMaterial { get; set; }
- public BPARelayCommand SaveMaterials { get; set; }
- public BPARelayCommand<int> RemoveCommand { get; set; }
-
- }
- }
|