diff --git a/SlnMesnac.Model/domain/base_product_info.cs b/SlnMesnac.Model/domain/base_product_info.cs
index c558fcf..34e10e7 100644
--- a/SlnMesnac.Model/domain/base_product_info.cs
+++ b/SlnMesnac.Model/domain/base_product_info.cs
@@ -48,36 +48,39 @@ namespace SlnMesnac.Model.domain
public string productName {get;set;}
///
- /// Desc:产品特点
+ /// Desc:产品图像
/// Default:
/// Nullable:True
///
- [SugarColumn(ColumnName="product_feature")]
- public string productFeature {get;set;}
+ [SugarColumn(ColumnName= "product_image")]
+ public string productImage { get;set;}
///
- /// Desc:产品描述
+ /// Desc:特点图像
/// Default:
/// Nullable:True
///
- [SugarColumn(ColumnName="product_describe")]
- public string productDescribe {get;set;}
+ [SugarColumn(ColumnName= "feature_image")]
+ public string featureImage { get;set;}
+
+ [SugarColumn(ColumnName= "analyze_image")]
+ public string analyzeImage { get;set;}
///
- /// Desc:产品参数
+ /// Desc:产品尺寸图像-左
/// Default:
/// Nullable:True
///
- [SugarColumn(ColumnName="product_param")]
- public string productParam {get;set;}
+ [SugarColumn(ColumnName= "size_left_image")]
+ public string sizeLeftImage { get;set;}
///
- /// Desc:产品尺寸
+ /// Desc:产品尺寸图像-右
/// Default:
/// Nullable:True
///
- [SugarColumn(ColumnName="product_size")]
- public string productSize {get;set;}
+ [SugarColumn(ColumnName= "size_right_image")]
+ public string sizeRightImage { get;set;}
///
/// Desc:创建人
diff --git a/SlnMesnac.WPF/App.xaml.cs b/SlnMesnac.WPF/App.xaml.cs
index d88acd7..052b3db 100644
--- a/SlnMesnac.WPF/App.xaml.cs
+++ b/SlnMesnac.WPF/App.xaml.cs
@@ -11,6 +11,8 @@ using System.Reflection;
using TouchSocket.Sockets;
using SlnMesnac.WPF.Attribute;
using SlnMesnac.WPF.Page.Login;
+using Prism.Events;
+using SlnMesnac.WPF.Event;
namespace SlnMesnac.WPF
{
@@ -108,6 +110,10 @@ namespace SlnMesnac.WPF
.FromAssemblyOf()
.AddClasses(classes => classes.WithAttribute()).AsSelf().WithTransientLifetime());
+ services.AddSingleton();
+
+
+ services.AddSingleton(typeof(ProductInfoEvent));
// 注册ORM
services.AddSqlSugarSetup();
diff --git a/SlnMesnac.WPF/Event/ProductCodeEvent.cs b/SlnMesnac.WPF/Event/ProductCodeEvent.cs
new file mode 100644
index 0000000..3f5c66a
--- /dev/null
+++ b/SlnMesnac.WPF/Event/ProductCodeEvent.cs
@@ -0,0 +1,14 @@
+using Prism.Events;
+using SlnMesnac.Model.domain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.WPF.Event
+{
+ public class ProductCodeEvent : PubSubEvent
+ {
+ }
+}
diff --git a/SlnMesnac.WPF/Event/ProductInfoEvent.cs b/SlnMesnac.WPF/Event/ProductInfoEvent.cs
new file mode 100644
index 0000000..60c245a
--- /dev/null
+++ b/SlnMesnac.WPF/Event/ProductInfoEvent.cs
@@ -0,0 +1,14 @@
+using Prism.Events;
+using SlnMesnac.Model.domain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.WPF.Event
+{
+ public class ProductInfoEvent : PubSubEvent
+ {
+ }
+}
diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml
index d3f9670..5898808 100644
--- a/SlnMesnac.WPF/Page/IndexControl.xaml
+++ b/SlnMesnac.WPF/Page/IndexControl.xaml
@@ -113,13 +113,13 @@
-
+
diff --git a/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml b/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml
index 3e7d2e4..7001602 100644
--- a/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml
+++ b/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml
@@ -25,16 +25,21 @@
-
+
+
+
+
-
+
-
+
-
+
+
+
@@ -42,8 +47,6 @@
-
-
@@ -54,7 +57,6 @@
-
@@ -70,6 +72,10 @@
+
+
+
+
@@ -149,7 +155,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -196,7 +220,7 @@
-
+
@@ -230,6 +254,10 @@
+
+
+
+
@@ -245,6 +273,10 @@
+
+
+
+
diff --git a/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml.cs b/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml.cs
index c3525d9..1012dce 100644
--- a/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml.cs
+++ b/SlnMesnac.WPF/Page/ProductDetails/DetailsEditControl.xaml.cs
@@ -1,4 +1,5 @@
-using SlnMesnac.WPF.Attribute;
+using Microsoft.Win32;
+using SlnMesnac.WPF.Attribute;
using SlnMesnac.WPF.ViewModel.ProductDetails;
using System;
using System.Collections.Generic;
@@ -24,14 +25,63 @@ namespace SlnMesnac.WPF.Page.ProductDetails
[RegisterAsSingletonAttribute]
public partial class DetailsEditControl : UserControl
{
+ private readonly ProductDetailsEditViewModel viewModel;
public DetailsEditControl(ProductDetailsEditViewModel productDetailsEditViewModel)
{
InitializeComponent();
-
- this.DataContext = productDetailsEditViewModel;
+ viewModel = productDetailsEditViewModel;
+ this.DataContext = viewModel;
}
-
+ private void ProductImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg";
+ if (openFileDialog.ShowDialog() == true)
+ {
+ viewModel.ProductImage = openFileDialog.FileName;
+ }
+ }
+
+ private void FeatureImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg";
+ if (openFileDialog.ShowDialog() == true)
+ {
+ viewModel.FeatureImage = openFileDialog.FileName;
+ }
+ }
+
+ private void AnalyzeImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg";
+ if (openFileDialog.ShowDialog() == true)
+ {
+ viewModel.AnalyzeImage = openFileDialog.FileName;
+ }
+ }
+
+ private void SizeLeftImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg";
+ if (openFileDialog.ShowDialog() == true)
+ {
+ viewModel.SizeLeftImage = openFileDialog.FileName;
+ }
+ }
+
+ private void SizeRightImage_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Image files (*.png;*.jpeg;*.jpg)|*.png;*.jpeg;*.jpg";
+ if (openFileDialog.ShowDialog() == true)
+ {
+ viewModel.SizeRightImage = openFileDialog.FileName;
+ }
+ }
}
diff --git a/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml b/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml
index a1848bb..a9d0f3d 100644
--- a/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml
+++ b/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml
@@ -24,18 +24,24 @@
-
+
+
+
-
+
+
+
+
+
+
-
-
+
@@ -44,22 +50,26 @@
-
+
-
+
-
+
+
+
+
+
@@ -82,10 +92,9 @@
-
+
-
+
@@ -102,9 +111,9 @@
-
+
-
+
@@ -121,9 +130,9 @@
-
+
-
+
@@ -140,8 +149,10 @@
-
-
+
+
+
+
@@ -158,33 +169,46 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
@@ -210,6 +234,10 @@
+
+
+
+
@@ -225,6 +253,10 @@
+
+
+
+
@@ -233,3 +265,4 @@
+
diff --git a/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml.cs b/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml.cs
index 9e517dd..e760d49 100644
--- a/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml.cs
+++ b/SlnMesnac.WPF/Page/ProductDetails/ProductDetailsControl.xaml.cs
@@ -1,4 +1,6 @@
-using System;
+using SlnMesnac.WPF.Attribute;
+using SlnMesnac.WPF.ViewModel.ProductDetails;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -18,11 +20,13 @@ namespace SlnMesnac.WPF.Page.ProductDetails
///
/// ProductDetailsControl.xaml 的交互逻辑
///
+ [RegisterAsSingletonAttribute]
public partial class ProductDetailsControl : UserControl
{
- public ProductDetailsControl()
+ public ProductDetailsControl(ProductDetailsViewModel productDetailsViewModel)
{
InitializeComponent();
+ this.DataContext = productDetailsViewModel;
}
}
}
diff --git a/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml b/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml
new file mode 100644
index 0000000..5cb863d
--- /dev/null
+++ b/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml.cs b/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml.cs
new file mode 100644
index 0000000..475df85
--- /dev/null
+++ b/SlnMesnac.WPF/Page/ProductInfo/ProductInfoControl.xaml.cs
@@ -0,0 +1,33 @@
+using SlnMesnac.WPF.Attribute;
+using SlnMesnac.WPF.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SlnMesnac.WPF.Page.ProductInfo
+{
+ ///
+ /// ProductInfoControl.xaml 的交互逻辑
+ ///
+ [RegisterAsSingletonAttribute]
+ public partial class ProductInfoControl : UserControl
+ {
+ public ProductInfoControl(ProductInfoViewModel productInfoViewModel)
+ {
+ InitializeComponent();
+
+ this.DataContext = productInfoViewModel;
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index 592adfb..ad496ca 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -13,6 +13,7 @@
+
@@ -43,6 +44,7 @@
+
@@ -55,6 +57,7 @@
+
diff --git a/SlnMesnac.WPF/Templates/image/Certification.jpg b/SlnMesnac.WPF/Templates/image/Certification.jpg
new file mode 100644
index 0000000..d1efcb4
Binary files /dev/null and b/SlnMesnac.WPF/Templates/image/Certification.jpg differ
diff --git a/SlnMesnac.WPF/ViewModel/Index/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/Index/IndexViewModel.cs
index 0dc7ee6..e5a676c 100644
--- a/SlnMesnac.WPF/ViewModel/Index/IndexViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/Index/IndexViewModel.cs
@@ -1,7 +1,11 @@
using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualBasic;
+using NVelocity.Util.Introspection;
+using Prism.Events;
using SlnMesnac.Serilog;
using SlnMesnac.WPF.Attribute;
+using SlnMesnac.WPF.Event;
using SlnMesnac.WPF.ViewModel.Base;
using System;
using System.Collections.Generic;
@@ -16,9 +20,12 @@ namespace SlnMesnac.WPF.ViewModel.Index
{
public readonly SerilogHelper _logger;
- public IndexViewModel(SerilogHelper logger)
+ private readonly IEventAggregator _eventAggregator;
+
+ public IndexViewModel(SerilogHelper logger, IEventAggregator eventAggregator)
{
_logger = logger;
+ _eventAggregator = eventAggregator;
}
///
@@ -29,6 +36,11 @@ namespace SlnMesnac.WPF.ViewModel.Index
private void LoadProductInfo(string deviceCode)
{
string code = deviceCode as string;
+
+ _eventAggregator.GetEvent().Publish(code);
+
+ var mainWindow = App.ServiceProvider.GetService();
+ mainWindow.ControlOnClick("ProductInfo");
}
}
}
diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
index 09723ba..c17ad5f 100644
--- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
@@ -7,6 +7,7 @@ using SlnMesnac.WPF.Attribute;
using SlnMesnac.WPF.Page;
using SlnMesnac.WPF.Page.Generate;
using SlnMesnac.WPF.Page.ProductDetails;
+using SlnMesnac.WPF.Page.ProductInfo;
using SlnMesnac.WPF.ViewModel.Base;
using System;
using System.Windows;
@@ -20,6 +21,9 @@ namespace SlnMesnac.WPF.ViewModel
private readonly GenerateControl _generateControl;
private readonly IndexControl _indexControl;
private readonly DetailsEditControl _detailsEditControl;
+
+ private readonly ProductInfoControl _productInfoControl;
+ private readonly ProductDetailsControl _productDetailsControl;
#region 参数定义
///
/// PLC设备状态
@@ -57,13 +61,18 @@ namespace SlnMesnac.WPF.ViewModel
#endregion
- public MainWindowViewModel(SerilogHelper logger,GenerateControl generateControl,IndexControl indexControl, DetailsEditControl detailsEditControl)
+ public MainWindowViewModel(SerilogHelper logger,GenerateControl generateControl,IndexControl indexControl, DetailsEditControl detailsEditControl,
+ ProductInfoControl productInfoControl,ProductDetailsControl productDetailsControl)
{
_logger = logger;
_generateControl = generateControl;
_indexControl = indexControl;
_detailsEditControl = detailsEditControl;
+ _productInfoControl = productInfoControl;
+ _productDetailsControl = productDetailsControl;
+
+
this.UserContent = _generateControl;
}
@@ -120,7 +129,7 @@ namespace SlnMesnac.WPF.ViewModel
/// 界面跳转
///
[RelayCommand]
- private void ControlOnClick(object obj)
+ public void ControlOnClick(object obj)
{
try
{
@@ -131,10 +140,16 @@ namespace SlnMesnac.WPF.ViewModel
UserContent = _indexControl;
break;
case "Set":
+ UserContent = _productInfoControl;
+ break;
+ case "EditDetails":
UserContent = _detailsEditControl;
break;
+ case "ProductInfo":
+ UserContent = _productDetailsControl;
+ break;
default:
- UserContent = _indexControl;
+ UserContent = _detailsEditControl;
break;
}
}
diff --git a/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsEditViewModel.cs b/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsEditViewModel.cs
index b236529..ca1acfa 100644
--- a/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsEditViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsEditViewModel.cs
@@ -1,7 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using Prism.Events;
using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service;
using SlnMesnac.WPF.Attribute;
+using SlnMesnac.WPF.Event;
using SlnMesnac.WPF.ViewModel.Base;
using System;
using System.Collections.Generic;
@@ -9,13 +12,24 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using static MaterialDesignThemes.Wpf.Theme.ToolBar;
namespace SlnMesnac.WPF.ViewModel.ProductDetails
{
[RegisterAsSingletonAttribute]
- public partial class ProductDetailsEditViewModel : BaseViewModel
+ public partial class ProductDetailsEditViewModel : ObservableObject
{
+ private readonly Ibase_product_infoServices _product_infoServices;
+
+ private readonly Ibase_product_featureServices _product_featureServices;
+
+ private readonly Ibase_product_describeServices _product_describeServices;
+
+ private readonly Ibase_product_paramServices _product_paramServices;
+
+ private readonly IEventAggregator _eventAggregator;
+
[ObservableProperty]
public ObservableCollection productFeature = new ObservableCollection();
@@ -25,48 +39,177 @@ namespace SlnMesnac.WPF.ViewModel.ProductDetails
[ObservableProperty]
public ObservableCollection productParams = new ObservableCollection();
+ [ObservableProperty]
+ public base_product_info productInfo = new base_product_info();
- public ProductDetailsEditViewModel()
+ [ObservableProperty]
+ public string productImage = string.Empty;
+
+ [ObservableProperty]
+ public string featureImage = string.Empty;
+
+ [ObservableProperty]
+ public string analyzeImage = string.Empty;
+
+ [ObservableProperty]
+ public string sizeLeftImage = string.Empty;
+
+ [ObservableProperty]
+ public string sizeRightImage = string.Empty;
+
+
+ public ProductDetailsEditViewModel(Ibase_product_infoServices product_InfoServices,Ibase_product_featureServices product_featureServices, Ibase_product_describeServices product_describeServices,
+ Ibase_product_paramServices product_paramServices, IEventAggregator eventAggregator)
{
+ _product_infoServices = product_InfoServices;
+ _product_featureServices = product_featureServices;
+ _product_describeServices = product_describeServices;
+ _product_paramServices = product_paramServices;
+
+ _eventAggregator = eventAggregator;
+ _eventAggregator.GetEvent().Subscribe(OnProductSelected);
+
+ }
+
+ private void OnProductSelected(base_product_info product)
+ {
+ ProductInfo = _product_infoServices.Query(x => x.productCode == product.productCode).First(); ;
+
Init();
}
-
private void Init()
{
- for(int i = 0; i < 2; i++)
- {
- ProductFeature.Add(new base_product_feature()
- {
- productFeature = string.Empty
- });
- }
+ ProductFeature.Clear();
+ ProductDescribe.Clear();
+ ProductParams.Clear();
+ var info = ProductInfo;
- for (int i = 0; i < 3; i++)
+ if (info != null)
{
- ProductDescribe.Add(new base_product_describe()
+ ProductImage = info.productImage;
+ FeatureImage = info.featureImage;
+ AnalyzeImage = info.analyzeImage;
+ SizeLeftImage = info.sizeLeftImage;
+ SizeRightImage = info.sizeRightImage;
+
+ var productFeatureInfo = _product_featureServices.Query(x => x.productCode == info.productCode);
+
+ if (productFeatureInfo.Count == 0)
{
- describeTitle = string.Empty,
- describeContent = string.Empty
- });
- }
- for (int i = 0; i < 19; i++)
- {
- ProductParams.Add(new base_product_param()
+ for (int i = 0; i < 2; i++)
+ {
+ ProductFeature.Add(new base_product_feature()
+ {
+ productFeature = string.Empty
+ });
+ }
+ }
+ else
{
- paramContent = string.Empty,
- });
+ ProductFeature = new ObservableCollection(productFeatureInfo);
+ }
+
+ var productDescribeInfo = _product_describeServices.Query(x => x.productCode == info.productCode);
+
+ if (productDescribeInfo.Count == 0)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ ProductDescribe.Add(new base_product_describe()
+ {
+ describeTitle = string.Empty,
+ describeContent = string.Empty
+ });
+ }
+ }
+ else
+ {
+ ProductDescribe = new ObservableCollection(productDescribeInfo);
+ }
+
+ var productParamsInfo = _product_paramServices.Query(x => x.productCode == info.productCode);
+
+ if (productParamsInfo.Count == 0)
+ {
+ for (int i = 0; i < 19; i++)
+ {
+ ProductParams.Add(new base_product_param()
+ {
+ paramContent = string.Empty,
+ });
+ }
+ }
+ else
+ {
+ ProductParams = new ObservableCollection(productParamsInfo);
+ }
}
}
[RelayCommand]
private void SavePrdouctInfo()
{
- var productFeatureInfo = ProductFeature;
+ var info = ProductInfo;
+
+ if(info != null)
+ {
+ info.productImage = productImage;
+ info.featureImage = featureImage;
+ info.analyzeImage = analyzeImage;
+ info.sizeLeftImage = sizeLeftImage;
+ info.sizeRightImage = sizeRightImage;
+ _product_infoServices.Update(info);
+
+ var productFeatureInfo = ProductFeature.ToList();
+ //productFeatureInfo.ToList().ForEach(x => x.productCode = info.productCode);
+
+ foreach(var item in productFeatureInfo)
+ {
+ item.productCode = info.productCode;
+ if (item.objid != 0)
+ {
+ _product_featureServices.Update(item);
+ }
+ else
+ {
+ _product_featureServices.Insert(item);
+ }
+ }
+
+ var productDescribeInfo = ProductDescribe.ToList();
+ //productDescribeInfo.ToList().ForEach(x => x.productCode = info.productCode);
+ foreach (var item in productDescribeInfo)
+ {
+ item.productCode = info.productCode;
+ if (item.objid != 0)
+ {
+ _product_describeServices.Update(item);
+ }
+ else
+ {
+ _product_describeServices.Insert(item);
+ }
+ }
+
+ var productParamsInfo = ProductParams.ToList();
+ //productParamsInfo.ToList().ForEach(x => x.productCode = info.productCode);
+ foreach (var item in productParamsInfo)
+ {
+ item.productCode = info.productCode;
+ if (item.objid != 0)
+ {
+ _product_paramServices.Update(item);
+ }
+ else
+ {
+ _product_paramServices.Insert(item);
+ }
+ }
+ }
+
- var productDescribeInfo = ProductDescribe;
- var productParamsInfo = ProductParams;
}
}
}
diff --git a/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsViewModel.cs b/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsViewModel.cs
new file mode 100644
index 0000000..eca1286
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/ProductDetails/ProductDetailsViewModel.cs
@@ -0,0 +1,122 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using Prism.Events;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service;
+using SlnMesnac.WPF.Attribute;
+using SlnMesnac.WPF.Event;
+using SlnMesnac.WPF.ViewModel.Base;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SlnMesnac.WPF.ViewModel.ProductDetails
+{
+ [RegisterAsSingletonAttribute]
+ public partial class ProductDetailsViewModel : BaseViewModel
+ {
+ private readonly Ibase_product_infoServices _product_infoServices;
+
+ private readonly Ibase_product_featureServices _product_featureServices;
+
+ private readonly Ibase_product_describeServices _product_describeServices;
+
+ private readonly Ibase_product_paramServices _product_paramServices;
+
+ private readonly IEventAggregator _eventAggregator;
+
+
+ [ObservableProperty]
+ public ObservableCollection productFeature = new ObservableCollection();
+
+ [ObservableProperty]
+ public ObservableCollection productDescribe = new ObservableCollection();
+
+ [ObservableProperty]
+ public ObservableCollection productParams = new ObservableCollection();
+
+ [ObservableProperty]
+ public base_product_info productInfo = new base_product_info();
+
+ public ProductDetailsViewModel(Ibase_product_infoServices product_infoServices, Ibase_product_featureServices product_featureServices, Ibase_product_describeServices product_describeServices,
+ Ibase_product_paramServices product_paramServices, IEventAggregator eventAggregator)
+ {
+ _product_featureServices = product_featureServices;
+ _product_describeServices = product_describeServices;
+ _product_paramServices = product_paramServices;
+ _product_infoServices = product_infoServices;
+
+ _eventAggregator = eventAggregator;
+ _eventAggregator.GetEvent().Subscribe(OnProductSelected);
+
+ }
+
+ private void OnProductSelected(string productCode)
+ {
+ Init(productCode);
+ }
+
+ private void Init(string productCode)
+ {
+ ProductFeature.Clear();
+ ProductDescribe.Clear();
+ ProductParams.Clear();
+
+ ProductInfo = _product_infoServices.Query(x => x.productCode == productCode).First();
+
+ var productFeatureInfo = _product_featureServices.Query(x => x.productCode == productCode);
+
+ if (productFeatureInfo.Count == 0)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ ProductFeature.Add(new base_product_feature()
+ {
+ productFeature = string.Empty
+ });
+ }
+ }
+ else
+ {
+ ProductFeature = new ObservableCollection(productFeatureInfo);
+ }
+
+ var productDescribeInfo = _product_describeServices.Query(x => x.productCode == productCode);
+
+ if (productDescribeInfo.Count == 0)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ ProductDescribe.Add(new base_product_describe()
+ {
+ describeTitle = string.Empty,
+ describeContent = string.Empty
+ });
+ }
+ }
+ else
+ {
+ ProductDescribe = new ObservableCollection(productDescribeInfo);
+ }
+
+ var productParamsInfo = _product_paramServices.Query(x => x.productCode == productCode);
+
+ if (productParamsInfo.Count == 0)
+ {
+ for (int i = 0; i < 19; i++)
+ {
+ ProductParams.Add(new base_product_param()
+ {
+ paramContent = string.Empty,
+ });
+ }
+ }
+ else
+ {
+ ProductParams = new ObservableCollection(productParamsInfo);
+ }
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/ViewModel/ProductInfo/ProductInfoViewModel.cs b/SlnMesnac.WPF/ViewModel/ProductInfo/ProductInfoViewModel.cs
new file mode 100644
index 0000000..6f648ff
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/ProductInfo/ProductInfoViewModel.cs
@@ -0,0 +1,79 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service;
+using SlnMesnac.WPF.ViewModel.Base;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using SlnMesnac.Common;
+using SlnMesnac.WPF.Attribute;
+using Prism.Events;
+using SlnMesnac.WPF.Event;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace SlnMesnac.WPF.ViewModel
+{
+ [RegisterAsSingletonAttribute]
+ public partial class ProductInfoViewModel : BaseViewModel
+ {
+
+ private readonly Ibase_product_infoServices _services;
+
+ private readonly IEventAggregator _eventAggregator;
+
+ [ObservableProperty]
+ public string productCodeStr = string.Empty;
+
+ [ObservableProperty]
+ public string productNameStr = string.Empty;
+
+
+ [ObservableProperty]
+ public ObservableCollection productInfoItems = new ObservableCollection();
+
+ public ProductInfoViewModel(Ibase_product_infoServices services, IEventAggregator eventAggregator)
+ {
+ _services = services;
+
+ _eventAggregator = eventAggregator;
+
+ QueryProductInfo();
+ }
+
+ [RelayCommand]
+ private void QueryProductInfo()
+ {
+ Expression> exp = s1 => true;
+
+ if(!string.IsNullOrEmpty(productCodeStr))
+ {
+ exp = exp.And(x => x.productCode == productCodeStr);
+ }
+
+ if (!string.IsNullOrEmpty(productNameStr))
+ {
+ exp = exp.And(x=>x.productName == productNameStr);
+ }
+
+ var infos = _services.Query(exp);
+
+ ProductInfoItems = new ObservableCollection(infos);
+ }
+
+ [RelayCommand]
+ private void EditProductInfo(string productCode)
+ {
+ var info = _services.Query(x=>x.productCode == productCode).First();
+
+ _eventAggregator.GetEvent().Publish(info);
+
+ var mainWindow = App.ServiceProvider.GetService();
+ mainWindow.ControlOnClick("EditDetails");
+ }
+ }
+}