Example #1
0
        private void BtDesvincular_Click(object sender, EventArgs e)
        {
            Tarjeta selectedTarjeta = (Tarjeta)lvTarjetas.SelectedItem;

            if (selectedTarjeta != null)
            {
                // Borra la tarjeta de la BD
                if (AccessHelper.DesvinculaTarjeta(selectedTarjeta.Id))
                {
                    // Borra la tarjeta de la lista temporal
                    _ListaTarjetas.Remove(
                        _ListaTarjetas.Where(x => x.Id == selectedTarjeta.Id)
                        .First()
                        );

                    // Activa el label info y luego el DispatcherTimer
                    tbInfo.Visibility = Visibility.Visible;
                    tbInfo.Foreground = new SolidColorBrush(Colors.DarkGreen);
                    tbInfo.Text       = "Se ha desvinculado la tarjeta correctamente.";
                    timerLabel.Start();
                }
                else
                {
                    // Activa el label info y luego el DispatcherTimer
                    tbInfo.Visibility = Visibility.Visible;
                    tbInfo.Foreground = new SolidColorBrush(Colors.DarkRed);
                    tbInfo.Text       = "No se ha podido desvincular la tarjeta.";
                    timerLabel.Start();
                }
            }
        }