diff --git a/Sln.Wcs.UI/MainWindow.xaml.cs b/Sln.Wcs.UI/MainWindow.xaml.cs
index 96bebae..efc3f50 100644
--- a/Sln.Wcs.UI/MainWindow.xaml.cs
+++ b/Sln.Wcs.UI/MainWindow.xaml.cs
@@ -1,6 +1,7 @@
using Sln.Wcs.UI.Attribute;
using Sln.Wcs.UI.Page.BasicInfo;
using Sln.Wcs.UI.Page.BasicInfo.DeviceInfo;
+using Sln.Wcs.UI.Page.BasicInfo.MaterialInfo;
using Sln.Wcs.UI.Page.Home;
using System.Windows;
using System.Windows.Controls.Primitives;
@@ -18,6 +19,7 @@ namespace Sln.Wcs.UI
private HomePage _homePage;
private BasicInfoPage _basicInfoPage;
private DeviceInfoPage _deviceInfoPage;
+ private MaterialInfoPage _materialInfoPage;
public MainWindow()
{
@@ -25,6 +27,7 @@ namespace Sln.Wcs.UI
_homePage = new HomePage();
_basicInfoPage = new BasicInfoPage();
_deviceInfoPage = new DeviceInfoPage();
+ _materialInfoPage = new MaterialInfoPage();
MainContent.Content = _homePage;
BtnBasicInfo.Checked += BtnBasicInfo_Checked;
@@ -88,7 +91,7 @@ namespace Sln.Wcs.UI
private void BtnMaterialInfo_Click(object sender, RoutedEventArgs e)
{
BtnBasicInfo.IsChecked = false;
- MainContent.Content = _basicInfoPage;
+ MainContent.Content = _materialInfoPage;
}
private void BtnWarehouseInfo_Click(object sender, RoutedEventArgs e)
diff --git a/Sln.Wcs.UI/Page/BasicInfo/DeviceInfo/DeviceInfoPage.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/DeviceInfo/DeviceInfoPage.xaml.cs
index a57c227..4bb13e6 100644
--- a/Sln.Wcs.UI/Page/BasicInfo/DeviceInfo/DeviceInfoPage.xaml.cs
+++ b/Sln.Wcs.UI/Page/BasicInfo/DeviceInfo/DeviceInfoPage.xaml.cs
@@ -77,6 +77,7 @@ namespace Sln.Wcs.UI.Page.BasicInfo.DeviceInfo
}
}
+ [ValueConversion(typeof(int), typeof(string))]
public class DeviceTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -96,6 +97,7 @@ namespace Sln.Wcs.UI.Page.BasicInfo.DeviceInfo
}
}
+ [ValueConversion(typeof(int), typeof(string))]
public class DeviceStatusConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml
new file mode 100644
index 0000000..a6f3439
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml
@@ -0,0 +1,358 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml.cs
new file mode 100644
index 0000000..45c95ad
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialAddWindow.xaml.cs
@@ -0,0 +1,95 @@
+using Microsoft.Extensions.DependencyInjection;
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.MaterialInfo
+{
+ public partial class MaterialAddWindow : Window
+ {
+ private readonly IBaseMaterialInfoService? _materialInfoService;
+ private readonly MaterialInfoPage _parentPage;
+
+ public MaterialAddWindow(MaterialInfoPage parentPage)
+ {
+ InitializeComponent();
+ _materialInfoService = App.ServiceProvider.GetService();
+ _parentPage = parentPage;
+ }
+
+ private void BtnConfirm_Click(object sender, RoutedEventArgs e)
+ {
+ if (_materialInfoService == null) return;
+
+ if (string.IsNullOrWhiteSpace(TxtMaterialCode.Text))
+ {
+ CustomMessageBox.Show("请输入物料编号", "提示", MessageBoxButton.OK);
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(TxtMaterialName.Text))
+ {
+ CustomMessageBox.Show("请输入物料名称", "提示", MessageBoxButton.OK);
+ return;
+ }
+
+ var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
+
+ var material = new BaseMaterialInfo
+ {
+ materialCode = TxtMaterialCode.Text.Trim(),
+ materialName = TxtMaterialName.Text.Trim(),
+ materialType = TxtMaterialType.Text?.Trim(),
+ materialBarcode = TxtMaterialBarcode.Text?.Trim(),
+ minStorageCycle = int.TryParse(TxtMinStorageCycle.Text, out int minCycle) ? minCycle : (int?)null,
+ maxStorageCycle = int.TryParse(TxtMaxStorageCycle.Text, out int maxCycle) ? maxCycle : (int?)null,
+ isFlag = isFlagItem?.Tag != null ? int.TryParse(isFlagItem.Tag.ToString(), out int flag) ? flag : (int?)null : null,
+ remark = TxtRemark.Text?.Trim(),
+ createdTime = DateTime.Now
+ };
+
+ var success = _materialInfoService.Insert(material);
+ if (success)
+ {
+ CustomMessageBox.Show("添加成功", "提示", MessageBoxButton.OK);
+ CloseAndRefresh();
+ }
+ else
+ {
+ CustomMessageBox.Show("添加失败", "错误", MessageBoxButton.OK);
+ }
+ }
+
+ private void BtnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ CloseAndRefresh();
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ CloseAndRefresh();
+ }
+
+ private void CloseAndRefresh()
+ {
+ ClearForm();
+ _parentPage.LoadData();
+ Close();
+ }
+
+ private void ClearForm()
+ {
+ TxtMaterialCode.Text = "";
+ TxtMaterialName.Text = "";
+ TxtMaterialType.Text = "";
+ TxtMaterialBarcode.Text = "";
+ TxtMinStorageCycle.Text = "";
+ TxtMaxStorageCycle.Text = "";
+ TxtRemark.Text = "";
+ CmbIsFlag.SelectedIndex = 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml
new file mode 100644
index 0000000..a3a5fde
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml
@@ -0,0 +1,358 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml.cs
new file mode 100644
index 0000000..fc3110d
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialEditWindow.xaml.cs
@@ -0,0 +1,104 @@
+using Microsoft.Extensions.DependencyInjection;
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.MaterialInfo
+{
+ public partial class MaterialEditWindow : Window
+ {
+ private readonly IBaseMaterialInfoService? _materialInfoService;
+ private readonly MaterialInfoPage _parentPage;
+ private readonly BaseMaterialInfo _material;
+
+ public MaterialEditWindow(MaterialInfoPage parentPage, BaseMaterialInfo material)
+ {
+ InitializeComponent();
+ _materialInfoService = App.ServiceProvider.GetService();
+ _parentPage = parentPage;
+ _material = material;
+
+ // 初始化表单数据
+ TxtMaterialCode.Text = material.materialCode;
+ TxtMaterialName.Text = material.materialName;
+ TxtMaterialType.Text = material.materialType;
+ TxtMaterialBarcode.Text = material.materialBarcode;
+ TxtMinStorageCycle.Text = material.minStorageCycle?.ToString();
+ TxtMaxStorageCycle.Text = material.maxStorageCycle?.ToString();
+ TxtRemark.Text = material.remark;
+
+ // 设置是否标识下拉框
+ if (material.isFlag.HasValue)
+ {
+ foreach (ComboBoxItem item in CmbIsFlag.Items)
+ {
+ if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == material.isFlag.Value)
+ {
+ item.IsSelected = true;
+ break;
+ }
+ }
+ }
+ }
+
+ private void BtnConfirm_Click(object sender, RoutedEventArgs e)
+ {
+ if (_materialInfoService == null) return;
+
+ if (string.IsNullOrWhiteSpace(TxtMaterialCode.Text))
+ {
+ CustomMessageBox.Show("请输入物料编号", "提示", MessageBoxButton.OK);
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(TxtMaterialName.Text))
+ {
+ CustomMessageBox.Show("请输入物料名称", "提示", MessageBoxButton.OK);
+ return;
+ }
+
+ var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
+
+ // 更新物料信息
+ _material.materialCode = TxtMaterialCode.Text.Trim();
+ _material.materialName = TxtMaterialName.Text.Trim();
+ _material.materialType = TxtMaterialType.Text?.Trim();
+ _material.materialBarcode = TxtMaterialBarcode.Text?.Trim();
+ _material.minStorageCycle = int.TryParse(TxtMinStorageCycle.Text, out int minCycle) ? minCycle : (int?)null;
+ _material.maxStorageCycle = int.TryParse(TxtMaxStorageCycle.Text, out int maxCycle) ? maxCycle : (int?)null;
+ _material.isFlag = isFlagItem?.Tag != null ? int.TryParse(isFlagItem.Tag.ToString(), out int flag) ? flag : (int?)null : null;
+ _material.remark = TxtRemark.Text?.Trim();
+ _material.updatedTime = DateTime.Now;
+
+ var success = _materialInfoService.Update(_material);
+ if (success)
+ {
+ CustomMessageBox.Show("修改成功", "提示", MessageBoxButton.OK);
+ CloseAndRefresh();
+ }
+ else
+ {
+ CustomMessageBox.Show("修改失败", "错误", MessageBoxButton.OK);
+ }
+ }
+
+ private void BtnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ CloseAndRefresh();
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ CloseAndRefresh();
+ }
+
+ private void CloseAndRefresh()
+ {
+ _parentPage.LoadData();
+ Close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml
new file mode 100644
index 0000000..8704b5f
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml
@@ -0,0 +1,409 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml.cs
new file mode 100644
index 0000000..eff4a45
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/MaterialInfo/MaterialInfoPage.xaml.cs
@@ -0,0 +1,107 @@
+using System.Globalization;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using Microsoft.Extensions.DependencyInjection;
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.MaterialInfo
+{
+ public partial class MaterialInfoPage : UserControl
+ {
+ private readonly IBaseMaterialInfoService? _materialInfoService;
+
+ public MaterialInfoPage()
+ {
+ InitializeComponent();
+ _materialInfoService = App.ServiceProvider.GetService();
+ LoadData();
+ }
+
+ public void LoadData()
+ {
+ if (_materialInfoService != null)
+ {
+ var list = _materialInfoService.Query();
+ MaterialGrid.ItemsSource = list;
+ }
+ }
+
+ private void BtnQuery_Click(object sender, RoutedEventArgs e)
+ {
+ if (_materialInfoService == null) return;
+
+ var code = TxtQueryCode.Text?.Trim();
+ var name = TxtQueryName.Text?.Trim();
+ var list = _materialInfoService.Query()
+ .Where(m => string.IsNullOrEmpty(code) || m.materialCode.Contains(code))
+ .Where(m => string.IsNullOrEmpty(name) || (m.materialName != null && m.materialName.Contains(name)))
+ .ToList();
+ MaterialGrid.ItemsSource = list;
+ }
+
+ private void BtnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ var window = new MaterialAddWindow(this);
+ window.Owner = Window.GetWindow(this);
+ window.ShowDialog();
+ }
+
+ private void BtnEdit_Click(object sender, RoutedEventArgs e)
+ {
+ if (MaterialGrid.SelectedItem is BaseMaterialInfo material)
+ {
+ var window = new MaterialEditWindow(this, material);
+ window.Owner = Window.GetWindow(this);
+ window.ShowDialog();
+ }
+ }
+
+ private void BtnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ if (_materialInfoService == null) return;
+
+ if (MaterialGrid.SelectedItem is BaseMaterialInfo material)
+ {
+ var result = CustomMessageBox.Show($"确认删除物料: {material.materialName}?", "删除确认", MessageBoxButton.YesNo);
+ if (result == MessageBoxResult.Yes)
+ {
+ var success = _materialInfoService.Delete(material);
+ if (success)
+ {
+ CustomMessageBox.Show("删除成功", "提示", MessageBoxButton.OK);
+ LoadData();
+ }
+ else
+ {
+ CustomMessageBox.Show("删除失败", "错误", MessageBoxButton.OK);
+ }
+ }
+ }
+ }
+ }
+
+ [ValueConversion(typeof(int), typeof(string))]
+ public class MaterialFlagConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null) return "否";
+
+ return (int)value switch
+ {
+ 1 => "是",
+ 0 => "否",
+ _ => "否"
+ };
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file