Files
mapo-core/MP-TAB2/MP-TAB.Client/Components/ProdAdvDispl.razor
T
2023-12-18 11:36:24 +01:00

122 lines
3.5 KiB
Plaintext

<div class="progress">
<div runat="server" id="divGreen" class="progress-bar bg-success" style="width: @(NumGreen)%">
@($"{NumGreen}%")
</div>
<div runat="server" id="divYellow" class="progress-bar bg-warning text-dark" style="width: @(NumYellow)%">
@($"{NumYellow}%")
</div>
<div runat="server" id="divGray" class="progress-bar bg-secondary" style="width: @(NumGray)%">
@($"{NumGray}%")
</div>
<div runat="server" id="divBlue" class="progress-bar bg-primary" style="width: @(NumBlue)%">
@($"{NumBlue}%")
</div>
</div>
<asp:HiddenField runat="server" ID="hfProdCount" />
@code {
/// <summary>
/// Conteggio dati produzione da mostrare
/// </summary>
[Parameter]
public ProdCounter CountData { get; set; } = null!;
/// <summary>
/// Numero pezzi CONFERMATI
/// </summary>
protected int NumPzConf { get; set; } = 0;
/// <summary>
/// Numero pezzi ORDINATI
/// </summary>
protected int NumPzOrd { get; set; } = 0;
/// <summary>
/// Numero pezzi PRODOTTI
/// </summary>
protected int NumPzProd { get; set; } = 0;
/// <summary>
/// Numero pezzi per display BLU
/// </summary>
protected int NumBlue { get; set; } = 0;
/// <summary>
/// Numero pezzi per display GRIGIO
/// </summary>
protected int NumGray { get; set; } = 40;
/// <summary>
/// Numero pezzi per display VERDE
/// </summary>
protected int NumGreen { get; set; } = 20;
/// <summary>
/// Numero pezzi per display GIALLO
/// </summary>
protected int NumYellow { get; set; } = 30;
protected override void OnParametersSet()
{
decimal denom = CountData.numPzProd > CountData.numPzOrd ? (decimal)CountData.numPzProd / 100 : (decimal)CountData.numPzOrd / 100;
denom = denom == 0 ? 1 : denom;
// calcolo se sono nel caso prod < ordinati o se sono andato OVER
if (CountData.numPzProd < CountData.numPzOrd)
{
nGreen = (int)Math.Floor((decimal)CountData.numPzConf / denom);
nYellow = (int)Math.Floor((decimal)(CountData.numPzProd - CountData.numPzConf) / denom);
nGray = 100 - (nGreen + nYellow);
nBlue = 0;
}
else
{
// devo verificare SE ne ho confermati meno che ordinati o meno...
if (CountData.numPzConf < CountData.numPzOrd)
{
nGreen = (int)Math.Floor((decimal)CountData.numPzConf / denom);
}
else
{
nGreen = (int)Math.Floor((decimal)CountData.numPzOrd / denom);
}
nBlue = 100 - nGreen;
nYellow = 0;
nGray = 0;
}
// disegno!
NumGreen = nGreen;
NumYellow = nYellow;
NumGray = nGray;
NumBlue = nBlue;
// base.OnParametersSet();
}
protected int nBlue = 0;
protected int nGray = 0;
protected int nGreen = 0;
protected int nYellow = 0;
/// <summary>
/// Classe gesitone conteggi produzione
/// </summary>
public class ProdCounter
{
/// <summary>
/// NUmero pezzi CONFERMATI
/// </summary>
public int numPzConf { get; set; } = 0;
/// <summary>
/// Numero pezzi ORDINATI
/// </summary>
public int numPzOrd { get; set; } = 0;
/// <summary>
/// Numero pezzi PRODOTTI
/// </summary>
public int numPzProd { get; set; } = 0;
}
}