change- 成品下线改入库方向

dev
liuwf 1 year ago
parent f6377d2904
commit 32c2558875

@ -14,6 +14,6 @@ namespace Admin.Core.IService
/// <summary>
/// 查出BASE_MATERIALINFO中存在的成品类型
/// </summary>
public Task<List<BaseMaterialInfo>> queryAsync(string search);
public Task<List<BaseMaterialInfo>> queryAsyncLike(string search);
}
}

@ -27,9 +27,9 @@ namespace Admin.Core.Service
}
/// <summary>
/// 1.查出BASE_MATERIALINFO中存在的成品类型
/// 1.条件查询使用,查出BASE_MATERIALINFO中存在的成品类型
/// </summary>
public async Task<List<BaseMaterialInfo>> queryAsync(string search)
public async Task<List<BaseMaterialInfo>> queryAsyncLike(string search)
{
List<BaseMaterialInfo> list;
if (!string.IsNullOrEmpty(search))

@ -2,6 +2,7 @@
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
@ -21,12 +22,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public partial class DirectionEditViewModel : ObservableObject
{
public ICommand QueryCommand { get; set; }
public RelayCommand<object> MouseClickCommand { get; set; }
public ICommand SaveCommand { get; set; }
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
public DirectionEditViewModel() {
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
QueryCommand = new RelayCommand(ExecuteQuery);
MouseClickCommand = new RelayCommand<object>(MouseClick);
SaveCommand = new RelayCommand(ExecuteSave);
Init();
}
@ -43,7 +46,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
MaterialDataGrid.Clear();
// 处理查询按钮点击事件
List<BaseMaterialInfo> materialInfoList = await _baseMaterialInfoServices.queryAsync(Search);
List<BaseMaterialInfo> materialInfoList = await _baseMaterialInfoServices.queryAsyncLike(Search);
int count = 0;
Application.Current.Dispatcher.Invoke(() =>
{
@ -53,6 +56,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
});
}
public void MouseClick(object obj)
{
var info = SelectedDataItem as DirectionEditModel;
if (info != null)
{
DirectionItemWindow quantityIssuedWindow = new DirectionItemWindow(info);
quantityIssuedWindow.ShowDialog();
}
}
private async void ExecuteSave()
{
@ -95,6 +109,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
}
private DirectionEditModel selectedDataItem;
public DirectionEditModel SelectedDataItem
{
get { return selectedDataItem; }
set
{
selectedDataItem = value;
OnPropertyChanged();
}
}
#region 初始化datagrid
private ObservableCollection<DirectionEditModel> materialDataGrid = new ObservableCollection<DirectionEditModel>();
public ObservableCollection<DirectionEditModel> MaterialDataGrid

@ -0,0 +1,128 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
namespace Aucma.Core.ProductOffLine.ViewModels
{
public partial class DirectionItemViewModel : ObservableObject
{
public RelayCommand<object> CloseWindowCommand { get; set; }
public RelayCommand SaveCommand { get; set; }
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
public DirectionItemViewModel(DirectionEditModel info) {
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
SaveCommand = new RelayCommand(updateDirection);
PlanInfo = info;
if("A".Equals(info.SpaceCode)){
IsSelectedOptionA = true;
}
else
{
IsSelectedOptionB = true;
}
}
private DirectionEditModel planInfo = new DirectionEditModel();
public DirectionEditModel PlanInfo
{
get { return planInfo; }
set {
planInfo = value;
OnPropertyChanged(nameof(PlanInfo));
}
}
#region 单选框
private bool _isSelectedOptionA;
public bool IsSelectedOptionA
{
get { return _isSelectedOptionA; }
set
{
if (_isSelectedOptionA != value)
{
_isSelectedOptionA = value;
OnPropertyChanged(nameof(IsSelectedOptionA));
// 如果选择了A选项将B选项设为false
if (_isSelectedOptionA)
{
IsSelectedOptionB = false;
}
}
}
}
private bool _isSelectedOptionB;
public bool IsSelectedOptionB
{
get { return _isSelectedOptionB; }
set
{
if (_isSelectedOptionB != value)
{
_isSelectedOptionB = value;
OnPropertyChanged(nameof(IsSelectedOptionB));
// 如果选择了B选项将A选项设为false
if (_isSelectedOptionB)
{
IsSelectedOptionA = false;
}
}
}
}
#endregion 关闭窗口
private void CloseWindow(object parameter)
{
var window = parameter as Window;
if (window != null)
{
window.Close();
}
}
private async void updateDirection()
{
BaseMaterialInfo info = await _baseMaterialInfoServices.FirstAsync(x=>x.ObjId==PlanInfo.ObjId);
if (IsSelectedOptionA)
{
info.InboundDirection = "A";
}
else
{
info.InboundDirection = "B";
}
bool result = await _baseMaterialInfoServices.UpdateAsync(info);
if (result)
{
MessageBox.Show(info.MaterialName+"入库方向修改成功");
}
}
}
}

@ -50,9 +50,9 @@
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="产品编" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="产品编" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="产品型号" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding SpaceCode}" Header="入库方向" Width="*"/>
<DataGridTextColumn Binding="{Binding SpaceCode}" Header="入库方向" Width="*" IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
</Border>

@ -9,15 +9,16 @@ namespace Aucma.Core.ProductOffLine.Views
/// </summary>
public partial class DirectionEditView : Window
{
private DirectionEditViewModel directionEditViewModel = new DirectionEditViewModel();
public DirectionEditView()
{
InitializeComponent();
this.DataContext = new DirectionEditViewModel();
this.DataContext = directionEditViewModel;
}
private void dataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// planInfoEditViewModel.MouseClick(sender);
directionEditViewModel.MouseClick(sender);
}

@ -0,0 +1,94 @@
<Window x:Class="Aucma.Core.ProductOffLine.Views.DirectionItemWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views"
mc:Ignorable="d"
Title="选择方向" Height="500" Width="500" Name="window" Background="White"
ResizeMode="NoResize" Topmost="True">
<Border Margin="5" Background="#1254AB" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="序 号:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0"/>
<TextBox x:Name="No" FontSize="20" Text="{Binding PlanInfo.No}" Foreground="#FFFFFF" Width="50" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品编码:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0"/>
<TextBox x:Name="MaterialCode" FontSize="20" Text="{Binding PlanInfo.MaterialCode}" Foreground="#FFFFFF" Width="260" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品型号:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0"/>
<TextBox x:Name="MaterialName" FontSize="20" Text="{Binding PlanInfo.MaterialName}" Foreground="#FFFFFF" Width="260" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="60,0,0,0" >
<!--样式-->
<StackPanel.Resources>
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<Grid Width="20" Height="20">
<Ellipse x:Name="BulletRadio" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
</Grid>
</BulletDecorator.Bullet>
<ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" RecognizesAccessKey="True"/>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="BulletRadio" Property="Fill" Value="Green"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<TextBlock Text="入库方向: " FontSize="20" Foreground="#FFFFFF" />
<RadioButton Content="A" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" />
<RadioButton Content="B" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Margin="10 0 0 0"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="保 存" FontSize="20" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="0,0,10,0" Height="50" Width="100" />
<Button Content="取 消" FontSize="20" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=window}" Background="#FF9900" Foreground="white" Margin="10,0,0,0" Height="50" BorderBrush="#FF9900" Width="100" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
</Window>

@ -0,0 +1,33 @@
using Admin.Core.Model;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Aucma.Core.ProductOffLine.Views
{
/// <summary>
/// DirectionItemWindow.xaml 的交互逻辑
/// </summary>
public partial class DirectionItemWindow : Window
{
private DirectionItemViewModel viewModel = null;
public DirectionItemWindow(DirectionEditModel info)
{
InitializeComponent();
this.DataContext = new DirectionItemViewModel(info);
}
}
}
Loading…
Cancel
Save