249 lines
6.1 KiB
C#
249 lines
6.1 KiB
C#
using EgwCoreLib.Razor;
|
|
using Microsoft.AspNetCore.Components;
|
|
using StockMan.CORE.Data;
|
|
using StockMan.Data.DbModels;
|
|
|
|
namespace StockMan.CORE.Components
|
|
{
|
|
public partial class StockGiacenze
|
|
{
|
|
#region Public Properties
|
|
|
|
public int ItemID { get => selFilter.ItemID; }
|
|
|
|
[Parameter]
|
|
public List<LocationModel> listLocation { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public List<ItemStockModel> listStock { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public ItemDetailsSelectFilter selFilter { get; set; } = null!;
|
|
|
|
public string userName { get => selFilter.userName; }
|
|
|
|
public decimal valoreUnit { get => valoreUnit; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected DataPager? pagerItemDetails = null!;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string _cliente { get; set; } = "";
|
|
|
|
protected DateTime _dataDocumento { get; set; } = DateTime.Now.Date;
|
|
|
|
protected string _documento { get; set; } = "RDA/DDT/FT";
|
|
|
|
protected string _fornitore { get; set; } = "";
|
|
|
|
protected decimal _importo { get; set; } = 0.00M;
|
|
|
|
protected string _note { get; set; } = "";
|
|
|
|
protected string _pos { get; set; } = "";
|
|
|
|
protected int _qta { get; set; } = 0;
|
|
|
|
protected string cardCss
|
|
{
|
|
get => (isCarico || isScarico || isRettifica) ? "border border-primary" : "";
|
|
}
|
|
|
|
protected string cliente
|
|
{
|
|
get => _cliente;
|
|
set => _cliente = value;
|
|
}
|
|
|
|
protected DateTime dataDocumento
|
|
{
|
|
get => _dataDocumento;
|
|
set => _dataDocumento = value;
|
|
}
|
|
|
|
protected string documento
|
|
{
|
|
get => _documento;
|
|
set => _documento = value;
|
|
}
|
|
|
|
protected string fornitore
|
|
{
|
|
get => _fornitore;
|
|
set => _fornitore = value;
|
|
}
|
|
|
|
protected string headerCss
|
|
{
|
|
get => (isCarico || isScarico || isRettifica) ? "bg-primary text-light" : "";
|
|
}
|
|
|
|
protected decimal importo
|
|
{
|
|
get => _importo;
|
|
set => _importo = value;
|
|
}
|
|
|
|
protected bool isCarico { get; set; } = false;
|
|
|
|
protected bool isRettifica { get; set; } = false;
|
|
|
|
protected bool isScarico { get; set; } = false;
|
|
|
|
protected List<ItemFluxModel> itemFlux { get; set; } = new List<ItemFluxModel>();
|
|
|
|
protected ItemStockModel itemStock { get; set; } = new ItemStockModel();
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
|
|
protected string note
|
|
{
|
|
get => _note;
|
|
set => _note = value;
|
|
}
|
|
|
|
protected string pos
|
|
{
|
|
get => _pos;
|
|
set => _pos = value;
|
|
}
|
|
|
|
protected int qta
|
|
{
|
|
get => _qta;
|
|
set => _qta = value;
|
|
}
|
|
|
|
[Inject]
|
|
protected StockDataService SDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void carico()
|
|
{
|
|
isScarico = false;
|
|
isRettifica = false;
|
|
isCarico = true;
|
|
}
|
|
|
|
protected void close()
|
|
{
|
|
isScarico = false;
|
|
isRettifica = false;
|
|
isCarico = false;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
protected void rettifica()
|
|
{
|
|
isScarico = false;
|
|
isCarico = false;
|
|
isRettifica = true;
|
|
}
|
|
|
|
protected void scarico()
|
|
{
|
|
isRettifica = false;
|
|
isCarico = false;
|
|
isScarico = true;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private async Task confermaMovimenti()
|
|
{
|
|
var done = await SDService.ConfermaMov(ItemID);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
private async Task eliminaDuplicati()
|
|
{
|
|
var done = await SDService.EliminaDup(ItemID);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
//itemFlux = await SDService.ItemFluxGetById(ItemID);
|
|
//var Stock = await SDService.ItemsStockGetById(ItemID);
|
|
if (listStock != null)
|
|
{
|
|
itemStock = listStock.FirstOrDefault();
|
|
}
|
|
|
|
//listLocation = await SDService.LocationGetAll();
|
|
}
|
|
|
|
private async Task saveCarico()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
string movTipo = "";
|
|
string cliOrForn = "";
|
|
int qtaScarCar = 0;
|
|
if (isCarico)
|
|
{
|
|
movTipo = "CAR";
|
|
cliOrForn = fornitore;
|
|
qtaScarCar = 0 + qta;
|
|
}
|
|
else if (isScarico)
|
|
{
|
|
movTipo = "SCAR";
|
|
cliOrForn = cliente;
|
|
qtaScarCar = 0 - qta;
|
|
}
|
|
else if (isRettifica)
|
|
{
|
|
movTipo = "RETT";
|
|
cliOrForn = cliente;
|
|
}
|
|
|
|
ItemFluxModel newRec = new ItemFluxModel()
|
|
{
|
|
ItemId = ItemID,
|
|
LocationId = pos,
|
|
MovTypeId = movTipo,
|
|
ExtLocationId = cliOrForn,
|
|
DtMov = DateTime.Now.Date,
|
|
Qta = qtaScarCar,
|
|
TotValue = importo,
|
|
OperatorId = userName,
|
|
Note = note,
|
|
CodDoc = documento,
|
|
ModOperatorId = userName
|
|
};
|
|
|
|
var done = await SDService.FluxAdd(newRec);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |