313 lines
8.4 KiB
C#
313 lines
8.4 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace ES3.WebUserControls
|
|
{
|
|
|
|
public partial class mod_planCreate : SteamWare.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// di default NASCONDE...
|
|
//toggleVisibility();
|
|
calcTotali();
|
|
}
|
|
}
|
|
public string CodGruppo
|
|
{
|
|
get
|
|
{
|
|
return hfCodGruppo.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodGruppo.Value = value;
|
|
}
|
|
}
|
|
public string CodArticolo
|
|
{
|
|
get
|
|
{
|
|
return hfCodArticolo.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodArticolo.Value = value;
|
|
}
|
|
}
|
|
public string IdxMacchina
|
|
{
|
|
get
|
|
{
|
|
return hfIdxMacchina.Value;
|
|
}
|
|
set
|
|
{
|
|
hfIdxMacchina.Value = value;
|
|
}
|
|
}
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
calcTotali();
|
|
}
|
|
/// <summary>
|
|
/// seleziona/deseleziona le righe indicate...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelAll_Click(object sender, EventArgs e)
|
|
{
|
|
// seleziono tutti i valori visibili nel datagrid
|
|
CheckBox chkbox = ((CheckBox)sender);
|
|
bool isChecked = chkbox.Checked;
|
|
if (!isChecked)
|
|
{
|
|
chkbox.ToolTip = traduci("btnSelAll");
|
|
}
|
|
else
|
|
{
|
|
chkbox.ToolTip = traduci("btnDeselAll");
|
|
}
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
|
|
}
|
|
calcTotali();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// comando reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
doReset();
|
|
}
|
|
private void doReset()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
raiseEvent(SteamWare.ucEvType.Reset);
|
|
}
|
|
|
|
protected void lbtToggle_Click(object sender, EventArgs e)
|
|
{
|
|
toggleVisibility();
|
|
}
|
|
|
|
private void toggleVisibility()
|
|
{
|
|
divDetail.Visible = !divDetail.Visible;
|
|
tgIcon.Attributes["class"] = divDetail.Visible ? "fa fa-chevron-up" : "fa fa-chevron-down";
|
|
}
|
|
|
|
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
calcTotali();
|
|
}
|
|
|
|
private void calcTotali()
|
|
{
|
|
// update valori calcolati in base a selezione...
|
|
int numOrd = 0;
|
|
int numPzOrd = 0;
|
|
decimal tempoMinOrd = 0;
|
|
decimal tc50p = 0;
|
|
int numPzTot = 0;
|
|
decimal tempoMinTot = 0;
|
|
Dictionary<string, int> ElArticoli = new Dictionary<string, int>();
|
|
string CodArt = "";
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
numPzOrd = 0;
|
|
tempoMinOrd = 0;
|
|
DateTime DataRif = DateTime.Now.Date;
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
try
|
|
{
|
|
int.TryParse(((TextBox)riga.FindControl("txtNumPezzi")).Text, out numPzOrd);
|
|
decimal.TryParse(((Label)riga.FindControl("lblTC50p")).Text, out tc50p);
|
|
tempoMinOrd = tc50p * numPzOrd;
|
|
CodArt = ((Label)riga.FindControl("lblCodArticolo")).Text;
|
|
if (numPzOrd > 0) numOrd++;
|
|
// salvo dictionary articoli...
|
|
if (ElArticoli.ContainsKey(CodArt))
|
|
{
|
|
ElArticoli[CodArt]++;
|
|
}
|
|
else
|
|
{
|
|
ElArticoli[CodArt] = 1;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
numPzTot += numPzOrd;
|
|
tempoMinTot += tempoMinOrd;
|
|
}
|
|
}
|
|
//lblNumPzTot.Text = $"{numPzTot:N0}";
|
|
numPzCalc = numPzTot;
|
|
lblOreTot.Text = $"{tempoMinTot / 60:N2}";
|
|
// controllo SE abilitare il crea gruppo o split...
|
|
divSplitOdl.Visible = numOrd == 1;
|
|
divConfirm.Visible = numOrd > 0;
|
|
divCreaGrp.Visible = (numOrd > 1) && (ElArticoli.Count == 1) && CodGruppo != "";
|
|
ddlMacc.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// Num pz totali calcolati
|
|
/// </summary>
|
|
protected int numPzCalc
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfNumPzTot.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
lblNumPzTot.Text = $"{value:N0}";
|
|
hfNumPzTot.Value = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Approva e pianifica richeiste...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtDoPlan_Click(object sender, EventArgs e)
|
|
{
|
|
int IdxPromessa = 0;
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
DateTime DataRif = DateTime.Now.Date;
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
try
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
// approvo la promessa COPIANDOLA
|
|
DataLayer.obj.taPlanRichieste.approvaRich(IdxPromessa, SteamWare.user_std.UtSn.utente);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
// update!
|
|
reportUpdate();
|
|
}
|
|
|
|
private void reportUpdate()
|
|
{
|
|
// aggiorno grView...
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
// segnalo update
|
|
raiseEvent(SteamWare.ucEvType.ReqUpdateParent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiama stored per creare NUOVO PODL, chiudere i selezionati, registrare associazione,...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtCreaGrp_Click(object sender, EventArgs e)
|
|
{
|
|
int IdxPromessa = 0;
|
|
int IdxPromessaOUT = 0;
|
|
int QtyEv = 0;
|
|
if (numPzCalc > 0)
|
|
{
|
|
// in primis CREA la richiesta raggruppata
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
DateTime DataRif = DateTime.Now.Date;
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
try
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
break;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
var resultIdxOut = DataLayer.obj.taPlanRichieste.creaGrp(IdxPromessa, SteamWare.user_std.UtSn.utente, ddlMacc.SelectedValue, CodGruppo, numPzCalc);
|
|
// se ho trovato una promessaOUT...
|
|
int.TryParse(resultIdxOut.ToString(), out IdxPromessaOUT);
|
|
if (IdxPromessaOUT > 0)
|
|
{
|
|
// poi alloca tutte le istanze alla richiesta....
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
DateTime DataRif = DateTime.Now.Date;
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
try
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
int.TryParse(((TextBox)riga.FindControl("txtNumPezzi")).Text, out QtyEv);
|
|
// approvo la promessa COPIANDOLA
|
|
DataLayer.obj.taPlanRichieste.allocaIst(IdxPromessa, IdxPromessaOUT, QtyEv, SteamWare.user_std.UtSn.utente, "GRP");
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in CreaGrp:{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// update!
|
|
reportUpdate();
|
|
}
|
|
|
|
protected void txtNumPezzi_TextChanged(object sender, EventArgs e)
|
|
{
|
|
calcTotali();
|
|
}
|
|
|
|
/// <summary>
|
|
/// cambia il colore del campo secondo la due date indicata
|
|
/// rosso: in ritardo (scaduta)
|
|
/// verde: > 2 week
|
|
/// giallo: altrimenti
|
|
/// </summary>
|
|
/// <param name="dueDate"></param>
|
|
/// <returns></returns>
|
|
public string cssDueDate(object dueDate)
|
|
{
|
|
DateTime oggi = DateTime.Today;
|
|
DateTime dataRif = oggi.AddDays(-1);
|
|
DateTime.TryParse(dueDate.ToString(), out dataRif);
|
|
string answ = "text-secondary";
|
|
if (dataRif < oggi)
|
|
{
|
|
answ = "text-danger";
|
|
}
|
|
else if (dataRif < oggi.AddDays(14))
|
|
{
|
|
answ = "text-warning";
|
|
}
|
|
else
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
}
|
|
} |