add-添加修改前提交

master
liuwf 1 year ago
parent 2c293f8ba1
commit 76b7abe823

@ -86,7 +86,7 @@ namespace Khd.Core.Wcs
SecondFloorAGV secondFloorAGV = new(_host, 2);
secondFloorAGV.StartPoint();
//二楼线体
// //二楼线体
SecondFloorLine secondFloorLine = new(_host, 2);
secondFloorLine.StartPoint();

@ -935,6 +935,9 @@ namespace Khd.Core.Wcs.Wcs
if (wcsTask == null)
{
WcsTaskManual? wcsTaskManual = dbContext.WcsTaskManual.Where(t => t.taskType == 999).FirstOrDefault();//调接口生成的任务
if (wcsTaskManual != null)
{
var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == wcsTaskManual.orderId);

@ -28,8 +28,9 @@
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="请选择容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
@ -37,6 +38,8 @@
<Button x:Name="SearchBtn" Content="搜索" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="SearchBtn_Click"/>
<Button Content="编辑" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="EditBtn_Click"/>
</StackPanel>
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="1"

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Khd.Core.Wpf.WindowPage"
mc:Ignorable="d"
Title="选择盘库型号" Height="600" Width="1500" WindowStartupLocation="CenterScreen" Background="#172557">
Title="选择盘库型号" Height="900" Width="1900" WindowStartupLocation="CenterScreen" Background="#172557">
<Window.Resources>
@ -30,6 +30,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
@ -49,8 +50,29 @@
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<DataGrid SelectionChanged="StockDataGrid_SelectionChanged"
<Border Grid.Row="1" Height="100" Background="Transparent" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0">
<ItemsControl x:Name="itemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
<!-- 使项自动换行 -->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" Padding="5">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding materialName}" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<Button Content="删除" FontSize="15" Width="50" Background="LightSkyBlue" Foreground="Red" Margin="0,0,10,0" Click="DeleteButton_Click" Tag="{Binding }"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
<Grid Grid.Row="2">
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="2" AlternationCount="2"
AutoGenerateColumns="False"
@ -73,6 +95,23 @@
<DataGrid.Columns>
<DataGridTemplateColumn Width="130*" Header="选择">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.Tag>
<Binding Path="IsSelected"/>
</Grid.Tag>
<CheckBox
IsChecked="{Binding Tag, RelativeSource={RelativeSource AncestorType=Grid}}"
Click="CheckPersonBox_Click"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="200*"
Binding="{Binding materialId}"

@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -17,6 +18,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using static Khd.Core.Wpf.Form.FormBoardT;
namespace Khd.Core.Wpf.WindowPage
{
@ -26,11 +28,18 @@ namespace Khd.Core.Wpf.WindowPage
public partial class InventoryMaterialWindow : Window
{
private IHost host = null;
private ObservableCollection<StockItem> itemsControlItems;
public InventoryMaterialWindow(IHost _host)
{
host = _host;
InitializeComponent();
Init();
itemsControlItems = new ObservableCollection<StockItem>();
itemsControl.ItemsSource = itemsControlItems;
}
public async Task Init()
@ -52,6 +61,7 @@ namespace Khd.Core.Wpf.WindowPage
// 将库存物料信息和物料详细信息合并
var stockDetails = materialInfos.Select(material => new StockItem
{
IsSelected = false,
materialId = material.MaterialId.ToString(),
materialCode = material.MaterialCode,
materialName = material.MaterialName,
@ -81,28 +91,10 @@ namespace Khd.Core.Wpf.WindowPage
private void StockDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 获取选中的项假设它是某种类型如StockItem
var selectedItem = StockDataGrid.SelectedItem as StockItem; // StockItem是你的数据项类型
if (selectedItem != null)
{
// 更新TextBox的内容为选中项的属性值
SelectMaterialId.Text = selectedItem.materialId.ToString(); // 假设MaterialId是一个属性
SelectMaterialName.Text = selectedItem.materialName; // 假设MaterialName是一个属性
}
else
{
// 如果没有选中项则清空TextBox的内容
SelectMaterialId.Text = string.Empty;
SelectMaterialName.Text = string.Empty;
}
}
public class StockItem
{
public bool IsSelected { get; set; }
public string materialId { get; set; }
public string materialCode { get; set; }
public string materialName { get; set; }
@ -124,9 +116,22 @@ namespace Khd.Core.Wpf.WindowPage
try
{
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
int locationCount = 0;
if (string.IsNullOrEmpty(SelectMaterialId.Text)){
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
}
else
{
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
}
var Orders = dbContext.WmsInventoryCheck.Where(t => t.CheckStatus == "0" || t.CheckStatus == "1").ToList();
if (Orders != null && Orders.Count > 0)
{
@ -138,7 +143,7 @@ namespace Khd.Core.Wpf.WindowPage
t.CheckStatus = "2";
});
dbContext.UpdateRange(Orders);
int locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
@ -163,7 +168,7 @@ namespace Khd.Core.Wpf.WindowPage
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("是否创建一个盘库任务?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
int locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
@ -172,7 +177,8 @@ namespace Khd.Core.Wpf.WindowPage
InventoriedAmount = 0,
InventoryingAmount = 0,
WarehouseId = 512,
CreateBy = "WCS"
CreateBy = "WCS",
MaterialId = string.IsNullOrEmpty(SelectMaterialId.Text) ? null : long.Parse(SelectMaterialId.Text)
});
dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!");
@ -188,5 +194,80 @@ namespace Khd.Core.Wpf.WindowPage
}
}
/// <summary>
/// 单选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckPersonBox_Click(object sender, RoutedEventArgs e)
{
if (sender is CheckBox checkbox)
{
dynamic Currentselected = StockDataGrid.SelectedItem;
if (checkbox.IsChecked != null && checkbox.IsChecked.Value)
{
if (itemsControlItems != null && itemsControlItems.Count >= 6)
{
MessageBox.Show("最多只能选择6个");
checkbox.IsChecked = false;
return;
}
// 添加选中项
string selectedItem = Currentselected.materialName;
bool isIn = itemsControlItems.Any(t => t.materialId == Currentselected.materialId);
if (!isIn)
{
itemsControlItems.Add(new StockItem
{
materialId = Currentselected.materialId,
materialCode = Currentselected.materialCode,
materialName = Currentselected.materialName,
materialSpec = Currentselected.materialSpec,
});
}
}
else
{
// 删除选中项
StockItem model = itemsControlItems.FirstOrDefault(x => x.materialId == Currentselected.materialId);
if (model != null)
{
itemsControlItems.Remove(model);
}
}
}
}
/// <summary>
/// 删除选中的值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
// 获取点击按钮的实例
Button button = sender as Button;
// 从按钮的 Tag 属性中获取当前数据项
StockItem itemToRemove = button.Tag as StockItem;
if (itemToRemove != null)
{
// 从集合中移除数据项
itemsControlItems.Remove(itemToRemove);
}
}
}
}

Loading…
Cancel
Save