308 lines
9.2 KiB
C#
308 lines
9.2 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
|
|
namespace ES3.WebUserControls
|
|
{
|
|
public partial class mod_newPromessaODL : System.Web.UI.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
setDefaults();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Testo conferma salvataggio (create/Edit)
|
|
/// </summary>
|
|
public string testoConf
|
|
{
|
|
get
|
|
{
|
|
string answ = "Crea Promessa ODL";
|
|
if (memLayer.ML.isInSessionObject("idxProm2Edit"))
|
|
{
|
|
answ = "Edit Promessa ODL";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
public void doSelPODL()
|
|
{
|
|
// se ho una promessa da clonare copio dati da quella...
|
|
int idxProm = 0;
|
|
try
|
|
{
|
|
if (memLayer.ML.isInSessionObject("idxProm2Clone"))
|
|
{
|
|
idxProm = memLayer.ML.IntSessionObj("idxProm2Clone");
|
|
}
|
|
else if (memLayer.ML.isInSessionObject("idxProm2Edit"))
|
|
{
|
|
idxProm = memLayer.ML.IntSessionObj("idxProm2Edit");
|
|
}
|
|
// provo a selezionare
|
|
var tPODL = DataLayer.obj.taPODL.getByKey(idxProm);
|
|
if (tPODL.Rows.Count > 0)
|
|
{
|
|
var rPODL = tPODL[0];
|
|
txtSearch.Text = rPODL.CodArticolo;
|
|
ddlArticolo.DataBind();
|
|
ddlArticolo.SelectedValue = rPODL.CodArticolo;
|
|
ddlGruppi.DataBind();
|
|
ddlGruppi.SelectedValue = rPODL.CodGruppo;
|
|
txtNumPz.Text = rPODL.NumPezzi.ToString();
|
|
txtPzPallet.Text = rPODL.PzPallet.ToString();
|
|
txtPrio.Text = rPODL.Priorita.ToString();
|
|
if (memLayer.ML.cdvb("ADM_TC_MinSec"))
|
|
{
|
|
txtTCms.Text = TempiCiclo.minSec(rPODL.TCAssegnato);
|
|
}
|
|
else
|
|
{
|
|
txtTCmc.Text = rPODL.TCAssegnato.ToString("N3");
|
|
}
|
|
ddlMacchine.SelectedValue = rPODL.IdxMacchina;
|
|
txtKeyExt.Text = rPODL.KeyRichiesta;
|
|
// svuoto se ci fosse cloning......
|
|
memLayer.ML.emptySessionVal("idxProm2Clone");
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
|
|
private void setDefaults()
|
|
{
|
|
// se abilitato in config inserisce i valori defaults x insert...
|
|
if (memLayer.ML.cdvb("resetDefaultPromessaOdl"))
|
|
{
|
|
txtNumPz.Text = "1";
|
|
txtPzPallet.Text = "1";
|
|
txtPrio.Text = "1";
|
|
// in base ad impostazione mostro TC come min:sec o min.cent
|
|
divTCms.Visible = false;
|
|
divTCmc.Visible = false;
|
|
if (memLayer.ML.cdvb("ADM_TC_MinSec"))
|
|
{
|
|
divTCms.Visible = true;
|
|
txtTCms.Text = "1:00";
|
|
}
|
|
else
|
|
{
|
|
divTCmc.Visible = true;
|
|
txtTCmc.Text = "1.00";
|
|
}
|
|
memLayer.ML.emptySessionVal("idxProm2Clone");
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
}
|
|
|
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|
{
|
|
ddlArticolo.DataBind();
|
|
}
|
|
|
|
#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 Gruppo = "";
|
|
string IdxMacchina = "";
|
|
string KeyReq = "";
|
|
int numPezzi = 0;
|
|
int pzPallet = 1;
|
|
decimal TCiclo = 0;
|
|
bool attiv = false;
|
|
int prio = 0;
|
|
|
|
try
|
|
{
|
|
CodArticolo = ddlArticolo.SelectedValue;
|
|
Gruppo = ddlGruppi.SelectedValue;
|
|
IdxMacchina = ddlMacchine.SelectedValue;
|
|
KeyReq = txtKeyExt.Text.Trim();
|
|
//IdxMacchina = txtMacchina.Text.Trim();
|
|
// se IdxMacchina è vuoto metto null...
|
|
if (IdxMacchina == "")
|
|
{
|
|
IdxMacchina = "0";
|
|
}
|
|
numPezzi = Convert.ToInt32(txtNumPz.Text.Trim());
|
|
|
|
if (memLayer.ML.cdvb("ADM_TC_MinSec"))
|
|
{
|
|
string[] sTC = txtTCms.Text.Trim().Split(':');
|
|
int numMin = 0;
|
|
int numSec = 0;
|
|
int.TryParse(sTC[0], out numMin);
|
|
int.TryParse(sTC[1], out numSec);
|
|
TCiclo = numMin + ((decimal)numSec) / 60;
|
|
}
|
|
else
|
|
{
|
|
decimal.TryParse(txtTCmc.Text.Replace(".", ","), out TCiclo);
|
|
}
|
|
pzPallet = Convert.ToInt32(txtPzPallet.Text.Trim());
|
|
attiv = chkAttiv.Checked;
|
|
int.TryParse(txtPrio.Text, out prio);
|
|
|
|
// controllo se sono in modalità EDIT faccio un update, altrimenti faccio un INSERT...
|
|
if (memLayer.ML.isInSessionObject("idxProm2Edit"))
|
|
{
|
|
int idxProm = memLayer.ML.IntSessionObj("idxProm2Edit");
|
|
DataLayer.obj.taPODL.updateQuery(KeyReq, KeyReq, attiv, CodArticolo, Gruppo, IdxMacchina, numPezzi, TCiclo, DateTime.Now, prio, pzPallet, idxProm);
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
else
|
|
{
|
|
// 2018.09.25 --> inserisco PROMESSA ODL
|
|
//MapoDb.DataLayer.obj.taODL.InsertQuery(CodArticolo, MapoDb.DataLayer.MatrOpr, IdxMacchina, numPezzi, TCiclo, pzPallet, chkToAs400.Checked, txtCommessa.Text.Trim());
|
|
DataLayer.obj.taPODL.insertQuery(KeyReq, KeyReq, attiv, CodArticolo, Gruppo, IdxMacchina, numPezzi, TCiclo, DateTime.Now, prio, pzPallet, "");
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Non sono riuscito ad inserire la PromessaODL con i seguenti parametri: {0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8}{9}{10}", KeyReq, attiv, CodArticolo, IdxMacchina, numPezzi, TCiclo, prio, pzPallet, memLayer.ML.IntSessionObj("idxProm2Edit"), Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
// 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)
|
|
{
|
|
memLayer.ML.emptySessionVal("idxProm2Clone");
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
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)
|
|
{
|
|
#if false
|
|
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;
|
|
#endif
|
|
}
|
|
/// <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>
|
|
/// selezione impianto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlGruppi_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ddlMacchine.DataBind();
|
|
}
|
|
|
|
/// <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
|
|
txtNumPz.Text = rigaOdl.NumPezzi.ToString();
|
|
if (memLayer.ML.cdvb("ADM_TC_MinSec"))
|
|
{
|
|
txtTCms.Text = TempiCiclo.minSec(rigaOdl.TCAssegnato);
|
|
}
|
|
else
|
|
{
|
|
txtTCmc.Text = rigaOdl.TCAssegnato.ToString("N3");
|
|
}
|
|
txtPzPallet.Text = rigaOdl.PzPallet.ToString();
|
|
}
|
|
}
|
|
} |