Exemple #1
0
        private void buttonEliminarSocio_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Si elimina este socio ya no podrá recuperar sus datos (información personal y pagos). \n\n Esta seguro que desea continuar?",
                                "Advertencia", MessageBoxButton.YesNo, MessageBoxImage.Question,
                                MessageBoxResult.No) == MessageBoxResult.No)
            {
                return;
            }

            try
            {
                Socio socio = SociosHandler.Instancia.ObtenerSocio(((DataSocioPreview)listaSocios.SelectedValue).Id);

                SociosHandler.Instancia.EliminarSocio(socio);

                dspreviews = SociosHandler.Instancia.ObtenerDSPInactivos();
                listaSocios.ItemsSource = dspreviews;
                filtrarListaSocios();
                Actualizar = true;
                MessageBox.Show("El socio ha sido eliminado del sistema exitosamente.", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error al eliminar socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Log(ex.ToString());
            }
        }
Exemple #2
0
        public PagoWindow(Socio socio, Pago ultimoPago, Pago pago)
        {
            InitializeComponent();

            this.socio      = socio;
            this.ultimoPago = ultimoPago;
            if (pago == null) // Nuevo Pago
            {
                dtpMesPago.Value      = DateTime.Now;
                dtpFechaIngreso.Value = DateTime.Now;

                foreach (Disciplina dsc in socio.Disciplinas.OrderBy(dsc => dsc.Nombre))
                {
                    double montoParcial = 0;
                    if (ultimoPago != null)
                    {
                        foreach (Monto mon in ultimoPago.Montos)
                        {
                            if (dsc.Id == mon.Disciplina.Id)
                            {
                                montoParcial = mon.MontoParcial;
                            }
                        }
                    }

                    listMontos.Items.Add(new Monto {
                        DisciplinaId = dsc.Id, Disciplina = dsc, MontoParcial = montoParcial
                    });
                }
                listMontos.SelectAll();
                listMontos.Focus();
            }
            else // Detalles de pago
            {
                //Deshabilitar controles
                dtpMesPago.IsEnabled          = false;
                dtpFechaIngreso.IsEnabled     = false;
                listMontos.IsEnabled          = false;
                buttonCancelar.Visibility     = System.Windows.Visibility.Hidden;
                buttonIngresarPago.Visibility = System.Windows.Visibility.Hidden;
                buttonCerrar.Visibility       = System.Windows.Visibility.Visible;
                buttonEliminar.Visibility     = System.Windows.Visibility.Visible;
                this.Title = "Pago Nº " + pago.Id.ToString();

                this.pago = pago;

                dtpMesPago.Value      = pago.MesPago;
                dtpFechaIngreso.Value = pago.Fecha;

                foreach (Monto mon in pago.Montos)
                {
                    listMontos.Items.Add(mon);
                }
                listMontos.SelectAll();
            }
        }
        /// <summary>
        /// Create a new Socio object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="nombre">Initial value of the Nombre property.</param>
        /// <param name="fechaInscripcion">Initial value of the FechaInscripcion property.</param>
        /// <param name="edad">Initial value of the Edad property.</param>
        public static Socio CreateSocio(global::System.Int64 id, global::System.String nombre, global::System.DateTime fechaInscripcion, global::System.Int64 edad)
        {
            Socio socio = new Socio();

            socio.Id               = id;
            socio.Nombre           = nombre;
            socio.FechaInscripcion = fechaInscripcion;
            socio.Edad             = edad;
            return(socio);
        }
        private void verFicha(Socio socio) // Poco eficiente
        {
            FichaSocio ficha = new FichaSocio(socio);

            ficha.ShowDialog();
            if (ficha.Actualizar.HasValue && ficha.Actualizar.Value)
            {
                dspreviews = SociosHandler.Instancia.ObtenerDSPActivos();
                listaSocios.ItemsSource = dspreviews;
                filtrarListaSocios();
                Actualizar = true;
            }
        }
        public SocioWindow(Socio editSocio)
        {
            InitializeComponent();

            if (editSocio == null) // nuevo socio
            {
                socio    = new Socio();
                socio.Id = 0; // Para conversion de imagen
                socio.FechaInscripcion     = DateTime.Now;
                gridDatosSocio.DataContext = this.socio;

                try
                {
                    listBoxDisciplinas.ItemsSource = DisciplinasHandler.Instancia.ObtenerDisciplinasHabilitadas();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al cargar disciplinas.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Logger.Log(ex.ToString());
                }
            }
            else // modificar socio
            {
                this.socio = editSocio;
                gridDatosSocio.DataContext = socio;
                this.Title = "Editando ficha de " + socio.Nombre;
                buttonCancelar2.Visibility      = System.Windows.Visibility.Visible;
                buttonGuardarCambios.Visibility = System.Windows.Visibility.Visible;
                buttonCancelar.Visibility       = System.Windows.Visibility.Hidden;
                buttonIngresarSocio.Visibility  = System.Windows.Visibility.Hidden;

                try
                {
                    IList <Disciplina> listDisciplinas = DisciplinasHandler.Instancia.ObtenerDisciplinasHabilitadas();
                    listBoxDisciplinas.ItemsSource           = listDisciplinas;
                    listBoxDisciplinas.SelectedItemsOverride = listDisciplinas
                                                               .Where(dsc => socio.Disciplinas
                                                                      .Any(dsc2 => dsc2.Id == dsc.Id))
                                                               .ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al cargar disciplinas.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Logger.Log(ex.ToString());
                }
            }
        }
 private void buttonDarBaja_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Socio socio = SociosHandler.Instancia.ObtenerSocio(((DataSocioPreview)lbSociosAtrasados.SelectedValue).Id);
         SocioDisciplinaWindow sdw = new SocioDisciplinaWindow(socio, true);
         sdw.ShowDialog();
         if (sdw.Actualizar.HasValue && sdw.Actualizar.Value)
         {
             cargarListaSociosAtrasados();
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("Ha ocurrido un error al leer datos socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         Logger.Log(ex.ToString());
     }
 }
        private void buttonDetallesPago_Click(object sender, RoutedEventArgs e)
        {
            bool?actualizar = new PagoWindow(socio, null, (Pago)listaPagos.SelectedItem).ShowDialog();

            if (actualizar.HasValue && actualizar.Value)
            {
                try
                {
                    socio = SociosHandler.Instancia.ObtenerSocio(socio.Id);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al cargar datos de socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Logger.Log(ex.ToString());
                }
                actualizarListaPagos();
                Actualizar = true;
            }
        }
 private void verFicha(long socioId)
 {
     try
     {
         Socio socio = SociosHandler.Instancia.ObtenerSocio(socioId);
         lbSociosAtrasados.SelectedItem = null;
         FichaSocio fichaSocio = new FichaSocio(socio);
         fichaSocio.ShowDialog();
         if (fichaSocio.Actualizar.HasValue && fichaSocio.Actualizar.Value)
         {
             cargarListaSociosAtrasados();
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("Ha ocurrido un error al leer datos socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         Logger.Log(ex.ToString());
     }
 }
        private void buttonNuevoPago_Click(object sender, RoutedEventArgs e)
        {
            Pago ultimoPago = socio.Pagos.OrderByDescending(p => p.MesPago).FirstOrDefault();
            bool?actualizar = new PagoWindow(socio, ultimoPago, null).ShowDialog();

            if (actualizar.HasValue && actualizar.Value)
            {
                try
                {
                    socio = SociosHandler.Instancia.ObtenerSocio(socio.Id);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al cargar datos de socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Logger.Log(ex.ToString());
                }
                actualizarListaPagos();
                Actualizar = true;
            }
        }
        public FichaSocio(Socio socio)
        {
            InitializeComponent();

            this.socio = socio;
            Title      = "Ficha de " + socio.Nombre;
            gridDatosSocio.DataContext = socio;

            try
            {
                string directory = System.IO.Directory.GetCurrentDirectory();
                string id_s      = (socio.Id).ToString();
                string img_path  = System.IO.Path.Combine(directory, @"imagenes\" + id_s + "_256.dat");

                if (!System.IO.File.Exists(img_path))
                {
                    buttonCargarImagen.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    buttonCargarImagen.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error cargar imágen.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Log(ex.ToString());
            }

            actualizarListaPagos();
            listaPagos.SelectedItems.Clear();
            buttonDetallesPago.IsEnabled = false;


            if (socio.Disciplinas.Count == 0) // Socio inactivo
            {
                buttonNuevoPago.IsEnabled = false;
            }
        }
 private void buttonDarBaja_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Socio socio = SociosHandler.Instancia.ObtenerSocio(((DataSocioPreview)listaSocios.SelectedValue).Id);
         SocioDisciplinaWindow sdw = new SocioDisciplinaWindow(socio, true);
         sdw.ShowDialog();
         if (sdw.Actualizar.HasValue && sdw.Actualizar.Value)
         {
             dspreviews = SociosHandler.Instancia.ObtenerDSPActivos();
             listaSocios.ItemsSource = dspreviews;
             filtrarListaSocios();
             Actualizar = true;
             verFicha(SociosHandler.Instancia.ObtenerSocio(socio.Id));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ha ocurrido un error al leer datos socio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         Logger.Log(ex.ToString());
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Socios EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSocios(Socio socio)
 {
     base.AddObject("Socios", socio);
 }