179 lines
5.3 KiB
C#
179 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using EgwCoreLib.Razor;
|
|
using EgwCoreLib.Razor.Data;
|
|
using StockMan.CORE;
|
|
using StockMan.CORE.Data;
|
|
using StockMan.CORE.Shared;
|
|
using StockMan.Data.DbModels;
|
|
using StockMan.Data;
|
|
using StackExchange.Redis;
|
|
|
|
namespace StockMan.CORE.Components
|
|
{
|
|
public partial class Location
|
|
{
|
|
[Parameter]
|
|
public string locSX_ID { get; set; } = "";
|
|
[Parameter]
|
|
public bool isSX { get; set; }
|
|
[Parameter]
|
|
public string locDX_ID { get; set; } = "";
|
|
public string currLoc { get; set; } = "";
|
|
[Inject]
|
|
protected StockDataService SDService { get; set; } = null!;
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
protected List<ItemStockModel>? listItemByLoc { get; set; } = null;
|
|
[Parameter]
|
|
public List<LocationModel>? ListLocationByType { get; set; } = null;
|
|
[Parameter]
|
|
public string UserName { get; set; } = "";
|
|
[Parameter]
|
|
public bool isChanged { get; set; } = false;
|
|
[Parameter]
|
|
public EventCallback<string> LocId_SX { get; set; }
|
|
[Parameter]
|
|
public EventCallback<string> LocId_DX { get; set; }
|
|
public ItemStockModel? currStock { get; set; } = null;
|
|
public int qty { get; set; } = 0;
|
|
public bool isLoading { get; set; } = false;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
protected int? _currItem;
|
|
protected int? currItem
|
|
{
|
|
get => _currItem;
|
|
set => _currItem = value;
|
|
}
|
|
|
|
protected string id
|
|
{
|
|
get => currLoc;
|
|
set
|
|
{
|
|
currLoc = value;
|
|
if (isSX)
|
|
{
|
|
setLocationSX(value);
|
|
}
|
|
else
|
|
{
|
|
setLocationDX(value);
|
|
}
|
|
ReloadData();
|
|
}
|
|
}
|
|
protected async Task setLocationSX(string locId)
|
|
{
|
|
await LocId_SX.InvokeAsync(locId);
|
|
}
|
|
protected async Task setLocationDX(string locId)
|
|
{
|
|
await LocId_DX.InvokeAsync(locId);
|
|
}
|
|
protected string rawCode
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = $"itemDetails?ItemID={currItem}";
|
|
return answ;
|
|
}
|
|
}
|
|
protected string bgCard
|
|
{
|
|
get => isSX ? "bg-primary" : "bg-success";
|
|
|
|
}
|
|
protected string locSxoDx
|
|
{
|
|
get => isSX ? "Locazione mittente:" : "locazione destinatario:";
|
|
|
|
}
|
|
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;
|
|
listItemByLoc = await SDService.ItemsGetByLocation(currLoc);
|
|
isLoading = false;
|
|
}
|
|
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 async Task SetMove(ItemStockModel item)
|
|
{
|
|
await Task.Delay(1);
|
|
currStock = item;
|
|
qty = item.QtyConf;
|
|
}
|
|
private async void selItemToDet(int selItem)
|
|
{
|
|
currItem = selItem;
|
|
await JSRuntime.InvokeAsync<object>("open", rawCode, "_blank");
|
|
}
|
|
}
|
|
} |