|
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.MorkS.Model;
- using BPASmartClient.MorkS.View;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace BPASmartClient.MorkS.ViewModel
- {
- internal class GoodsMakeViewModel : NotifyBase
- {
- public ObservableCollection<GoodsModel> GoodsModels { get; set; } = new ObservableCollection<GoodsModel>();
- public BPARelayCommand<string> SendOrderCommand { get; set; }
-
- public BPARelayCommand<string> DeleteOrderCommand { get; set; }
- public BPARelayCommand EditCommand { get; set; }
-
- public GoodsMakeViewModel()
- {
- Json<Recipes>.Read();
- GoodsModels = Json<Recipes>.Data.GoodsModels;
- ActionManage.GetInstance.Register(new Action<object>((res) =>
- {
- if (res != null && res is GoodsModel goods)
- {
- var result = GoodsModels.FirstOrDefault(p => p.OrderNum == goods.OrderNum);
- if (result == null)
- {
- GoodsModels.Add(goods);
- Json<Recipes>.Save();
- }
- else
- {
- MessageBox.Show("新增订单失败!","提示", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
- }
- }), "orderEdit");
- SendOrderCommand = new BPARelayCommand<string>((s) =>
- {
- var res = GoodsModels.FirstOrDefault(p => p.OrderNum.Equals(s));
- if (res != null)
- {
- new MorksSimorderModel() { Bowloc = res.BowlLoc, NoodleLoc = res.NoodlesLoc }.Publish();
- }
-
-
- });
- EditCommand = new BPARelayCommand(() =>
- {
-
- GoodsEditView goodsEditView = new GoodsEditView();
- goodsEditView.ShowDialog();
- });
-
- DeleteOrderCommand = new BPARelayCommand<string>((res) =>
- {
- if (!string.IsNullOrEmpty(res))
- {
- var re = GoodsModels.FirstOrDefault(p=>p.OrderNum.Equals(res));
- if (re != null)
- {
- GoodsModels.Remove(re);
- Json<Recipes>.Save();
- }
- else
- {
- MessageBox.Show("未查找到当前订单,删除失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
- }
-
- });
- }
- }
- }
|