105 lines
2.2 KiB
C++
105 lines
2.2 KiB
C++
|
#include <recarray.h>
|
||
|
#include <relapp.h>
|
||
|
|
||
|
#include "cg0.h"
|
||
|
#include "cg0700a.h"
|
||
|
|
||
|
#include <pconti.h>
|
||
|
#include <saldi.h>
|
||
|
#include <automask.h>
|
||
|
#include <validate.h>
|
||
|
|
||
|
///////////////////////////////////////////////////////////
|
||
|
// TCheck_PIVA_mask
|
||
|
///////////////////////////////////////////////////////////
|
||
|
|
||
|
class TOccas_mask : public TAutomask
|
||
|
{
|
||
|
protected:
|
||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
|
||
|
public:
|
||
|
TOccas_mask() : TAutomask("cg0700a") { }
|
||
|
};
|
||
|
bool TOccas_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
|
{
|
||
|
switch (o.dlg())
|
||
|
{
|
||
|
case O_COFI:
|
||
|
if (e == fe_modify)
|
||
|
{
|
||
|
TMask& m = o.mask();
|
||
|
TString16 cofi = m.get(O_COFI);
|
||
|
if (cofi.blank())
|
||
|
cofi = m.get(O_CODICE);
|
||
|
|
||
|
if (cf_check(m.get(O_STATONAS), cofi))
|
||
|
{
|
||
|
int giorno = atoi(cofi.mid(9,2));
|
||
|
m.set(O_SESSO, giorno > 40 ? "F" : "M");
|
||
|
|
||
|
if (m.field(O_COMUNENAS).empty())
|
||
|
m.set(O_COMUNENAS, cofi.mid(11,4), 0x2);
|
||
|
|
||
|
if (m.field(O_DATANAS).empty())
|
||
|
{
|
||
|
const TFixed_string mesi("ABCDEHLMPRST");
|
||
|
const int mese = mesi.find(cofi[8])+1;
|
||
|
int anno = atoi(cofi.mid(6,2));
|
||
|
if (giorno > 0 && mese > 0 && anno > 0)
|
||
|
{
|
||
|
giorno %= 40;
|
||
|
anno += anno < 5 ? 2000 : 1900;
|
||
|
m.set(O_DATANAS, TDate(giorno, mese, anno));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
default: break;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
class TOccasionali_app : public TRelation_application
|
||
|
{
|
||
|
TOccas_mask * _msk;
|
||
|
TRelation *_rel;
|
||
|
|
||
|
bool user_create();
|
||
|
bool user_destroy();
|
||
|
virtual TMask* get_mask(int mode) {return _msk;}
|
||
|
virtual bool changing_mask(int mode) {return FALSE;}
|
||
|
|
||
|
public:
|
||
|
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
||
|
virtual bool check_autorization() const { return false; }
|
||
|
virtual TRelation* get_relation() const {return _rel;}
|
||
|
};
|
||
|
|
||
|
HIDDEN inline TOccasionali_app& app() { return (TOccasionali_app&) main_app();}
|
||
|
|
||
|
bool TOccasionali_app::user_create()
|
||
|
{
|
||
|
open_files(LF_OCCAS, 0);
|
||
|
|
||
|
_rel = new TRelation(LF_OCCAS);
|
||
|
_msk = new TOccas_mask() ;
|
||
|
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
bool TOccasionali_app::user_destroy()
|
||
|
{
|
||
|
delete _rel;
|
||
|
delete _msk;
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
int cg0700(int argc, char* argv[])
|
||
|
{
|
||
|
TOccasionali_app a ;
|
||
|
a.run(argc, argv, TR("Clienti/Fornitori Occasionali"));
|
||
|
return 0;
|
||
|
}
|