change - 添加物料信息页面
parent
96da10c07b
commit
b9413e28fe
@ -0,0 +1,358 @@
|
|||||||
|
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.MaterialInfo.MaterialAddWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="添加物料"
|
||||||
|
Height="500" Width="520"
|
||||||
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
Background="Transparent"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
ShowInTaskbar="False"
|
||||||
|
WindowStartupLocation="CenterOwner">
|
||||||
|
<Window.Resources>
|
||||||
|
<!-- 标题样式 -->
|
||||||
|
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||||
|
<Setter Property="FontSize" Value="20"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Margin" Value="0,0,0,20"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 标签样式(左侧标题) -->
|
||||||
|
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="MinWidth" Value="70"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 输入框样式 -->
|
||||||
|
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#0D0D18"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="TextBox">
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
|
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsFocused" Value="True">
|
||||||
|
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 下拉框样式 -->
|
||||||
|
<Style x:Key="FormComboBoxStyle" TargetType="ComboBox">
|
||||||
|
<Setter Property="Background" Value="#0D0D18"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBox">
|
||||||
|
<Grid>
|
||||||
|
<Border x:Name="Border" Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="4">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="30"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Grid.Column="0" x:Name="ContentSite"
|
||||||
|
Margin="10,0,30,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
RecognizesAccessKey="True"
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<ToggleButton Grid.ColumnSpan="2" x:Name="ToggleButton" ClickMode="Press" Focusable="False"
|
||||||
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Background="Transparent" BorderThickness="0">
|
||||||
|
<ToggleButton.Template>
|
||||||
|
<ControlTemplate TargetType="ToggleButton">
|
||||||
|
<Border Background="Transparent"/>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ToggleButton.Template>
|
||||||
|
</ToggleButton>
|
||||||
|
<Path Grid.Column="1" x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
Data="M 0 0 L 6 6 L 12 0 Z" Fill="#B0B0B0"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<Popup x:Name="Popup" AllowsTransparency="True" IsOpen="{TemplateBinding IsDropDownOpen}" PopupAnimation="Slide"
|
||||||
|
Placement="Bottom" Focusable="False">
|
||||||
|
<Border x:Name="DropDown" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
Background="#1A1A2E" BorderBrush="#3A3A4A" BorderThickness="1" CornerRadius="4" Margin="0,2,0,0">
|
||||||
|
<ScrollViewer Margin="4">
|
||||||
|
<StackPanel IsItemsHost="True"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsDropDownOpen" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
<Setter TargetName="Arrow" Property="Data" Value="M 0 6 L 6 0 L 12 6 Z"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 下拉项样式 -->
|
||||||
|
<Style TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBoxItem">
|
||||||
|
<Border x:Name="Border" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="2">
|
||||||
|
<ContentPresenter/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="#252540"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 确认按钮样式 -->
|
||||||
|
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2196F3"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="28,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 取消按钮样式 -->
|
||||||
|
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="28,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 关闭按钮样式 -->
|
||||||
|
<Style x:Key="CloseBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="16"/>
|
||||||
|
<Setter Property="Width" Value="30"/>
|
||||||
|
<Setter Property="Height" Value="30"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Border Background="#1A1A2E" CornerRadius="8" Margin="10">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect BlurRadius="20" ShadowDepth="3" Opacity="0.5"/>
|
||||||
|
</Border.Effect>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 标题栏 -->
|
||||||
|
<Grid Grid.Row="0" Background="#252540" Margin="-1,-1,-1,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Text="添加物料" Foreground="#ECF0F1" FontSize="16" FontWeight="SemiBold"
|
||||||
|
VerticalAlignment="Center" Margin="16,12"/>
|
||||||
|
<Button Grid.Column="1" Content="✕" Style="{StaticResource CloseBtnStyle}" Click="BtnClose_Click" Margin="0,0,8,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 表单内容 -->
|
||||||
|
<StackPanel Grid.Row="1" Margin="24,16,24,24" Width="450" HorizontalAlignment="Center">
|
||||||
|
|
||||||
|
<!-- 第一行:物料编号 + 物料名称 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="物料编号" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMaterialCode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="物料名称" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaterialName" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第二行:物料类型 + 物料条码 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="物料类型" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMaterialType" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="物料条码" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaterialBarcode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第三行:最短存放周期 + 最长存放周期 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="最短周期(天)" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMinStorageCycle" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="最长周期(天)" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaxStorageCycle" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第四行:是否标识 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="是否标识" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<ComboBox Grid.Column="2" x:Name="CmbIsFlag" Style="{StaticResource FormComboBoxStyle}">
|
||||||
|
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||||
|
<ComboBoxItem Content="是" Tag="1"/>
|
||||||
|
<ComboBoxItem Content="否" Tag="0"/>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="" Style="{StaticResource LabelStyle}" Visibility="Hidden"/>
|
||||||
|
<TextBox Grid.Column="6" Style="{StaticResource FormTextBoxStyle}" Visibility="Hidden"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第五行:备注 -->
|
||||||
|
<Grid Margin="0,0,0,24">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="备注" Style="{StaticResource LabelStyle}" VerticalAlignment="Top" Margin="0,8,0,0"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtRemark" Style="{StaticResource FormTextBoxStyle}" Height="60" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 按钮区域 -->
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Content="取消" Style="{StaticResource CancelBtnStyle}" Click="BtnCancel_Click" Margin="0,0,12,0"/>
|
||||||
|
<Button Content="确认" Style="{StaticResource ConfirmBtnStyle}" Click="BtnConfirm_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</Window>
|
||||||
@ -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<IBaseMaterialInfoService>();
|
||||||
|
_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,358 @@
|
|||||||
|
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.MaterialInfo.MaterialEditWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="编辑物料"
|
||||||
|
Height="500" Width="520"
|
||||||
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
Background="Transparent"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
ShowInTaskbar="False"
|
||||||
|
WindowStartupLocation="CenterOwner">
|
||||||
|
<Window.Resources>
|
||||||
|
<!-- 标题样式 -->
|
||||||
|
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||||
|
<Setter Property="FontSize" Value="20"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Margin" Value="0,0,0,20"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 标签样式(左侧标题) -->
|
||||||
|
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="MinWidth" Value="70"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 输入框样式 -->
|
||||||
|
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#0D0D18"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="TextBox">
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
|
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsFocused" Value="True">
|
||||||
|
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 下拉框样式 -->
|
||||||
|
<Style x:Key="FormComboBoxStyle" TargetType="ComboBox">
|
||||||
|
<Setter Property="Background" Value="#0D0D18"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBox">
|
||||||
|
<Grid>
|
||||||
|
<Border x:Name="Border" Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="4">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="30"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ContentPresenter Grid.Column="0" x:Name="ContentSite"
|
||||||
|
Margin="10,0,30,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
RecognizesAccessKey="True"
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
<ToggleButton Grid.ColumnSpan="2" x:Name="ToggleButton" ClickMode="Press" Focusable="False"
|
||||||
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Background="Transparent" BorderThickness="0">
|
||||||
|
<ToggleButton.Template>
|
||||||
|
<ControlTemplate TargetType="ToggleButton">
|
||||||
|
<Border Background="Transparent"/>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ToggleButton.Template>
|
||||||
|
</ToggleButton>
|
||||||
|
<Path Grid.Column="1" x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
Data="M 0 0 L 6 6 L 12 0 Z" Fill="#B0B0B0"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<Popup x:Name="Popup" AllowsTransparency="True" IsOpen="{TemplateBinding IsDropDownOpen}" PopupAnimation="Slide"
|
||||||
|
Placement="Bottom" Focusable="False">
|
||||||
|
<Border x:Name="DropDown" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
Background="#1A1A2E" BorderBrush="#3A3A4A" BorderThickness="1" CornerRadius="4" Margin="0,2,0,0">
|
||||||
|
<ScrollViewer Margin="4">
|
||||||
|
<StackPanel IsItemsHost="True"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsDropDownOpen" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
<Setter TargetName="Arrow" Property="Data" Value="M 0 6 L 6 0 L 12 6 Z"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 下拉项样式 -->
|
||||||
|
<Style TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBoxItem">
|
||||||
|
<Border x:Name="Border" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="2">
|
||||||
|
<ContentPresenter/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="#252540"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 确认按钮样式 -->
|
||||||
|
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2196F3"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="28,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 取消按钮样式 -->
|
||||||
|
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="28,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 关闭按钮样式 -->
|
||||||
|
<Style x:Key="CloseBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="16"/>
|
||||||
|
<Setter Property="Width" Value="30"/>
|
||||||
|
<Setter Property="Height" Value="30"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Border Background="#1A1A2E" CornerRadius="8" Margin="10">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect BlurRadius="20" ShadowDepth="3" Opacity="0.5"/>
|
||||||
|
</Border.Effect>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 标题栏 -->
|
||||||
|
<Grid Grid.Row="0" Background="#252540" Margin="-1,-1,-1,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Text="编辑物料" Foreground="#ECF0F1" FontSize="16" FontWeight="SemiBold"
|
||||||
|
VerticalAlignment="Center" Margin="16,12"/>
|
||||||
|
<Button Grid.Column="1" Content="✕" Style="{StaticResource CloseBtnStyle}" Click="BtnClose_Click" Margin="0,0,8,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 表单内容 -->
|
||||||
|
<StackPanel Grid.Row="1" Margin="24,16,24,24" Width="450" HorizontalAlignment="Center">
|
||||||
|
|
||||||
|
<!-- 第一行:物料编号 + 物料名称 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="物料编号" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMaterialCode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="物料名称" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaterialName" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第二行:物料类型 + 物料条码 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="物料类型" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMaterialType" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="物料条码" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaterialBarcode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第三行:最短存放周期 + 最长存放周期 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="最短周期(天)" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtMinStorageCycle" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="最长周期(天)" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<TextBox Grid.Column="6" x:Name="TxtMaxStorageCycle" Style="{StaticResource FormTextBoxStyle}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第四行:是否标识 -->
|
||||||
|
<Grid Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="24"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="是否标识" Style="{StaticResource LabelStyle}"/>
|
||||||
|
<ComboBox Grid.Column="2" x:Name="CmbIsFlag" Style="{StaticResource FormComboBoxStyle}">
|
||||||
|
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||||
|
<ComboBoxItem Content="是" Tag="1"/>
|
||||||
|
<ComboBoxItem Content="否" Tag="0"/>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="" Style="{StaticResource LabelStyle}" Visibility="Hidden"/>
|
||||||
|
<TextBox Grid.Column="6" Style="{StaticResource FormTextBoxStyle}" Visibility="Hidden"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 第五行:备注 -->
|
||||||
|
<Grid Margin="0,0,0,24">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="备注" Style="{StaticResource LabelStyle}" VerticalAlignment="Top" Margin="0,8,0,0"/>
|
||||||
|
<TextBox Grid.Column="2" x:Name="TxtRemark" Style="{StaticResource FormTextBoxStyle}" Height="60" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 按钮区域 -->
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Content="取消" Style="{StaticResource CancelBtnStyle}" Click="BtnCancel_Click" Margin="0,0,12,0"/>
|
||||||
|
<Button Content="确认" Style="{StaticResource ConfirmBtnStyle}" Click="BtnConfirm_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</Window>
|
||||||
@ -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<IBaseMaterialInfoService>();
|
||||||
|
_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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,409 @@
|
|||||||
|
<UserControl x:Class="Sln.Wcs.UI.Page.BasicInfo.MaterialInfo.MaterialInfoPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Sln.Wcs.UI.Page.BasicInfo.MaterialInfo"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="600" d:DesignWidth="1000"
|
||||||
|
Background="#0D0D18">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<!-- 物料状态转换器 -->
|
||||||
|
<local:MaterialFlagConverter x:Key="MaterialFlagConverter"/>
|
||||||
|
|
||||||
|
<!-- 表格样式 -->
|
||||||
|
<Style x:Key="DataGridStyle" TargetType="DataGrid">
|
||||||
|
<Setter Property="Background" Value="#1A1A2E"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="RowBackground" Value="#1A1A2E"/>
|
||||||
|
<Setter Property="AlternatingRowBackground" Value="#16162A"/>
|
||||||
|
<Setter Property="GridLinesVisibility" Value="Horizontal"/>
|
||||||
|
<Setter Property="HorizontalGridLinesBrush" Value="#2A2A35"/>
|
||||||
|
<Setter Property="VerticalGridLinesBrush" Value="#2A2A35"/>
|
||||||
|
<Setter Property="HeadersVisibility" Value="Column"/>
|
||||||
|
<Setter Property="SelectionMode" Value="Single"/>
|
||||||
|
<Setter Property="SelectionUnit" Value="FullRow"/>
|
||||||
|
<Setter Property="CanUserAddRows" Value="False"/>
|
||||||
|
<Setter Property="CanUserDeleteRows" Value="False"/>
|
||||||
|
<Setter Property="AutoGenerateColumns" Value="False"/>
|
||||||
|
<Setter Property="IsReadOnly" Value="True"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#252540"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="Padding" Value="12,10"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0,0,1,1"/>
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="Padding" Value="12,8"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="DataGridCell">
|
||||||
|
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#3D3D5C"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="DataGridRow">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="#2A2A45"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#3D3D5C"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 操作按钮样式 -->
|
||||||
|
<Style x:Key="OperateBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="FontSize" Value="12"/>
|
||||||
|
<Setter Property="Padding" Value="10,5"/>
|
||||||
|
<Setter Property="Margin" Value="0,0,6,0"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="EditBtnStyle" TargetType="Button" BasedOn="{StaticResource OperateBtnStyle}">
|
||||||
|
<Setter Property="Foreground" Value="#64B5F6"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="DeleteBtnStyle" TargetType="Button" BasedOn="{StaticResource OperateBtnStyle}">
|
||||||
|
<Setter Property="Foreground" Value="#EF5350"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 标题样式 -->
|
||||||
|
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||||
|
<Setter Property="FontSize" Value="24"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Margin" Value="0,0,16,16"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 添加按钮样式 -->
|
||||||
|
<Style x:Key="AddBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2196F3"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="16,6"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="+" FontSize="16" FontWeight="Bold" Margin="0,0,6,0" VerticalAlignment="Center"/>
|
||||||
|
<ContentPresenter VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 查询按钮样式 -->
|
||||||
|
<Style x:Key="QueryBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="16,6"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="🔍" FontSize="12" Margin="0,0,6,0" VerticalAlignment="Center"/>
|
||||||
|
<ContentPresenter VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 表单标签样式 -->
|
||||||
|
<Style x:Key="FormLabelStyle" TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 表单输入框样式 -->
|
||||||
|
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#252540"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="10,8"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="TextBox">
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
|
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsFocused" Value="True">
|
||||||
|
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 确认按钮样式 -->
|
||||||
|
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2196F3"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="24,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- 取消按钮样式 -->
|
||||||
|
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#3A3A4A"/>
|
||||||
|
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||||
|
<Setter Property="FontSize" Value="13"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
|
<Setter Property="Padding" Value="24,10"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||||
|
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<Grid Margin="24">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 页面标题栏 -->
|
||||||
|
<Grid Grid.Row="0" Margin="0,0,0,16">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="20"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="120"/>
|
||||||
|
<ColumnDefinition Width="20"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="120"/>
|
||||||
|
<ColumnDefinition Width="16"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="物料信息" Style="{StaticResource TitleStyle}" Margin="0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="2" Text="物料编号" Style="{StaticResource FormLabelStyle}" VerticalAlignment="Center"/>
|
||||||
|
<TextBox Grid.Column="4" x:Name="TxtQueryCode" Style="{StaticResource FormTextBoxStyle}" VerticalAlignment="Center"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="6" Text="物料名称" Style="{StaticResource FormLabelStyle}" VerticalAlignment="Center"/>
|
||||||
|
<TextBox Grid.Column="8" x:Name="TxtQueryName" Style="{StaticResource FormTextBoxStyle}" VerticalAlignment="Center"/>
|
||||||
|
|
||||||
|
<Button Grid.Column="10" Content="查询" Style="{StaticResource QueryBtnStyle}" Click="BtnQuery_Click" VerticalAlignment="Center"/>
|
||||||
|
<Button Grid.Column="12" Content="添加物料" Style="{StaticResource AddBtnStyle}" Click="BtnAdd_Click" VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 数据表格 -->
|
||||||
|
<DataGrid x:Name="MaterialGrid" Grid.Row="1" Style="{StaticResource DataGridStyle}">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="物料编号" Binding="{Binding materialCode}" Width="120">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="物料名称" Binding="{Binding materialName}" Width="*">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="物料类型" Binding="{Binding materialType}" Width="100">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="物料条码" Binding="{Binding materialBarcode}" Width="120">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="最短存放周期(天)" Binding="{Binding minStorageCycle}" Width="120">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="最长存放周期(天)" Binding="{Binding maxStorageCycle}" Width="120">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="是否标识" Binding="{Binding isFlag, Converter={StaticResource MaterialFlagConverter}}" Width="100">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="备注" Binding="{Binding remark}" Width="*">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="更新时间" Binding="{Binding updatedTime, StringFormat='{}{0:yyyy-MM-dd HH:mm}'}" Width="150">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<!-- 操作列 -->
|
||||||
|
<DataGridTemplateColumn Header="操作" Width="140">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<Button Content="编辑" Style="{StaticResource EditBtnStyle}" Click="BtnEdit_Click"/>
|
||||||
|
<Button Content="删除" Style="{StaticResource DeleteBtnStyle}" Click="BtnDelete_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -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<IBaseMaterialInfoService>();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue