Files
MoonPro.net/MP-ADM/WebUserControls/mod_newOdl.ascx.cs
T
2018-10-27 11:58:26 +02:00

158 lines
4.5 KiB
C#

using SteamWare;
using System;
namespace MoonPro_site.WebUserControls
{
public partial class mod_newOdl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
#region gestione eventi
public event EventHandler eh_nuovoValore;
#endregion
/// <summary>
/// conferma inserimento TC
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOk_Click(object sender, EventArgs e)
{
// controllo se ho tutti i valori ok...
string CodArticolo = "";
string IdxMacchina = "";
int numPezzi = 0;
int pzPallet = 1;
decimal TCiclo = 0;
try
{
CodArticolo = ddlArticolo.SelectedValue;
IdxMacchina = ddlMacchine.SelectedValue;
//IdxMacchina = txtMacchina.Text.Trim();
// se IdxMacchina è vuoto metto null...
if (IdxMacchina == "")
{
IdxMacchina = "0";
}
numPezzi = Convert.ToInt32(txtPezzi.Text.Trim());
TCiclo = Convert.ToDecimal(txtTempoCiclo.Text.Trim().Replace(".", ","));
pzPallet = Convert.ToInt32(txtPzPallet.Text.Trim());
MapoDb.DataLayer.obj.taODL.InsertQuery(CodArticolo, MapoDb.DataLayer.MatrOpr, IdxMacchina, numPezzi, TCiclo, pzPallet, chkToAs400.Checked, txtCommessa.Text.Trim());
}
catch
{
logger.lg.scriviLog(string.Format("Non sono riuscito ad inserire l'ODL con i seguenti parametri: {0} | {1} | {2} | {3} | {4}", CodArticolo, IdxMacchina, numPezzi, TCiclo, pzPallet), tipoLog.ERROR);
}
// segnalo update
if (eh_nuovoValore != null)
{
eh_nuovoValore(this, new EventArgs());
}
}
/// <summary>
/// annullamento inserimento
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCancel_Click(object sender, EventArgs e)
{
if (eh_nuovoValore != null)
{
eh_nuovoValore(this, new EventArgs());
}
}
/// <summary>
/// aggiorno label min e centesimi
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtTempoCiclo_TextChanged(object sender, EventArgs e)
{
string text = "";
string txtMinCent = txtTempoCiclo.Text.Trim().Replace(".", ",");
int min = 0;
int sec = 0;
try
{
// cerco di convertire in min/sec
min = Convert.ToInt32(Math.Floor(Convert.ToDouble(txtMinCent)));
sec = Convert.ToInt32((Convert.ToDouble(txtMinCent) - min) * 60);
text = string.Format("{0}:{1:00}", min, sec);
}
catch
{ }
lblMinSec.Text = text;
}
/// <summary>
/// selezione articolo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlArticolo_SelectedIndexChanged(object sender, EventArgs e)
{
showLastTimeAndNote();
}
/// <summary>
/// mostro elenco ultimi 5 tempi e note...
/// </summary>
private void showLastTimeAndNote()
{
// update tempi ciclo!
grViewTempi.DataBind();
}
/// <summary>
/// selezione impianto
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlMacchine_SelectedIndexChanged(object sender, EventArgs e)
{
showLastTimeAndNote();
}
/// <summary>
/// reset della selezione
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// resetta la selezione dei valori in caso di modifiche su altri controlli
/// </summary>
public void resetSelezione()
{
grViewTempi.SelectedIndex = -1;
grViewTempi.DataBind();
}
/// <summary>
/// evento selezione riga: salvo tempo e qta nei campi input...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grViewTempi_SelectedIndexChanged(object sender, EventArgs e)
{
// ricavo i dati selezionati
int idxOdl = 0;
try
{
idxOdl = Convert.ToInt32(grViewTempi.SelectedValue);
}
catch
{ }
MapoDb.DS_ProdTempi.ODLRow rigaOdl = MapoDb.DataLayer.obj.taODL.getByIdx(idxOdl, false)[0];
// precompilo dati pezzi/tempi
txtPezzi.Text = rigaOdl.NumPezzi.ToString();
txtTempoCiclo.Text = rigaOdl.TCAssegnato.ToString("0.00");
txtPzPallet.Text = rigaOdl.PzPallet.ToString();
}
}
}