@page "/Warehouse" @using Syncfusion.Blazor.Cards @using Syncfusion.Blazor.Grids @using SytelineSaAppEfDataModel.Dtos @using Syncfusion.Blazor.DropDowns @using FilterType = Syncfusion.Blazor.Grids.FilterType @using SelectionMode = Syncfusion.Blazor.Grids.SelectionMode @using Syncfusion.Blazor.Navigations @inject WarehouseService WarehouseService @inject NavigationManager NavigationManager

Dokumenty WZ na Magazynie

Klient
@if (_isVisible) {
Dokumenty WZ
}
FA Krosno Manager © @(DateTime.Now.Year)
@code { private SfGrid _grid; private IEnumerable _clients = new List(); private IEnumerable _materialTransactions = new List(); private IEnumerable _dataSource = new List(); private WzClientDto? _selectedClient; bool _isVisible = false; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { _clients = await WarehouseService.GetAllClientsAsync(); StateHasChanged(); } } private async Task OnValueChange(ChangeEventArgs args) { if (args.Value.HasValue) { _selectedClient = args.ItemData; _isVisible = true; _materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0); _dataSource = _materialTransactions.GroupBy(x => x.MTGroupNum).Select(x => x.First()).ToList(); } else { _selectedClient = null; _isVisible = false; } StateHasChanged(); } private async Task CreatePackingList() { var selectedRecords = await _grid.GetSelectedRecordsAsync(); if (selectedRecords.Any()) { WzHeaderDto wzHeader = new WzHeaderDto { ID = Guid.NewGuid(), FK_Client = _selectedClient?.ID }; await WarehouseService.CreateWzHeaderAsync(wzHeader); switch (_selectedClient?.Name.ToUpper()) { case "MEYLE": IList rows = new List(); IList materialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList(); foreach (MaterialTransactionDto materialTransactionDto in materialTransactions) { CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty); ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum); rows.Add(new WzRowMeyleDto { ID = Guid.NewGuid(), Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0), ItemNumber = item.CustItem, OrderNumber = customerOrder.CustPo, WzNumber = materialTransactionDto.MTGroupNum ?? string.Empty, FK_Header = wzHeader.ID }); } await WarehouseService.CreateWzRowsMeyleAsync(rows); break; } NavigationManager.NavigateTo("/Warehouse/PackList/" + wzHeader.ID); } } }