示例#1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string nombre = tbNombre.Text.Trim();

            if (ValidarComboBox.opcionValida(cbEjercicioOPersona, cbEjercicioOPersona.Text) &&
                !String.IsNullOrEmpty(nombre))
            {
                if (cbEjercicioOPersona.SelectedItem.ToString() == "Ejercicios")
                {
                    Ejercicios.insertarEjercicio(nombre);
                }
                else if (cbEjercicioOPersona.SelectedItem.ToString() == "Personas" && double.TryParse(tbAltura.Text, out double altura))
                {
                    Personas.insertarPersona(nombre, altura);
                }
                else
                {
                    MessageBox.Show("¡Recordá que la altura tiene que ser un número!");
                }
            }
            else
            {
                MessageBox.Show("Recordá que el nombre no puede estar vacío. Además, solo se pueden seleccionar personas o ejercicios.");
            }

            RecargarDataGridView();
            tbNombre.Text = "";
            tbAltura.Text = "";
            tbNombre.Focus();
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (ValidarComboBox.opcionValida(cbPersonas, cbPersonas.Text))
            {
                #region Inicializacion variables
                String      fecha     = Fecha.convertirFormatoUniversal(dtpActualizacion.Value);
                DataRowView Persona   = (DataRowView)cbPersonas.Items[cbPersonas.SelectedIndex];
                int         personaID = Convert.ToInt32(Persona.Row["id"]);
                #endregion
                if (double.TryParse(tbPeso.Text, out double peso) &&
                    fotosPersona.Count != 0)
                {
                    int DetallesPersonaID = DetallesPersonas.insertarDetallesPersona(peso, fecha, personaID);

                    foreach (Image Foto in fotosPersona)
                    {
                        byte[] fotoPersona = ConversorImagenes.ConvertirImagenBytes(Foto);
                        DetallesPersonas.insertarFoto(DetallesPersonaID, fotoPersona);
                    }

                    MessageBox.Show("¡Los cambios han sigo guardados correctamente!");
                    limpiarForm();
                }
                else
                {
                    MessageBox.Show("¡Recorda que debes seleccionar al menos una foto, y que el peso debe ser numérico!");
                }
            }
            else
            {
                MessageBox.Show("¡Recordá que tenes que elegir una persona!");
            }
        }
示例#3
0
 private void btnAgregarEjercicio_Click(object sender, EventArgs e)
 {
     if (ValidarComboBox.opcionValida(cbOpcion, cbOpcion.Text) &&
         ValidarComboBox.opcionValida(cbEjercicios, cbEjercicios.Text))
     {
         DataRowView Ejercicio   = (DataRowView)cbEjercicios.Items[cbEjercicios.SelectedIndex];
         int         ejercicioID = Convert.ToInt32(Ejercicio.Row["id"]);
         Rutinas.insertarEjercicioRutina(ejercicioID, rutinaID);
         actualizarDataGridViews();
         cbEjercicios.Focus();
     }
     else
     {
         MessageBox.Show("¡Primero tenes que seleccionar una opción de rutina y algún ejercicio!");
     }
 }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (ValidarComboBox.opcionValida(cbPersonas, cbPersonas.Text) &&
                ValidarComboBox.opcionValida(cbEjercicios, cbEjercicios.Text))
            {
                #region Inicializacion variables
                int         tope          = Convert.ToInt32(tbCantidadSeries.Text);
                int[]       arregloRepSeg = generarArreglo <int>("textRepOSeg", tope);
                double[]    arregloPesos  = generarArreglo <double>("textPeso", tope);
                String      fecha         = Fecha.convertirFormatoUniversal(dtpDiaEntrenamiento.Value);
                DataRowView Persona       = (DataRowView)cbPersonas.Items[cbPersonas.SelectedIndex];
                int         personaID     = Convert.ToInt32(Persona.Row["id"]);
                DataRowView Ejercicio     = (DataRowView)cbEjercicios.Items[cbEjercicios.SelectedIndex];
                int         ejercicioID   = Convert.ToInt32(Ejercicio.Row["id"]);
                #endregion

                if (arregloPesos != null &&
                    arregloRepSeg != null &&
                    ValidarComboBox.opcionValida(cbRepOseg, cbRepOseg.Text))
                {
                    int setID = Sets.obtenerSet(fecha, personaID);
                    if (setID == 0)
                    {
                        setID = Sets.insertarSet(fecha, personaID);
                    }
                    for (int i = 0; i < tope; i++)
                    {
                        if (cbRepOseg.SelectedItem.ToString() == "Repeticiones")
                        {
                            Series.insertarSerieRepeticiones(setID, ejercicioID, arregloRepSeg[i], arregloPesos[i]);
                        }
                        else
                        {
                            Series.insertarSerieSegundos(setID, ejercicioID, arregloRepSeg[i], arregloPesos[i]);
                        }
                    }

                    MessageBox.Show("¡La serie se ha insertado correctamente!");
                    limpiarForm();
                }
            }
            else
            {
                MessageBox.Show("Recordá que las personas y los ejercicios deben ser ingresados correctamente");
            }
        }
示例#5
0
 private void RecargarDataGridView()
 {
     if (ValidarComboBox.opcionValida(cbEjercicioOPersona, cbEjercicioOPersona.Text))
     {
         if (cbEjercicioOPersona.SelectedItem.ToString() == "Personas")
         {
             dataGridView1.DataSource = Personas.obtenerPersonas().Tables[0];
             lAltura.Visible          = true;
             tbAltura.Visible         = true;
         }
         else
         {
             dataGridView1.DataSource = Ejercicios.obtenerEjercicios().Tables[0];
             lAltura.Visible          = false;
             tbAltura.Visible         = false;
         }
     }
 }