* Added EmailAddresses and WzNumbers to WzHeader

* Changed approach to send email to addresses added to WzHeader
This commit is contained in:
2025-05-25 11:01:18 +02:00
parent 1a4ff2ef6d
commit ad641560ea
10 changed files with 160 additions and 54 deletions

View File

@@ -8,6 +8,7 @@
@using FilterType = Syncfusion.Blazor.Grids.FilterType
@using SelectionMode = Syncfusion.Blazor.Grids.SelectionMode
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Popups
@inject WarehouseService WarehouseService
@inject NavigationManager NavigationManager
@@ -61,8 +62,7 @@
<h5 class="text-primary mb-3">Packling Listy</h5>
</CardHeader>
<CardContent>
<SfGrid @ref="_wzHeadersGrid"
AllowFiltering="true"
<SfGrid AllowFiltering="true"
AllowPaging="true"
AllowSorting="true"
AllowSelection="true"
@@ -71,6 +71,7 @@
EnableAdaptiveUI="true">
<GridColumns>
<GridColumn Field=@nameof(WzHeaderDto.ID) HeaderText="ID" TextAlign="TextAlign.Center" Width="110"></GridColumn>
<GridColumn Field=@nameof(WzHeaderDto.WzNumbers) HeaderText="Numery WZ" TextAlign="TextAlign.Center" Width="100"></GridColumn>
<GridColumn Field=@nameof(WzHeaderDto.CreatedDate) HeaderText="Data utworzenia" TextAlign="TextAlign.Center" Width="100"></GridColumn>
</GridColumns>
<GridFilterSettings Type="FilterType.Excel"/>
@@ -82,6 +83,18 @@
</SfCard>
}
</CardContent>
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
<DialogTemplates>
<Content>
<p>Błąd: Zaznacz przynajmniej jeden rekord, żeby wygenerowac Pack List!</p>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
</DialogButtons>
</SfDialog>
<CardFooter>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
@@ -90,7 +103,6 @@
@code {
private SfGrid<MaterialTransactionDto> _grid;
private SfGrid<WzHeaderDto> _wzHeadersGrid;
private IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
private IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
private IEnumerable<MaterialTransactionDto> _dataSource = new List<MaterialTransactionDto>();
@@ -101,6 +113,8 @@
private WzHeaderDto? _selectedHeader;
private SfDropDownList<Guid?, WzClientDto> _dropdown;
private bool _isVisible;
private bool Visibility { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@@ -109,14 +123,15 @@
_clients = await WarehouseService.GetAllClientsAsync();
_clients = _clients.Where(x => x.Name.Equals("MEYLE", StringComparison.OrdinalIgnoreCase));
StateHasChanged();
var savedClientId = await LocalStorage.GetItemAsync<Guid?>("SelectedClientId");
if (savedClientId != null && _clients.FirstOrDefault(c => c.ID == savedClientId) is {} savedClient)
{
await OnValueChange(new ChangeEventArgs<Guid?, WzClientDto>() { Value = savedClient.ID });
}
StateHasChanged();
StateHasChanged();
}
}
}
@@ -156,43 +171,54 @@
private async Task CreatePackingList()
{
var selectedRecords = await _grid.GetSelectedRecordsAsync();
if (selectedRecords.Any())
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<WzRowMeyleDto> rows = new List<WzRowMeyleDto>();
IList<MaterialTransactionDto> 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);
Visibility = true;
return;
}
WzHeaderDto wzHeader = new WzHeaderDto
{
ID = Guid.NewGuid(),
FK_Client = _selectedClient?.ID,
CreatedDate = DateTime.Now,
WzNumbers = string.Join(", ",selectedRecords.Select(x => x.MTGroupNum).Distinct())
};
await WarehouseService.CreateWzHeaderAsync(wzHeader);
switch (_selectedClient?.Name.ToUpper())
{
case "MEYLE":
IList<WzRowMeyleDto> rows = new List<WzRowMeyleDto>();
IList<MaterialTransactionDto> 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);
}
private void HideModal()
{
Visibility = false;
}
}