Crear un fichero de texto desde un CEESI_Informe
Código VB6:
Sub Show()
gform.Botonera.activarscripts=True
gform.Botonera.BotonAdd "InformeTXT", "BotPersGeneraInformeTXT", , 0, True, 123
End Sub
Sub Botonera_AfterExecute(aBotonera, aBoton)
If aboton.name = "BotPersGeneraInformeTXT" Then
InformeTXT
End If
End Sub
Sub InformeTXT()
lIdInforme=999
Set pCuaderno = gCn.Obj.DameObjeto("Informes", "Where IdInforme=" & lIdInforme)
Set lCol = gcn.DameNewCollection
lCol.Add CLng(Parametro1),"PEtiqueta"'Donde etiqueta es un campo de
CEESI_Informes_Parametros
lCol.Add CLng(ParametroN),"PEtiqueta"
Set pCuaderno.Objeto.ColParametros = lcol
lfilename="C:\Prueba.txt"
lCadena = pCuaderno.Objeto.GeneraInforme(lErrores)
Set lUt = CreateObject("AhoraUtil.CUtil")
lUt.GuardaFichero cstr(lFileName), cstr(lCadena)
If Len(lErrores) > 0 Then
If MsgBox("El informe se ha generado con errores.¿Desea visualizarlos?", 20, "Genera
Informes") = 6 Then
Set lFrm = gCn.AhoraProceso("DameZoom", False, gCn)
lPrt = "Errores informe: " & gcn.damevalorcampo("Select descrip from ceesi_informes where idinforme=" & lIdInforme)
lFrm.Carga cstr(lPrt), cstr(lErrores)
End If
Else
MsgBox "El informe se ha generado correctamente", 64, "Genera Informes"
End If
End subCódigo C#:
using AhoraCore;
using AhoraOCX;
using AhoraSistema;
using static AhoraCore.VBA.Interaction;
using static AhoraCore.VbMsgBoxResult;
using static AhoraCore.VbMsgBoxStyle;
using System;
using AhoraAsistentes;
using AhoraGeneral;
using AhoraUtil;
namespace AhoraScriptsPantalla
{
public class AhoraCl_frmClientes : AhoraOCX.AhoraBaseScript
{
public void Show()
{
try
{
((ICntBotonera)((IForm)gForm).Controls["Botonera"]).ActivarScripts = true;
((ICntBotonera)((IForm)gForm).Controls["Botonera"]).BotonAdd("InformeTXT", "BotPersGeneraInformeTXT", "", (ETipo_Menu)0, true, 123);
}
catch (Exception)
{
throw;
}
}
public override void Botonera_AfterExecute(ICntBotonera aBotonera, IAhoraTool aBoton)
{
base.Botonera_AfterExecute(aBotonera, aBoton);
try
{
if (aBoton.Name == "BotPersGeneraInformeTXT")
{
InformeTXT();
}
}
catch (Exception)
{
throw;
}
}
public void InformeTXT()
{
Valor lPrt = ValorEmpty.Value;
IFrmZoom lFrm = null;
//CUtil lUt = null;
Valor lErrores = ValorEmpty.Value;
Valor lCadena = ValorEmpty.Value;
Valor lfilename = ValorEmpty.Value;
Valor ParametroN = ValorEmpty.Value;
Valor Parametro1 = ValorEmpty.Value;
IVB6Collection<Valor> lCol = null;
IInforme pCuaderno = null;
Valor lIdInforme = ValorEmpty.Value;
try
{
lIdInforme = 999;
pCuaderno = (IInforme)gCn.Obj.DameObjeto("Informes", "Where IdInforme=" + lIdInforme);
lCol = gCn.DameNewCollection();
lCol.Add((int)Parametro1, "PEtiqueta");
//...
lCol.Add((int)ParametroN, "PEtiqueta");
((IInforme)pCuaderno).ColParametros = lCol;
lfilename = @"C:\Prueba.txt";
lCadena = ((IInforme)pCuaderno).GeneraInforme(ref lErrores);
//lUt = new AhoraUtil.CUtil();;
CUtil.GuardaFichero((string)lfilename, (string)lCadena);
if (lErrores.ToString().Length > 0)
{
if ((int)MsgBox("El informe se ha generado con errores.¿Desea visualizarlos?", (VbMsgBoxStyle)20, "Genera Informes") == 6)
{
lFrm = (IFrmZoom)gCn.AhoraProceso("DameZoom", out _, gCn);
lPrt = "Errores informe: " + gCn.DameValorCampo("Select descrip from ceesi_informes where idinforme=" + lIdInforme);
lFrm.Carga((string)lPrt, (string)lErrores);
}
}
else
{
MsgBox("El informe se ha generado correctamente", (VbMsgBoxStyle)64, "Genera Informes");
}
}
catch (Exception)
{
throw;
}
}
}
}¿Le ha sido útil este artículo?
¡Qué bien!
Gracias por sus comentarios
¡Sentimos mucho no haber sido de ayuda!
Gracias por sus comentarios
Sus comentarios se han enviado
Agradecemos su esfuerzo e intentaremos corregir el artículo