199 lines
7.2 KiB
C#
199 lines
7.2 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
public partial class mod_insertRichiesta : System.Web.UI.UserControl
|
|
{
|
|
#region eventi
|
|
|
|
public event EventHandler eh_newReq;
|
|
public event EventHandler eh_done;
|
|
|
|
#endregion
|
|
|
|
protected bool _causVis = false;
|
|
/// <summary>
|
|
/// determina la visibilità del panel causali
|
|
/// </summary>
|
|
public bool causaliVisibili
|
|
{
|
|
get
|
|
{
|
|
return _causVis;
|
|
}
|
|
set
|
|
{
|
|
_causVis = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// avvio controllo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
traduciObj();
|
|
setFixedVal();
|
|
fixVisibPnl();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta i valori calcolati e fissi...
|
|
/// </summary>
|
|
private void setFixedVal()
|
|
{
|
|
// recupero valori di riferimento
|
|
int shift = memLayer.ML.confReadInt("shiftTurno");
|
|
int durataTurno = memLayer.ML.confReadInt("durataTurno");
|
|
int turno = Convert.ToInt32(Math.Ceiling((double)Convert.ToDouble(DateTime.Now.AddHours(-shift + 1).Hour) / durataTurno));
|
|
int delay = memLayer.ML.confReadInt("defaultDelay");
|
|
// inserisco valori di default
|
|
//txtDataOra.Text = string.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now);
|
|
//txtDataLav.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now.AddHours(-shift + 1));
|
|
txtDataOra.Text = DateTime.Now.ToString(memLayer.ML.CRS("ddMMyyyyHHmm"));
|
|
txtDataLav.Text = DateTime.Now.AddHours(-shift + 1).ToString(memLayer.ML.CRS("ddMMyyyy"));
|
|
txtTurnoLav.Text = turno.ToString();
|
|
mod_dataOra1.valore = DateTime.Now.AddMinutes(-delay);
|
|
chkImpFermo.Checked = false;
|
|
}
|
|
/// <summary>
|
|
/// sistema la visibilità dei controlli
|
|
/// </summary>
|
|
private void fixVisibPnl()
|
|
{
|
|
divCausali.Visible = _causVis;
|
|
}
|
|
/// <summary>
|
|
/// traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
/// <summary>
|
|
/// sistema le labels
|
|
/// </summary>
|
|
private void traduciObj()
|
|
{
|
|
lblTitolo.Text = traduci("lblInsRichiestaMtz");
|
|
lblDataOra.Text = traduci("lblDataOraRich");
|
|
lblDataLav.Text = traduci("lblDataLav");
|
|
lblTurnoLav.Text = traduci("lblTurnoLav");
|
|
btnSend.Text = traduci("btnInviaRichiesta");
|
|
lblImpianto.Text = traduci("lblImpianto");
|
|
lblMacchina.Text = traduci("lblMacchina");
|
|
lblDescrGuasto.Text = traduci("lblDescrGuasto");
|
|
lblDettagliGuasto.Text = traduci("lblDettagliGuasto");
|
|
lblMatr.Text = traduci("lblMatr");
|
|
lblPrior.Text = traduci("lblPrior");
|
|
lblFermaDalleData.Text = traduci("lblFermaDalle");
|
|
lblAmbito.Text = traduci("lblAmbito");
|
|
lblTipoGuasto.Text = traduci("lblTipoGuasto");
|
|
chkImpFermo.Text = traduci("chkImpFermo");
|
|
// setup stringhe rimando link
|
|
lnkbInsertNewReq.Text = traduci("lnkbInsertNewReq");
|
|
lnkGoToReqList.Text = traduci("lnkGoToReqList");
|
|
lblEsitoInserimento.Text = traduci("lblEsitoInserimento");
|
|
// setup stringhe validazione
|
|
valSummary.HeaderText = traduci("errori");
|
|
rfvReparto.ErrorMessage = string.Format("{0}: {1}", traduci("campoRichiesto"), traduci("reparto"));
|
|
rfvMacchina.ErrorMessage = string.Format("{0}: {1}", traduci("campoRichiesto"), traduci("macchina"));
|
|
rfvMatr.ErrorMessage = string.Format("{0}: {1}", traduci("campoRichiesto"), traduci("matricola"));
|
|
rfvCausali.ErrorMessage = string.Format("{0}: {1}", traduci("campoRichiesto"), traduci("causali"));
|
|
rfvDescrizione.ErrorMessage = string.Format("{0}: {1}", traduci("campoRichiesto"), traduci("descrizione"));
|
|
}
|
|
/// <summary>
|
|
/// aggiorna elenco macchine selezionato impianto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void listImpianti_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// aggiorno altro selettore...
|
|
listMacchine.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// salva ed invia richeista
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSend_Click(object sender, EventArgs e)
|
|
{
|
|
// salvare valori...
|
|
int? numReq = 0;
|
|
try
|
|
{
|
|
// sistemo i valori
|
|
// 2015.02.16 fix datetime!!!
|
|
//DateTime richiesta = Convert.ToDateTime(txtDataOra.Text.Trim());
|
|
//DateTime dataLav = Convert.ToDateTime(txtDataLav.Text.Trim());
|
|
|
|
DateTime richiesta = WebGimUtils.convDate(txtDataOra.Text.Trim(), memLayer.ML.CRS("ddMMyyyy"), memLayer.ML.CRS("culture"), true);
|
|
DateTime dataLav = WebGimUtils.convDate(txtDataLav.Text.Trim(), memLayer.ML.CRS("ddMMyyyy"), memLayer.ML.CRS("culture"));
|
|
|
|
DateTime inizioGuasto = mod_dataOra1.valore;
|
|
if (memLayer.ML.confReadInt("_logLevel") > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("richiesta: {0} -> {1}", txtDataOra.Text, richiesta));
|
|
logger.lg.scriviLog(string.Format("dataLav: {0} -> {1}", txtDataLav.Text, dataLav));
|
|
logger.lg.scriviLog(string.Format("inizioGuasto: {0}", mod_dataOra1.valore));
|
|
}
|
|
int turno = Convert.ToInt32(txtTurnoLav.Text);
|
|
string matr = txtMatr.Text.Trim();
|
|
int idxAmbito = Convert.ToInt32(ddlAmbito.SelectedValue);
|
|
int idxPrior = Convert.ToInt32(ddlPrior.SelectedValue);
|
|
bool isFermo = chkImpFermo.Checked;
|
|
int idxTipo = Convert.ToInt32(ddlTipo.SelectedValue);
|
|
int idxImpianto = Convert.ToInt32(listImpianti.SelectedValue);
|
|
int idxMacchina = Convert.ToInt32(listMacchine.SelectedValue);
|
|
string descrizione = txtDescrizione.Text.Trim();
|
|
int idxCausale = 1;
|
|
// cerco se ci sia un altro valore selezionato...
|
|
try
|
|
{
|
|
idxCausale = Convert.ToInt32(listCausali.SelectedValue);
|
|
}
|
|
catch
|
|
{ }
|
|
if (memLayer.ML.confReadInt("_logLevel") > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("stp_IntMtz_insRichiesta, valori: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9} | {10} | {11} | {12} | {13} | {14}", richiesta, dataLav, turno, matr, inizioGuasto, idxAmbito, idxPrior, isFermo, idxTipo, idxImpianto, idxMacchina, descrizione, idxCausale, false, 0));
|
|
}
|
|
// stored inserimento!
|
|
TA_app.obj.taInterventiMtz.insRichiesta(richiesta, dataLav, turno, matr, inizioGuasto, idxAmbito, idxPrior, isFermo, idxTipo, idxImpianto, idxMacchina, descrizione, idxCausale, false, 0, ref numReq);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog("Errore inserimento nuova richiesta!", tipoLog.ERROR);
|
|
logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION);
|
|
}
|
|
//poi mostrare pnl richiesta con "ticket" generato + link x vedere elenco oppure nuova...
|
|
pnlMain_InsRichiesta.Visible = false;
|
|
pnlMain_ShowTicket.Visible = true;
|
|
lblNumRichInserted.Text = string.Format("{0} <b>{1}</b>", traduci("newReqInserted"), (int)numReq);
|
|
if (eh_done != null)
|
|
{
|
|
eh_done(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// inverte visibilità pannelli
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkbtnInsertNewReq_Click(object sender, EventArgs e)
|
|
{
|
|
pnlMain_InsRichiesta.Visible = true;
|
|
pnlMain_ShowTicket.Visible = false;
|
|
if (eh_newReq != null)
|
|
{
|
|
eh_newReq(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|