You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.3 KiB
C#
95 lines
3.3 KiB
C#
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<IBaseLocationInfoService>();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|