//public int GetIdDetCaja (string fecha)
        //{
        //    int ID;
        //    DataTable dt = new DataTable();
        //    TheGym k = new TheGym
        //    {
        //        FechaIdDetCaja = TxFecha.Text
        //    };
        //    dt = k.GetEstadoDetCaja();
        //    if (dt.Rows.Count > 0)
        //    {

        //    }
        //    else
        //    {

        //    }

        //    return ID;
        //}

        protected void BtnAceptar_Click(object sender, EventArgs e)
        {
            string    ID;
            int       auxiliar;
            DateTime  auxiliar1;
            DataTable dt = new DataTable();
            TheGym    k  = new TheGym
            {
                FechaIdDetCaja = TxFecha.Text
            };

            dt = k.GetEstadoDetCaja();
            if (dt.Rows.Count < 1)
            {
                //dt = ;
                //ID = Session["IdSession"]; GetIdDetCaja
                //ID = 3;
                DataTable dt1 = new DataTable();
                dt1 = k.GetEstadoDetCajaAP();
                if (dt1.Rows.Count > 0)
                {
                    DataTable dt2 = new DataTable();
                    dt2              = k.GetIdDetCaja();
                    ID               = dt2.Rows[0][0].ToString();
                    k.FKDetCajaMov   = ID;
                    k.FKFormaPagoMov = DdlMedioPago.SelectedValue.ToString();
                    k.EstadoMov      = "Ingreso";
                    k.ComprobanteMov = TxbComprobante.Text;
                    k.MontoMov       = TxTotal.Text;
                    k.ConceptoMov    = "Pago Plan";
                    k.HoraMov        = Convert.ToString(DateTime.Now.TimeOfDay);

                    k.AddMovimientoCaja();

                    k.FechaCuota      = TxFecha.Text;
                    k.FK_clienteCuota = GridView1.SelectedRow.Cells[0].Text;
                    k.FK_planCuota    = DdlPlan.SelectedValue.ToString();
                    k.MontoCuota      = TxTotal.Text;
                    DataTable aux1 = new DataTable();
                    k.IDPlanVencimiento = DdlPlan.SelectedValue;
                    aux1               = k.GetVencimiento();
                    auxiliar           = Convert.ToInt32(aux1.Rows[0][0].ToString());
                    auxiliar1          = Convert.ToDateTime(TxFecha.Text).AddDays(auxiliar);
                    k.VencimientoCuota = Convert.ToString(auxiliar1);
                    k.AddCuota();
                }
                else
                {
                    LblError.Visible   = true;
                    LblError.Text      = "Caja No Abierta";
                    LblError.ForeColor = System.Drawing.Color.Red;
                }
            }
            else
            {
                LblError.Visible   = true;
                LblError.Text      = "Caja Cerrada";
                LblError.ForeColor = System.Drawing.Color.Red;
            }
        }
        //protected void btnconsultar_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        gridclientes.Visible = true;

        //        TheGym k = new TheGym();
        //        k.NombreClienteBusc = tbnombre.Text;
        //        DataTable dt = k.GetClienteNom();
        //        if (dt.Rows.Count > 0)
        //        {
        //            gridclientes.DataSource = dt;
        //            gridclientes.DataBind();
        //            gridclientes.Focus();
        //            lblerror.Text = "";
        //        }
        //        else
        //        {
        //            lblerror.Text = "No se encontraron clientes relacionados";
        //        }

        //        flag = true;
        //    }
        //    catch (Exception ex)
        //    {

        //        lblerror.Text = ex.Message.ToString();
        //    }

        //}


        protected void btnregistrar_Click(object sender, EventArgs e)
        {
            try
            {
                string    ID;
                int       auxiliar;
                DateTime  auxiliar1;
                DataTable dt = new DataTable();
                TheGym    k  = new TheGym
                {
                    FechaIdDetCaja = lblFecha.Text
                };
                dt = k.GetEstadoDetCaja();
                if (dt.Rows.Count < 1)
                {
                    //dt = ;
                    //ID = Session["IdSession"]; GetIdDetCaja
                    //ID = 3;
                    DataTable dt1 = new DataTable();
                    dt1 = k.GetEstadoDetCajaAP();
                    if (dt1.Rows.Count > 0)
                    {
                        DataTable dt2 = new DataTable();
                        dt2              = k.GetIdDetCaja();
                        ID               = dt2.Rows[0][0].ToString();
                        k.FKDetCajaMov   = ID;
                        k.FKFormaPagoMov = ddlformadepago.SelectedValue.ToString();
                        k.EstadoMov      = "Ingreso";
                        k.ComprobanteMov = TbComprobante.Text;
                        k.MontoMov       = tbmonto.Text;
                        k.ConceptoMov    = "Pago Plan";
                        k.HoraMov        = Convert.ToString(DateTime.Now.TimeOfDay);

                        k.AddMovimientoCaja();

                        k.FechaCuota      = lblFecha.Text;
                        k.FK_clienteCuota = id;
                        k.FK_planCuota    = ddlplan.SelectedValue.ToString();
                        k.MontoCuota      = tbmonto.Text;
                        DataTable aux1 = new DataTable();
                        k.IDPlanVencimiento = ddlplan.SelectedValue;
                        aux1               = k.GetVencimiento();
                        auxiliar           = Convert.ToInt32(aux1.Rows[0][0].ToString());
                        auxiliar1          = Convert.ToDateTime(lblFecha.Text).AddDays(auxiliar);
                        k.VencimientoCuota = Convert.ToString(auxiliar1);
                        k.AddCuota();

                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true);
                        Label1.Text = "El cobro se ha registrado exitosamente!";
                        btngenerarcomprobante.Visible = true;
                        btnregistrar.Visible          = false;
                        btngenerarcomprobante.Visible = true;
                        btncancelar.Visible           = false;
                        btnvolver.Visible             = true;
                        tbmonto.Text           = string.Empty;
                        TbComprobante.Text     = string.Empty;
                        lblComprobante.Visible = false;
                        TbComprobante.Visible  = false;
                        ddlformadepago.ClearSelection();
                        ddlplan.ClearSelection();

                        //panelseleccioncliente.Visible = true;
                        //panelseleccioncliente.Focus();
                        //paneldatosdecobro.Visible = false;
                        //tbnombre.Text = "";
                    }
                    else
                    {
                        Label1.Visible       = true;
                        Label1.ForeColor     = System.Drawing.Color.Red;
                        btnregistrar.Enabled = false;
                        Label1.Text          = "Caja No Abierta";
                    }
                }
                else
                {
                    Label1.Visible   = true;
                    Label1.Text      = "Caja Cerrada";
                    Label1.ForeColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message.ToString();
            }
        }