|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections.ObjectModel;
- using BPASmart.Model;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmart.RecipeManagement.View;
- using System.Windows.Controls;
- using BPASmart.RecipeManagement.Globle;
- using BPASmartClient.Helper;
-
- namespace BPASmart.RecipeManagement.ViewModel
- {
- public class MaterialManagerViewModel : ObservableObject
- {
- /// <summary>
- /// 原料集合
- /// </summary>
- public ObservableCollection<RecipeMaterials> MaterialList { get; set; } = Json<LocalMaterails>.Data.locaMaterails;
-
- public RelayCommand CreateMaterailCommand { get; set; }
- public RelayCommand<object> EditMaterailCommand { get; set; }
- public RelayCommand<object> DeleteMaterailCommand { get; set; }
-
-
- private void EditMaterail(object o)
- {
- if (o == null) return;
- if (o is int item && item >= 0)
- {
- GlobleData.ChangeMaterail = new RecipeMaterials();
- GlobleData.ChangeMaterail = MaterialList[item];
- MaterialConfigure materialConfigure = new MaterialConfigure();
- materialConfigure.ShowDialog();
- }
- }
-
- private void DeleteMaterail(object o)
- {
- if (o == null) return;
- if (o is int item && item >= 0)
- {
- MaterialList.RemoveAt(item);
- Json<LocalMaterails>.Save();
- }
- }
-
- public MaterialManagerViewModel()
- {
-
-
- CreateMaterailCommand = new RelayCommand(() =>
- {
- GlobleData.ChangeMaterail = null;
- MaterialConfigure materialConfigure = new MaterialConfigure();
- materialConfigure.ShowDialog();
- });
-
- EditMaterailCommand = new RelayCommand<object>(EditMaterail);
-
- DeleteMaterailCommand = new RelayCommand<object>(DeleteMaterail);
- }
- }
- }
|