diff --git a/Sln.Wcs.Model/Domain/BaseLocationInfo.cs b/Sln.Wcs.Model/Domain/BaseLocationInfo.cs
index d8d8b22..83194e7 100644
--- a/Sln.Wcs.Model/Domain/BaseLocationInfo.cs
+++ b/Sln.Wcs.Model/Domain/BaseLocationInfo.cs
@@ -1,4 +1,4 @@
-using SqlSugar;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -194,5 +194,11 @@ namespace Sln.Wcs.Model.Domain
///
[SugarColumn(ColumnName = "updated_time")]
public DateTime? updatedTime { get; set; }
+
+ ///
+ /// 序号(用于列表显示,不参与数据库操作)
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int RowIndex { get; set; }
}
}
diff --git a/Sln.Wcs.UI/Controls/CustomMessageBox.xaml.cs b/Sln.Wcs.UI/Controls/CustomMessageBox.xaml.cs
index 7c706b4..6550828 100644
--- a/Sln.Wcs.UI/Controls/CustomMessageBox.xaml.cs
+++ b/Sln.Wcs.UI/Controls/CustomMessageBox.xaml.cs
@@ -24,8 +24,17 @@ namespace Sln.Wcs.UI.Controls
{
window.PanelOneButton.Visibility = Visibility.Visible;
window.PanelTwoButtons.Visibility = Visibility.Collapsed;
- window.TxtIcon.Text = "✓";
- window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4CAF50"));
+
+ if (title.Contains("错误") || title.Contains("失败") || title.Contains("警告"))
+ {
+ window.TxtIcon.Text = "✕";
+ window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#F44336"));
+ }
+ else
+ {
+ window.TxtIcon.Text = "✓";
+ window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4CAF50"));
+ }
}
else if (button == MessageBoxButton.YesNo)
{
diff --git a/Sln.Wcs.UI/MainWindow.xaml.cs b/Sln.Wcs.UI/MainWindow.xaml.cs
index b828713..bfb5df1 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.LocationInfo;
using Sln.Wcs.UI.Page.BasicInfo.MaterialInfo;
using Sln.Wcs.UI.Page.BasicInfo.StoreInfo;
using Sln.Wcs.UI.Page.Home;
@@ -22,6 +23,7 @@ namespace Sln.Wcs.UI
private DeviceInfoPage _deviceInfoPage;
private MaterialInfoPage _materialInfoPage;
private StoreInfoPage _storeInfoPage;
+ private LocationInfoPage _locationInfoPage;
public MainWindow()
{
@@ -31,6 +33,7 @@ namespace Sln.Wcs.UI
_deviceInfoPage = new DeviceInfoPage();
_materialInfoPage = new MaterialInfoPage();
_storeInfoPage = new StoreInfoPage();
+ _locationInfoPage = new LocationInfoPage();
MainContent.Content = _homePage;
BtnBasicInfo.Checked += BtnBasicInfo_Checked;
@@ -106,7 +109,7 @@ namespace Sln.Wcs.UI
private void BtnLocationInfo_Click(object sender, RoutedEventArgs e)
{
BtnBasicInfo.IsChecked = false;
- MainContent.Content = _basicInfoPage;
+ MainContent.Content = _locationInfoPage;
}
private void BtnExit_Click(object sender, RoutedEventArgs e)
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml
new file mode 100644
index 0000000..2bc5cfb
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml
@@ -0,0 +1,393 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml.cs
new file mode 100644
index 0000000..b2d2b74
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationAddWindow.xaml.cs
@@ -0,0 +1,94 @@
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.LocationInfo
+{
+ public partial class LocationAddWindow : Window
+ {
+ private readonly IBaseLocationInfoService _locationService;
+
+ public LocationAddWindow()
+ {
+ InitializeComponent();
+ _locationService = App.ServiceProvider.GetService();
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private void BtnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private void BtnConfirm_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(TxtLocationCode.Text))
+ {
+ CustomMessageBox.Show("请输入库位编号", "提示");
+ TxtLocationCode.Focus();
+ return;
+ }
+
+ try
+ {
+ var location = new BaseLocationInfo
+ {
+ locationCode = TxtLocationCode.Text.Trim(),
+ locationName = TxtLocationName.Text.Trim(),
+ locationArea = TxtLocationArea.Text.Trim(),
+ storeCode = TxtStoreCode.Text.Trim(),
+ locationRows = int.TryParse(TxtLocationRows.Text, out int rows) ? rows : null,
+ locationColumns = int.TryParse(TxtLocationColumns.Text, out int cols) ? cols : null,
+ locationLayers = int.TryParse(TxtLocationLayers.Text, out int layers) ? layers : null,
+ locationStatus = GetSelectedStatus(CmbLocationStatus),
+ agvPosition = TxtAgvPosition.Text.Trim(),
+ deviceCode = TxtDeviceCode.Text.Trim(),
+ materialCode = TxtMaterialCode.Text.Trim(),
+ palletBarcode = TxtPalletBarcode.Text.Trim(),
+ stackCount = TxtStackCount.Text.Trim(),
+ isFlag = GetSelectedIsFlag(CmbIsFlag),
+ remark = TxtRemark.Text.Trim(),
+ createdBy = Environment.UserName,
+ createdTime = DateTime.Now
+ };
+
+ _locationService.Insert(location);
+ CustomMessageBox.Show("添加成功", "提示");
+ DialogResult = true;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ CustomMessageBox.Show($"添加失败: {ex.Message}", "错误");
+ }
+ }
+
+ private int GetSelectedStatus(ComboBox cmb)
+ {
+ if (cmb.SelectedItem is ComboBoxItem item && item.Tag != null)
+ {
+ return int.TryParse(item.Tag.ToString(), out int status) ? status : 0;
+ }
+ return 0;
+ }
+
+ private int GetSelectedIsFlag(ComboBox cmb)
+ {
+ if (cmb.SelectedItem is ComboBoxItem item && item.Tag != null)
+ {
+ return int.TryParse(item.Tag.ToString(), out int flag) ? flag : 0;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml
new file mode 100644
index 0000000..3828195
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml
@@ -0,0 +1,393 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml.cs
new file mode 100644
index 0000000..c132139
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationEditWindow.xaml.cs
@@ -0,0 +1,132 @@
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.LocationInfo
+{
+ public partial class LocationEditWindow : Window
+ {
+ private readonly IBaseLocationInfoService _locationService;
+ private readonly BaseLocationInfo _location;
+
+ public LocationEditWindow(BaseLocationInfo location)
+ {
+ InitializeComponent();
+ _locationService = App.ServiceProvider.GetService();
+ _location = location;
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ TxtLocationCode.Text = _location.locationCode;
+ TxtLocationName.Text = _location.locationName;
+ TxtLocationArea.Text = _location.locationArea;
+ TxtStoreCode.Text = _location.storeCode;
+ TxtLocationRows.Text = _location.locationRows?.ToString() ?? "";
+ TxtLocationColumns.Text = _location.locationColumns?.ToString() ?? "";
+ TxtLocationLayers.Text = _location.locationLayers?.ToString() ?? "";
+ TxtAgvPosition.Text = _location.agvPosition;
+ TxtDeviceCode.Text = _location.deviceCode;
+ TxtMaterialCode.Text = _location.materialCode;
+ TxtPalletBarcode.Text = _location.palletBarcode;
+ TxtStackCount.Text = _location.stackCount;
+ TxtRemark.Text = _location.remark;
+
+ SetSelectedStatus(_location.locationStatus ?? 0);
+ SetSelectedIsFlag(_location.isFlag ?? 0);
+ }
+
+ private void SetSelectedStatus(int status)
+ {
+ foreach (ComboBoxItem item in CmbLocationStatus.Items)
+ {
+ if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == status)
+ {
+ CmbLocationStatus.SelectedItem = item;
+ return;
+ }
+ }
+ CmbLocationStatus.SelectedIndex = 0;
+ }
+
+ private void SetSelectedIsFlag(int isFlag)
+ {
+ foreach (ComboBoxItem item in CmbIsFlag.Items)
+ {
+ if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == isFlag)
+ {
+ CmbIsFlag.SelectedItem = item;
+ return;
+ }
+ }
+ CmbIsFlag.SelectedIndex = 0;
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private void BtnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private void BtnConfirm_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ _location.locationName = TxtLocationName.Text.Trim();
+ _location.locationArea = TxtLocationArea.Text.Trim();
+ _location.storeCode = TxtStoreCode.Text.Trim();
+ _location.locationRows = int.TryParse(TxtLocationRows.Text, out int rows) ? rows : null;
+ _location.locationColumns = int.TryParse(TxtLocationColumns.Text, out int cols) ? cols : null;
+ _location.locationLayers = int.TryParse(TxtLocationLayers.Text, out int layers) ? layers : null;
+ _location.locationStatus = GetSelectedStatus(CmbLocationStatus);
+ _location.agvPosition = TxtAgvPosition.Text.Trim();
+ _location.deviceCode = TxtDeviceCode.Text.Trim();
+ _location.materialCode = TxtMaterialCode.Text.Trim();
+ _location.palletBarcode = TxtPalletBarcode.Text.Trim();
+ _location.stackCount = TxtStackCount.Text.Trim();
+ _location.isFlag = GetSelectedIsFlag(CmbIsFlag);
+ _location.remark = TxtRemark.Text.Trim();
+ _location.updatedBy = Environment.UserName;
+ _location.updatedTime = DateTime.Now;
+
+ _locationService.Update(_location);
+ CustomMessageBox.Show("更新成功", "提示");
+ DialogResult = true;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ CustomMessageBox.Show($"更新失败: {ex.Message}", "错误");
+ }
+ }
+
+ private int GetSelectedStatus(ComboBox cmb)
+ {
+ if (cmb.SelectedItem is ComboBoxItem item && item.Tag != null)
+ {
+ return int.TryParse(item.Tag.ToString(), out int status) ? status : 0;
+ }
+ return 0;
+ }
+
+ private int GetSelectedIsFlag(ComboBox cmb)
+ {
+ if (cmb.SelectedItem is ComboBoxItem item && item.Tag != null)
+ {
+ return int.TryParse(item.Tag.ToString(), out int flag) ? flag : 0;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml
new file mode 100644
index 0000000..7d0d03e
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml
@@ -0,0 +1,472 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml.cs b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml.cs
new file mode 100644
index 0000000..a86c182
--- /dev/null
+++ b/Sln.Wcs.UI/Page/BasicInfo/LocationInfo/LocationInfoPage.xaml.cs
@@ -0,0 +1,188 @@
+using Microsoft.Extensions.DependencyInjection;
+using Sln.Wcs.Model.Domain;
+using Sln.Wcs.Repository.service;
+using Sln.Wcs.UI.Controls;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace Sln.Wcs.UI.Page.BasicInfo.LocationInfo
+{
+ public partial class LocationInfoPage : UserControl
+ {
+ private readonly IBaseLocationInfoService _locationService;
+ private string _searchLocationCode = "";
+ private string _searchLocationName = "";
+ private int? _searchLocationStatus = null;
+
+ public LocationInfoPage()
+ {
+ InitializeComponent();
+ _locationService = App.ServiceProvider.GetService();
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _locationService.Query()
+ .Where(x => string.IsNullOrEmpty(_searchLocationCode) || (x.locationCode != null && x.locationCode.Contains(_searchLocationCode)))
+ .Where(x => string.IsNullOrEmpty(_searchLocationName) || (x.locationName != null && x.locationName.Contains(_searchLocationName)))
+ .Where(x => !_searchLocationStatus.HasValue || x.locationStatus == _searchLocationStatus)
+ .OrderByDescending(x => x.updatedTime)
+ .ToList();
+
+ for (int i = 0; i < list.Count; i++)
+ {
+ list[i].RowIndex = i + 1;
+ }
+
+ dataGrid.ItemsSource = list;
+ }
+ catch (Exception ex)
+ {
+ CustomMessageBox.Show($"加载数据失败: {ex.Message}", "错误");
+ }
+ }
+
+ private void BtnSearch_Click(object sender, RoutedEventArgs e)
+ {
+ _searchLocationCode = txtLocationCode.Text.Trim();
+ _searchLocationName = txtLocationName.Text.Trim();
+ _searchLocationStatus = GetSelectedStatus();
+
+ LoadData();
+ }
+
+ private int? GetSelectedStatus()
+ {
+ if (cmbLocationStatus.SelectedItem is ComboBoxItem item && item.Tag != null)
+ {
+ if (int.TryParse(item.Tag.ToString(), out int status))
+ {
+ return status;
+ }
+ }
+ return null;
+ }
+
+ private void BtnReset_Click(object sender, RoutedEventArgs e)
+ {
+ txtLocationCode.Text = "";
+ txtLocationName.Text = "";
+ cmbLocationStatus.SelectedIndex = 0;
+
+ _searchLocationCode = "";
+ _searchLocationName = "";
+ _searchLocationStatus = null;
+
+ LoadData();
+ }
+
+ private void BtnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ var window = new LocationAddWindow
+ {
+ Owner = Window.GetWindow(this)
+ };
+
+ if (window.ShowDialog() == true)
+ {
+ LoadData();
+ }
+ }
+
+ private void BtnEdit_Click(object sender, RoutedEventArgs e)
+ {
+ if (dataGrid.SelectedItem is BaseLocationInfo location)
+ {
+ var window = new LocationEditWindow(location)
+ {
+ Owner = Window.GetWindow(this)
+ };
+
+ if (window.ShowDialog() == true)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void BtnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ if (dataGrid.SelectedItem is BaseLocationInfo location)
+ {
+ var result = CustomMessageBox.Show(
+ $"确定要删除库位 \"{location.locationCode}\" 吗?",
+ "确认删除",
+ MessageBoxButton.YesNo
+ );
+
+ if (result == MessageBoxResult.Yes)
+ {
+ try
+ {
+ _locationService.Delete(location);
+ CustomMessageBox.Show("删除成功", "提示");
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ CustomMessageBox.Show($"删除失败: {ex.Message}", "错误");
+ }
+ }
+ }
+ }
+
+ private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ BtnEdit_Click(sender, e);
+ }
+ }
+
+ public class LocationStatusConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is int status)
+ {
+ return status switch
+ {
+ 0 => "未使用",
+ 1 => "已使用",
+ 2 => "锁库",
+ 3 => "异常",
+ _ => "未知"
+ };
+ }
+ return "未知";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class IsFlagConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is int isFlag)
+ {
+ return isFlag == 1 ? "是" : "否";
+ }
+ return "否";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}