Files
MoonPro.net/MP-Tablet/fixODL.aspx.cs
T

98 lines
2.4 KiB
C#

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
{
public partial class fixODL : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
fixBtnImpostaODL();
DateTime adesso = DateTime.Now;
hfDataTo.Value = adesso.ToString();
hfDataFrom.Value = adesso.AddMonths(-1).ToString();
}
}
private void fixBtnImpostaODL()
{
// verifico se selezionato un ODL sorgente...
lbtSetODL.Visible = idxODL > 0;
}
/// <summary>
/// idx macchina selezionata
/// </summary>
public int idxODL
{
get
{
int answ = 0;
try
{
answ = Convert.ToInt32(ddlODL.SelectedValue);
}
catch
{ }
return answ;
}
}
/// <summary>
/// idx macchina selezionata
/// </summary>
public int idxMacchina
{
get
{
return memLayer.ML.IntSessionObj("IdxMacchina");
}
set
{
memLayer.ML.setSessionVal("IdxMacchina", value);
}
}
protected void ddlODL_SelectedIndexChanged(object sender, EventArgs e)
{
fixBtnImpostaODL();
}
/// <summary>
/// Registra attivazione ODL per macchina corrente...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtSetODL_Click(object sender, EventArgs e)
{
if (idxMacchina > 0 && idxODL > 0)
{
// registro ODL retroattivamente...
DataLayer.obj.taODL.insPostumo(idxODL, idxMacchina.ToString());
}
// controllo: se il nuovo ODL è stato registrato --> rimando a pagina ODL/Attrezzaggio...
bool odlOk = false;
try
{
// ricalcolo MSE
DataLayer.obj.taMSE.getByRefreshData(0);
// verifico!
int idxODL = DataLayer.obj.taMSE.getByIdxMacchina(idxMacchina.ToString())[0].idxODL;
odlOk = (idxODL > 0);
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore recupero ODL corrente da confermare per la macchina {0}{1}{2}", idxMacchina, Environment.NewLine, exc), tipoLog.ERROR);
}
if(odlOk)
{
Response.Redirect("ODL");
}
}
}
}