Example #1
0
        //metodo para agregar Socio
        public static int AgregarSocio(Socio s, String query)
        {
            int          retorno = 0;
            MySqlCommand cmd     = new MySqlCommand(String.Format(query, s.Dni, s.Nombre, s.Apellido), Conexion.obtenerConexion());

            retorno = cmd.ExecuteNonQuery();
            return(retorno);
        }
Example #2
0
        //metodo para buscar un profesor
        public static List <Socio> BuscarSocio(int dni)
        {
            List <Socio> _lista = new List <Socio>();

            MySqlCommand    cmd    = new MySqlCommand(String.Format("SELECT socio.dni, socio.nombre, socio.apellido FROM socio WHERE socio.dni = '{0}'", dni), Conexion.obtenerConexion());
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Socio ejer = new Socio();
                ejer.Nombre   = reader.GetString(1);
                ejer.Apellido = reader.GetString(2);
                ejer.Dni      = reader.GetInt32(0);


                _lista.Add(ejer);
            }
            return(_lista);
        }
Example #3
0
        private void btn_armarPlan_Click(object sender, EventArgs e)
        {
            if (ValidarDatos())
            {
                #region agrega Socio

                //Negrada
                //int dni = Clases.Metodos.ObtenerDniSocio(txt_NombreClientePlan.Text, txt_apellidoClientePlan.Text);

                int dni = Clases.Metodos.ValidarSocio(Convert.ToInt32(txt_dniSocio.Text));

                if (dni > 0)
                {
                    //si existe, actualiza los datos
                    Clases.Socio socio = new Clases.Socio();
                    string       query = "UPDATE socio SET socio.nombre = '" + txt_NombreClientePlan.Text.ToString() + "' , socio.apellido = '" + txt_apellidoClientePlan.Text.ToString() + "' WHERE socio.dni = " + Convert.ToInt32(txt_dniSocio.Text);
                    socio.Dni      = Convert.ToInt32(txt_dniSocio.Text);
                    socio.Nombre   = txt_NombreClientePlan.Text;
                    socio.Apellido = txt_apellidoClientePlan.Text;
                    int retorno = Clases.Metodos.AgregarSocio(socio, query);
                }
                else
                {
                    //si no existe, lo AGREGA
                    Clases.Socio socio = new Clases.Socio();
                    string       query = "INSERT INTO socio (dni, nombre, apellido) values ('{0}', '{1}', '{2}')";
                    socio.Dni      = Convert.ToInt32(txt_dniSocio.Text);
                    socio.Nombre   = txt_NombreClientePlan.Text;
                    socio.Apellido = txt_apellidoClientePlan.Text;
                    int retorno = Clases.Metodos.AgregarSocio(socio, query);
                }


                #endregion

                #region agrega PlanEjercicios
                Clases.PlanEjercicio plan = new Clases.PlanEjercicio();
                string query2             = "INSERT INTO planejercicios (nroPlan, dniSocio, fechaInicio, fechaFin, numSesiones, dniProfe, objetivo, observacion) " +
                                            "values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')";

                int nroPlan = Clases.Metodos.ObtenerNroPlanSocio(Convert.ToInt32(txt_dniSocio.Text));
                plan.numPlan     = nroPlan + 1;
                plan.dniSocio    = Convert.ToInt32(txt_dniSocio.Text);
                plan.fechaInicio = picker_fechaInicio.Text;
                plan.fechaFin    = picker_fechaFin.Text;
                plan.numSesiones = Convert.ToInt32(cmb_sesionesPlan.Value);
                plan.dniProfe    = Clases.Metodos.ObtenerDniProfe(cmb_profesor.Text);
                plan.objetivo    = txt_obj.Text;
                plan.obserb      = txt_obs.Text;
                int retorno2 = Clases.Metodos.AgregarDatosPlan(plan, query2);
                #endregion


                TabsSesiones tab = new TabsSesiones();
                tab.dniSocio = plan.dniSocio;
                tab.numPlan  = plan.numPlan;
                tab.Show();
                Decimal cantsesiones = cmb_sesionesPlan.Value;

                for (int i = 0; i < cantsesiones; i++)
                {
                    int sesion = i + 1;
                    tab.tabControl1.TabPages.Add(new MyTabPage(new FormPlanEjercicios(), sesion, plan.numPlan, plan.dniSocio));
                }


                #region Limpia FORMULARIO
                txt_dniSocio.Text      = "DNI";
                txt_dniSocio.ForeColor = Color.DimGray;

                txt_apellidoClientePlan.Text      = "APELLIDO";
                txt_apellidoClientePlan.ForeColor = Color.DimGray;

                txt_NombreClientePlan.Text      = "NOMBRE";
                txt_NombreClientePlan.ForeColor = Color.DimGray;

                cmb_sesionesPlan.Value = 1;

                txt_obj.Text = "";
                txt_obs.Text = "";

                cmb_profesor.SelectedIndex = -1;

                picker_fechaInicio.MinDate = DateTime.Today;
                picker_fechaFin.MinDate    = DateTime.Today.AddDays(1);
                picker_fechaInicio.Text    = DateTime.Now.ToString("dd/MM/yyyy");
                picker_fechaFin.Text       = DateTime.Now.AddDays(30).ToString("dd/MM/yyyy");
                #endregion
            }
        }