using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
    public class AddMaterialViewModel : NotifyBase, IDialogDataContext
    {
        

        public AddMaterialViewModel()
        {

            SaveCommand = new BPARelayCommand(() =>
            {
                RequestClose?.Invoke(MaterialInfo);
            });
            CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); });
        }

        public string Title => "添加物料";

        public event Action<object> RequestClose;

        public void OnDialogOpened(object parameters)
        {
            if (parameters is MaterialTB material)
            {
                MaterialInfo = material;
            }
        }

        public MaterialTB MaterialInfo { get => materialInfo; set { materialInfo = value; OnPropertyChanged(); } }
        private MaterialTB materialInfo = new();
        public BPARelayCommand SaveCommand { get; set; }
        public BPARelayCommand CancelCommand { get; set; }
    }
}
