You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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);
- }
- }
- }
|