using AppData; using SteamWare; using System; using System.Text.RegularExpressions; namespace C_TRACK.WebUserControls { public partial class mod_addTask : System.Web.UI.UserControl { /// /// evento aggiunta record /// 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"); } /// /// RegExp x Cod ARTICOLO /// protected string reCodArt = memLayer.ML.cdv("regExp_CodArt"); /// /// RegExp x Cod COMMESSA /// protected string reNumTask = memLayer.ML.cdv("regExp_NumTask"); /// /// RegExp x QTA /// protected string reQta = memLayer.ML.cdv("regExp_QtaRic"); /// /// RegExp x RESET / CANCEL /// protected string reReset = memLayer.ML.cdv("regExp_KO"); /// /// RegExp x CONFERMA /// protected string reAddNew = memLayer.ML.cdv("regExp_AddNew"); /// /// RegExp x CONFERMA /// protected string reDelete = memLayer.ML.cdv("regExp_DEL"); /// /// Input da processare... /// public string newInput { set { processInput(value); } } /// /// Effettua riconoscimento input e determina valori commessa / articolo / qta /// /// 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(); } /// /// Cod ARTICOLO corrente /// public string CodArticolo { get { return memLayer.ML.StringSessionObj("currCodArt"); } set { memLayer.ML.setSessionVal("currCodArt", value); } } /// /// Cod COMMESSA corrente /// public string NumTask { get { return memLayer.ML.StringSessionObj("currNumTask"); } set { memLayer.ML.setSessionVal("currNumTask", value); } } /// /// QTA da produrre /// 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")); } } }