Ejemplo n.º 1
0
        protected void btnregistrar_Click(object sender, EventArgs e)
        {
            try
            {
                string idrutina;

                DataTable aux1 = new DataTable();

                TheGym k = new TheGym
                {
                    NombreRutina = tbnombre.Text,
                    IDEmpleado   = Label5.Text,
                    IDCliete     = idcliente
                };


                aux1 = k.AddRutina();


                idrutina = aux1.Rows[0][0].ToString();



                for (int i = 0; i < gridejerciciosrutina.Rows.Count; i++)
                {
                    TheGym q = new TheGym
                    {
                        IDRutina    = idrutina,
                        IDEjercicio = gridejerciciosrutina.Rows[i].Cells[2].Text,
                        Serie       = gridejerciciosrutina.Rows[i].Cells[3].Text,
                        Repeticion  = gridejerciciosrutina.Rows[i].Cells[4].Text,
                        Dia         = gridejerciciosrutina.Rows[i].Cells[5].Text
                    };



                    q.AddDetalleRutina();

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
                }
            }
            catch (Exception ex)
            {
                lblerror.Text = ex.Message.ToString();
            }
        }
        protected void btneditarRutina_Click1(object sender, EventArgs e)
        {
            try
            {
                string idrutina;



                idrutina = gridfichaderutina.SelectedRow.Cells[0].Text;

                TheGym n = new TheGym
                {
                    IDRutina = idrutina
                };
                n.BorrarDetalle();

                for (int i = 0; i < gridejerciciosrutina.Rows.Count; i++)
                {
                    TheGym q = new TheGym
                    {
                        IDRutina    = idrutina,
                        IDEjercicio = gridejerciciosrutina.Rows[i].Cells[2].Text,
                        Serie       = gridejerciciosrutina.Rows[i].Cells[3].Text,
                        Repeticion  = gridejerciciosrutina.Rows[i].Cells[4].Text,
                        Dia         = gridejerciciosrutina.Rows[i].Cells[5].Text
                    };



                    q.AddDetalleRutina();
                }

                Label2.Text = "Se Edito correctamente la rutina";
                Label2.Focus();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
            }
            catch (Exception ex)
            {
                lblerror.Text = ex.Message.ToString();
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
        }
Ejemplo n.º 3
0
        protected void btnregistrar_Click(object sender, EventArgs e)
        {
            try
            {
                string idrutina;

                DataTable aux1 = new DataTable();

                TheGym k = new TheGym
                {
                    NombreRutina = tbnombrerutina.Text,
                    IDEmpleado   = lblentrenadordni.Text,
                    IDCliete     = lblid.Text
                };


                aux1 = k.AddRutina();


                idrutina = aux1.Rows[0][0].ToString();



                for (int i = 0; i < griddetallerutina.Rows.Count; i++)
                {
                    TheGym q = new TheGym
                    {
                        IDRutina    = idrutina,
                        IDEjercicio = griddetallerutina.Rows[i].Cells[2].Text,
                        Serie       = griddetallerutina.Rows[i].Cells[3].Text,
                        Repeticion  = griddetallerutina.Rows[i].Cells[4].Text,
                        Dia         = griddetallerutina.Rows[i].Cells[5].Text
                    };



                    q.AddDetalleRutina();


                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
                }
                //mensaje de exito de registro
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
                //vuelvo a vaciar datos
                tbnombrerutina.Text = null;
                //significa que estaba viendo y ahora vuelve a la busqueda
                btnañadir.CausesValidation    = false;
                btnregistrar.CausesValidation = false;
                btncancelar.CausesValidation  = false;
                lblerror.Text = "";
                griddetallerutina.DataSource = null;
                griddetallerutina.DataBind();
            }
            catch (Exception ex)
            {
                lblerror.Text = ex.Message.ToString();
            }


            //vuelvo a vaciar datos
            tbnombrerutina.Text = null;
            //significa que estaba viendo y ahora vuelve a la busqueda
            btnañadir.CausesValidation    = false;
            btnregistrar.CausesValidation = false;
            btncancelar.CausesValidation  = false;
            lblerror.Text = "";
            griddetallerutina.DataSource = null;
            griddetallerutina.DataBind();
            Tabla.Rows.Clear();
            griddetallerutina.Dispose();
        }