This commit was manufactured by cvs2svn to create branch 'R_10_00'.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21924 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2e1de295fb
commit
e87ed0d8f2
259
ha/ha3800.cpp
Executable file
259
ha/ha3800.cpp
Executable file
@ -0,0 +1,259 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
#include <recarray.h>
|
||||
#include <tabmod.h>
|
||||
|
||||
#include <doc.h>
|
||||
#include <rdoc.h>
|
||||
#include <../ve/velib.h>
|
||||
|
||||
#include "ha3800a.h"
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Maschera
|
||||
//////////////////////////////////////////////
|
||||
class TInserimento_storico_mask : public TAutomask
|
||||
{
|
||||
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
TInserimento_storico_mask();
|
||||
};
|
||||
|
||||
|
||||
bool TInserimento_storico_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
{
|
||||
case F_ANNO:
|
||||
if (e == fe_modify)
|
||||
{
|
||||
//cambiando l'anno propone in automatico il dadata adata
|
||||
const int anno = o.get_long();
|
||||
const TDate ini_anno(1, 1, anno);
|
||||
set(F_DADATA, ini_anno);
|
||||
const TDate fine_anno(31, 12, anno);
|
||||
set(F_ADATA, fine_anno);
|
||||
}
|
||||
break;
|
||||
case F_DADATA:
|
||||
case F_ADATA:
|
||||
if (e == fe_modify || e == fe_close)
|
||||
{
|
||||
//controlla che le date appartengano all'anno selezionato (e impedisce di lasciare date vuote!!!)
|
||||
const TDate data = get_date(o.dlg());
|
||||
const int anno = get_int(F_ANNO);
|
||||
if (data.year() != anno)
|
||||
return error_box("La data deve appartenere all'anno selezionato!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TInserimento_storico_mask::TInserimento_storico_mask() : TAutomask("ha3800a")
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Applicazione
|
||||
//////////////////////////////////////////////
|
||||
class TInserimento_storico : public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
void elabora(const TMask& mask);
|
||||
public:
|
||||
void main_loop();
|
||||
};
|
||||
|
||||
|
||||
void TInserimento_storico::elabora(const TMask& mask)
|
||||
{
|
||||
//1) legge la configurazione per avere i parametri di query
|
||||
TConfig config(CONFIG_DITTA, "ha");
|
||||
const TString4 tipo2elab = config.get("Doc2ElabTip");
|
||||
const TString4 stato2elab = config.get("Doc2ElabSta");
|
||||
const TString8 caus_open = config.get("CausOpen");
|
||||
const TString8 caus_close = config.get("CausClose");
|
||||
//..e anche la maschera
|
||||
const long anno = mask.get_long(F_ANNO);
|
||||
const TDate da_data = mask.get_date(F_DADATA);
|
||||
const TDate a_data = mask.get_date(F_ADATA);
|
||||
|
||||
//2) raccatta le numerazioni valide in base al tipo di documento in configurazione
|
||||
const TString& str_tipo = cache().get("%TIP", tipo2elab, "I1");
|
||||
TString_array num_doc;
|
||||
const int num_del_tipo = numerazioni_documenti(num_doc, str_tipo);
|
||||
|
||||
#ifdef DBG
|
||||
ofstream numerazioni("c:/temp/numerazioni.txt", ios::app);
|
||||
#endif
|
||||
|
||||
//3) giro su ogni numerazione per trovare le righe che servono
|
||||
for (int n = 0; n < num_del_tipo; n++)
|
||||
{
|
||||
const TString4 codnum = num_doc.row(n);
|
||||
|
||||
TString query;
|
||||
query << "USE RDOC KEY 2";
|
||||
query << "\nSELECT (DOC.STATO=#STATO)&&(BETWEEN(DOC.DATADOC,#DADATA,#ADATA))";
|
||||
query << "\nJOIN DOC INTO PROVV==PROVV ANNO==ANNO CODNUM==CODNUM NDOC==NDOC";
|
||||
query << "\nFROM CODNUM=#CODNUM ANNO=#ANNO PROVV=D";
|
||||
query << "\nTO CODNUM=#CODNUM ANNO=#ANNO PROVV=D";
|
||||
|
||||
TISAM_recordset rdoc_recset(query);
|
||||
rdoc_recset.set_var("#STATO", stato2elab);
|
||||
rdoc_recset.set_var("#DADATA", da_data);
|
||||
rdoc_recset.set_var("#ADATA", a_data);
|
||||
rdoc_recset.set_var("#CODNUM", codnum);
|
||||
rdoc_recset.set_var("#ANNO", anno);
|
||||
|
||||
const long rdoc_recset_items = rdoc_recset.items();
|
||||
|
||||
//date tutte le righedoc che soddisfano la query, deve tener conto solo di quelle..
|
||||
//..non ancora registrate in precedenza e che, soprattutto, abbiano una causale sensata
|
||||
for (bool ok = rdoc_recset.move_first(); ok; ok = rdoc_recset.move_next())
|
||||
{
|
||||
//controllo della causale
|
||||
TString8 caus = rdoc_recset.get(RDOC_CAUSMAG).as_string();
|
||||
//se la causale non è sulla riga controlla quella di testata
|
||||
if (caus.empty())
|
||||
caus = rdoc_recset.get(DOC_CAUSMAG).as_string();
|
||||
|
||||
//solo le righdoc con causale sensata proseguono
|
||||
if (caus == caus_open || caus == caus_close)
|
||||
{
|
||||
//bool di scrimage
|
||||
const bool bopen = caus == caus_open;
|
||||
|
||||
//3_A) tabella &ATT
|
||||
//poichè documento apertura deve controllare se per caso la macchina è nuova
|
||||
//dati del record corrente (vale anche per le chiusure in quanto esistono macchine..
|
||||
//..di antica data senza registrazioni!)
|
||||
const long doc_anno = rdoc_recset.get(RDOC_ANNO).as_int();
|
||||
const TString4 doc_codnum = rdoc_recset.get(RDOC_CODNUM).as_string();
|
||||
const long doc_ndoc = rdoc_recset.get(RDOC_NDOC).as_int();
|
||||
const TString& codart = rdoc_recset.get(RDOC_CODART).as_string();
|
||||
const TString& matricola = rdoc_recset.get(RDOC_LIVELLO).as_string();
|
||||
TString80 codtab;
|
||||
codtab.format("%-15s%-15s", (const char*)codart, (const char*)matricola);
|
||||
TModule_table tab_att("&ATT");
|
||||
const int err = tab_att.read();
|
||||
//se l'attrezzatura (intesa come codart+matricola) non esiste -> la deve aggiungere
|
||||
if (err != NOERR)
|
||||
tab_att.put("CODTAB", codtab);
|
||||
|
||||
//comunque deve scrivere il cliente e la data perchè è un'apertura quindi la macchina è assegnata..
|
||||
//..al cliente con questo documento
|
||||
const long doc_clifo = rdoc_recset.get(DOC_CODCF).as_int();
|
||||
const TDate doc_datadoc = rdoc_recset.get(DOC_DATADOC).as_date();
|
||||
|
||||
//se la macchina viene assegnata ad un cliente (movimento di apertura) -> va messo il clifo..
|
||||
if (bopen)
|
||||
tab_att.put("I0", doc_clifo);
|
||||
else //..senno' torna alla casa madre e sparisce il clifo
|
||||
tab_att.put("I0", 0L);
|
||||
|
||||
tab_att.put("D0", doc_datadoc);
|
||||
|
||||
tab_att.write_rewrite();
|
||||
|
||||
//3_B) tabella &HIS
|
||||
//controllo sul ndoc se per caso questa riga l'ha già importata, senno' deve aggiungere un record
|
||||
//query sulla storia di questa macchina
|
||||
TString query_his;
|
||||
query_his << "USE &HIS";
|
||||
query_his << "\nFROM CODTAB=#CODTAB";
|
||||
query_his << "\nTO CODTAB=#CODTAB";
|
||||
TISAM_recordset recset_his(query_his);
|
||||
recset_his.set_var("#CODTAB", codtab);
|
||||
|
||||
const long recset_his_items = recset_his.items();
|
||||
|
||||
TModule_table tab_his("&HIS");
|
||||
int n_line_to_update = 0;
|
||||
|
||||
//cerca se la riga esiste già nello storico e va solo aggiornata
|
||||
for (bool ok = recset_his.move_last(); ok; ok = recset_his.move_prev())
|
||||
{
|
||||
long curr_anno;
|
||||
if (bopen)
|
||||
curr_anno = recset_his.get("S4[1,4]").as_int();
|
||||
else
|
||||
curr_anno = recset_his.get("S5[1,4]").as_int();
|
||||
if (curr_anno == doc_anno)
|
||||
{
|
||||
TString4 curr_codnum;
|
||||
if (bopen)
|
||||
curr_codnum = recset_his.get("S4[5,8]").as_string();
|
||||
else
|
||||
curr_codnum = recset_his.get("S5[5,8]").as_string();
|
||||
if (curr_codnum == doc_codnum)
|
||||
{
|
||||
long curr_ndoc;
|
||||
if (bopen)
|
||||
curr_ndoc = recset_his.get("S4[9,15]").as_int();
|
||||
else
|
||||
curr_ndoc = recset_his.get("S5[9,15]").as_int();
|
||||
if (curr_ndoc == doc_ndoc)
|
||||
{
|
||||
n_line_to_update = recset_his.get("CODTAB[31,35]").as_int();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //for (bool ok = recset_his.move...
|
||||
//se la riga non c'era -> va aggiunta
|
||||
if (n_line_to_update == 0)
|
||||
n_line_to_update = recset_his_items + 1;
|
||||
|
||||
//adesso ha il numero di riga da aggiornare
|
||||
TString80 new_codtab;
|
||||
new_codtab.format("%30s%05d", (const char*) codtab, n_line_to_update);
|
||||
tab_his.put("CODTAB", new_codtab);
|
||||
//ed aggiunge tutti i campi
|
||||
tab_his.put("S0", rdoc_recset.get(RDOC_DESCR).as_string());
|
||||
//tab_his.put("S2", articolo_collegato);
|
||||
tab_his.put("S3", rdoc_recset.get(RDOC_CODMAG).as_string());
|
||||
tab_his.put("S4[1,4]", doc_anno);
|
||||
tab_his.put("S4[5,8]", doc_codnum);
|
||||
tab_his.put("S4[9,15]", doc_ndoc);
|
||||
tab_his.put("S6", rdoc_recset.get(RDOC_UMQTA).as_string());
|
||||
tab_his.put("S7", "C");
|
||||
tab_his.put("I0", rdoc_recset.get(DOC_CODCF).as_string());
|
||||
tab_his.put("D0", doc_datadoc);
|
||||
const real qta = rdoc_recset.get(RDOC_QTA).as_real();
|
||||
tab_his.put("R0", qta);
|
||||
const real prezzo = rdoc_recset.get(RDOC_PREZZO).as_real();
|
||||
const real importo = qta * prezzo;
|
||||
tab_his.put("R1", importo);
|
||||
|
||||
tab_his.write_rewrite();
|
||||
} //if (caus==caus_open || ...
|
||||
|
||||
|
||||
} //for (bool ok = rdoc_recset.move_first()...
|
||||
|
||||
} //for (int n = 0; n < num_del_tipo...
|
||||
}
|
||||
|
||||
void TInserimento_storico::main_loop()
|
||||
{
|
||||
TInserimento_storico_mask mask;
|
||||
while (mask.run() == K_ENTER)
|
||||
{
|
||||
elabora(mask);
|
||||
}
|
||||
}
|
||||
|
||||
int ha3800(int argc, char* argv[])
|
||||
{
|
||||
TInserimento_storico app;
|
||||
app.run(argc, argv, TR("Inserimento storico attrezzature"));
|
||||
return 0;
|
||||
}
|
3
ha/ha3800a.h
Executable file
3
ha/ha3800a.h
Executable file
@ -0,0 +1,3 @@
|
||||
#define F_ANNO 201
|
||||
#define F_DADATA 202
|
||||
#define F_ADATA 203
|
30
ha/ha3800a.uml
Executable file
30
ha/ha3800a.uml
Executable file
@ -0,0 +1,30 @@
|
||||
#include "ha3800a.h"
|
||||
|
||||
PAGE "Inserimento storico attrezzature" -1 -1 64 4
|
||||
|
||||
NUMBER F_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "Anno "
|
||||
FLAGS "A"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
DATE F_DADATA
|
||||
BEGIN
|
||||
PROMPT 1 2 "Dal "
|
||||
END
|
||||
|
||||
DATE F_ADATA
|
||||
BEGIN
|
||||
PROMPT 25 2 "Al "
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "" 0 0 0 2
|
||||
|
||||
#include <elabar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user