From 32a92bd876ae43e881269c283b379a245a483c81 Mon Sep 17 00:00:00 2001 From: luca Date: Mon, 18 Feb 2008 11:19:10 +0000 Subject: [PATCH] Patch level :10.0 4.0 Files correlati : Ricompilazione Demo : [ ] Commento :prima generazione del .csv del CONAI (non propriamente una bellezza!) git-svn-id: svn://10.65.10.50/trunk@16195 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- tp/tp0900.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/tp/tp0900.cpp b/tp/tp0900.cpp index 9d27029ee..a5780c03a 100755 --- a/tp/tp0900.cpp +++ b/tp/tp0900.cpp @@ -7,6 +7,9 @@ #include #include #include +#include + +#include /////////////////////////////////////////////////////////// // MASCHERA @@ -38,6 +41,24 @@ bool TDichiarazione_CONAI_mask::on_field_event(TOperable_field& o, TField_event return true; } + +///////////////////////////////////////////////////////////// +// CSV RECORDSET +///////////////////////////////////////////////////////////// + +class TDichiarazione_CONAI_csv_recordset : public TCSV_recordset +{ +public: + TDichiarazione_CONAI_csv_recordset(); +}; + + +TDichiarazione_CONAI_csv_recordset::TDichiarazione_CONAI_csv_recordset() +: TCSV_recordset("CSV(,)\n") +{ +} + + /////////////////////////////////////////////////////////// // APPLICAZIONE /////////////////////////////////////////////////////////// @@ -138,18 +159,55 @@ void TDichiarazione_CONAI::crea_csv(const TMask& mask) const rdoc.set_var("#ADATA", datafin); rdoc.set_var("#CODART", codart); + //creazione del csv recordset che verra' riempito dai record del recordset rdoc + TDichiarazione_CONAI_csv_recordset csv; + const TString path = "C:/temp/cazzone.csv"; + + //quante righe dello sheet processa? + const long tot_items = sf.items(); + //Visto che e' possibile avere una secchiata di numerazioni, gli tocca fare un giro per ogni numerazione FOR_EACH_SHEET_ROW(sf, r, row) { - //estrazione della numerazione e del tipo del record corrente dello sheet - + //estrazione definitiva dei record che soddisfano il casino di parametri richiesti rdoc.set_var("#CODNUM", TVariant(row->get(0))); rdoc.set_var("#TIPODOC", TVariant(row->get(2))); const long items = rdoc.items(); +#ifdef DBG warning_box("Hai trovato %ld righe bello!", items); +#endif + + //E crea pure la progind.. + TProgind pi(tot_items, TR("Estrazione righe..."), true, true); + + for (bool ok = rdoc.move_first(); ok; ok = rdoc.move_next()) + { + if (!pi.addstatus(1)) + break; + + //creazione di un nuovo record da esportare + csv.new_rec(""); + + csv.set(0, rdoc.get(RDOC_CODNUM)); + csv.set(1, rdoc.get(RDOC_ANNO)); + csv.set(2, rdoc.get(RDOC_NDOC)); + csv.set(3, rdoc.get(RDOC_NRIGA)); + csv.set(4, rdoc.get(RDOC_CODART)); + csv.set(5, rdoc.get(RDOC_PREZZO)); + csv.set(6, rdoc.get(RDOC_UMQTA)); + csv.set(7, rdoc.get(RDOC_QTA)); + } + + csv.save_as(path, fmt_text); } + + + +#ifdef DBG + xvt_sys_goto_url(path, "open"); +#endif }