206 lines
5.4 KiB
C#
206 lines
5.4 KiB
C#
using AppData;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace C_TRACK.WebUserControls
|
|
{
|
|
public partial class mod_addTask : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// evento aggiunta record
|
|
/// </summary>
|
|
public event EventHandler eh_created;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
CodArticolo = "";
|
|
NumTask = "";
|
|
Quantita = 0;
|
|
}
|
|
checkValori();
|
|
}
|
|
|
|
private void checkValori()
|
|
{
|
|
// verifica quali valori siano disponibili e di conseguenza visualizza COLORE...
|
|
divArticolo.Attributes.Remove("class");
|
|
divCommessa.Attributes.Remove("class");
|
|
divQta.Attributes.Remove("class");
|
|
divArticolo.Attributes.Add("class", CodArticolo != "" ? "col-3 text-center table-success text-success" : "col-3 text-center text-secondary");
|
|
divCommessa.Attributes.Add("class", NumTask != "" ? "col-3 text-center table-success text-success" : "col-3 text-center text-secondary");
|
|
divQta.Attributes.Add("class", Quantita > 0 ? "col-3 text-center table-success text-success" : "col-3 text-center text-secondary");
|
|
}
|
|
/// <summary>
|
|
/// RegExp x Cod ARTICOLO
|
|
/// </summary>
|
|
protected string reCodArt = memLayer.ML.cdv("regExp_CodArt");
|
|
/// <summary>
|
|
/// RegExp x Cod COMMESSA
|
|
/// </summary>
|
|
protected string reNumTask = memLayer.ML.cdv("regExp_NumTask");
|
|
/// <summary>
|
|
/// RegExp x QTA
|
|
/// </summary>
|
|
protected string reQta = memLayer.ML.cdv("regExp_QtaRic");
|
|
/// <summary>
|
|
/// RegExp x RESET / CANCEL
|
|
/// </summary>
|
|
protected string reReset = memLayer.ML.cdv("regExp_KO");
|
|
/// <summary>
|
|
/// RegExp x CONFERMA
|
|
/// </summary>
|
|
protected string reAddNew = memLayer.ML.cdv("regExp_AddNew");
|
|
/// <summary>
|
|
/// RegExp x CONFERMA
|
|
/// </summary>
|
|
protected string reDelete = memLayer.ML.cdv("regExp_DEL");
|
|
/// <summary>
|
|
/// Input da processare...
|
|
/// </summary>
|
|
public string newInput
|
|
{
|
|
set
|
|
{
|
|
processInput(value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Effettua riconoscimento input e determina valori commessa / articolo / qta
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
private void processInput(string value)
|
|
{
|
|
// verifico se sia un articolo...
|
|
Match testReset = Regex.Match(value, reReset);
|
|
Match testDelete = Regex.Match(value, reDelete);
|
|
Match testAddNew = Regex.Match(value, reAddNew);
|
|
Match testCodArt = Regex.Match(value, reCodArt);
|
|
Match testNumTask = Regex.Match(value, reNumTask);
|
|
Match testQta = Regex.Match(value, reQta);
|
|
|
|
|
|
if (testReset.Success)
|
|
{
|
|
CodArticolo = "";
|
|
NumTask = "";
|
|
Quantita = 0;
|
|
}
|
|
else if (testDelete.Success)
|
|
{
|
|
// creo...
|
|
dataLayer.man.taTL.deleteQuery(NumTask);
|
|
// resetto!
|
|
CodArticolo = "";
|
|
NumTask = "";
|
|
Quantita = 0;
|
|
// invoco update...
|
|
if (eh_created != null)
|
|
{
|
|
eh_created(this, new EventArgs());
|
|
}
|
|
}
|
|
else if (testAddNew.Success)
|
|
{
|
|
// se qta > 0 ed ho articolo e commessa...
|
|
if (Quantita > 0 && CodArticolo != "" && NumTask != "")
|
|
{
|
|
// creo...
|
|
dataLayer.man.taTL.insertQuery(NumTask, CodArticolo, Quantita);
|
|
// resetto!
|
|
CodArticolo = "";
|
|
NumTask = "";
|
|
Quantita = 0;
|
|
// invoco update...
|
|
if (eh_created != null)
|
|
{
|
|
eh_created(this, new EventArgs());
|
|
}
|
|
}
|
|
}
|
|
else if (testCodArt.Success)
|
|
{
|
|
CodArticolo = value;
|
|
}
|
|
else if (testNumTask.Success)
|
|
{
|
|
NumTask = value;
|
|
}
|
|
else if (testQta.Success)
|
|
{
|
|
int qta = 0;
|
|
int.TryParse(value, out qta);
|
|
Quantita = qta;
|
|
}
|
|
|
|
// non match con RegExp --> ricerca ESPLICITA, se abilitato ricerca estesa
|
|
if (memLayer.ML.CRB("OptEnableMapoIn") && !(testCodArt.Success || testNumTask.Success))
|
|
{
|
|
var tabArt = dataLayer.man.taAnArt.getByKey(value);
|
|
if (tabArt.Rows.Count > 0)
|
|
{
|
|
CodArticolo = value;
|
|
}
|
|
else
|
|
{
|
|
var tabTask = dataLayer.man.taTL.getByKey(value);
|
|
if (tabTask.Rows.Count > 0)
|
|
{
|
|
NumTask = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
checkValori();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cod ARTICOLO corrente
|
|
/// </summary>
|
|
public string CodArticolo
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("currCodArt");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("currCodArt", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Cod COMMESSA corrente
|
|
/// </summary>
|
|
public string NumTask
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("currNumTask");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("currNumTask", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// QTA da produrre
|
|
/// </summary>
|
|
public int Quantita
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("currQta");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("currQta", value);
|
|
}
|
|
}
|
|
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
processInput(memLayer.ML.CRS("regExp_KO"));
|
|
}
|
|
}
|
|
} |