225 lines
6.4 KiB
C#
225 lines
6.4 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_insComm : BaseUserControl
|
|
{
|
|
/// <summary>
|
|
/// registrato nuovo valore
|
|
/// </summary>
|
|
public event EventHandler eh_inserting;
|
|
/// <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)
|
|
{
|
|
|
|
}
|
|
|
|
protected void lbtAddCommento_Click(object sender, EventArgs e)
|
|
{
|
|
dataOraEv = DateTime.Now;
|
|
showInsert();
|
|
}
|
|
|
|
protected void showInsert()
|
|
{
|
|
fixPanels(false, true, false);
|
|
// imposto valori
|
|
txtDate.Text = dataOraEv.ToString("yyyy-MM-ddTHH:mm");
|
|
#if false
|
|
txtTime.Text = dataOraEv.ToString("HH:mm");
|
|
#endif
|
|
txtCommento.Text = "";
|
|
// sollevo evento!
|
|
if (eh_inserting != null)
|
|
{
|
|
eh_inserting(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
private void fixPanels(bool showBtn, bool showComm, bool showEventi)
|
|
{
|
|
// mostro dati da compilare e nascondo button...
|
|
pnlButtons.Visible = showBtn;
|
|
pnlDate.Visible = !showBtn;
|
|
}
|
|
|
|
protected void lbtAnnulla_Click(object sender, EventArgs e)
|
|
{
|
|
// tolgo da sessione dataOra corrente...
|
|
memLayer.ML.emptySessionVal("dataOraEv");
|
|
fixPanels(true, false, false);
|
|
// sollevo evento!
|
|
if (eh_reset != null)
|
|
{
|
|
eh_reset(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
protected void lbtSalva_Click(object sender, EventArgs e)
|
|
{
|
|
salvaCommento();
|
|
}
|
|
/// <summary>
|
|
/// effettua salvataggio del commento indicato (data/ora e testo)
|
|
/// </summary>
|
|
public void salvaCommento()
|
|
{
|
|
// salvo!
|
|
string idxMacchina = memLayer.ML.StringSessionObj("idxMacchina");
|
|
int idxTipo = memLayer.ML.CRI("idxTipoCommento");
|
|
string CodArticolo = "ND";
|
|
try
|
|
{
|
|
// cerco di recuperare CodArticolo da evento
|
|
CodArticolo = DataLayerObj.taODL.getByMacchinaPeriodo(idxMacchina, dataOraEv, dataOraEv)[0].CodArticolo;
|
|
}
|
|
catch
|
|
{
|
|
CodArticolo = "ND";
|
|
}
|
|
string commento = txtCommento.Text.Trim();
|
|
// elimino eventuale record precedente
|
|
try
|
|
{
|
|
DataLayerObj.taEventi.DeleteQuery(idxMacchina, dataOraEv);
|
|
}
|
|
catch
|
|
{ }
|
|
// inserisco nuovo record
|
|
DataLayerObj.taEventi.Insert(idxMacchina, dataOraEv, idxTipo, CodArticolo, commento, DataLayerObj.MatrOpr, "-");
|
|
doUpdate();
|
|
}
|
|
|
|
private void doUpdate()
|
|
{
|
|
// aggiorno vista...
|
|
fixPanels(true, false, false);
|
|
if (eh_newVal != null)
|
|
{
|
|
eh_newVal(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
protected void txtDate_TextChanged(object sender, EventArgs e)
|
|
{
|
|
salvaDataOra();
|
|
}
|
|
|
|
private void salvaDataOra()
|
|
{
|
|
DateTime inizioStato = DateTime.Now;
|
|
try
|
|
{
|
|
#if false
|
|
DateTime ora = Convert.ToDateTime(txtTime.Text);
|
|
inizioStato = Convert.ToDateTime(txtDate.Text).AddHours(ora.Hour).AddMinutes(ora.Minute);
|
|
#endif
|
|
DateTime.TryParse(txtDate.Text, out inizioStato);
|
|
}
|
|
catch
|
|
{ }
|
|
dataOraEv = inizioStato;
|
|
}
|
|
|
|
protected void txtTime_TextChanged(object sender, EventArgs e)
|
|
{
|
|
salvaDataOra();
|
|
}
|
|
|
|
public void caricaCommento()
|
|
{
|
|
string idxMacchina = memLayer.ML.StringSessionObj("idxMacchina");
|
|
DS_applicazione.EventListRow riga = null;
|
|
DateTime inizioStato = DateTime.Now;
|
|
try
|
|
{
|
|
inizioStato = Convert.ToDateTime(memLayer.ML.objSessionObj("inizioStato"));
|
|
dataOraEv = inizioStato;
|
|
riga = DataLayerObj.taEventi.GetByMacchinaPeriodo(idxMacchina, inizioStato, inizioStato)[0];
|
|
txtDate.Text = riga.InizioStato.ToString("yyyy-MM-ddTHH:mm");
|
|
txtCommento.Text = riga.Value;
|
|
}
|
|
catch
|
|
{ }
|
|
fixPanels(false, true, false);
|
|
}
|
|
/// <summary>
|
|
/// determian se mostrare pulsante salva (non serve x dichiarazioni fermata)
|
|
/// </summary>
|
|
public bool showSalva
|
|
{
|
|
set
|
|
{
|
|
lbtSalva.Visible = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta la label x inserimento commento singolo / con dichiarazione fermata
|
|
/// </summary>
|
|
public string labelAddCommento
|
|
{
|
|
set
|
|
{
|
|
lblAddComm.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta data/ora del commento
|
|
/// </summary>
|
|
public DateTime dataEv
|
|
{
|
|
set
|
|
{
|
|
// salvo in sessione dataOra corrente...
|
|
dataOraEv = value;
|
|
// mostro insert!
|
|
showInsert();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// commento inserito
|
|
/// </summary>
|
|
public string commento
|
|
{
|
|
get
|
|
{
|
|
return txtCommento.Text.Trim();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// data-ora selezionata
|
|
/// </summary>
|
|
protected DateTime dataOraEv
|
|
{
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("dataOraEv", value);
|
|
}
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Now;
|
|
try
|
|
{
|
|
answ = Convert.ToDateTime(memLayer.ML.objSessionObj("dataOraEv"));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
}
|
|
} |