Beispiel #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                rutina.fechaDesde     = dtpFechaDesde.Value;
                rutina.fechaHasta     = dtpFechaHasta.Value;
                rutina.serie          = int.Parse(txtSeries.Text);
                rutina.repeticion     = int.Parse(txtRepeticiones.Text);
                rutina.tiempoduracion = txtTiempoDuracion.Text;
                rutina.descanso       = txtDescanso.Text;
                rutina.pesokg         = float.Parse(txtKg.Text);
                this.validarRelacionesTablas();

                if (rutina.idrutina > 0)
                {
                    dbGimnasio.Entry(rutina).State = EntityState.Modified;
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                dbGimnasio.SaveChanges();
                this.Close();
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                this.ValidarCatch(ex);
                throw;
            }
        }
Beispiel #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (telefono.idtelefono > 0)
            {
                try
                {
                    telefono.numero = txtNumeroTelefono.Text;

                    dbGimnasio.Entry(telefono).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();

                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
                {
                    this.ValidateCatch(ex);
                    throw;
                }
            }
            else
            {
                if (cboTipoTelefono.SelectedIndex != -1 && !string.IsNullOrEmpty(txtNumeroTelefono.Text))
                {
                    idtipotelefono = (int)cboTipoTelefono.SelectedValue;
                    numero         = txtNumeroTelefono.Text;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Ambos campos son requeridos.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Beispiel #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                calle.nombre_calle = txtNombreCalle.Text;

                if (calle.idcalle > 0)
                {
                    dbGimnasio.Entry(calle).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtNombreCalle.Text))
                    {
                        dbGimnasio.Calles.Add(calle);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("La caja de texto no puede estar vacia.", "Advertendcia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtNombreCalle.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                this.ValidarCatch(ex);
                throw;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                tipo_Usuario.tipo = txtTipoUsuario.Text;

                if (tipo_Usuario.idtipousuario > 0)
                {
                    dbGimnasio.Entry(tipo_Usuario).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtTipoUsuario.Text))
                    {
                        dbGimnasio.Tipos_Usuarios.Add(tipo_Usuario);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("La caja de texto no puede estar vacía.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtTipoUsuario.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                this.ValidateCatch(ex);
                throw;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (tipo_Calentamiento.idtipocalentamiento > 0)
                {
                    tipo_Calentamiento.nombre = txtTipoCalentamiento.Text;

                    dbGimnasio.Entry(tipo_Calentamiento).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();

                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtTipoCalentamiento.Text))
                    {
                        nombre_tipo_calentamiento = txtTipoCalentamiento.Text;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("El campo de texto no puede estar vacío.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtTipoCalentamiento.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                this.ValidateCatch(ex);
                throw;
            }
        }
Beispiel #6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Lo cargamos de este modo porque el combo esta cargado con tipos anonimos.
                control_Ingreso.Cliente = dbGimnasio.Clientes.Find(cboCliente.SelectedValue);
                this.Turnos();
                control_Ingreso.fecha = dtpFechaIngreso.Value;

                if (control_Ingreso.idcontrolingreso > 0)
                {
                    dbGimnasio.Entry(control_Ingreso).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (cboCliente.SelectedIndex != -1)
                    {
                        dbGimnasio.Control_Ingresos.Add(control_Ingreso);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Se debe seleccionar un Cliente", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        cboCliente.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            FrmGestionControlIngreso.botonGuardarPresionado = true;
        }
Beispiel #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ejercicio.nombre = txtNombreEjercicio.Text;
            ejercicio.imagen = resizeImage(imageToByteArray(pbxImagen.Image));

            if (ejercicio.idejercicio > 0)
            {
                try
                {
                    dbGimnasio.Entry(ejercicio).State = EntityState.Modified;
                    dbGimnasio.Configuration.AutoDetectChangesEnabled = true;

                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dbGimnasio.SaveChanges();
                    this.Close();
                }
                catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
                {
                    this.validarCatch(ex);
                    throw;
                }
            }
            else
            {
                try
                {
                    if (string.IsNullOrEmpty(txtNombreEjercicio.Text))
                    {
                        MessageBox.Show("El campo 'Ejercicio' no puede estar vacío.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtNombreEjercicio.Focus();
                    }
                    else
                    {
                        dbGimnasio.Ejercicios.Add(ejercicio);
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dbGimnasio.SaveChanges();
                        this.Close();
                        Reportes.ReporteEjercicio reporteEjercicio = new Reportes.ReporteEjercicio(ejercicio.idejercicio);
                        reporteEjercicio.ShowDialog();
                    }
                }
                catch (DbEntityValidationException ex)
                {
                    this.validarCatch(ex);
                    throw;
                }
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                tipo_Telefono.tipo_telefono = txtTipoTelefono.Text;

                if (tipo_Telefono.idtipotelefono > 0)
                {
                    dbGimnasio.Entry(tipo_Telefono).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtTipoTelefono.Text))
                    {
                        dbGimnasio.Tipos_Telefonos.Add(tipo_Telefono);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("La caja de texto no puede estar vacía.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtTipoTelefono.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
Beispiel #9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                cardio.Duracion = txtDuración.Text;
                cardio.ritmo    = txtRitmo.Text;

                if (cardio.idcardio > 0)
                {
                    dbGimnasio.Entry(cardio).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtDuración.Text) && !string.IsNullOrEmpty(txtRitmo.Text))
                    {
                        dbGimnasio.Cardios.Add(cardio);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ambos campos son requeridos.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        private void Guardar()
        {
            try
            {
                localidad.localidad = txtLocalidadNombre.Text;

                if (localidad.idlocalidad > 0)
                {
                    dbGimnasio.Entry(localidad).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtLocalidadNombre.Text))
                    {
                        dbGimnasio.Localidads.Add(localidad);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("El campo de texto no puede estar vacío.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtLocalidadNombre.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
Beispiel #11
0
        //private void llenarGrillaEjercicio()
        //{
        //    ejercicio = new Ejercicio();
        //    ejercicio.ejercicio_nombre = FrmNuevoEditarEjercicio.ejercicio_nombre;
        //    ejercicio.ejercicio_imagen = FrmNuevoEditarEjercicio.image;

        //    if (rutina.Ejercicios == null)
        //    {
        //        rutina.Ejercicios = new ObservableCollection<Ejercicio>();
        //    }

        //    rutina.Ejercicios.Add(ejercicio);

        //    FrmNuevoEditarEjercicio.ejercicio_nombre = "";
        //    FrmNuevoEditarEjercicio.image = null;
        //}

        //private void cargarGrillaEjercicios()
        //{
        //    if (rutina.Ejercicios != null)
        //    {
        //        var listaEjercicios = from e in rutina.Ejercicios
        //                              select new
        //                              {
        //                                  idejercicio = e.ejercicio_idejercicio,
        //                                  nombre = e.ejercicio_nombre,
        //                                  imagen = FrmNuevoEditarEjercicio.byteArrayToImage(e.ejercicio_imagen),
        //                                  isDelected = e.ejercicio_delete
        //                              };

        //        gridEjercicio.DataSource = listaEjercicios.Where(e => e.isDelected == false).ToList();
        //        ((DataGridViewImageColumn)gridEjercicio.Columns[2]).ImageLayout = DataGridViewImageCellLayout.Zoom;
        //        ((DataGridViewImageColumn)gridEjercicio.Columns[2]).DefaultCellStyle.NullValue = null;
        //    }
        //}

        //private void btnQuitarEjercicio_Click(object sender, EventArgs e)
        //{
        //    if (gridEjercicio.Rows.Count > 0 && gridEjercicio.SelectedRows.Count > 0)
        //    {
        //        int idSeleccionado = (int)celdaFilaActual(gridEjercicio, 0);

        //        string mensaje = "¿Está seguro que desea quitar?";
        //        string titulo = "Eliminación";
        //        DialogResult respuesta = MessageBox.Show(mensaje, titulo, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        //        if (respuesta == DialogResult.Yes)
        //        {
        //            int idDetalleSeleccionado = gridEjercicio.CurrentRow.Index;
        //            rutina.Ejercicios.RemoveAt(idDetalleSeleccionado);
        //            cargarGrillaEjercicios();
        //        }
        //    }
        //}

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                rutina.fechaDesde     = dtpFechaDesde.Value;
                rutina.fechaHasta     = dtpFechaHasta.Value;
                rutina.serie          = int.Parse(txtSeries.Text);
                rutina.repeticion     = int.Parse(txtRepeticiones.Text);
                rutina.tiempoduracion = txtTiempoDuracion.Text;
                rutina.descanso       = txtDescanso.Text;
                rutina.pesokg         = float.Parse(txtKg.Text);
                this.validarRelacionesTablas();

                if (rutina.idrutina > 0)
                {
                    dbGimnasio.Entry(rutina).State = EntityState.Modified;
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    dbGimnasio.Rutinas.Add(rutina);
                    MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                dbGimnasio.SaveChanges();
                Close();
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                domicilio.Calle = (Calle)cboCalle.SelectedItem;
                if (!string.IsNullOrEmpty(txtNumeroCalle.Text))
                {
                    domicilio.numero = Convert.ToInt32(txtNumeroCalle.Text);
                }


                if (domicilio.iddomicilio > 0)
                {
                    dbGimnasio.Entry(domicilio).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (cboCalle.SelectedIndex != -1)
                    {
                        dbGimnasio.Domicilios.Add(domicilio);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar una Calle.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        cboCalle.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar porque la consola debbug no muestra el error real.
            {
                this.ValidarCatch(ex);
                throw;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ejercicio.nombre = txtNombreEjercicio.Text;
            ejercicio.imagen = resizeImage(imageToByteArray(pbxImagen.Image));

            if (ejercicio.idejercicio > 0)
            {
                try
                {
                    dbGimnasio.Entry(ejercicio).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    this.Close();

                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
                {
                    this.ValidarCatch(ex);
                    throw;
                }
            }
        }
Beispiel #14
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                calentamiento.duracion    = txtDuracion.Text;
                calentamiento.descripcion = txtDescripcion.Text;

                if (calentamiento.idcalentamiento > 0)
                {
                    dbGimnasio.Entry(calentamiento).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtDuracion.Text))
                    {
                        dbGimnasio.Calentamientos.Add(calentamiento);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("La caja de texto Duración no puede estar vacia.", "Afvertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtDuracion.Focus();
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                this.ValidateCatch(ex);
                throw;
            }

            FrmGestionCaletamiento.BotonGuardarPresionado = true;
        }
Beispiel #15
0
        private void Guardar()
        {
            try
            {
                usuario.Tipo_Usuario = (Tipo_Usuario)cboTipoUsuario.SelectedItem;
                usuario.user         = txtUser.Text;
                usuario.password     = obtenerSha512Hash(txtPassword.Text);

                if (usuario.idusuario > 0)
                {
                    dbGimnasio.Entry(usuario).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (cboTipoUsuario.SelectedIndex != -1 && !string.IsNullOrEmpty(txtUser.Text))
                    {
                        dbGimnasio.Usuarios.Add(usuario);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar un Tipo de Usuario y especificar un nombre de Usuario.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                this.ValidateCatch(ex);
                throw;
            }
        }
Beispiel #16
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                cliente.nombre          = txtNombre.Text;
                cliente.apellido        = txtApellido.Text;
                cliente.fechaNacimiento = dtpFechaNacimiento.Value;
                cliente.edad            = Int32.Parse(CalcularEdad(dtpFechaNacimiento.Value).ToString());
                genero();
                cliente.Localidad    = (Localidad)cboLocalidad.SelectedItem;
                cliente.fechaIngreso = dtpFechaIngreso.Value;
                if (dbGimnasio.Domicilios.Find(FrmGestionDomicilio.iddomicilio) != null)
                {
                    cliente.Domicilio = dbGimnasio.Domicilios.Find(FrmGestionDomicilio.iddomicilio);
                }
                cliente.objetivos       = txtObjetivos.Text;
                cliente.lecturaCorporal = txtLecturaCorporal.Text;
                if (!string.IsNullOrEmpty(txtPeso.Text))
                {
                    cliente.peso = float.Parse(txtPeso.Text);
                }

                if (cliente.idcliente > 0)
                {
                    dbGimnasio.Entry(cliente).State = EntityState.Modified;
                    dbGimnasio.SaveChanges();
                    MessageBox.Show("Se ha modificado correctamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (this.IsValidate())
                    {
                        dbGimnasio.Clientes.Add(cliente);
                        dbGimnasio.SaveChanges();
                        MessageBox.Show("Se ha guardado correctamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Los campos de Nombre, Apellido, Localidad, Domicilio y Peso son requeridos, por favor complete todos.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (DbEntityValidationException ex) //<-- Sí ocurre alguna excepción al guardar
            {
                foreach (var dbEntityValidation in ex.EntityValidationErrors)
                {
                    Console.WriteLine("El tipo de entidad \"{0}\" en el estado \"{1}\" tiene los siguientes errores de validación:",
                                      dbEntityValidation.Entry.Entity.GetType().Name, dbEntityValidation.Entry.State);
                    foreach (var ve in dbEntityValidation.ValidationErrors)
                    {
                        Console.WriteLine("- Propiedad: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            FrmGestionClientes.botonGuardarPresionado = true;
        }