Exemplo n.º 1
0
        private void qrReader_OnCodeDecoded(object sender, EventArgs e)
        {
            string myCode = qrReader.Code;

            if (!string.IsNullOrEmpty(myCode))
            {
                Guid uniqueCode;
                try
                {
                    lblDescrizione.Text = string.Empty;
                    uniqueCode          = new Guid(myCode);
                }
                catch
                {
                    lblDescrizione.Text = "Cartellino non valido";                     //Se il codice è un codice ad cazzum, non un GUID, è ovviamente un QR Code sbagliato
                    return;
                }
                SostanzeManager manager  = new SostanzeManager(DatabaseContext);
                NewSostanze     sostanza = manager.GetSubstanceFromQRCode(uniqueCode);
                if (sostanza == null)
                {
                    lblDescrizione.Text = "Non è un cartellino sostanza";
                }
                else
                {
                    txtElencoIngredienti.Text += sostanza.Nome + "\r\n";
                    hidField.Value            += sostanza.Progressivo + ";";
                    lblDescrizione.Text        = "Ingrediente inserito";
                    btnCrea.Enabled            = true;
                }
            }
        }
Exemplo n.º 2
0
        void qrReader_OnCodeDecoded(object sender, EventArgs e)
        {
            string myCode = qrReader.Code;

            svuotaControlli();
            if (!string.IsNullOrEmpty(myCode))
            {
                Guid uniqueCode;
                try
                {
                    uniqueCode = new Guid(myCode);
                }
                catch
                {
                    lblDescrizione.Text = "Cartellino non valido"; //Se il codice è un codice ad cazzum, non un GUID, è ovviamente un QR Code sbagliato
                    return;
                }
                SostanzeManager manager = new SostanzeManager(DatabaseContext);
                NewSostanze     myItem  = manager.GetSubstanceFromQRCode(uniqueCode);
                if (myItem == null)
                {
                    lblDescrizione.Text = "Non è un cartellino di un composto";
                    return;
                }
                if (myItem.Tipo == 0 || myItem.Tipo == 2 || myItem.Tipo == 3)
                {
                    lblNome.Text = myItem.Nome;
                    if (!string.IsNullOrWhiteSpace(myItem.Descrizione))
                    {
                        lblDescrizione.Text = myItem.Descrizione.Replace("\r", "<br />");
                    }
                    if (!string.IsNullOrWhiteSpace(myItem.Effetto))
                    {
                        lblEffetto.Text = myItem.Effetto.Replace("\r", "<br />");
                    }
                    lblData.Text      = myItem.DataScadenza.HasValue ? myItem.DataScadenza.Value.ToString("dd/MM/yyyy") : string.Empty;
                    lblCosto.Text     = myItem.Costo.ToString();
                    lblEfficacia.Text = myItem.ValoreEfficacia.ToString();
                    lblTipo.Text      = myItem.TipoSostanze.Descrizione;
                    lblModoUso.Text   = myItem.ModoUso;
                    if (!string.IsNullOrWhiteSpace(myItem.Immagine))
                    {
                        imgOggetto.Visible  = true;
                        imgOggetto.ImageUrl = myItem.Immagine;
                    }
                }
                else
                {
                    lblDescrizione.Text = "La sostanza non è nè un ingrediente nè una tossina o droga (forse medicinale?)";
                }
            }
        }