add - 物料信息
parent
b9413e28fe
commit
628d1dd9de
@ -0,0 +1,322 @@
|
||||
<UserControl x:Class="Sln.Wcs.UI.Page.BasicInfo.StoreInfo.StoreInfoPage"
|
||||
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.StoreInfo"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="1000"
|
||||
Background="#0D0D18">
|
||||
<UserControl.Resources>
|
||||
<!-- 表格样式 -->
|
||||
<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>
|
||||
</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}" Height="34" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="6" Text="仓库名称" Style="{StaticResource FormLabelStyle}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Column="8" x:Name="TxtQueryName" Style="{StaticResource FormTextBoxStyle}" Height="34" VerticalAlignment="Center"/>
|
||||
|
||||
<Button Grid.Column="10" Content="查询" Style="{StaticResource QueryBtnStyle}" Height="34" Click="BtnQuery_Click" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="12" Content="添加仓库" Style="{StaticResource AddBtnStyle}" Click="BtnAdd_Click" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<DataGrid x:Name="StoreDataGrid" Grid.Row="1" Style="{StaticResource DataGridStyle}" LoadingRow="StoreDataGrid_LoadingRow">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="序号" Width="60" Binding="{Binding RowIndex}">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="仓库编号" Binding="{Binding storeCode}" 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 storeName}" Width="*">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="是否标识" Binding="{Binding isFlag}" 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,99 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sln.Wcs.Model.Domain;
|
||||
using Sln.Wcs.Repository.service;
|
||||
using Sln.Wcs.UI.Controls;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.BasicInfo.StoreInfo
|
||||
{
|
||||
public partial class StoreInfoPage : UserControl
|
||||
{
|
||||
private readonly IBaseStoreInfoService? _storeInfoService;
|
||||
|
||||
public StoreInfoPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeInfoService = App.ServiceProvider.GetService<IBaseStoreInfoService>();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
public void LoadData()
|
||||
{
|
||||
if (_storeInfoService != null)
|
||||
{
|
||||
var list = _storeInfoService.Query();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].RowIndex = i + 1;
|
||||
}
|
||||
StoreDataGrid.ItemsSource = list;
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
|
||||
{
|
||||
e.Row.Header = e.Row.GetIndex() + 1;
|
||||
}
|
||||
|
||||
private void BtnQuery_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_storeInfoService == null) return;
|
||||
|
||||
var code = TxtQueryCode.Text?.Trim();
|
||||
var name = TxtQueryName.Text?.Trim();
|
||||
var list = _storeInfoService.Query()
|
||||
.Where(m => string.IsNullOrEmpty(code) || (m.storeCode != null && m.storeCode.Contains(code)))
|
||||
.Where(m => string.IsNullOrEmpty(name) || (m.storeName != null && m.storeName.Contains(name)))
|
||||
.ToList();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].RowIndex = i + 1;
|
||||
}
|
||||
StoreDataGrid.ItemsSource = list;
|
||||
}
|
||||
|
||||
private void BtnAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var window = new Windows.StoreAddWindow(this);
|
||||
window.Owner = Window.GetWindow(this);
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
private void BtnEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (StoreDataGrid.SelectedItem is BaseStoreInfo store)
|
||||
{
|
||||
var window = new Windows.StoreEditWindow(this, store);
|
||||
window.Owner = Window.GetWindow(this);
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnDelete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_storeInfoService == null) return;
|
||||
|
||||
if (StoreDataGrid.SelectedItem is BaseStoreInfo store)
|
||||
{
|
||||
var result = CustomMessageBox.Show($"确认删除仓库: {store.storeName}?", "删除确认", MessageBoxButton.YesNo);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var success = _storeInfoService.Delete(store);
|
||||
if (success)
|
||||
{
|
||||
CustomMessageBox.Show("删除成功", "提示", MessageBoxButton.OK);
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show("删除失败", "错误", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,311 @@
|
||||
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.StoreInfo.Windows.StoreAddWindow"
|
||||
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="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="TxtStoreCode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="仓库名称" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="6" x:Name="TxtStoreName" 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,93 @@
|
||||
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.StoreInfo.Windows
|
||||
{
|
||||
public partial class StoreAddWindow : Window
|
||||
{
|
||||
private readonly IBaseStoreInfoService? _storeInfoService;
|
||||
private readonly StoreInfoPage _parentPage;
|
||||
|
||||
public StoreAddWindow(StoreInfoPage parentPage)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeInfoService = App.ServiceProvider.GetService<IBaseStoreInfoService>();
|
||||
_parentPage = parentPage;
|
||||
}
|
||||
|
||||
private void BtnConfirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_storeInfoService == null) return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TxtStoreCode.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入仓库编号", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TxtStoreName.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入仓库名称", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
|
||||
int? isFlag = null;
|
||||
if (isFlagItem?.Tag != null && int.TryParse(isFlagItem.Tag.ToString(), out int flag))
|
||||
{
|
||||
isFlag = flag;
|
||||
}
|
||||
|
||||
var store = new BaseStoreInfo
|
||||
{
|
||||
storeCode = TxtStoreCode.Text.Trim(),
|
||||
storeName = TxtStoreName.Text.Trim(),
|
||||
isFlag = isFlag,
|
||||
remark = TxtRemark.Text?.Trim(),
|
||||
createdTime = DateTime.Now,
|
||||
createdBy = "Admin"
|
||||
};
|
||||
|
||||
var success = _storeInfoService.Insert(store);
|
||||
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()
|
||||
{
|
||||
TxtStoreCode.Text = "";
|
||||
TxtStoreName.Text = "";
|
||||
TxtRemark.Text = "";
|
||||
CmbIsFlag.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,311 @@
|
||||
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.StoreInfo.Windows.StoreEditWindow"
|
||||
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="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="TxtStoreCode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="仓库名称" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="6" x:Name="TxtStoreName" 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,102 @@
|
||||
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.StoreInfo.Windows
|
||||
{
|
||||
public partial class StoreEditWindow : Window
|
||||
{
|
||||
private readonly IBaseStoreInfoService? _storeInfoService;
|
||||
private readonly StoreInfoPage _parentPage;
|
||||
private readonly BaseStoreInfo _store;
|
||||
|
||||
public StoreEditWindow(StoreInfoPage parentPage, BaseStoreInfo store)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeInfoService = App.ServiceProvider.GetService<IBaseStoreInfoService>();
|
||||
_parentPage = parentPage;
|
||||
_store = store;
|
||||
|
||||
// 初始化表单数据
|
||||
TxtStoreCode.Text = store.storeCode;
|
||||
TxtStoreName.Text = store.storeName;
|
||||
TxtRemark.Text = store.remark;
|
||||
|
||||
// 设置是否标识下拉框
|
||||
if (store.isFlag.HasValue)
|
||||
{
|
||||
foreach (ComboBoxItem item in CmbIsFlag.Items)
|
||||
{
|
||||
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == store.isFlag.Value)
|
||||
{
|
||||
item.IsSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnConfirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_storeInfoService == null) return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TxtStoreCode.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入仓库编号", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TxtStoreName.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入仓库名称", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
|
||||
int? isFlag = null;
|
||||
if (isFlagItem?.Tag != null && int.TryParse(isFlagItem.Tag.ToString(), out int flag))
|
||||
{
|
||||
isFlag = flag;
|
||||
}
|
||||
|
||||
// 更新仓库信息
|
||||
_store.storeCode = TxtStoreCode.Text.Trim();
|
||||
_store.storeName = TxtStoreName.Text.Trim();
|
||||
_store.isFlag = isFlag;
|
||||
_store.remark = TxtRemark.Text?.Trim();
|
||||
_store.updatedTime = DateTime.Now;
|
||||
_store.updatedBy = "Admin";
|
||||
|
||||
var success = _storeInfoService.Update(_store);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue