311 lines
11 KiB
C#
311 lines
11 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Web.UI;
|
|
|
|
namespace MP_ADM.WebUserControls
|
|
{
|
|
public partial class mod_newPromessaODL : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
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";
|
|
txtDueDate.Text = $"{DateTime.Today}";
|
|
// 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.0000";
|
|
}
|
|
memLayer.ML.emptySessionVal("idxProm2Clone");
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// mostro elenco ultimi 5 tempi e note...
|
|
/// </summary>
|
|
private void showLastTimeAndNote()
|
|
{
|
|
// update tempi ciclo!
|
|
grViewTempi.DataBind();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <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");
|
|
raiseNewVal();
|
|
}
|
|
|
|
/// <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;
|
|
DateTime dueDate = DateTime.Today;
|
|
|
|
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
|
|
{
|
|
TCiclo= decimal.Parse(txtTCmc.Text, CultureInfo.InvariantCulture);
|
|
}
|
|
pzPallet = Convert.ToInt32(txtPzPallet.Text.Trim());
|
|
attiv = chkAttiv.Checked;
|
|
int.TryParse(txtPrio.Text, out prio);
|
|
DateTime.TryParse(txtDueDate.Text, out dueDate);
|
|
|
|
// controllo se sono in modalità EDIT faccio un update, altrimenti faccio un INSERT...
|
|
if (memLayer.ML.isInSessionObject("idxProm2Edit"))
|
|
{
|
|
int idxProm = memLayer.ML.IntSessionObj("idxProm2Edit");
|
|
DataLayerObj.taPODL.updateQuery(KeyReq, KeyReq, attiv, CodArticolo, Gruppo, IdxMacchina, numPezzi, TCiclo, dueDate, prio, pzPallet, idxProm);
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
else
|
|
{
|
|
// 2018.09.25 --> inserisco PROMESSA ODL
|
|
//MapoDb.DataLayerObj.taODL.InsertQuery(CodArticolo, MapoDb.DataLayer.MatrOpr, IdxMacchina, numPezzi, TCiclo, pzPallet, chkToAs400.Checked, txtCommessa.Text.Trim());
|
|
DataLayerObj.taPODL.insertQuery(KeyReq, KeyReq, attiv, CodArticolo, Gruppo, IdxMacchina, numPezzi, TCiclo, dueDate, prio, pzPallet, "");
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Non sono riuscito ad inserire la PromessaODL con i seguenti parametri: {KeyReq} | {attiv} | {CodArticolo} | {IdxMacchina} | {numPezzi} | {TCiclo} | {prio} | {pzPallet} | {dueDate} | {memLayer.ML.IntSessionObj("idxProm2Edit")}{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
memLayer.ML.emptySessionVal("idxProm2Edit");
|
|
}
|
|
// segnalo update
|
|
raiseNewVal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// selezione articolo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlArticolo_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>
|
|
/// selezione impianto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlMacchine_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
showLastTimeAndNote();
|
|
}
|
|
|
|
/// <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
|
|
{ }
|
|
DS_ProdTempi.ODLRow rigaOdl = DataLayerObj.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("N4", CultureInfo.InvariantCulture);
|
|
}
|
|
txtPzPallet.Text = rigaOdl.PzPallet.ToString();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
setDefaults();
|
|
}
|
|
}
|
|
|
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|
{
|
|
ddlArticolo.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// aggiorno label min e centesimi
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtTempoCiclo_TextChanged(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
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 = DataLayerObj.taPODL.getByKey(idxProm);
|
|
if (tPODL.Rows.Count > 0)
|
|
{
|
|
var rPODL = tPODL[0];
|
|
txtSearch.Text = rPODL.CodArticolo.Trim();
|
|
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("N4", CultureInfo.InvariantCulture);
|
|
}
|
|
ddlMacchine.SelectedValue = rPODL.IdxMacchina;
|
|
txtKeyExt.Text = rPODL.KeyRichiesta;
|
|
txtDueDate.Text = $"{rPODL.DueDate:yyyy-MM-dd}";
|
|
// svuoto se ci fosse cloning......
|
|
memLayer.ML.emptySessionVal("idxProm2Clone");
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
grViewTempi.SelectedIndex = -1;
|
|
grViewTempi.DataBind();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |