diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
index 19d26ded..45b13638 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
@@ -1,4 +1,6 @@
-using System;
+
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@@ -7,24 +9,24 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodBigStation.Model
{
- public class RemoteRecipeData
+ public class RemoteRecipeData : ObservableObject
{
///
/// 配方名称
///
- public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; } }
+ public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;
///
/// 配方ID
///
- public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
+ public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
///
/// 托盘编号
///
- public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; } }
+ public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;
///
diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
index 9a69a2c9..3f95a527 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodBigStation.Model
{
- public class RemoteRecipeRawMaterial
+ public class RemoteRecipeRawMaterial :ObservableObject
{
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}
@@ -14,19 +15,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
///
/// 原料对应的桶号
///
- public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
+ public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value;OnPropertyChanged(); } }
private int _mRawMaterialBarrelNum;
///
/// 需要原料重量
///
- public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } }
+ public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private double _mRawMaterialWeight;
///
/// 原料对应料仓的位置
///
- public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; } }
+ public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
index 1ce7f330..124a23fb 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
Title="RecipeInfosView"
- Width="550"
- Height="450"
+ Width="800"
+ Height="550"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
@@ -52,7 +52,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml.cs
index 5742f815..eb4e17c6 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml.cs
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml.cs
@@ -23,9 +23,24 @@ namespace BPASmartClient.JXJFoodBigStation.View
public RecipeInfosView()
{
InitializeComponent();
-
+ this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseRecipeInfosView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseRecipeInfosView");
}
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void ComboBox_KeyUp(object sender, KeyEventArgs e)
+ {
+
+ }
+
+ private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
+ {
+
+ }
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
index 2713578d..9947abee 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
@@ -13,6 +13,9 @@
mc:Ignorable="d">
+
+
+
@@ -37,6 +40,112 @@
+
+
+
+
+
+
@@ -49,6 +158,16 @@
+
-
-
+
+
+ HorizontalAlignment="Left"
+ VerticalAlignment="Top"
+ Columns="8" />
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
index ad4390da..41f87b64 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
@@ -9,6 +9,8 @@ using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.CustomResource.Pages.Model;
+using BPASmartClient.JXJFoodBigStation.Model.Siemens;
+using System.Windows.Forms;
namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
@@ -33,10 +35,89 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}
}), "RecipeInfo");
- ReturnPage = new RelayCommand(() =>
+ AddRecipe = new RelayCommand(() => {
+ RawMaterialsInfo.Add(new RemoteRecipeRawMaterial());
+ });
+ Comfirm = new RelayCommand(() =>
{
- ActionManage.GetInstance.Send("CloseRecipeInfosView");
+ var bom= Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == RecipeCode);
+ if (bom == null)//新配方
+ {
+ var name= Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
+ if (name == null)
+ {
+ go:
+ long recipeCode = new Random().Next(10000, 99999);
+ var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
+ if (res == null)
+ {
+ Json.Data.Recipes.Add(new RemoteRecipeData { RecipeCode = recipeCode, RawMaterial= RawMaterialsInfo,RecipeName=RecipeName,TrayCode=TrayCode});
+ Json.Save();
+ }
+ else
+ {
+ goto go;
+ }
+ ActionManage.GetInstance.Send("CloseRecipeInfosView");
+ }
+ else
+ {
+
+ MessageBox.Show("配方名称重复,请重命名!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ }
+ else//编辑已有配方
+ {
+
+ bom.RawMaterial.Clear();
+ foreach (var item in RawMaterialsInfo)
+ {
+ bom.RawMaterial.Add(item);
+ }
+ bom.RecipeName = RecipeName;
+ Json.Save();
+ ActionManage.GetInstance.Send("CloseRecipeInfosView");
+ }
+ });
+
+ SaveAs = new RelayCommand(() => {
+
+ var bom = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
+ var rec = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == RecipeCode);
+ if (bom == null && rec != null)//配方名称更改
+ {
+
+ prop: long recipeCode = new Random().Next(10000, 99999);//配方唯一ID,后期根据实际要求更改
+ var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
+ if (res == null)
+ {
+ Json.Data.Recipes.Add(new RemoteRecipeData { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加
+ Json.Save();
+ }
+ else
+ {
+ goto prop;
+ }
+ ActionManage.GetInstance.Send("CloseRecipeInfosView");
+ }
+ else
+ {
+ MessageBox.Show("另存配方失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ ActionManage.GetInstance.Send("CloseNewRecipeView");
});
+
+ RemoveRecipe = new RelayCommand((materilaName) => {
+
+ var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialLocation==materilaName);
+ if (res != null)
+ RawMaterialsInfo.Remove(res);
+ });
+ //ReturnPage = new RelayCommand(() =>
+ //{
+ // ActionManage.GetInstance.Send("CloseRecipeInfosView");
+ //});
}
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
@@ -50,6 +131,14 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public RelayCommand ReturnPage { get; set; }
- public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection();
+ public RelayCommand AddRecipe { get; set; }
+
+ public RelayCommand Comfirm { get; set; }
+
+ public RelayCommand SaveAs { get; set; }
+
+ public RelayCommand RemoveRecipe { get; set; }
+
+ public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection() ;
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
index 74fe86f7..4e1b5789 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
@@ -23,10 +23,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class RecipeReceiveViewModel : ObservableObject
{
- ObservableCollection RawMaterials { get; set; } = new ObservableCollection();
+ public ObservableCollection RawMaterials { get; set; } = new ObservableCollection();
public RecipeReceiveViewModel()
{
- //Json.Read();
+ Json.Read();
Recipes = Json.Data.Recipes;
DetailsCommand = new RelayCommand