346 lines
11 KiB
C#
346 lines
11 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_ADM.WebUserControls
|
|
{
|
|
public partial class cmp_planApprove : BaseUserControl
|
|
{
|
|
#region Protected Properties
|
|
|
|
/// <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();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
public string CodArticolo
|
|
{
|
|
get
|
|
{
|
|
return hfCodArticolo.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodArticolo.Value = value;
|
|
}
|
|
}
|
|
|
|
public string CodCliente
|
|
{
|
|
get
|
|
{
|
|
return hfCodCliente.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodCliente.Value = value;
|
|
}
|
|
}
|
|
|
|
public string CodGruppo
|
|
{
|
|
get
|
|
{
|
|
return hfCodGruppo.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodGruppo.Value = value;
|
|
}
|
|
}
|
|
|
|
public string IdxMacchina
|
|
{
|
|
get
|
|
{
|
|
return hfIdxMacchina.Value;
|
|
}
|
|
set
|
|
{
|
|
hfIdxMacchina.Value = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void calcTotali()
|
|
{
|
|
// update valori calcolati in base a selezione...
|
|
int numOrd = 0;
|
|
int QtaRem = 0;
|
|
decimal tempoMinOrd = 0;
|
|
decimal tc50p = 0;
|
|
int numPzTot = 0;
|
|
decimal tempoMinTot = 0;
|
|
Dictionary<string, int> ElArticoli = new Dictionary<string, int>();
|
|
string CodArt = "";
|
|
txtNumPz.Text = "0";
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
QtaRem = 0;
|
|
tempoMinOrd = 0;
|
|
DateTime DataRif = DateTime.Now.Date;
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
try
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblQtaRem")).Text, out QtaRem);
|
|
decimal.TryParse(((Label)riga.FindControl("lblTC50p")).Text, out tc50p);
|
|
tempoMinOrd = tc50p * QtaRem;
|
|
CodArt = ((Label)riga.FindControl("lblCodArticolo")).Text;
|
|
if (QtaRem > 0) numOrd++;
|
|
// salvo dictionary articoli...
|
|
if (ElArticoli.ContainsKey(CodArt))
|
|
{
|
|
ElArticoli[CodArt]++;
|
|
}
|
|
else
|
|
{
|
|
ElArticoli[CodArt] = 1;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
numPzTot += QtaRem;
|
|
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;
|
|
if (numOrd == 1)
|
|
{
|
|
// se visibile metto il NUM PEZZI standard
|
|
txtNumPz.Text = $"{numPzTot}";
|
|
}
|
|
divCmd.Visible = numOrd > 0;
|
|
// divConfirm.Visible = numOrd > 0;
|
|
divCreaGrp.Visible = (numOrd > 1) && (ElArticoli.Count == 1) && CodGruppo != "";
|
|
// sistemo dimensione div
|
|
divData.Attributes.Remove("class");
|
|
divCmd.Attributes.Remove("class");
|
|
if (divCmd.Visible)
|
|
{
|
|
divData.Attributes.Add("class", "col-9 pr-1");
|
|
divCmd.Attributes.Add("class", "col-3 pl-1");
|
|
}
|
|
else
|
|
{
|
|
divData.Attributes.Add("class", "col-12");
|
|
divCmd.Attributes.Add("class", "col-0");
|
|
}
|
|
ddlMacc.DataBind();
|
|
}
|
|
|
|
private void Cmp_numRow_eh_newNum(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = cmp_numRow.numRowPag;
|
|
}
|
|
|
|
private void doReset()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
raiseReset();
|
|
}
|
|
|
|
private void reportUpdate()
|
|
{
|
|
// aggiorno grView...
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
// segnalo update
|
|
raiseNewVal();
|
|
}
|
|
|
|
private void toggleVisibility()
|
|
{
|
|
divDetail.Visible = !divDetail.Visible;
|
|
tgIcon.Attributes["class"] = divDetail.Visible ? "fa fa-chevron-up" : "fa fa-chevron-down";
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <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();
|
|
}
|
|
|
|
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
calcTotali();
|
|
}
|
|
|
|
/// <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 = DataLayerObj.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
|
|
DataLayerObj.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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Approva e pianifica richieste...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtDoPlan_Click(object sender, EventArgs e)
|
|
{
|
|
int IdxPromessa = 0;
|
|
int numPzOrd = 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);
|
|
int.TryParse(txtNumPz.Text, out numPzOrd);
|
|
// approvo la promessa COPIANDOLA con eventuale variazione
|
|
DataLayerObj.taPlanRichieste.approvaRich(IdxPromessa, numPzOrd, user_std.UtSn.utente);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
// update!
|
|
reportUpdate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// comando reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
doReset();
|
|
}
|
|
|
|
protected void lbtToggle_Click(object sender, EventArgs e)
|
|
{
|
|
toggleVisibility();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
cmp_numRow.numRowPag = memLayer.ML.CRI("_righeDataGridShort") / 2;
|
|
grView.PageSize = cmp_numRow.numRowPag;
|
|
// di default NASCONDE...
|
|
//toggleVisibility();
|
|
calcTotali();
|
|
}
|
|
cmp_numRow.eh_newNum += Cmp_numRow_eh_newNum;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
calcTotali();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |