* Fixed Focus issues in Grid
This commit is contained in:
@@ -94,3 +94,12 @@ main {
|
|||||||
right: 0.75rem;
|
right: 0.75rem;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.e-grid .e-row.e-selection {
|
||||||
|
background-color: #D3D3D3 !important; /* Jasny szary */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Domyślny styl dla wierszy (na wszelki wypadek) */
|
||||||
|
.e-grid .e-row {
|
||||||
|
background-color: #FFFFFF; /* Biały, domyślny kolor */
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
CssClass="e-outline"/>
|
CssClass="e-outline"/>
|
||||||
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
CssClass="e-outline" @ref="_scanner" />
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</SfCard>
|
</SfCard>
|
||||||
<SfGrid @ref="_grid"
|
<SfGrid @ref="_grid"
|
||||||
@@ -53,7 +53,8 @@
|
|||||||
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
||||||
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
||||||
<ToolbarItem Type="ItemType.Button" Text="Podziel Linię" Id="SplitLineButton"
|
<ToolbarItem Type="ItemType.Button" Text="Podziel Linię" Id="SplitLineButton"
|
||||||
PrefixIcon="e-icons e-split-horizontal" OnClick="ShowSplitDialog" Disabled="IsDisabled"/>
|
PrefixIcon="e-icons e-split-horizontal" OnClick="ShowSplitDialog"
|
||||||
|
Disabled="IsDisabled"/>
|
||||||
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
||||||
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
||||||
</ToolbarItems>
|
</ToolbarItems>
|
||||||
@@ -72,7 +73,8 @@
|
|||||||
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PalletNumber) AllowEditing="true"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PalletNumber) AllowEditing="true"
|
||||||
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumberSl) AllowEditing="true" TextAlign="TextAlign.Center"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumberSl) AllowEditing="true"
|
||||||
|
TextAlign="TextAlign.Center"
|
||||||
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
||||||
@@ -114,15 +116,17 @@
|
|||||||
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
</DialogButtons>
|
</DialogButtons>
|
||||||
</SfDialog>
|
</SfDialog>
|
||||||
|
|
||||||
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityValidation" AllowPrerender="true">
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityValidation" AllowPrerender="true">
|
||||||
<DialogTemplates>
|
<DialogTemplates>
|
||||||
<Content>
|
<Content>
|
||||||
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
||||||
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od <b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od
|
||||||
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety: '<b>@PalletNumber</b>')</p></li>
|
<b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
||||||
|
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety:
|
||||||
|
'<b>@PalletNumber</b>')</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</Content>
|
</Content>
|
||||||
</DialogTemplates>
|
</DialogTemplates>
|
||||||
@@ -131,10 +135,24 @@
|
|||||||
</DialogButtons>
|
</DialogButtons>
|
||||||
</SfDialog>
|
</SfDialog>
|
||||||
|
|
||||||
<SfDialog Width="500px" Title="Podziel Linię" IsModal="true" @bind-Visible="VisibilityLineSplitter" AllowPrerender="true">
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
<DialogTemplates>
|
<DialogTemplates>
|
||||||
<Content>
|
<Content>
|
||||||
<label for="textBox" class="form-label">Podziel linię <b>@SelectedRow?.FaIndex</b> podając ilość sztuk dla nowej linii:</label>
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Podziel Linię" IsModal="true" @bind-Visible="VisibilityLineSplitter"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<label for="textBox" class="form-label">Podziel linię <b>@SelectedRow?.FaIndex</b> podając ilość
|
||||||
|
sztuk dla nowej linii:</label>
|
||||||
<SfTextBox ID="newQuantity" Type="InputType.Number" @bind-Value="@NewQuantity"
|
<SfTextBox ID="newQuantity" Type="InputType.Number" @bind-Value="@NewQuantity"
|
||||||
CssClass="e-outline"/>
|
CssClass="e-outline"/>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -165,13 +183,14 @@
|
|||||||
private List<WzRowMeyleDto> SelectedRows { get; set; } = new();
|
private List<WzRowMeyleDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
private string WzNumber { get; set; } = string.Empty;
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
private bool _isValid;
|
private bool _isValid;
|
||||||
|
|
||||||
private bool Visibility { get; set; }
|
private bool Visibility { get; set; }
|
||||||
private bool VisibilityValidation { get; set; }
|
private bool VisibilityValidation { get; set; }
|
||||||
private bool VisibilityLineSplitter { get; set; }
|
private bool VisibilityLineSplitter { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
private string? EmailAddresses { get; set; } = string.Empty;
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
private string PalletNumber { get; set; } = "0";
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
@@ -187,6 +206,7 @@
|
|||||||
Visibility = false;
|
Visibility = false;
|
||||||
VisibilityValidation = false;
|
VisibilityValidation = false;
|
||||||
VisibilityLineSplitter = false;
|
VisibilityLineSplitter = false;
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
|
||||||
LastScannedValue = ScannedValue;
|
LastScannedValue = ScannedValue;
|
||||||
ScannedValue = string.Empty;
|
ScannedValue = string.Empty;
|
||||||
@@ -200,9 +220,9 @@
|
|||||||
{
|
{
|
||||||
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
TransactionModelsByPartNumber = await GetTransactionModels();
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
EmailAddresses = _wzHeader.EmailAddresses;
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
@@ -213,7 +233,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveChanges()
|
private async Task SaveChanges()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
{
|
{
|
||||||
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
@@ -258,21 +278,21 @@
|
|||||||
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
if (int.Parse(PalletNumber) <= 0)
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
{
|
{
|
||||||
ShowValidationMessage();
|
VisibilityPalletNumber = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScannedValue = obj.Value.Trim();
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
if (materialTransactionByPartNumber == null && IsValidScannedValue(obj.Value))
|
if (materialTransactionByPartNumber == null && IsValidScannedValue(obj.Value))
|
||||||
{
|
{
|
||||||
FillMeylePartNumber(ScannedValue);
|
FillMeylePartNumber(ScannedValue);
|
||||||
|
|
||||||
LastScannedValue = ScannedValue;
|
LastScannedValue = ScannedValue;
|
||||||
ScannedValue = string.Empty;
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
@@ -290,7 +310,7 @@
|
|||||||
ShowValidationMessage();
|
ShowValidationMessage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastScannedValue = ScannedValue;
|
LastScannedValue = ScannedValue;
|
||||||
ScannedValue = string.Empty;
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
@@ -306,13 +326,12 @@
|
|||||||
return scannedValue.StartsWith(format);
|
return scannedValue.StartsWith(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillMeylePartNumber(string scannedValue)
|
private async Task FillMeylePartNumber(string scannedValue)
|
||||||
{
|
{
|
||||||
if (SelectedRow != null)
|
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRow?.FaIndex && x.Quantity == SelectedRow?.Quantity);
|
||||||
|
|
||||||
|
if (SelectedRow != null && !SelectedRows.Any())
|
||||||
{
|
{
|
||||||
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRow?.ItemNumber && x.Quantity == SelectedRow?.Quantity);
|
|
||||||
FocusGridRow(rowIndex);
|
|
||||||
|
|
||||||
SelectedRow.PartNumber = scannedValue;
|
SelectedRow.PartNumber = scannedValue;
|
||||||
ChangedRecords.Add(SelectedRow);
|
ChangedRecords.Add(SelectedRow);
|
||||||
}
|
}
|
||||||
@@ -323,65 +342,92 @@
|
|||||||
ChangedRecords.Add(wzRowMeyleDto);
|
ChangedRecords.Add(wzRowMeyleDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveChanges();
|
await SaveChanges();
|
||||||
InvokeAsync(StateHasChanged);
|
|
||||||
_grid.Refresh();
|
|
||||||
_scanner.FocusAsync();
|
|
||||||
ChangedRecords.Clear();
|
ChangedRecords.Clear();
|
||||||
|
SelectedRows.Clear();
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
private async Task FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
{
|
{
|
||||||
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
await _grid.ClearSelectionAsync();
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
List<int> selectedIndices = new List<int>();
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
switch (rowIndex)
|
switch (rowIndex)
|
||||||
{
|
{
|
||||||
case -1 when int.Parse(PalletNumber) <= 0:
|
|
||||||
ShowValidationMessage();
|
|
||||||
LastScannedValue = ScannedValue;
|
|
||||||
ScannedValue = string.Empty;
|
|
||||||
return;
|
|
||||||
case -1:
|
case -1:
|
||||||
{
|
{
|
||||||
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
if (SelectedRows.Count == 0)
|
if (SelectedRows.Count == 0)
|
||||||
{
|
{
|
||||||
ShowValidationMessage();
|
ShowValidationMessage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (WzRowMeyleDto wzRowMeyleDto in SelectedRows)
|
rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRows.First().FaIndex && x.Quantity == SelectedRows.First().Quantity);
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
{
|
{
|
||||||
wzRowMeyleDto.PartNumberSl = scannedValue;
|
foreach (var record in combination)
|
||||||
ChangedRecords.Add(wzRowMeyleDto);
|
{
|
||||||
|
record.PartNumberSl = scannedValue;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
|
||||||
|
int index = WzRowsMeyle.IndexOf(record);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
selectedIndices.Add(index);
|
||||||
|
Console.WriteLine($"Dodano indeks: {index}"); // Debugowanie
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
FocusGridRow(rowIndex);
|
|
||||||
|
|
||||||
SelectedRow = WzRowsMeyle[rowIndex];
|
SelectedRow = WzRowsMeyle[rowIndex];
|
||||||
|
selectedIndices.Add(rowIndex);
|
||||||
|
|
||||||
SelectedRow.PartNumberSl = ScannedValue;
|
SelectedRow.PartNumberSl = scannedValue;
|
||||||
SelectedRow.PalletNumber = int.Parse(PalletNumber);
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
{
|
{
|
||||||
ChangedRecords.Add(SelectedRow);
|
ChangedRecords.Add(SelectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveChanges();
|
await SaveChanges();
|
||||||
InvokeAsync(StateHasChanged);
|
|
||||||
_grid.Refresh();
|
|
||||||
_scanner.FocusAsync();
|
|
||||||
ChangedRecords.Clear();
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
if (selectedIndices.Any())
|
||||||
|
{
|
||||||
|
await _grid.SelectRowsAsync(selectedIndices.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FocusGridRow(int rowIndex)
|
private void FocusGridRow(int rowIndex)
|
||||||
@@ -391,10 +437,10 @@
|
|||||||
int pageSize = _grid.PageSettings.PageSize;
|
int pageSize = _grid.PageSettings.PageSize;
|
||||||
int targetPage = (rowIndex / pageSize) + 1;
|
int targetPage = (rowIndex / pageSize) + 1;
|
||||||
_grid.GoToPageAsync(targetPage);
|
_grid.GoToPageAsync(targetPage);
|
||||||
|
|
||||||
rowIndex %= pageSize;
|
rowIndex %= pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
_grid.SelectRowAsync(rowIndex);
|
_grid.SelectRowAsync(rowIndex);
|
||||||
_grid.ScrollIntoViewAsync(rowIndex: rowIndex);
|
_grid.ScrollIntoViewAsync(rowIndex: rowIndex);
|
||||||
_grid.FocusAsync();
|
_grid.FocusAsync();
|
||||||
@@ -438,18 +484,20 @@
|
|||||||
OrderNumber = SelectedRow.OrderNumber,
|
OrderNumber = SelectedRow.OrderNumber,
|
||||||
PalletNumber = SelectedRow.PalletNumber,
|
PalletNumber = SelectedRow.PalletNumber,
|
||||||
WzNumber = SelectedRow.WzNumber,
|
WzNumber = SelectedRow.WzNumber,
|
||||||
TransactionNumber = SelectedRow.TransactionNumber += 10000
|
TransactionNumber = SelectedRow.TransactionNumber += 10000,
|
||||||
|
PartNumberSl = SelectedRow.PartNumberSl,
|
||||||
|
PartNumber = SelectedRow.PartNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
WzRowsMeyle.Add(splitRow);
|
WzRowsMeyle.Add(splitRow);
|
||||||
SelectedRow.Quantity -= newQuantity;
|
SelectedRow.Quantity -= newQuantity;
|
||||||
|
|
||||||
ChangedRecords.Add(SelectedRow);
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
|
||||||
await WarehouseService.CreateWzRowsMeyleAsync(new List<WzRowMeyleDto> { splitRow });
|
await WarehouseService.CreateWzRowsMeyleAsync(new List<WzRowMeyleDto> { splitRow });
|
||||||
await UpdateRows(ChangedRecords);
|
await UpdateRows(ChangedRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
VisibilityLineSplitter = false;
|
VisibilityLineSplitter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,4 +512,32 @@
|
|||||||
SelectedRow = obj.Data;
|
SelectedRow = obj.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMeyleDto>> FindCombinations(List<WzRowMeyleDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMeyleDto>>();
|
||||||
|
var currentCombination = new List<WzRowMeyleDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMeyleDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user