143 lines
3.2 KiB
C++
Executable File
143 lines
3.2 KiB
C++
Executable File
#include "tc2.h"
|
||
#include "tctbico.h"
|
||
|
||
// gestione tabelle IPSOA
|
||
#include <modaut.h>
|
||
#include <modtbapp.h>
|
||
#include <tabutil.h>
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// TConti_mask
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TConti_mask : public TMask
|
||
{
|
||
private:
|
||
|
||
protected:
|
||
|
||
public:
|
||
TConti_mask(const char * maskname);
|
||
~TConti_mask();
|
||
};
|
||
|
||
TConti_mask::TConti_mask(const char * maskname)
|
||
: TMask(maskname)
|
||
{
|
||
TString disp;
|
||
int fpos = 0;
|
||
int pos = 2;
|
||
TFilename tmp;
|
||
tmp.tempdir();
|
||
tmp.add("tmp.msk");
|
||
|
||
for (int i = 1; i <= 6; i++)
|
||
{
|
||
const int len = ini_get_int(CONFIG_DITTA, "tc", "IPLIVPC", 0, i);
|
||
const short id = F_CODTAB + i;
|
||
|
||
if (len <= 0)
|
||
{
|
||
field(id).hide();
|
||
field(id).disable();
|
||
}
|
||
else
|
||
{
|
||
ofstream out(tmp);
|
||
TString prompt = (i == 1) ? "Codice " : "";
|
||
TEdit_field & kfld = efield(id);
|
||
|
||
kfld.set_prompt(prompt);
|
||
pos += prompt.len() + 2;
|
||
kfld.set_rect(pos, 2, len, 1, len);
|
||
pos += len + 2;
|
||
|
||
TString80 fld("CODTAB[");
|
||
|
||
fld << ++fpos << ',';
|
||
fpos += len -1;
|
||
fld << fpos << "]";
|
||
kfld.set_field(fld);
|
||
out << "US &ICO\n";
|
||
|
||
if (len > 0)
|
||
{
|
||
if (i > 1)
|
||
out << "CO IN " << id - 1 << '\n';
|
||
out << "IN " << fld << ' ' << id << '\n';
|
||
disp << "DI \"" << prompt << "@" << max(len, prompt.len()) << "\" " << fld << '\n';
|
||
out << disp << "DI \"Descrizione@60\" S0\n";
|
||
if (i > 1)
|
||
out << "CO OU " << id - 1 << '\n';
|
||
out << "OU " << id << ' ' << fld << '\n';
|
||
}
|
||
out << "EN" << '\n';
|
||
out.close();
|
||
TScanner scan(tmp);
|
||
while (scan.pop() != "EN")
|
||
kfld.parse_item(scan);
|
||
}
|
||
}
|
||
ofstream out(tmp);
|
||
TEdit_field & dfld = efield(F_DESC);
|
||
|
||
out << "US &ICO KEY 2\n";
|
||
out << "IN S0 " << F_DESC << '\n';
|
||
out << "DI \"Descrizione@60\" S0\n" << disp;
|
||
out << "CO OU " << F_CODTAB1 << '\n';
|
||
out << "EN" << '\n';
|
||
out.close();
|
||
TScanner scan(tmp);
|
||
while (scan.pop() != "EN")
|
||
dfld.parse_item(scan);
|
||
}
|
||
|
||
TConti_mask::~TConti_mask()
|
||
{
|
||
}
|
||
|
||
// applicazione per la gestione delle tabelle di magazzino
|
||
class Tab_app_IPSOA : public TTable_module_application
|
||
{
|
||
protected: // TRelation_application
|
||
virtual bool user_create() ;
|
||
};
|
||
|
||
HIDDEN inline Tab_app_IPSOA& app() { return (Tab_app_IPSOA&)main_app(); }
|
||
|
||
bool Tab_app_IPSOA::user_create()
|
||
{
|
||
/*
|
||
la Tab_application::user_create() apre la maschera TMask in modo automatico
|
||
basandosi sul parametro passato sulla linea di comando e sulla convenzione
|
||
nome = "BATB"+parametro;
|
||
ORA:
|
||
- questa convenzione cambier<65> per separare i programmi (e le maschere)
|
||
dei vari pacchetti
|
||
In tal caso ridefinire il metodo virtual mask_name()
|
||
- secondo il nuovo stile, gli handler vanno posti in maschere derivate
|
||
dalla TMask (TMask_tabzucc, TMask_tabcau, ecc), pertanto occorre che
|
||
la maschera aperta sia del tipo corretto
|
||
per questo motivo la maschera viene creata dalla user_create()
|
||
*/
|
||
|
||
bool ok = TTable_module_application::user_create();
|
||
|
||
if (ok)
|
||
{
|
||
TMask& mask = *get_mask(MODE_QUERY);
|
||
TString name = mask.source_file(); name.lower();
|
||
|
||
if (name.find("ico") >= 0)
|
||
set_mask(new TConti_mask(name));
|
||
}
|
||
return ok;
|
||
}
|
||
|
||
int tc2100(int argc, char **argv)
|
||
{
|
||
Tab_app_IPSOA a;
|
||
a.run(argc, argv, TR("Tabella"));
|
||
return 0;
|
||
}
|