Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/branches/R_10_00@21944 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2011-04-13 14:05:12 +00:00
parent 56498e8cc7
commit 57acddff0a
6 changed files with 174 additions and 13 deletions

View File

@ -50,7 +50,7 @@ bool THA_table_app::protected_record(TRectype& record)
{ {
//controlla che l'attrezzatura non abbia record nella tabella della storia attrezzature //controlla che l'attrezzatura non abbia record nella tabella della storia attrezzature
TString query; TString query;
query << "USE &HAHIS"; query << "USE &HIS";
query << "\nFROM CODTAB=#CODATTR"; query << "\nFROM CODTAB=#CODATTR";
query << "\nTO CODTAB=#CODATTR"; query << "\nTO CODTAB=#CODATTR";

View File

@ -2,6 +2,7 @@
#include <automask.h> #include <automask.h>
#include <config.h> #include <config.h>
#include <recarray.h> #include <recarray.h>
#include <reputils.h>
#include <tabmod.h> #include <tabmod.h>
#include <doc.h> #include <doc.h>
@ -93,6 +94,13 @@ void TInserimento_storico::elabora(const TMask& mask)
ofstream numerazioni("c:/temp/numerazioni.txt", ios::app); ofstream numerazioni("c:/temp/numerazioni.txt", ios::app);
#endif #endif
//vogliono pure il log! che rompicazzo
TLog_report log("Righe storico aggiunte");
log.kill_duplicates();
log.log(0, "");
log.log(0, "Anno-Num.-Ndoc--Codart Matricola --Cliente");
log.log(0, "");
//3) giro su ogni numerazione per trovare le righe che servono //3) giro su ogni numerazione per trovare le righe che servono
for (int n = 0; n < num_del_tipo; n++) for (int n = 0; n < num_del_tipo; n++)
{ {
@ -237,12 +245,21 @@ void TInserimento_storico::elabora(const TMask& mask)
const real importo = qta * prezzo; const real importo = qta * prezzo;
tab_his.put("R1", importo); tab_his.put("R1", importo);
tab_his.write_rewrite(); const int written = tab_his.write_rewrite();
//segna sul log la riga aggiunta alla tabella storico &HIS
if (written == NOERR)
{
TString msg;
msg.format("%4d%1s%4s%1s%7d%2s%30s%2s%6d", doc_anno, "-", (const char*)doc_codnum, "-", doc_ndoc, "--", (const char*)codtab, "--", doc_clifo);
//msg << doc_anno << "-" << doc_codnum << "-" << doc_ndoc << "--" << codtab << "--" << doc_clifo;
log.log(0, msg);
}
} //if (caus==caus_open || .. } //if (caus==caus_open || ..
} //for (bool ok = rdoc_recset.move_first()... } //for (bool ok = rdoc_recset.move_first()...
} //for (int n = 0; n < num_del_tipo... } //for (int n = 0; n < num_del_tipo...
log.preview();
} }
void TInserimento_storico::main_loop() void TInserimento_storico::main_loop()

View File

@ -1,6 +1,7 @@
#include <applicat.h> #include <applicat.h>
#include <automask.h> #include <automask.h>
#include <defmask.h> #include <defmask.h>
#include <execp.h>
#include <recarray.h> #include <recarray.h>
#include <recset.h> #include <recset.h>
#include <relation.h> #include <relation.h>
@ -178,6 +179,22 @@ bool TCoffee_tree::select_attr(const TString& codart, const TString& matricola)
return found; return found;
} }
//////////////////////////////////////////////
// Metodi static di ordinamento dello sheet
//////////////////////////////////////////////
static int sort_by_data(TSheet_field& s, int r1, int r2)
{
TToken_string& s1 = s.row(r1);
TToken_string& s2 = s.row(r2);
const int datacomp_pos = s.cid2index(S_DATA);
const TDate d1 = s1.get(datacomp_pos);
const TDate d2 = s2.get(datacomp_pos);
int cmp = int(d2 - d1);
return cmp;
}
////////////////////////////////////////////// //////////////////////////////////////////////
// Maschera // Maschera
////////////////////////////////////////////// //////////////////////////////////////////////
@ -237,7 +254,8 @@ void TGestione_attrezzature_mask::fill_sheet_storico(const TString& codattr)
} }
} }
//mostra e aggiorna lo sheet //mostra e aggiorna lo sheet ordinato per data (in alto le date maggiori)
sf_righe.sort(sort_by_data);
sf_righe.show(); sf_righe.show();
sf_righe.force_update(); sf_righe.force_update();
@ -276,7 +294,7 @@ bool TGestione_attrezzature_mask::write()
//per prima cosa mette la chiave del record che è così fatta: //per prima cosa mette la chiave del record che è così fatta:
// codart=codtab[1,5] - matricola=codtab[16,30] - nriga=codtab[31,35] // codart=codtab[1,5] - matricola=codtab[16,30] - nriga=codtab[31,35]
TString80 curr_codtab; TString80 curr_codtab;
curr_codtab.format("%05d", r + 1); curr_codtab.format("%05d", sf_righe.items() - r);
curr_codtab.insert(codtab); curr_codtab.insert(codtab);
//azzera il record senno' nei campi vuoti ci metterebbe quelli del record precedente //azzera il record senno' nei campi vuoti ci metterebbe quelli del record precedente
//deve azzerare la tabella, senno' perde il codice modulo HA ed il codice tabella HIS //deve azzerare la tabella, senno' perde il codice modulo HA ed il codice tabella HIS
@ -327,6 +345,7 @@ bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_even
{ {
switch (o.dlg()) switch (o.dlg())
{ {
//campi //campi
case F_CODCF: case F_CODCF:
if (e == fe_modify) if (e == fe_modify)
@ -385,8 +404,85 @@ bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_even
{ {
_sheet_dirty = true; _sheet_dirty = true;
} }
if (e == se_notify_add)
{
//quando si aggiunge una riga si deve fare il sorting in modo che venga come prima riga in alto
TSheet_field& sf = sfield(o.dlg());
TToken_string& row = sf.row(jolly); //riga corrente appena aggiunta
row.add(TDate(TODAY), sf.cid2index(S_DATA));
row.add(get(F_CODCF), sf.cid2index(S_CODCF));
sf.sort(sort_by_data);
sf.force_update();
sf.post_select(0); //evidenzia la prima riga
}
break; break;
//bottoni //bottoni
case DLG_ADD_NEW:
if (e == fe_button)
{
//per prima cosa deve controllare che siano pieni i campi chiave della tabella ttrezzature, senno' non puo'..
//..aggiungere una cippa
if (get(F_COD_ART).empty() || get(F_COD_MATR).empty())
return warning_box(TR("E' necessario compilare articolo e matricola per aggiungere una nuova attrezzatura!"));
TString80 codtab;
const TString& codart = get(F_COD_ART);
const TString& matricola = get(F_COD_MATR);
codtab.format("%-15s%-15s", (const char*)codart, (const char*)matricola);
//se l'utonto tentasse di inserire come nuova un'attrezzatura già esistente va cazziato!
TModule_table tab_att("&ATT");
tab_att.put("CODTAB", codtab);
const int err = tab_att.read();
if (err == NOERR)
return warning_box(TR("L'attrezzatura con questa matricola esiste gia'!"));
TFilename trans_ini;
trans_ini.temp(NULL, "ini");
TString4 filenumber;
filenumber << LF_TABMOD;
//i config vanno chiusi senno' non si riescono ad usare
{
TConfig ini(trans_ini, "Transaction");
ini.set("Action", "INSERT");
ini.set_paragraph(filenumber);
ini.set("CODTAB", codtab);
ini.set("I0", get(F_CODCF));
ini.set("D0", TDate(TODAY));
}
//invio del config al gestore della tabella &ATT
TString80 cmd;
cmd << "ha0 -0 &ATT /i" << trans_ini;
TExternal_app app(cmd);
//lettura dell'ini di ritorno compilato
if (app.run() == NOERR)
{
//setta sulla maschera i valori di ritorno del .ini (riempiti dal gestore di &ATT)
TConfig ini(trans_ini, "Transaction");
if (ini.get("Result") == "OK")
{
ini.set_paragraph(filenumber);
TString80 codtab = ini.get("CODTAB");
codtab.strip("\""); //elimina eventuali " che vengono dall'ini
set(F_COD_ART, codtab.left(5));
set(F_COD_MATR, codtab.mid(15,15));
const long codcf = ini.get_long("I0");
set(F_CODCF, codcf);
const TDate data_storico = ini.get("D0");
TSheet_field& sf = sfield(F_STORICO);
TToken_string& row = sf.row(-1);
row.add("C", sf.cid2index(S_TIPO));
row.add(data_storico, sf.cid2index(S_DATA));
row.add(codcf, sf.cid2index(S_CODCF));
sf.force_update();
}
}
}
break;
case DLG_SAVEREC: case DLG_SAVEREC:
if (e == fe_button && check_fields()) if (e == fe_button && check_fields())
{ {
@ -433,6 +529,9 @@ TGestione_attrezzature_mask::TGestione_attrezzature_mask() : TAutomask("ha3900a"
TCoffee_tree* ct = new TCoffee_tree; TCoffee_tree* ct = new TCoffee_tree;
tf.set_tree(ct); tf.set_tree(ct);
TSheet_field& sf_storico = sfield(F_STORICO);
sf_storico.set_append(false);
//inizializza lo "sporcatore" dello sheet //inizializza lo "sporcatore" dello sheet
_sheet_dirty = false; _sheet_dirty = false;
} }

View File

@ -3,6 +3,7 @@
#define F_COD_ART 303 #define F_COD_ART 303
#define F_DESCR_ART 304 #define F_DESCR_ART 304
#define F_COD_MATR 305 #define F_COD_MATR 305
#define DLG_ADD_NEW 306
//tree //tree
#define F_ATTREZZATURE 350 #define F_ATTREZZATURE 350

View File

@ -16,12 +16,12 @@ PAGE "Gestione attrezzature" 0 2 0 0
GROUPBOX DLG_NULL 79 5 GROUPBOX DLG_NULL 79 5
BEGIN BEGIN
PROMPT 0 0 "@bParametri" PROMPT 1 0 "@bParametri"
END END
NUMBER F_CODCF 6 NUMBER F_CODCF 6
BEGIN BEGIN
PROMPT 1 1 "Cliente " PROMPT 2 1 "Cliente "
FLAGS "R" FLAGS "R"
USE LF_CLIFO USE LF_CLIFO
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -37,7 +37,7 @@ END
STRING F_DESCF 50 STRING F_DESCF 50
BEGIN BEGIN
PROMPT 22 1 "" PROMPT 23 1 ""
USE LF_CLIFO KEY 2 USE LF_CLIFO KEY 2
INPUT TIPOCF "C" INPUT TIPOCF "C"
INPUT RAGSOC F_DESCF INPUT RAGSOC F_DESCF
@ -51,7 +51,7 @@ END
STRING F_COD_ART 5 STRING F_COD_ART 5
BEGIN BEGIN
PROMPT 1 2 "Articolo " PROMPT 2 2 "Articolo "
FLAGS "U" FLAGS "U"
USE LF_ANAMAG SELECT GRMERC="50" USE LF_ANAMAG SELECT GRMERC="50"
INPUT CODART F_COD_ART INPUT CODART F_COD_ART
@ -65,7 +65,7 @@ END
STRING F_DESCR_ART 50 STRING F_DESCR_ART 50
BEGIN BEGIN
PROMPT 22 2 "" PROMPT 23 2 ""
USE LF_ANAMAG KEY 2 SELECT GRMERC="50" USE LF_ANAMAG KEY 2 SELECT GRMERC="50"
INPUT DESCR F_DESCR_ART INPUT DESCR F_DESCR_ART
DISPLAY "Descrizione@50" DESCR DISPLAY "Descrizione@50" DESCR
@ -76,7 +76,7 @@ END
STRING F_COD_MATR 15 STRING F_COD_MATR 15
BEGIN BEGIN
PROMPT 1 3 "Matricola " PROMPT 2 3 "Matricola "
FLAGS "U" FLAGS "U"
USE &ATT USE &ATT
JOIN LF_ANAMAG INTO CODART=CODTAB[1,5] JOIN LF_ANAMAG INTO CODART=CODTAB[1,5]
@ -89,9 +89,15 @@ BEGIN
OUTPUT F_COD_ART CODTAB[1,5] OUTPUT F_COD_ART CODTAB[1,5]
OUTPUT F_COD_MATR CODTAB[16,30] OUTPUT F_COD_MATR CODTAB[16,30]
OUTPUT F_CODCF I0 OUTPUT F_CODCF I0
CHECKTYPE REQUIRED CHECKTYPE SEARCH
END END
BUTTON DLG_ADD_NEW 20 1
BEGIN
PROMPT 53 3 "Nuova attrezzatura"
END
TEXT DLG_NULL TEXT DLG_NULL
BEGIN BEGIN
PROMPT 1 5 "@bAttrezzature" PROMPT 1 5 "@bAttrezzature"
@ -99,7 +105,7 @@ END
TLIST F_ATTREZZATURE 78 5 TLIST F_ATTREZZATURE 78 5
BEGIN BEGIN
PROMPT 0 6 "Attrezzatura" PROMPT 1 6 "Attrezzatura"
DISPLAY "Codice@20" CODTAB DISPLAY "Codice@20" CODTAB
DISPLAY "Descrizione@35" S0 DISPLAY "Descrizione@35" S0
DISPLAY "Cliente" I0 DISPLAY "Cliente" I0
@ -156,7 +162,6 @@ DATE S_DATA
BEGIN BEGIN
PROMPT 58 1 "Data " PROMPT 58 1 "Data "
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
FLAGS "A"
FIELD D0 FIELD D0
END END

39
ha/hasthis.uml Executable file
View File

@ -0,0 +1,39 @@
#include "hatbatt.h"
PAGE "Attrezzature" -1 -1 78 3
NUMBER F_CODCF 6
BEGIN
PROMPT 1 1 "Cliente "
FLAGS "U"
USE LF_CLIFO
INPUT TIPOCF "C"
INPUT CODCF F_CODCF
DISPLAY "Codice" CODCF
DISPLAY "Descrizione@50" RAGSOC
OUTPUT F_CODCF CODCF
OUTPUT F_RAGSOC RAGSOC
CHECKTYPE NORMAL
FIELD #CODCF
END
STRING F_RAGSOC 50
BEGIN
PROMPT 20 1 ""
USE LF_CLIFO KEY 2
INPUT TIPOCF "C"
INPUT RAGSOC F_RAGSOC
DISPLAY "Descrizione@50" RAGSOC
DISPLAY "Codice" CODCF
COPY OUTPUT F_CODCF
CHECKTYPE NORMAL
END
ENDPAGE
TOOLBAR "" 0 0 0 2
#include "printbar.h"
ENDPAGE
ENDMAK