284 lines
7.3 KiB
C#
284 lines
7.3 KiB
C#
using EgwCoreLib.Razor;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using StockMan.CORE.Data;
|
|
using StockMan.Data.DbModels;
|
|
|
|
namespace StockMan.CORE.Components
|
|
{
|
|
public partial class Location
|
|
{
|
|
#region Public Properties
|
|
|
|
public string currLoc { get; set; } = "";
|
|
|
|
public ItemStockModel? currStock { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public bool isChanged { get; set; } = false;
|
|
|
|
public bool isLoading { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public bool isSX { get; set; }
|
|
|
|
[Parameter]
|
|
public List<LocationModel>? ListLocationByType { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public string locDX_ID { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public EventCallback<string> LocId_DX { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> LocId_SX { get; set; }
|
|
|
|
[Parameter]
|
|
public string locSX_ID { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public string UserName { get; set; } = "";
|
|
[Parameter]
|
|
public LocSXSelectFilter actFilterSX { get; set; } = new LocSXSelectFilter();
|
|
[Parameter]
|
|
public LocDXSelectFilter actFilterDX { get; set; } = new LocDXSelectFilter();
|
|
[Parameter]
|
|
public EventCallback<int> updateRecordCount { get; set; }
|
|
private int currPageSX
|
|
{
|
|
get => actFilterSX.CurrPage;
|
|
set => actFilterSX.CurrPage = value;
|
|
}
|
|
|
|
private int numRecordSX
|
|
{
|
|
get => actFilterSX.NumRec;
|
|
set => actFilterSX.NumRec = value;
|
|
}
|
|
private int currPageDX
|
|
{
|
|
get => actFilterDX.CurrPage;
|
|
set => actFilterDX.CurrPage = value;
|
|
}
|
|
|
|
private int numRecordDX
|
|
{
|
|
get => actFilterDX.NumRec;
|
|
set => actFilterDX.NumRec = value;
|
|
}
|
|
private int _totalCount = 0;
|
|
private int totalCount
|
|
{
|
|
get => _totalCount;
|
|
set
|
|
{
|
|
if (_totalCount != value)
|
|
{
|
|
_totalCount = value;
|
|
updateRecordCount.InvokeAsync(value);
|
|
}
|
|
}
|
|
}
|
|
public int qty { get; set; } = 0;
|
|
|
|
protected DataPager? pagerLocation;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected int? _currItem;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string bgCard
|
|
{
|
|
get => isSX ? "bg-primary" : "bg-success";
|
|
}
|
|
|
|
protected int? currItem
|
|
{
|
|
get => _currItem;
|
|
set => _currItem = value;
|
|
}
|
|
|
|
protected string id
|
|
{
|
|
get
|
|
{
|
|
if (isSX)
|
|
{
|
|
return actFilterSX.idSx;
|
|
}
|
|
else
|
|
{
|
|
return actFilterDX.idDx;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
if (isSX)
|
|
{
|
|
actFilterSX.idSx = value;
|
|
}
|
|
else
|
|
{
|
|
actFilterDX.idDx = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
protected List<ItemStockModel>? listItemByLoc { get; set; } = null;
|
|
protected List<ItemStockModel>? listSearch { get; set; } = null;
|
|
|
|
protected string locSxoDx
|
|
{
|
|
get => isSX ? "Locazione mittente:" : "locazione destinatario:";
|
|
}
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
|
|
protected string rawCode
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = $"itemDetails?ItemID={currItem}";
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected StockDataService SDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ForceReloadSX(int newNum)
|
|
{
|
|
numRecordSX = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPageSX(int newNum)
|
|
{
|
|
currPageSX = newNum;
|
|
}
|
|
protected void ForceReloadDX(int newNum)
|
|
{
|
|
numRecordDX = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPageDX(int newNum)
|
|
{
|
|
currPageDX = newNum;
|
|
}
|
|
|
|
protected async Task Move()
|
|
{
|
|
bool done = false;
|
|
if (currStock != null)
|
|
{
|
|
if (qty != currStock.QtyConf)
|
|
{
|
|
if (!isChanged)
|
|
{
|
|
done = await SDService.MoveItems_New(currStock.Id, locSX_ID, locDX_ID, UserName, qty);
|
|
}
|
|
else
|
|
{
|
|
done = await SDService.MoveItems_New(currStock.Id, locDX_ID, locSX_ID, UserName, qty);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!isChanged)
|
|
{
|
|
done = await SDService.MoveItems(currStock.Id, locSX_ID, locDX_ID, UserName);
|
|
}
|
|
else
|
|
{
|
|
done = await SDService.MoveItems(currStock.Id, locDX_ID, locSX_ID, UserName);
|
|
}
|
|
}
|
|
}
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (isSX && !isChanged)
|
|
{
|
|
currLoc = locSX_ID;
|
|
}
|
|
else if (isSX && isChanged)
|
|
{
|
|
currLoc = locDX_ID;
|
|
}
|
|
else if (!isSX && !isChanged)
|
|
{
|
|
currLoc = locDX_ID;
|
|
}
|
|
else if (!isSX && isChanged)
|
|
{
|
|
currLoc = locSX_ID;
|
|
}
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
listSearch = await SDService.ItemsGetByLocation(currLoc);
|
|
totalCount = listSearch.Count;
|
|
if (isSX)
|
|
{
|
|
listItemByLoc = listSearch.Skip(numRecordSX * (currPageSX - 1)).Take(numRecordSX).ToList();
|
|
}
|
|
else
|
|
{
|
|
listItemByLoc = listSearch.Skip(numRecordDX * (currPageDX - 1)).Take(numRecordDX).ToList();
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
protected async Task setLocationDX(string locId)
|
|
{
|
|
await LocId_DX.InvokeAsync(locId);
|
|
}
|
|
|
|
protected async Task setLocationSX(string locId)
|
|
{
|
|
await LocId_SX.InvokeAsync(locId);
|
|
}
|
|
|
|
protected async Task SetMove(ItemStockModel item)
|
|
{
|
|
await Task.Delay(1);
|
|
currStock = item;
|
|
qty = item.QtyConf;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private async void selItemToDet(int selItem)
|
|
{
|
|
currItem = selItem;
|
|
await JSRuntime.InvokeAsync<object>("open", rawCode, "_blank");
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |