Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/branches/R_10_00@21092 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-10-29 13:19:54 +00:00
parent e3904a340f
commit 61c70e46fc
3 changed files with 254 additions and 47 deletions

View File

@ -11,6 +11,7 @@
#include <pconti.h>
#include <clifo.h>
#include "..\pr\agenti.h"
const char* const APPNAME = TR("Importazione anagrafiche HARDY");
@ -369,7 +370,6 @@ THardy_transfer::~THardy_transfer()
void THardy_transfer::aggiorna_record(TRectype& rec, const TString_array& lista_campi)
{
TString campo_dest, campo_orig, valore, str;
FOR_EACH_ARRAY_ROW(lista_campi,i,row)
{
row->get(0, campo_dest);
@ -378,26 +378,12 @@ void THardy_transfer::aggiorna_record(TRectype& rec, const TString_array& lista_
{
if (campo_orig[0] == '_')
{
TToken_string elabora(campo_orig.mid(1),',');
const TString& str = elabora.get();
if (str == "TAB") // formato _TAB, <tabella da leggere>,<valore CODTAB>, <campo da leggere>
if (campo_orig.starts_with("_FISSO")) // valore fisso indicato in configurazione
{
const TString4 tab = elabora.get(); // tabella da leggere
const TString80 campo = elabora.get();
const TString16 codtab = get_str(campo);
const TString80 campotab = elabora.get();
valore = cache().get(tab, codtab, campotab);
}
else if (str == "FISSO")
valore = elabora.get(); // valore fisso indicato in configurazione
else if (str == "TRADUCI")
{
const TString80 campo = elabora.get();
const TString80 contenuto = get_str(campo);
TConfig& ini = config();
valore = ini.get(contenuto,campo);
}
if (str == "_STREXPR") // formato _STREXPR, espressione
valore = campo_orig.after(',');
valore.trim();
} else
if (campo_orig.starts_with("_STREXPR")) // formato _STREXPR, espressione
{
TExpression expr(campo_orig.after(','), _strexpr);
for (int v = 0; v < expr.numvar(); v++)
@ -407,7 +393,25 @@ void THardy_transfer::aggiorna_record(TRectype& rec, const TString_array& lista_
}
valore = expr.as_string();
valore.trim();
} else
if (campo_orig.starts_with("_TAB")) // formato _TAB,<tabella da leggere>,<valore CODTAB>, <campo da leggere>
{
TToken_string elabora(campo_orig, ',');
const TString4 tab = elabora.get(1); // tabella da leggere
const TString16 codtab = get_str(elabora.get());
const TString16 campotab = elabora.get();
valore = cache().get(tab, codtab, campotab);
}
else
if (campo_orig.starts_with("_TRADUCI"))
{
const TString80 campo = campo_orig.after(',');
const TString80 contenuto = get_str(campo);
TConfig& ini = config();
valore = ini.get(contenuto,campo);
}
else
valore.cut(0);
}
else
valore = get_str(campo_orig);
@ -859,6 +863,8 @@ long THardy_clienti::get_codcf(const TString &key)
default:
codcf = cod_hardy;
}
if (codcf > 999999)
codcf = 0;
return codcf;
}
@ -883,16 +889,154 @@ bool THardy_clienti::trasferisci()
// costruisco la chiave
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
if (codcf > 0)
{
rec.zero();
rec.put(CLI_TIPOCF, "C");
rec.put(CLI_CODCF, codcf);
// ricerca comune
const TString8 cap = get_str("IdCap"); //cap
TString80 loc = get_str("Localita"); //località
const TString8 com = cap2comune(cap,loc); //codice comune
const TString8 stato = get_str("IdNazione"); //stato
rec.put(CLI_CAPCF, cap);
if (com.full() && !com.blank())
{
rec.put(CLI_COMCF, com); //se riesce la CAP2COMUNE, inserisco il codice comune
loc = "";
rec.put(CLI_LOCCF, loc);
}
else
{
rec.put(CLI_COMCF, com);
if (stato != "IT" && !stato.blank()) //altrimenti metto tutto nella località, eventualmente concatenando lo stato
loc << " - " << stato;
rec.put(CLI_LOCCF, loc);
}
aggiorna_record(rec, lista_campi);
test_write(clienti);
}
else
{
TString msg;
msg << TR("Impossibile determinare il codice del cliente") << " '" << key << '\'';
log(msg);
}
}
clienti.close();
return write_enabled();
}
long THardy_fornitori::get_codcf(const TString &key)
{
long codcf = atoi(key.mid(3,6));
return codcf;
}
bool THardy_fornitori::trasferisci()
{
TString query =
"SELECT * "
"FROM dbo.Fornitori ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi;
ini.list_variables(lista_campi, true, "FORNITORI", true);
TSystemisamfile clienti(LF_CLIFO);
clienti.open(_lock);
TRectype& rec = clienti.curr();
THardy_iterator hi(this);
while (++hi)
{
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
if (codcf > 0)
{
rec.zero();
rec.put(CLI_TIPOCF, "F");
rec.put(CLI_CODCF, codcf);
// ricerca comune
const TString8 cap = get_str("IdCap"); //cap
TString80 loc = get_str("Localita"); //località
const TString8 com = cap2comune(cap,loc); //codice comune
const TString8 stato = get_str("IdNazione"); //stato
rec.put(CLI_CAPCF, cap);
if (com.full() && !com.blank())
{
rec.put(CLI_COMCF, com); //se riesce la CAP2COMUNE, inserisco il codice comune
loc = "";
rec.put(CLI_LOCCF, loc);
}
else
{
rec.put(CLI_COMCF, com);
if (stato != "IT" && !stato.blank()) //altrimenti metto tutto nella località, eventualmente concatenando lo stato
loc << " - " << stato;
rec.put(CLI_LOCCF, loc);
}
aggiorna_record(rec, lista_campi);
test_write(clienti);
}
else
{
TString msg;
msg << TR("Impossibile determinare il codice del fornitore") << " '" << key << '\'';
log(msg);
}
}
clienti.close();
return write_enabled();
}
TString& THardy_agenti::get_codage(const TString& key)
{
TString16 codage(key);
return codage.right_just(5,'0');
}
bool THardy_agenti::trasferisci()
{
TString query =
"SELECT * "
"FROM dbo.Agenti ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi;
ini.list_variables(lista_campi, true, "AGENTI", true);
TSystemisamfile agenti(LF_AGENTI);
agenti.open(_lock);
TRectype& rec = agenti.curr();
THardy_iterator hi(this);
while (++hi)
{
const TString16 key = get_str("IdAgente");
TString8 codage = get_codage(key);
if (codage > 0)
{
rec.zero();
rec.put(AGE_CODAGE, codage);
aggiorna_record(rec, lista_campi);
test_write(agenti);
}
else
{
TString msg;
msg << TR("Impossibile determinare il codice dell'agente") << " '" << key << '\'';
log(msg);
}
}
agenti.close();
return write_enabled();
}
///////////////////////////////////////////////////////////
// TImportazioneHardy_mask
///////////////////////////////////////////////////////////
@ -1032,6 +1176,22 @@ void TImportazioneHardy_mask::trasferisci()
book.add(log);
rep_to_print = true;
}
if (go_on && get_bool(F_FOR))
{
THardy_fornitori pc;
pc.init(TR("Fornitori"), query_header, log);
go_on = pc.trasferisci();
book.add(log);
rep_to_print = true;
}
if (go_on && get_bool(F_AGENTI))
{
THardy_agenti pc;
pc.init(TR("Agenti"), query_header, log);
go_on = pc.trasferisci();
book.add(log);
rep_to_print = true;
}
if (rep_to_print && book.pages() > 0)
book.preview();

View File

@ -202,29 +202,22 @@ public:
virtual bool trasferisci();
};
/*
class THardy_clifo : public THardy_transfer
class THardy_fornitori : public THardy_transfer
{
TCache_th* _agenti;
TCache_th* _banche;
bool _only_agenti;
protected:
int cancella_clifo(TLocalisamfile& clifo) const;
long get_next_key(const char tipocf) const;
void update_statusflag_codcontab(const TString& custsuppcode, const int statusflag, const TString& codcontab);
void aggiorna_record(TRectype& rec, const TString_array& lista_campi);
void aggiorna_banca();
void trasferisci_conai(TRectype& rec);
const TString& decode_agente(const long codforn);
const TString& get_agente();
long get_codcf(const TString& key);
public:
virtual bool trasferisci();
THardy_clifo(bool only_agenti);
~THardy_clifo();
};
*/
class THardy_agenti : public THardy_transfer
{
protected:
TString& get_codage(const TString& key);
public:
virtual bool trasferisci();
};
class TCache_art;
class TCache_umart;

View File

@ -117,8 +117,8 @@ DESCR = RagioneSociale
[PARAMETRI]
PCON=04|05
[CLIENTI]
RAGSOC = RagioneSociale
[FORNITORI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
CIVCF =
LOCALITACF =
@ -162,7 +162,61 @@ STATO =
CODVAL =
CODLIN =
FIDO =
CODPAG = PaymentCode
CODPAG =
RICALT =
OGGETTI =
SOSPESO =
DIRTY =
REFERENTE = Referente
VALINTRA =
[CLIENTI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
CIVCF =
LOCALITACF =
STATOCF = _TAB,%TPS,IdIso,S6
COMCF =
CAPCF = CAP
COFI = CodiceFiscale
STATOPAIV =
PAIV = PartitaIVA
TIPOPERS =
ALLEG =
CODALLEG =
GRUPPO =
CONTO =
GRUPPORIC =
CONTORIC =
SOTTOCRIC =
TIPOAPER =
CODANAGPER =
PTEL =
TEL = Telefono1
PTEL2 =
TEL2 = Telefono2
PTEL3 =
TEL3 = TelCellulare
PFAX =
FAX = TelFax
PTELEX =
TELEX =
MAIL = EMail
DATANASC =
STATONASC =
COMNASC =
CODSTAT =
CODABI =
CODCAB =
NUMCC =
IBAN =
OCCAS =
STATO =
CODVAL =
CODLIN =
FIDO =
CODPAG =
RICALT =
OGGETTI =
SOSPESO =