|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.FoodStationTest.Model;
- using BPASmartClient.FoodStationTest.Model.Bom;
- using BPA.Helper;
- using BPA.Helper;
-
- using System.Collections.ObjectModel;
- using System.Linq;
-
- namespace BPASmartClient.FoodStationTest.ViewModel
- {
- public class BomOfMaterialViewModel : NotifyBase
- {
- public BomOfMaterialViewModel()
- {
- RawMaterialInfo = Json<DevicePar>.Data.BomMaterial;
- AddMaterial = new BPARelayCommand(() =>
- {
- RawMaterialInfo.Add(new BomMaterial()
- {
- Count = Json<DevicePar>.Data.BomMaterial.Count + 1,
- });
- });
- SaveMaterials = new BPARelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
- {
- Json<DevicePar>.Save();
- MessageNotify.GetInstance.ShowUserLog($"西门子物料清单保存成功");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
- }
- });
- GetBomMaterialData = new BPARelayCommand(() =>
- {
- 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 BPARelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认是否删除所有原料数据!") == true)
- {
- Json<DevicePar>.Data.BomMaterial.Clear();
- MessageNotify.GetInstance.ShowUserLog($"西门子物料清单删除完成");
- }
- });
- RemoveCommand = new BPARelayCommand<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 BPARelayCommand AddMaterial { get; set; }
- public BPARelayCommand SaveMaterials { get; set; }
- public BPARelayCommand<int> RemoveCommand { get; set; }
- public BPARelayCommand GetBomMaterialData { get; set; }
- public BPARelayCommand DeleteAllMaterial { get; set; }
-
- }
- }
|