ad2995f5b5
install su 218 e winlab
217 lines
6.6 KiB
C#
217 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using C2P_Data;
|
|
|
|
namespace C2P.WebUserControls
|
|
{
|
|
public partial class mod_createNewStdCost : SteamWare.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
showCreate = false;
|
|
}
|
|
updateViews();
|
|
// verifico se sto eseguendo task lungo di caricamento...
|
|
if (runningQLC)
|
|
{
|
|
queueLenght();
|
|
processQLC();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// processa generazione record QLC
|
|
/// </summary>
|
|
private void processQLC()
|
|
{
|
|
logger.lg.scriviLog(string.Format("Inizio Processing dati QLC x StdCost: {0} rec", queueLenght()), tipoLog.INFO);
|
|
DateTime tick = DateTime.Now;
|
|
// chiamo processing di merge ordini e generazione schede...
|
|
try
|
|
{
|
|
generateNewQLC();
|
|
logger.lg.scriviLog(string.Format("FINE Processing dati QLC x StdCost: {0} rec", queueLenght()), tipoLog.INFO);
|
|
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in generazione listini StdCost: {0}", exc), tipoLog.EXCEPTION);
|
|
showCreate = false;
|
|
updateViews();
|
|
}
|
|
if (queueLenght() > 0)
|
|
{
|
|
// salvo che voglio continuare caricamento dati...
|
|
runningQLC = true;
|
|
Response.Redirect("~/StdCostList");
|
|
}
|
|
else
|
|
{
|
|
showCreate = false;
|
|
updateViews();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// genera batch di record StdCostList
|
|
/// </summary>
|
|
private void generateNewQLC()
|
|
{
|
|
// inizializzo
|
|
int rec2procQLC = 100;
|
|
try
|
|
{
|
|
rec2procQLC = memLayer.ML.confReadInt("rec2procQLC");
|
|
}
|
|
catch
|
|
{ }
|
|
// processing...
|
|
if (queueLenght() > 0)
|
|
{
|
|
DtProxy.man.taSC2C.generateNewQLC(rec2procQLC, string.Format("Created by {0} on {1:dd/MM/yy HH:mm}", user_std.UtSn.userNameAD, DateTime.Now), "C");
|
|
}
|
|
else
|
|
{
|
|
// salvo che ho finito con caricamento dati...
|
|
runningQLC = false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// aggiorna dati
|
|
/// </summary>
|
|
private void updateViews()
|
|
{
|
|
divNewData.Visible = showCreate;
|
|
if (showCreate)
|
|
{
|
|
lblBtnNew.Text = traduci("CreateStdCostList");
|
|
}
|
|
else
|
|
{
|
|
lblBtnNew.Text = traduci("ShowCreate");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// modalità creazione nuovo listino...
|
|
/// </summary>
|
|
protected bool showCreate
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.BoolSessionObj("stdCostShowCreate");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("stdCostShowCreate", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// quantità batch x creazione nuovo listino
|
|
/// </summary>
|
|
protected int batchQty
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("batchQty");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("batchQty", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// RawMatCost x creazione nuovo listino
|
|
/// </summary>
|
|
protected decimal RawMatCost
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToDecimal(memLayer.ML.objSessionObj("RawMatCost"));
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("RawMatCost", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica se sia in corso un run di creazione QLC
|
|
/// </summary>
|
|
protected bool runningQLC
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.BoolSessionObj("runningQLC");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("runningQLC", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// lunghezza coda da acquisire + update visualizzazione
|
|
/// </summary>
|
|
private int queueLenght()
|
|
{
|
|
int qLen = 0;
|
|
try
|
|
{
|
|
qLen = DtProxy.man.taSC2C.countRemaining()[0].RecordsIn;
|
|
}
|
|
catch
|
|
{ }
|
|
lblAcqOut.Text = string.Format("{0} records", qLen);
|
|
return qLen;
|
|
}
|
|
/// <summary>
|
|
/// richiesta creazione listino
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
// se era in create AVVIO CREAZIONE NUOVI DATI!!!!
|
|
if (showCreate)
|
|
{
|
|
// salvo dati x creazione
|
|
batchQty = 0;
|
|
RawMatCost = 0;
|
|
try
|
|
{
|
|
batchQty = Convert.ToInt32(txtBatchQty.Text);
|
|
RawMatCost = Convert.ToDecimal(txtBase6060.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
if (batchQty > 0 && RawMatCost > 0)
|
|
{
|
|
// elimino eventuale listino vecchio
|
|
logger.lg.scriviLog("Inizio cancellazione dati QLC odierni", tipoLog.INFO);
|
|
DtProxy.man.taSCL.deleteByDate(DateTime.Now);
|
|
logger.lg.scriviLog("Fine cancellazione dati QLC odierni", tipoLog.INFO);
|
|
// creo elenco articoli da generare...
|
|
logger.lg.scriviLog("Inizio creazione elenco articoli x listino QLC", tipoLog.INFO);
|
|
DtProxy.man.taSC2C.insertForDate(RawMatCost, batchQty);
|
|
logger.lg.scriviLog("Fine creazione elenco articoli x listino QLC", tipoLog.INFO);
|
|
// avvio creazione record (in small batch...)
|
|
lblAcqOut.Text = "";
|
|
processQLC();
|
|
}
|
|
else
|
|
{
|
|
lblAcqOut.Text = traduci("ERR-QLC-001");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
showCreate = !showCreate;
|
|
}
|
|
updateViews();
|
|
}
|
|
}
|
|
} |