using MapoDb;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MoonProTablet.WebUserControls
{
public partial class cmp_newODL : System.Web.UI.UserControl
{
///
/// registrato nuovo valore
///
public event EventHandler eh_newVal;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
setDefaults();
}
}
///
/// idxMacchina selezionata
///
public string idxMacchina
{
get
{
return hfIdxMacchina.Value;
}
set
{
hfIdxMacchina.Value = value;
}
}
///
/// imposta valori std
///
private void setDefaults()
{
txtNumPz.Text = "1";
txtTC_min.Text = "1";
txtTC_sec.Text = "0";
}
protected void lbtCreaOdlProvv_Click(object sender, EventArgs e)
{
// effettua creazione ODL provvisorio e riporta a parent...
int numPz = 1;
int.TryParse(txtNumPz.Text, out numPz);
int numMin = 0;
int numSec = 0;
int.TryParse(txtTC_min.Text, out numMin);
int.TryParse(txtTC_sec.Text, out numSec);
decimal tCiclo = numMin + ((decimal)numSec) / 60;
string note = txtNote.Text.Trim();
#if false
// insert su DB
DataLayer.obj.taODL.insertProvv(ddlArticolo.SelectedValue, idxMacchina, numPz, tCiclo, note);
#endif
// calcolo stringa macchina e articolo...
var rMacchina = DataLayer.obj.taMacchine.GetByIdx(idxMacchina)[0];
var rArticolo = DataLayer.obj.taAnagArt.getByCod(ddlArticolo.SelectedValue)[0];
string macchina = string.Format("{0} ({1} | {2} | {3})", rMacchina.Nome, rMacchina.IdxMacchina, rMacchina.CodMacchina, rMacchina.Descrizione);
string articolo = string.Format("{0} ({1} | {2})", rArticolo.DescArticolo, rArticolo.CodArticolo, rArticolo.Disegno);
// invio email notifica creazione ODL PROVVISORIO (da riconciliare...)
string subject = "Effettuato attrezzaggio con ODL provvisorio";
string oggetto = string.Format("E' stato effettuato unattrezzaggio con ODL provvisorio.
Macchina: {0}
Articolo: {1}
Lanciati {2} pezzi con T.Ciclo {3:N3} ({4}:{5} min:sec).
Note operatore: {6}", macchina, articolo, numPz, tCiclo, numMin, numSec, note);
gestEmail.geAuth.mandaEmail(memLayer.ML.confReadString("_fromEmail"), memLayer.ML.confReadString("_adminEmail"), subject, oggetto);
// sollevo evento!
if (eh_newVal != null)
{
eh_newVal(this, new EventArgs());
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
ddlArticolo.DataBind();
}
}
}