|
|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|