119 lines
2.7 KiB
C++
Executable File
119 lines
2.7 KiB
C++
Executable File
#include <relapp.h>
|
|
|
|
#include "sc1.h"
|
|
#include "sc1300a.h"
|
|
|
|
class SollecitiStorici_app : public TRelation_application
|
|
{
|
|
TMask* _msk;
|
|
TRelation* _rel;
|
|
|
|
protected:
|
|
|
|
virtual TMask* get_mask(int mode) { return _msk;}
|
|
virtual bool changing_mask(int mode) { return FALSE;}
|
|
virtual TRelation* get_relation() const { return _rel;}
|
|
virtual bool user_create() ;
|
|
virtual bool user_destroy() ;
|
|
virtual int write(const TMask& m);
|
|
|
|
static bool zap_handler(TMask_field& f, KEY k);
|
|
|
|
static SollecitiStorici_app& app()
|
|
{ return (SollecitiStorici_app&)main_app();}
|
|
|
|
public:
|
|
|
|
void zap_cliente(const char* c);
|
|
|
|
SollecitiStorici_app() {}
|
|
virtual ~SollecitiStorici_app() {}
|
|
};
|
|
|
|
|
|
bool SollecitiStorici_app::user_create()
|
|
{
|
|
_rel = new TRelation(LF_PAGSCA);
|
|
_msk = new TMask("sc1300a");
|
|
|
|
_msk->set_handler(F_ZAP, zap_handler);
|
|
set_search_field(F_TIPO);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool SollecitiStorici_app::user_destroy()
|
|
{
|
|
delete _rel;
|
|
delete _msk;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool SollecitiStorici_app::zap_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE && !f.mask().get(F_CODICE).empty())
|
|
{
|
|
if (yesno_box("Si desidera azzerare l'archivio solleciti per "
|
|
"il cliente %s?", (const char*)f.mask().get(F_DESCR)))
|
|
{
|
|
app().zap_cliente(f.mask().get(F_CODICE));
|
|
return f.mask().stop_run(K_ESC);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void SollecitiStorici_app::zap_cliente(const char* cod)
|
|
{
|
|
TLocalisamfile& sr = _rel->lfile();
|
|
sr.zero(); sr.put("CODICE", cod);
|
|
int err = NOERR;
|
|
|
|
for (err = sr.read(_isgteq);
|
|
err == NOERR && sr.get("CODICE") == cod;
|
|
err = sr.next())
|
|
sr.remove();
|
|
}
|
|
|
|
int SollecitiStorici_app::write(const TMask& m)
|
|
{
|
|
TLocalisamfile& sr = _rel->lfile();
|
|
_rel->save_status();
|
|
|
|
sr.zero(); sr.put("CODICE", m.get(F_CODICE));
|
|
int err = NOERR;
|
|
bool ok = TRUE;
|
|
|
|
TDate data;
|
|
TDate dmsk(m.get(F_DATA));
|
|
|
|
for (err = sr.read(_isgteq);
|
|
err == NOERR && sr.get("CODICE") == m.get(F_CODICE);
|
|
err = sr.next())
|
|
{
|
|
int tipo = sr.get_int("TIPO");
|
|
data = sr.get_date("DATASPED");
|
|
|
|
if (tipo >= m.get_int(F_TIPO) && data <= dmsk)
|
|
{
|
|
error_box("Sollecito di grado inferiore ad uno precedente (%s, grado %d)",
|
|
(const char*)data.string(), tipo);
|
|
ok = FALSE;
|
|
break;
|
|
}
|
|
}
|
|
_rel->restore_status();
|
|
|
|
if (ok) return TRelation_application::write(m);
|
|
|
|
return ok;
|
|
}
|
|
|
|
int sc1300(int argc, char** argv)
|
|
{
|
|
SollecitiStorici_app a;
|
|
a.run(argc, argv, "Archivio Storico Solleciti");
|
|
return 0;
|
|
}
|