protected void ObtenerDatosCabecera(int nReferencia)
    {
        if (nReferencia > 0)
        {
            #region solicitud existente
            CABECERAGV oCab = CABECERAGV.ObtenerDatosCabecera(nReferencia);
            hdnReferencia.Text         = oCab.t420_idreferencia.ToString();
            hdnInteresado.Text         = oCab.t314_idusuario_interesado.ToString();
            sNodoUsuario               = oCab.t303_denominacion_beneficiario;
            hdnOficinaLiquidadora.Text = oCab.t010_idoficina.ToString();
            hdnEstado.Text             = oCab.t431_idestado;
            hdnEstadoAnterior.Text     = oCab.t431_idestado;
            txtInteresado.Text         = oCab.Interesado;
            //txtReferencia.Text = oCab.t420_idreferencia.ToString("#,###");
            sNodoUsuario     = oCab.t303_denominacion_beneficiario;
            txtConcepto.Text = oCab.t420_concepto;
            //txtEmpresa.Text = oCab.t313_denominacion;
            //cboMotivo.SelectedValue = oCab.t423_idmotivo.ToString();
            txtOficinaLiq.Text        = oCab.t010_desoficina;
            hdnIdProyectoSubNodo.Text = (oCab.t305_idproyectosubnodo.HasValue) ? oCab.t305_idproyectosubnodo.ToString() : "";
            txtProyecto.Text          = (oCab.t305_idproyectosubnodo.HasValue) ? ((int)oCab.t301_idproyecto).ToString("#,###") + " - " + oCab.t301_denominacion : "";
            cboMoneda.SelectedValue   = oCab.t422_idmoneda.ToString();
            if (oCab.t420_justificantes.HasValue)
            {
                if ((bool)oCab.t420_justificantes)
                {
                    rdbJustificantes.Items[0].Selected = true;
                }
                else
                {
                    rdbJustificantes.Items[1].Selected = true;
                }
            }
            txtObservacionesNota.Text     = oCab.t420_comentarionota;
            hdnAnotacionesPersonales.Text = Utilidades.escape(oCab.t420_anotaciones);
            if (oCab.t001_idficepi_interesado != (int)Session["GVT_IDFICEPI_ENTRADA"])
            {
                divAnotaciones.Style.Add("visibility", "hidden");
            }

            hdnOficinaBase.Text = "";

            if (oCab.t431_idestado == "P")//Aparcada
            {
                //setEmpresaTerritorio(oCab.t314_idusuario_interesado);
                int idEmpresaDefecto = GASVI.DAL.Configuracion.GetEmpresaDefecto(null, oCab.t001_codred);
                setEmpresaTerritorio(oCab.t314_idusuario_interesado, oCab.t001_idficepi_interesado, oCab.Interesado,
                                     idEmpresaDefecto, oCab.t313_idempresa);
            }
            else
            {
                txtEmpresa.Text      = oCab.t313_denominacion;
                hdnIDEmpresa.Text    = oCab.t313_idempresa.ToString();
                hdnIDTerritorio.Text = oCab.t007_idterrfis.ToString();
                lblTerritorio.Text   = oCab.t007_nomterrfis;
            }

            //hdnIDEmpresa.Text = oCab.t313_idempresa.ToString();
            //hdnIDTerritorio.Text = oCab.t007_idterrfis.ToString();
            //lblTerritorio.Text = oCab.t007_nomterrfis;

            cldKMCO.InnerText = oCab.t420_impkmco.ToString("N");
            cldDCCO.InnerText = oCab.t420_impdico.ToString("N");
            cldMDCO.InnerText = oCab.t420_impmdco.ToString("N");
            cldDECO.InnerText = oCab.t420_impdeco.ToString("N");
            cldDACO.InnerText = oCab.t420_impalco.ToString("N");
            cldKMEX.InnerText = oCab.t420_impkmex.ToString("N");
            cldDCEX.InnerText = oCab.t420_impdiex.ToString("N");
            cldMDEX.InnerText = oCab.t420_impmdex.ToString("N");
            cldDEEX.InnerText = oCab.t420_impdeex.ToString("N");
            cldDAEX.InnerText = oCab.t420_impalex.ToString("N");
            #endregion
        }
        else //Nueva nota
        {
            #region nueva solicitud
            USUARIO oUsuario = USUARIO.Obtener((int)Session["GVT_USUARIOSUPER"]);

            txtInteresado.Text = oUsuario.Nombre;
            hdnInteresado.Text = oUsuario.t314_idusuario.ToString();
            sNodoUsuario       = oUsuario.t303_denominacion;
            txtEmpresa.Text    = oUsuario.t313_denominacion;
            txtOficinaLiq.Text = (oUsuario.oOficinaLiquidadora != null) ? oUsuario.oOficinaLiquidadora.t010_desoficina : "";

            if (oUsuario.t422_idmoneda != "" && oUsuario.t422_idmoneda != null) //Moneda por defecto a nivel de usuario
            {
                cboMoneda.SelectedValue = oUsuario.t422_idmoneda.ToString();
            }
            if (oUsuario.oDietaKm != null)
            {
                cldKMCO.InnerText = oUsuario.oDietaKm.t069_ick.ToString("N");
                cldDCCO.InnerText = oUsuario.oDietaKm.t069_icdc.ToString("N");
                cldMDCO.InnerText = oUsuario.oDietaKm.t069_icmd.ToString("N");
                cldDECO.InnerText = oUsuario.oDietaKm.t069_icde.ToString("N");
                cldDACO.InnerText = oUsuario.oDietaKm.t069_icda.ToString("N");
            }
            if (oUsuario.oTerritorio != null)
            {
                cldKMEX.InnerText = oUsuario.oTerritorio.T007_ITERK.ToString("N");
                cldDCEX.InnerText = oUsuario.oTerritorio.T007_ITERDC.ToString("N");
                cldMDEX.InnerText = oUsuario.oTerritorio.T007_ITERMD.ToString("N");
                cldDEEX.InnerText = oUsuario.oTerritorio.T007_ITERDE.ToString("N");
                cldDAEX.InnerText = oUsuario.oTerritorio.T007_ITERDA.ToString("N");
            }

            hdnOficinaBase.Text        = (oUsuario.t010_idoficina_base.HasValue) ? oUsuario.t010_idoficina_base.ToString() : "";
            hdnOficinaLiquidadora.Text = (oUsuario.oOficinaLiquidadora != null) ? oUsuario.oOficinaLiquidadora.t010_idoficina.ToString() : "";

            //1ºComprobar si el profesional tiene más de una empresa.
            //setEmpresaTerritorio((int)Session["GVT_USUARIOSUPER"]);
            setEmpresaTerritorio(oUsuario.t314_idusuario, oUsuario.t001_idficepi, oUsuario.Nombre,
                                 oUsuario.t313_idempresa_defecto, 0);
            #endregion
        }
    }