Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@17020 c028cbd2-c16b-5b4b-a496-9718f37d4682
156 lines
3.7 KiB
C++
Executable File
156 lines
3.7 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <relation.h>
|
|
|
|
#include "../lv/lvconsplan.h"
|
|
#include "../lv/lvrconsplan.h"
|
|
#include "../lv/lvpasplan.h"
|
|
|
|
#include "lv2.h"
|
|
#include "lv2100a.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TGenera_planning maschera
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TGenera_planning_mask : public TAutomask
|
|
{
|
|
public:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
TGenera_planning_mask (const char* name) : TAutomask(name) {}
|
|
};
|
|
|
|
bool TGenera_planning_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
return true;
|
|
}
|
|
/*
|
|
/////////////////////////////////////////////////////////////
|
|
// TGenera_planning recordset
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
class TGenera_planning_recordset : public TCSV_recordset
|
|
{
|
|
public:
|
|
TEsporta_ps0713_recordset();
|
|
};
|
|
|
|
|
|
TGenera_planning_recordset::TEsporta_ps0713_recordset()
|
|
: TCSV_recordset("CSV(\"\t\")")
|
|
{
|
|
}
|
|
*/
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TGenera_planning applicazione
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TGenera_planning_app : public TSkeleton_application
|
|
{
|
|
|
|
TGenera_planning_mask* _msk;
|
|
|
|
protected:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
bool elimina_planning(const TDate& dadata, const TDate& adata) const;
|
|
bool genera_codplan(long& key) const;
|
|
|
|
public:
|
|
bool transfer();
|
|
virtual void main_loop();
|
|
};
|
|
|
|
bool TGenera_planning_app::create()
|
|
{
|
|
_msk = new TGenera_planning_mask("lv2100a");
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TGenera_planning_app::destroy()
|
|
{
|
|
delete _msk;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
//funzione che controlla se il planning per una certa data esiste già
|
|
/*bool TGenera_planning_app::elimina_planning(const TDate& dadata, const TDate& adata) const
|
|
{
|
|
long codplan = 0;
|
|
|
|
TRelation tplan(LF_LVCONSPLAN); //instanzio una relazione sul file LF_LVCONSPLAN
|
|
TRelation rplan(LF_LVRCONSPLAN); //instanzio una relazione sul file LF_LVRCONSPLAN
|
|
|
|
for (TDate tmp = dadata; tmp <= adata; ++tmp)
|
|
{
|
|
TRectype& rec = tplan.curr(); //cerco se esiste la testata del planning
|
|
rec.zero();
|
|
rec.put(LVCONSPLAN_DTCONS,data);
|
|
|
|
TCursor cur(&tplan,"",2,&rec,&rec);
|
|
const TRecnotype items = cur.items();
|
|
if (items > 0)
|
|
{
|
|
cur.freeze();
|
|
codplan = rec.get_long(LVCONSPLAN_CODPLAN);
|
|
}
|
|
|
|
return found; //restituisco il codice del planning se esite già, altrimento rstituisco zero
|
|
}*/
|
|
|
|
//funzione che genera il codplan (prende l'ultimo esistente e lo incrementa di uno)
|
|
bool TGenera_planning_app::genera_codplan(long& key) const
|
|
{
|
|
long num = 1;
|
|
TLocalisamfile tplan(LF_LVCONSPLAN);
|
|
if (tplan.last() == NOERR)
|
|
num += tplan.get_long(LVCONSPLAN_CODPLAN);
|
|
key = num;
|
|
return true;
|
|
}
|
|
|
|
bool TGenera_planning_app::transfer()
|
|
{
|
|
const TDate dadata = _msk->get(F_DADATA);
|
|
const TDate adata = _msk->get(F_ADATA);
|
|
const TString8 codcf = _msk->get(F_CODCF);
|
|
const TString8 coditi = _msk->get(F_CODITI);
|
|
|
|
TLocalisamfile tplan(LF_LVCONSPLAN);
|
|
TLocalisamfile rplan(LF_LVRCONSPLAN);
|
|
TLocalisamfile pplan(LF_LVPASPLAN);
|
|
|
|
for (TDate tmp = dadata; tmp <= adata; ++tmp)
|
|
{
|
|
//long codplan = cerca_planning(dadata,adata); //controllo se un planning per una certa data esiste già
|
|
|
|
/*if (!codplan)
|
|
{*/
|
|
long key;
|
|
int giorno = tmp.wday();
|
|
genera_codplan(key);
|
|
long key1 = key;
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
void TGenera_planning_app::main_loop()
|
|
{
|
|
while (_msk->run() == K_ENTER)
|
|
transfer();
|
|
}
|
|
|
|
int lv2100(int argc, char* argv[])
|
|
{
|
|
TGenera_planning_app app;
|
|
app.run(argc, argv, TR("Generazione automatica planning"));
|
|
return 0;
|
|
}
|