Advertisement
onzulin

metodo del listbox para seleccion de ficheros

Mar 21st, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.67 KB | None | 0 0
  1.  private void ListBoxArchiveEarn_Tapped(object sender, TappedRoutedEventArgs e)
  2.         {
  3.             //tambien hay que realizar las cuentas y ya hemos terminado el programa
  4.             double earn = 0;
  5.             double spent = 0;
  6.             double balance = 0;
  7.  
  8.  
  9.             List<Transacciones> LTransaccionesEarn = new List<Transacciones>();
  10.             List<ArchivoTransacciones> ArchivoTransacciones = new List<ArchivoTransacciones>();
  11.            
  12.             ArchivoTransacciones = Db.Table<ArchivoTransacciones>().ToList();
  13.             //probemos si es null el objeto listBoxFilesSelectedEarn que eso pasara cuando le damos al boton order by
  14.             listBoxFilesSelectedEarn = ((sender as ListBox).SelectedItem as Archivos);
  15.             if (listBoxFilesSelectedEarn != null)
  16.             {
  17.                 try
  18.                 {
  19.                     ListBoxEarn.Items.Clear();
  20.                 }
  21.                 catch (Exception ex)
  22.                 {
  23.                     MessageDialog msg = new MessageDialog(ex.Message);
  24.                     msg.ShowAsync();
  25.                 }
  26.                 IArchivosEarn = ArchivoTransacciones.Where(archivos => archivos.idarchivo == listBoxFilesSelectedEarn.idarchivo);
  27.                 LTransaccionesEarn = Db.Table<Transacciones>().ToList();
  28.  
  29.                 //limpiamos la ListBoxEarn entera antes
  30.                
  31.                 //estos bucles foreach para introducir la informacion de las tablas justo lo que necesito
  32.                
  33.                 foreach (ArchivoTransacciones archivos in IArchivosEarn)
  34.                 {
  35.                     //aqui ya vemos elemento a elemento las propiedades que nos interesen
  36.                     foreach (Transacciones transacciones in LTransaccionesEarn)
  37.                     {
  38.                         if (transacciones.idtransaccion == archivos.idtransaccion)
  39.                         {
  40.                             //añadir objeto a objeto y luego mostrarlos
  41.                             ListBoxEarn.Items.Add(transacciones);
  42.                             earn += transacciones.amount;
  43.                            
  44.                             //aqui voy añadiendo en una List los objetos y los borro
  45.                         }
  46.                     }
  47.                 }
  48.                 ListaTransaccionesEarn.Clear();
  49.                 foreach (Transacciones transacciones in ListBoxEarn.Items)
  50.                 {
  51.                     ListaTransaccionesEarn.Add(transacciones);
  52.                 }
  53.  
  54.                 TextBoxTotalEarn.Text = earn.ToString();
  55.                 if (TextBoxTotalSpent.Text == "")
  56.                 {
  57.                     TextBoxTotalSpent.Text = "0";
  58.                     spent = Convert.ToDouble(TextBoxTotalSpent.Text);
  59.                 }
  60.                 else
  61.                 {
  62.                     spent = Convert.ToDouble(TextBoxTotalSpent.Text);
  63.                 }
  64.  
  65.  
  66.                 balance = earn - spent;
  67.                 SolidColorBrush mySolidColorBrush = new SolidColorBrush();
  68.                 if (balance >= 0)
  69.                 {
  70.                     // eesto pinta el color en un tono verde
  71.                     mySolidColorBrush.Color = Color.FromArgb(255, 2, 144, 70);
  72.                     TextBoxBalance.Foreground = mySolidColorBrush;
  73.                 }
  74.                 else
  75.                 {
  76.                     mySolidColorBrush.Color = Color.FromArgb(255, 191, 9, 19);
  77.                     TextBoxBalance.Foreground = mySolidColorBrush;
  78.                 }
  79.                 TextBoxBalance.Text = balance.ToString();
  80.                 TextBoxTotalEarn.Text = earn.ToString();
  81.                 TextBoxTotalSpent.Text = spent.ToString();
  82.             }
  83.            
  84.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement