onzulin

codigo del metodo ListBoxArchiveEarn_Tapped

Mar 28th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.49 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.             IEnumerable<Transacciones> ITransacciones;
  12.  
  13.             ArchivoTransacciones = Db.Table<ArchivoTransacciones>().ToList();
  14.             //probemos si es null el objeto listBoxFilesSelectedEarn que eso pasara cuando le damos al boton order by
  15.            
  16.             listBoxFilesSelectedEarn = ((sender as ListBox).SelectedItem as Archivos);
  17.            
  18.             if (listBoxFilesSelectedEarn != null)
  19.             {
  20.                 try
  21.                 {
  22.                     ListBoxEarn.Items.Clear();
  23.                 }
  24.                 catch (Exception ex)
  25.                 {
  26.                     MessageDialog msg = new MessageDialog(ex.Message);
  27.                     msg.ShowAsync();
  28.                 }
  29.                 IArchivosEarn = ArchivoTransacciones.Where(archivos => archivos.idarchivo == listBoxFilesSelectedEarn.idarchivo);
  30.                 LTransaccionesEarn = Db.Table<Transacciones>().ToList();
  31.                 if (BusquedaEarn == false)
  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.                 }
  49.                 else
  50.                 {
  51.                     ListBoxEarn.ItemsSource = ListaTransaccionesEarn;
  52.                     earn = ListaTransaccionesEarn.Sum(transacciones => transacciones.amount);
  53.                 }
  54.                
  55.                  
  56.                 /*
  57.                 ITransacciones = from transaccion in LTransaccionesEarn
  58.                                  join archivo in ArchivoTransacciones on transaccion.idtransaccion equals archivo.idarchivo
  59.                                  where archivo.idarchivo == listBoxFilesSelectedEarn.idarchivo
  60.                                  select transaccion;
  61.                 ListBoxEarn.ItemsSource = ITransacciones;
  62.                 */
  63.                
  64.                
  65.                
  66.                 BusquedaEarn = false;
  67.                 ListaTransaccionesEarn.Clear();
  68.                 foreach (Transacciones transacciones in ListBoxEarn.Items)
  69.                 {
  70.                     ListaTransaccionesEarn.Add(transacciones);
  71.                 }
  72.                
  73.                 TextBoxTotalEarn.Text = earn.ToString();
  74.                 if (TextBoxTotalSpent.Text == "")
  75.                 {
  76.                     TextBoxTotalSpent.Text = "0";
  77.                     spent = Convert.ToDouble(TextBoxTotalSpent.Text);
  78.                 }
  79.                 else
  80.                 {
  81.                     spent = Convert.ToDouble(TextBoxTotalSpent.Text);
  82.                 }
  83.  
  84.  
  85.                 balance = earn - spent;
  86.                 SolidColorBrush mySolidColorBrush = new SolidColorBrush();
  87.                 if (balance >= 0)
  88.                 {
  89.                     // eesto pinta el color en un tono verde
  90.                     mySolidColorBrush.Color = Color.FromArgb(255, 2, 144, 70);
  91.                     TextBoxBalance.Foreground = mySolidColorBrush;
  92.                 }
  93.                 else
  94.                 {
  95.                     mySolidColorBrush.Color = Color.FromArgb(255, 191, 9, 19);
  96.                     TextBoxBalance.Foreground = mySolidColorBrush;
  97.                 }
  98.                 TextBoxBalance.Text = balance.ToString();
  99.                 TextBoxTotalEarn.Text = earn.ToString();
  100.                 TextBoxTotalSpent.Text = spent.ToString();
  101.  
  102.                
  103.             }
  104.            
  105.         }
Add Comment
Please, Sign In to add comment