195 lines
9.5 KiB
C++
195 lines
9.5 KiB
C++
//---------------------------------------------------------------------------
|
||
#include <Filectrl.hpp>
|
||
#include <vcl.h>
|
||
#pragma hdrstop
|
||
|
||
#include "Unit1.h"
|
||
//---------------------------------------------------------------------------
|
||
#pragma package(smart_init)
|
||
#pragma resource "*.dfm"
|
||
TForm1 *Form1;
|
||
//---------------------------------------------------------------------------
|
||
__fastcall TForm1::TForm1(TComponent* Owner)
|
||
: TForm(Owner)
|
||
{
|
||
if ( !ParamStr(1).IsEmpty() )
|
||
TbD->TableName = ParamStr(1) + "Datos\\Tb_Ref.db";
|
||
TbD->IndexName = "FamIdx";
|
||
TbD->Active = true;
|
||
GenerarIndice( "tprodl.htm" );
|
||
Label2->Font->Color = clMaroon;
|
||
GenerarEnlaces();
|
||
Timer1->Enabled = true;
|
||
}
|
||
//---------------------------------------------------------------------------
|
||
void __fastcall TForm1::GenerarIndice( AnsiString FicheroSalida )
|
||
{
|
||
int Nivel = 0, NivelPrimario;
|
||
int iFileHandle;
|
||
AnsiString Header, Body, Footer, Familia, Hijo, CSS;
|
||
|
||
|
||
Header = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> \
|
||
<meta name=\"GENERATOR\" content=\"JDsoft.\"> \
|
||
<title>Arbol Indice</title><base target=\"descripcion\">\
|
||
<link rel=\"stylesheet\" type=\"text/css\" href=\"images\\db2htm-i.css\" body=\"images\\db2htm-i.css\"> <head> \
|
||
<body bgcolor=\"#FFFFFF\" link=\"#FFFFFF\" vlink=\"#FFFFFF\"> \
|
||
<div align=\"center\"><center> \
|
||
<table border=\"1\" style=\"CURSOR: hand;\" cellpadding=\"5\" cellspacing=\"0\" width=\"150\" bgcolor=\"#000080\" bordercolordark=\"#1D8DFE\" bordercolorlight=\"#000000\"> ";
|
||
Footer = "</table></center></div></body></html>";
|
||
CSS = "class=z onmouseover=\"this.className='a';return true\" onmouseout=\"this.className='z';\" ";
|
||
|
||
iFileHandle = FileCreate( FicheroSalida );
|
||
|
||
FileWrite(iFileHandle, Header.c_str(), Header.Length() );
|
||
|
||
ProgressBar1->Position = 0;
|
||
ProgressBar1->Max = TbD->RecordCount;
|
||
TbD->First();
|
||
while( !TbD->Eof )
|
||
{
|
||
if ( TbD->FieldByName("EsNodo")->AsInteger == -1 )
|
||
{
|
||
NivelPrimario = TbD->FieldByName("Familia")->AsInteger;
|
||
if ( (NivelPrimario & 0xFF000000) ) Nivel = 1;
|
||
if ( (NivelPrimario & 0x00FF0000) ) Nivel = 2;
|
||
if ( (NivelPrimario & 0x0000FF00) ) Nivel = 3;
|
||
if ( (NivelPrimario & 0x000000FF) ) Nivel = 4;
|
||
|
||
#define Nivel_1 24
|
||
#define Nivel_2 16
|
||
#define Nivel_3 8
|
||
#define NivelRuptura Nivel_2
|
||
|
||
Familia = AnsiString( NivelPrimario>>NivelRuptura );
|
||
Hijo = TbD->FieldByName("Familia")->AsString;
|
||
switch( Nivel )
|
||
{
|
||
case 1:
|
||
Body ="<tr><td><br></td></tr><tr><a href=\""+Familia+".htm#"+Hijo+"\"><td "+CSS+" ><font size=\"4\" face=\"Verdana\">"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</font></td></a></tr>";
|
||
break;
|
||
case 2:
|
||
Body ="<tr><a href=\""+Familia+".htm#"+Hijo+"\"><td "+CSS+" ><font size=\"2\" face=\"Verdana\">"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</font></td></a></tr>";
|
||
break;
|
||
case 3:
|
||
Body ="<tr><a href=\""+Familia+".htm#"+Hijo+"\"><td "+CSS+" ><font size=\"0\" face=\"Verdana\">"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</font></td></a></tr>";
|
||
break;
|
||
case 4:
|
||
Body ="<tr><a href=\""+Familia+".htm#"+Hijo+"\"><td "+CSS+" ><font size=\"-2\" face=\"Verdana\">"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</font></td></a></tr>";
|
||
break; //
|
||
}
|
||
FileWrite(iFileHandle, Body.c_str(), Body.Length() );
|
||
}
|
||
ProgressBar1->Position++;
|
||
TbD->Next();
|
||
}
|
||
|
||
FileWrite(iFileHandle, Footer.c_str(), Footer.Length() );
|
||
FileClose(iFileHandle);
|
||
|
||
}
|
||
//---------------------------------------------------------------------------
|
||
void __fastcall TForm1::GenerarEnlaces()
|
||
{
|
||
int Nivel = 0, NivelPrimario;
|
||
int iFileHandle;
|
||
AnsiString Header, Body, Footer, Familia, Hijo, ImageName;
|
||
|
||
|
||
Header = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> \
|
||
<meta name=\"GENERATOR\" content=\"JDsoft.\"> \
|
||
<title>Arbol Indice</title> <link rel=\"stylesheet\" type=\"text/css\" href=\"images\\db2htm-l.css\" body=\"images\\db2htm-l.css\"><script src=\"images\\code.js\"></script><head> \
|
||
<body background=\"images\\fondo.gif\" bgcolor=\"#0D5AB9\" text=\"#000000\" link=\"#FFFF00\" vlink=\"#FFFF00\" topmargin=\"0\" leftmargin=\"0\"><table>";
|
||
Footer = "</table><p>*Estos precios no incluyen IVA<br><3E>ltima actualizaci<63>n de esta p<>gina <font color=\"#00FF00\">"+DateToStr(Date())+" - "+TimeToStr(Time())+"</font></p></body></html>";
|
||
|
||
|
||
if (!DirectoryExists( "imgprod" ))
|
||
CreateDir("imgprod");
|
||
|
||
iFileHandle = FileCreate( "errores.html" );
|
||
FileWrite(iFileHandle, Header.c_str(), Header.Length() );
|
||
|
||
ProgressBar1->Position = 0;
|
||
ProgressBar1->Max = TbD->RecordCount;
|
||
TbD->First();
|
||
while( !TbD->Eof )
|
||
{
|
||
if ( TbD->FieldByName("EsNodo")->AsInteger == -1 )
|
||
{
|
||
NivelPrimario = TbD->FieldByName("Familia")->AsInteger;
|
||
if ( (NivelPrimario & 0xFF000000) ) Nivel = 1;
|
||
if ( (NivelPrimario & 0x00FF0000) ) Nivel = 2;
|
||
if ( (NivelPrimario & 0x0000FF00) ) Nivel = 3;
|
||
if ( (NivelPrimario & 0x000000FF) ) Nivel = 4;
|
||
|
||
Familia = AnsiString( NivelPrimario>>NivelRuptura );
|
||
Hijo = TbD->FieldByName("Familia")->AsString;
|
||
|
||
if ( Nivel==1 ||
|
||
(NivelRuptura==16 && Nivel==2) ||
|
||
(NivelRuptura==8 && Nivel==3) )
|
||
{
|
||
FileWrite(iFileHandle, Footer.c_str(), Footer.Length() );
|
||
FileClose(iFileHandle);
|
||
|
||
iFileHandle = FileCreate( Familia+".htm" );
|
||
FileWrite(iFileHandle, Header.c_str(), Header.Length() );
|
||
}
|
||
|
||
switch( Nivel )
|
||
{
|
||
case 1:
|
||
case 2:
|
||
Body = "</table><br><br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"20\"><img src=\"images\\gradhort.gif\" width=\"20\" height=\"32\"></td> <td width=\"100%\" background=\"images\\gradhor.gif\"><font size=\"5\"><strong>"+
|
||
TbD->FieldByName("Nombre del Producto")->AsString+"</strong></font></td></tr></table><p><br><br></p> \
|
||
<table border=\"1\" cellspacing=\"0\" width=\"100%\" bordercolor=\"#000000\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#000000\"> \
|
||
<tr><td align=\"center\" bgcolor=\"#000000\"><font color=\"#FFFFFF\" size=\"4\" face=\"Verdana\"><strong>Foto</strong></font></td><td align=\"center\" bgcolor=\"#000000\"><font color=\"#FFFFFF\" size=\"4\" face=\"Verdana\"><strong>Articulo</strong></font></td><td align=\"center\" bgcolor=\"#000000\"><font color=\"#FFFFFF\" size=\"4\" face=\"Verdana\"><strong>Cod.</strong></font></td><td align=\"right\" bgcolor=\"#000000\"><font color=\"#FFFFFF\" size=\"4\" face=\"Verdana\"><strong>P.V.P</strong></font></td><td align=\"center\" bgcolor=\"#000000\"><font color=\"#FFFFFF\" size=\"4\" face=\"Verdana\"><strong><3E></strong></font></td><td width=\"10\"> </td><td align=\"center\" width=\"28\" bgcolor=\"#000000\"><img src=\"images\\comprar2.gif\" border=\"0\"></td></tr>";
|
||
break;
|
||
case 3:
|
||
Body = "<tr><td><a name=\""+Hijo+"\"> </a></td><td><font size=\"4\" color=\"#FFFFFF\" face=\"Verdana\"><strong>"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</strong></font></td><td> </td><td align=\"right\"> </td><td> </td><td> </td><td> </td></tr>";
|
||
break;
|
||
case 4:
|
||
Body = "<tr><td><a name=\""+Hijo+"\"> </a></td><td><font color=\"#FFFFFF\" face=\"Verdana\"><strong>"+TbD->FieldByName("Nombre del Producto")->AsString+
|
||
"</strong></font></td><td> </td><td align=\"right\"> </td><td> </td><td> </td><td> </td></tr>";
|
||
break;
|
||
}
|
||
} else {
|
||
Body = "<tr><td align=\"center\" >";
|
||
if ( ! TbD->FieldByName( "PathImagen" )->AsString.IsEmpty() &&
|
||
FileExists( ParamStr(1) + TbD->FieldByName( "PathImagen" )->AsString) )
|
||
{
|
||
ImageName = ExtractFileName(TbD->FieldByName( "PathImagen" )->AsString);
|
||
CopyFile( AnsiString(ParamStr(1) + TbD->FieldByName( "PathImagen" )->AsString).c_str(),
|
||
AnsiString("imgprod\\" + ImageName ).c_str(), True );
|
||
Body = Body + "<a href=\"javascript:Preview('" + ImageName + "')\"><img src=\"images\\checkit.gif\" border=\"0\" ></a></td>";
|
||
//COPIAR IMAGEN AL DIRECTORIO LOCAL
|
||
} else {
|
||
Body = Body + " </td>";
|
||
}
|
||
Body = Body + "<td><font color=\"#FFFFFF\" face=\"Verdana\">"+TbD->FieldByName("Nombre del Producto")->AsString+"</font></td><td> </td><td align=\"right\"><font color=\"#FFFFFF\" face=\"Verdana\">" +
|
||
FormatCurr("###,###,###.#0", TbD->FieldByName("Precio Venta 1")->AsCurrency )+"</font></td><td align=\"right\"><font color=\"#FFFFFF\" face=\"Verdana\">" +
|
||
FormatCurr("###,###,###.#0", TbD->FieldByName("Precio Venta 1")->AsCurrency / 166.386 )+"</font></td><td width=\"10\"> </td><td align=\"center\" width=\"28\"><a href=\"javascript:comprar('"+TbD->FieldByName("ForcedIndex")->AsString+"','"+TbD->FieldByName("Nombre del Producto")->AsString+"','"+TbD->FieldByName("Precio Venta 1")->AsString+"');\"><img src=\"images\\comprar2.gif\" border=\"0\" width=\"28\" height=\"28\"></a></td></tr>";
|
||
}
|
||
FileWrite(iFileHandle, Body.c_str(), Body.Length() );
|
||
ProgressBar1->Position++;
|
||
TbD->Next();
|
||
}
|
||
|
||
FileWrite(iFileHandle, Footer.c_str(), Footer.Length() );
|
||
FileClose(iFileHandle);
|
||
|
||
}
|
||
//---------------------------------------------------------------------------
|
||
void __fastcall TForm1::Timer1Timer(TObject *Sender)
|
||
{
|
||
if ( TbD->Active )
|
||
TbD->Active = false;
|
||
Close();
|
||
}
|
||
//---------------------------------------------------------------------------
|