Exemplo n.º 1
0
 private void txtISSN_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     try
     {
         scanner.Read(e);
         if (e.Key == Key.Return)
         {
             var magazine = new MagazineModel(_connection).Get().OrderByDescending(p => p.Numero)
                            .FirstOrDefault(p => p.ISSN == scanner.resultCode);
             if (magazine != null)
             {
                 cbTipologia.SelectedValue = magazine.IdTipologia;
                 txtNomePeriodico.Text     = listaPeriodici.FirstOrDefault(p => p.IdPeriodico == magazine.IdPeriodico)?.Nome ?? string.Empty;
                 txtNomeRivista.Text       = magazine.Nome;
                 txtNumero.Text            = (magazine.Numero + 1)?.ToString() ?? string.Empty;
                 txtPrezzo.Text            = magazine.Prezzo.ToString();
             }
             scanner.resultCode = string.Empty;
         }
     }
     catch
     {
         ///TODO: to be implemented
         MessageBox.Show("Errore durante la lettura del codice a barre");
     }
 }
Exemplo n.º 2
0
 private void cbInserto_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     try
     {
         scanner.Read(e);
         if (e.Key == Key.Return)
         {
             magazine           = MagazineList.FirstOrDefault(p => p.ISSN == scanner.resultCode);
             scanner.resultCode = string.Empty;
             if (magazine != null)
             {
                 cbInserto.SelectedItem = new { Nome = $"{magazine.Nome} - Numero {magazine.Numero}", magazine.IdMagazine };
                 GetAmountOfCopies();
             }
             else
             {
                 cbInserto.Text = string.Empty;
                 MessageBox.Show("Rivista non trovata");
             }
         }
     }
     catch
     {
         ///TODO: to be implemented
         MessageBox.Show("Errore nel rilevamento della rivista con lo scanner");
     }
 }
        private void MagazineSoldWindow_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                scanner.Read(e);
                if (e.Key == Key.Return)
                {
                    var rivistaVendutaNelCarrello = MagazineSoldList.OrderByDescending(p => p.Numero)
                                                    .FirstOrDefault(p => p.ISSN == scanner.resultCode);

                    magazine = MagazineAvailable.OrderByDescending(p => p.Numero)
                               .FirstOrDefault(p => p.ISSN == scanner.resultCode &&
                                               (p.Numero == (rivistaVendutaNelCarrello?.Numero ?? p.Numero)) &&
                                               (p.NumeroCopieTotale >
                                                (rivistaVendutaNelCarrello?.CopieVendute ?? 0) + p.NumeroCopieVendute + p.NumeroCopieRese));

                    if (magazine != null)
                    {
                        ImportMagazineSelectedIntoSold(magazine);
                        AggiungiCopiaVendutaAlMagazine(1);
                        AggiungiItemAlCarrello();
                    }
                    else
                    {
                        MessageBox.Show("Il magazine cercato non è disponibile: terminate le copie o codice non valido.");
                    }
                    scanner.resultCode = string.Empty;
                    cbInserto.Text     = string.Empty;
                }
            }
            catch
            {
                //TODO: to be implemented
                MessageBox.Show("Problemi durante la lettura del codice a barre.");
            }
        }