|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.MorkCL.Model.DB;
- using BPASmartClient.MorkCL.Server;
-
- namespace BPASmartClient.MorkCL.ViewModel
- {
- public class AddRawMaterialViewModel : NotifyBase
- {
- private ObservableCollection<AccessoriesTB> accessories;
- private ObservableCollection<IngredientsTB> ingredients;
- private ObservableCollection<SeasoningTB> seasonings;
-
- public AddRawMaterialViewModel()
- {
- //InitialTestData();
-
- RefreshData();
-
- RemoveAccessoryCommand = new BPARelayCommand<string>((Id) =>
- {
- if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
- {
- return;
- }
- var result = SqliteHelper.GetInstance.DelAccessories(Id);
- if (result)
- {
- RefreshData();
- NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除辅料信息成功!");
- }
- });
- RemoveIngreditentCommand = new BPARelayCommand<string>((Id) =>
- {
- if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
- {
- return;
- }
- var result = SqliteHelper.GetInstance.DelIngredients(Id);
- if (result)
- {
- RefreshData();
- NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除主料信息成功!");
- }
- });
- RemoveSeasoningCommand = new BPARelayCommand<string>((Id) =>
- {
- if (!MessageNotify.GetInstance.ShowDialog($"请确认 ,是否删除物料信息【{Id}】?"))
- {
- return;
- }
- var result = SqliteHelper.GetInstance.DelSeasoning(Id);
- if (result)
- {
- RefreshData();
- NoticeDemoViewModel.OpenMsg(CustomResource.UserControls.EnumPromptType.Success, Application.Current.MainWindow, "提示", "删除调料信息成功!");
- }
- });
-
- AddMaterialCommand = new BPARelayCommand<string>((materialType) =>
- {
- EditRawMaterialView editRawMaterialView = new EditRawMaterialView();
- ActionManage.GetInstance.Send("OpenEditRawMaterialView", new MaterialBase());
- ActionManage.GetInstance.Send("ChangeMaterialType", materialType);
- if (editRawMaterialView.ShowDialog() == true)
- {
- RefreshData();
- }
- });
-
- EditCommand = new BPARelayCommand<object>((o) =>
- {
- EditRawMaterialView editRawMaterialView = new EditRawMaterialView();
- ActionManage.GetInstance.Send("OpenEditRawMaterialView", o);
- if (editRawMaterialView.ShowDialog() == true)
- {
- RefreshData();
- }
- });
- }
-
- private void InitialTestData()
- {
- Accessories = new ObservableCollection<AccessoriesTB>();
- for (int i = 0; i < 8; i++)
- {
- Accessories.Add(new AccessoriesTB() { Id = i.ToString(), Name = $"第{i}样", Loc = i });
- }
- Ingredients = new();
- for (int i = 0; i < 12; i++)
- {
- Ingredients.Add(new IngredientsTB() { Id = i.ToString(), Name = $"第{i}样" });
- }
- Seasonings = new();
- for (int i = 0; i < 3; i++)
- {
- Seasonings.Add(new SeasoningTB() { Id = i.ToString(), Name = $"第{i}样", Loc = i });
- }
- }
-
- private void RefreshData()
- {
- Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());
- Accessories = new ObservableCollection<AccessoriesTB>(SqliteHelper.GetInstance.GetAccessories().OrderBy(tb => tb.Loc));
- Seasonings = new ObservableCollection<SeasoningTB>(SqliteHelper.GetInstance.GetSeasoning().OrderBy(tb => tb.Loc));
- }
-
- /// <summary>辅料信息集合</summary>
- public ObservableCollection<AccessoriesTB> Accessories
- { get => accessories; set { accessories = value; OnPropertyChanged(); } }
-
- /// <summary>主料信息集合</summary>
- public ObservableCollection<IngredientsTB> Ingredients
- { get => ingredients; set { ingredients = value; OnPropertyChanged(); } }
-
- /// <summary>调料信息集合</summary>
- public ObservableCollection<SeasoningTB> Seasonings
- { get => seasonings; set { seasonings = value; OnPropertyChanged(); } }
-
- /// <summary>删除辅料信息</summary>
- public BPARelayCommand<string> RemoveAccessoryCommand { get; set; }
-
- /// <summary>删除主料信息</summary>
- public BPARelayCommand<string> RemoveIngreditentCommand { get; set; }
-
- /// <summary>删除调料信息</summary>
- public BPARelayCommand<string> RemoveSeasoningCommand { get; set; }
-
- /// <summary>添加物料信息。</summary>
- public BPARelayCommand<string> AddMaterialCommand { get; set; }
-
- /// <summary>编辑物料信息。</summary>
- public BPARelayCommand<object> EditCommand { get; set; }
- }
- }
|