using System; using System.Web.UI; namespace NKC_WF.WebUserControls { public partial class cmp_barcode : BaseUserControl { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { resetInput(); resetMessage(); } else if (string.IsNullOrEmpty(inputAcquired)) { checkRaiseEv(); } } /// /// evento modifica testo /// /// /// protected void txtBarcode_TextChanged(object sender, EventArgs e) { checkRaiseEv(); } /// /// Verifica se inviare evento /// private void checkRaiseEv() { if (valueRead != inputAcquired) { // registro NUOVO cmd inputAcquired = valueRead; // alzo evento SOLO SE il nuovo valore è diverso da null... if (!string.IsNullOrEmpty(inputAcquired)) { raiseEvent(); } } else { if (string.IsNullOrEmpty(inputAcquired)) { resetInput(); } } resetInput(); } /// /// Comando acquisito da Barcode /// public string inputAcquired { get { return hfLastCmd.Value; } set { hfLastCmd.Value = value; } } /// /// Valore acquisito in lettura barcode /// protected string valueRead { get { return txtBarcode.Text.Trim(); } set { txtBarcode.Text = value; } } /// /// Reset input del barcode SENZA generare evento... /// /// public void resetInput() { valueRead = ""; txtBarcode.Focus(); } /// /// reset messaggio /// public void resetMessage() { lblOutput.Visible = false; lblOutput.Text = ""; } /// /// Gestione output da mostrare (opzionale /// /// /// public void showOutput(string cssClass, string messaggio) { // In primis: mostro qualcosa SOLO SE ho del testo lblOutput.Visible = !string.IsNullOrEmpty(messaggio); lblOutput.Text = messaggio; lblOutput.Attributes.Remove("class"); lblOutput.Attributes.Add("class", cssClass); } } }