|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.MorkCL.Model.DB;
- using BPASmartClient.MorkCL.Model.Json;
- using BPASmartClient.MorkCL.Server;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkCL.ViewModel
- {
- public class ManualSetItemStorageViewModel:NotifyBase
- {
- public ManualSetItemStorageViewModel()
- {
- ActionManage.GetInstance.Register((object o) =>
- {
- if (o is not null && o is int storageIndex)
- {
- if (storageIndex >= 0 && storageIndex <= 11)
- {
- var storage = Json<ItemStorageInfo>.Data.IngredientsStorage[storageIndex];
- if (storage is not null)
- {
- Storage = new();
- StorageIndex = storageIndex;
- Storage.Weight = storage.Weight;
- Storage.Name = storage.Name;
- Storage.IsEmploy = storage.IsEmploy;
- Storage.MaterialID = storage.MaterialID;
- }
- }
-
- }
- }, "SendItemStorageInfo", true);
-
- //获取所有主料。
- Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());
-
- SaveCommand = new(() =>
- {
- if (Storage.Weight is float f)
- {
- if (f > 0)
- {
- if (StorageIndex >= 0 && StorageIndex <= 11)
- {
- var storage = Json<ItemStorageInfo>.Data.IngredientsStorage[StorageIndex];
- storage.Name = Storage.Name;
- storage.Weight = Storage.Weight;
- storage.MaterialID = Ingredients.FirstOrDefault(material => material.Name == Storage.Name).Id;
- storage.IsEmploy = true;
- Json<ItemStorageInfo>.Save();
-
- ActionManage.GetInstance.Send("CloseManualSetStorageView", true);
- }
- else
- {
-
- }
- }
- else
- MessageNotify.GetInstance.ShowDialog("重量不应小于零,请确认后再试。");
- }
- else
- MessageNotify.GetInstance.ShowDialog("重量因为数字,请确认后再试。");
-
-
- });
- }
- private ItemStorage _storage;
- /// <summary>
- /// 仓位信息
- /// </summary>
- public ItemStorage Storage
- {
- get { return _storage; }
- set { _storage = value; OnPropertyChanged(); }
- }
- private int _storageIndex;
- /// <summary>
- /// 仓位索引。
- /// </summary>
- public int StorageIndex
- {
- get { return _storageIndex; }
- set { _storageIndex = value; OnPropertyChanged(); }
- }
-
- private ObservableCollection<IngredientsTB> _Ingredients;
-
- /// <summary>所有的主料数据。作为ComboBox的数据源。</summary>
- public ObservableCollection<IngredientsTB> Ingredients
- {
- get { return _Ingredients; }
- set { _Ingredients = value; OnPropertyChanged(); }
- }
-
- public BPARelayCommand SaveCommand { get; set; }
-
- }
- }
|