222 lines
5.3 KiB
C#
222 lines
5.3 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_regScarti : System.Web.UI.UserControl
|
|
{
|
|
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_newVal;
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_reset;
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
checkAll();
|
|
}
|
|
}
|
|
|
|
private void checkAll()
|
|
{
|
|
fixData();
|
|
checkOdl();
|
|
lblOut.Text = "";
|
|
switchBtnConferma(true);
|
|
lbtShowScarti.Visible = odlOk;
|
|
lblConfScarti.Visible = !odlOk;
|
|
}
|
|
|
|
private void fixData()
|
|
{
|
|
DateTime adesso = DateTime.Now;
|
|
txtData.Text = adesso.ToString("yyyy-MM-dd");
|
|
txtOra.Text = adesso.ToString("HH:mm");
|
|
numPzScarto = 1;
|
|
}
|
|
/// <summary>
|
|
/// Num pezzi scarto
|
|
/// </summary>
|
|
protected int numPzScarto
|
|
{
|
|
set
|
|
{
|
|
txtNumPz.Text = value.ToString();
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(txtNumPz.Text, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifica se abbia un ODL ATTIVO
|
|
/// </summary>
|
|
private void checkOdl()
|
|
{
|
|
lbtShowScarti.Visible = odlOk;
|
|
lblConfScarti.Visible = !odlOk;
|
|
lblMancaODL.Visible = !odlOk;
|
|
}
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
|
|
/// </summary>
|
|
/// <summary>
|
|
/// restituisce css disabled SE odl NON OK...
|
|
/// </summary>
|
|
public string cssBtnConf
|
|
{
|
|
get
|
|
{
|
|
return odlOk ? "" : "disabled";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifica ODL OK (ovvero caricato x macchina...)
|
|
/// </summary>
|
|
public bool odlOk
|
|
{
|
|
get
|
|
{
|
|
bool answ = true;
|
|
// carico i dati preliminari: ODL
|
|
int idxOdl = 0; // userò ODL del turno
|
|
try
|
|
{
|
|
idxOdl = DataLayer.obj.taODL.getByMacchinaAperto(idxMacchina)[0].IdxODL;
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore a recuperare ODL per la macchina {0}", idxMacchina), tipoLog.ERROR);
|
|
}
|
|
// se ODL > 0 è ok!!!
|
|
answ = (idxOdl > 0);
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
string answ = memLayer.ML.StringSessionObj("IdxMacchina");
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// cambio stato visibilità pannello e testo button
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtShowContr_Click(object sender, EventArgs e)
|
|
{
|
|
switchBtnConferma(!divDetail.Visible);
|
|
}
|
|
/// <summary>
|
|
/// determina comportamento btn conferma
|
|
/// </summary>
|
|
private void switchBtnConferma(bool showConf)
|
|
{
|
|
divDetail.Visible = showConf;
|
|
if (showConf)
|
|
{
|
|
lblShowScarti.Text = "Nascondi Registrazione SCARTI";
|
|
}
|
|
else
|
|
{
|
|
lblShowScarti.Text = "Mostra Registrazione SCARTI";
|
|
// sollevo evento!
|
|
if (eh_reset != null)
|
|
{
|
|
eh_reset(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void resetControlli()
|
|
{
|
|
txtNote.Text = "";
|
|
// nascondo!
|
|
switchBtnConferma(false);
|
|
}
|
|
/// <summary>
|
|
/// salvo produzione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtSalva_Click(object sender, EventArgs e)
|
|
{
|
|
salvaRegScarti("ND");
|
|
}
|
|
/// <summary>
|
|
/// Effettua salvataggio in registro scarti
|
|
/// </summary>
|
|
private void salvaRegScarti(string causale)
|
|
{
|
|
// salvo registrazione scarto...
|
|
DateTime dataRif = DateTime.Now;
|
|
try
|
|
{
|
|
// ricompongo data dai 2 controlli
|
|
DateTime dateOnly;
|
|
DateTime timeOnly;
|
|
DateTime.TryParse(txtData.Text, out dateOnly);
|
|
DateTime.TryParse(txtOra.Text, out timeOnly);
|
|
dataRif = dateOnly.Add(timeOnly.TimeOfDay);
|
|
}
|
|
catch
|
|
{ }
|
|
DataLayer.obj.taRS.insertQuery(idxMacchina, dataRif, causale, numPzScarto, txtNote.Text.Trim(), DataLayer.MatrOpr);
|
|
// sollevo evento!
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
resetControlli();
|
|
}
|
|
|
|
/// <summary>
|
|
/// rimanda alla pagina di dettaglio della macchina scelta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void hlRegistra_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lnkbtn = (LinkButton)sender;
|
|
string causale = "";
|
|
try
|
|
{
|
|
causale = lnkbtn.CommandArgument;
|
|
}
|
|
catch
|
|
{ }
|
|
// se vuoto metto ND...
|
|
causale = (causale == "") ? "ND" : causale;
|
|
salvaRegScarti(causale);
|
|
// sollevo evento!
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
} |