326 lines
8.2 KiB
C#
326 lines
8.2 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 Movimenti
|
|
{
|
|
#region Public Properties
|
|
|
|
public ItemFamSelectFilter currFilter { get; set; } = new ItemFamSelectFilter();
|
|
|
|
public int ItemID { get => selFilter.ItemID; }
|
|
|
|
[Parameter]
|
|
public List<LocationModel> listLocation { get; set; } = null!;
|
|
|
|
public List<ItemFluxModel> searchtemFlux { 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 cliente
|
|
{
|
|
get => _cliente;
|
|
set => _cliente = value;
|
|
}
|
|
|
|
protected DateTime dataDocumento
|
|
{
|
|
get => _dataDocumento;
|
|
set => _dataDocumento = value;
|
|
}
|
|
|
|
protected string documento
|
|
{
|
|
get => _documento;
|
|
set => _documento = value;
|
|
}
|
|
|
|
protected string enable
|
|
{
|
|
get => (isDup || isMod) ? "Background-color: #fff" : "Background-color: #e9ecef; pointer-events: none";
|
|
}
|
|
|
|
protected ItemFluxModel fluxToShow { get; set; } = new ItemFluxModel();
|
|
|
|
protected string fornitore
|
|
{
|
|
get => _fornitore;
|
|
set => _fornitore = value;
|
|
}
|
|
|
|
protected decimal importo
|
|
{
|
|
get => _importo;
|
|
set => _importo = value;
|
|
}
|
|
|
|
protected bool isCarico { get; set; } = false;
|
|
|
|
protected bool isDup { get; set; } = false;
|
|
|
|
protected bool isMod { get; set; } = false;
|
|
|
|
protected bool isRettifica { get; set; } = false;
|
|
|
|
protected bool isScarico { get; set; } = false;
|
|
|
|
protected List<ItemFluxModel> itemFlux { get; set; } = new List<ItemFluxModel>();
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[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!;
|
|
|
|
protected int totalCount { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string dateCss(DateTime? dataToCheck)
|
|
{
|
|
string answ = "";
|
|
if (dataToCheck != null)
|
|
{
|
|
answ = "text-decoration-line-through";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected async Task delete(ItemFluxModel flux)
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
var ok = await JSRuntime.InvokeAsync<bool>("confirm", $"Confermare di voler eliminare il movimento in data {flux.DtMov.Date}");
|
|
|
|
if (ok)
|
|
{
|
|
var done = await SDService.DeleteFlux(flux);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected async Task duplicate()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
ItemFluxModel newRec = new ItemFluxModel()
|
|
{
|
|
ItemId = fluxToShow.ItemId,
|
|
LocationId = fluxToShow.LocationId,
|
|
MovTypeId = fluxToShow.MovTypeId,
|
|
ExtLocationId = fluxToShow.ExtLocationId,
|
|
DtMov = DateTime.Now.Date,
|
|
Qta = fluxToShow.Qta,
|
|
TotValue = fluxToShow.TotValue,
|
|
OperatorId = userName,
|
|
Note = "---DUPLICATED---",
|
|
CodDoc = fluxToShow.CodDoc,
|
|
ModOperatorId = userName
|
|
};
|
|
|
|
var done = await SDService.FluxAdd(newRec);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
protected async Task dupMode()
|
|
{
|
|
await Task.Delay(1);
|
|
isDup = true;
|
|
}
|
|
|
|
protected async Task edit()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
var done = await SDService.FluxMod(fluxToShow);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
protected async Task editMode(ItemFluxModel flux)
|
|
{
|
|
await Task.Delay(1);
|
|
fluxToShow = flux;
|
|
isMod = true;
|
|
}
|
|
|
|
protected void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
protected void UpdateTotCount(int newTotCount)
|
|
{
|
|
totalCount = newTotCount;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get => currFilter.CurrPage;
|
|
set => currFilter.CurrPage = value;
|
|
}
|
|
|
|
private int numRecord
|
|
{
|
|
get => currFilter.NumRec;
|
|
set => currFilter.NumRec = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task dupItem(ItemFluxModel flux)
|
|
{
|
|
await Task.Delay(1);
|
|
isDup = true;
|
|
fluxToShow = flux;
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
searchtemFlux = await SDService.ItemFluxGetById(ItemID);
|
|
totalCount = searchtemFlux.Count;
|
|
itemFlux = searchtemFlux.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
|
|
//listLocation = await SDService.LocationGetAll();
|
|
}
|
|
|
|
private async Task saveCarico()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
string movTipo = "";
|
|
string cliOrForn = "";
|
|
|
|
if (isCarico)
|
|
{
|
|
movTipo = "CAR";
|
|
cliOrForn = fornitore;
|
|
}
|
|
else if (isScarico)
|
|
{
|
|
movTipo = "SCAR";
|
|
cliOrForn = cliente;
|
|
}
|
|
else if (isRettifica)
|
|
{
|
|
movTipo = "SCAR";
|
|
cliOrForn = cliente;
|
|
}
|
|
|
|
ItemFluxModel newRec = new ItemFluxModel()
|
|
{
|
|
ItemId = ItemID,
|
|
LocationId = pos,
|
|
MovTypeId = movTipo,
|
|
ExtLocationId = cliOrForn,
|
|
DtMov = DateTime.Now.Date,
|
|
Qta = qta,
|
|
TotValue = importo,
|
|
UnitVal = (importo / qta),
|
|
OperatorId = userName,
|
|
Note = note,
|
|
CodDoc = documento,
|
|
ModOperatorId = userName
|
|
};
|
|
|
|
var done = await SDService.FluxAdd(newRec);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
private async Task setItem(ItemFluxModel flux)
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
fluxToShow = flux;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |