protected void grvnotarecojo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int fila    = Convert.ToInt32(e.CommandArgument);
            int idabono = Convert.ToInt32(grvnotarecojo.Rows[fila].Cells[0].Text);

            if (e.CommandName == "Eliminar")
            {
                NotaRecojoDAO db = new NotaRecojoDAO();
                db.Eliminar(idabono);
                db.EliminarDetalle(idabono);
                cargar();
                string script = "openModal();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "correcto", script, true);
            }
            else if (e.CommandName == "Modificar")
            {
                int id = Convert.ToInt32(grvnotarecojo.Rows[fila].Cells[0].Text);
                Response.Redirect("ModNotaRecojo.aspx?IDMP=" + id, true);
            }
            else if (e.CommandName == "Imprimir")
            {
                string ID    = grvnotarecojo.Rows[fila].Cells[0].Text;
                string sRuta = "Reportes/frmNotaRecojo.aspx?Id=" + ID;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Window1", "<script> window.open('" + sRuta + "');</script>", false);
            }
        }
 protected void btnguardar_Click(object sender, EventArgs e)
 {
     try
     {
         Model.Enity.NotaRecojo nt = new Model.Enity.NotaRecojo();
         nt.Id            = Convert.ToInt32(Request.QueryString["IDMP"]);
         nt.Numero_Recojo = txtnumerorecojo.Text;
         nt.Id_Vendedor   = Convert.ToInt32(txtxvendedor.Text);
         nt.Id_Cliente    = Convert.ToInt32(ddlcliente.SelectedValue);
         nt.Nota          = txtnota.Text;
         nt.Fecha         = txtfecha.Text;
         nt.sw            = chkrecojo.Checked;
         Int32 id = nt.Id;
         if (chkrecojo.Checked == true)
         {
             nt.swdecrip = "Si Recogio";
         }
         else
         {
             nt.swdecrip = "No Recogio";
         }
         NotaRecojoDAO nota = new NotaRecojoDAO();
         nota.ActualizarNotaRecojo(nt);
         nota.EliminarDetalle(id);
         foreach (GridViewRow fila in grvDetalles.Rows)
         {
             NotaRecojoDetalle det    = new NotaRecojoDetalle();
             TextBox           precio = (TextBox)fila.FindControl("txtprecio");
             det.Id_Producto = Convert.ToInt32(fila.Cells[0].Text);
             det.Precio      = Convert.ToDecimal(precio.Text);
             nota.InsertarNotaRecojoDetalle(det, id);
         }
         Response.Redirect("ManteNotaRecojo.aspx", true);
     }
     catch (Exception ex)
     {
         txtmensaje.Text = ex.Message;
         string script = "openModal();";
         ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", script, true);
     }
 }