Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento : copia ed elimina un listino (sulla copia ancora qualche dubbio) git-svn-id: svn://10.65.10.50/trunk@19354 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b77fa67792
commit
c25b51cef4
257
ve/ve2500.cpp
257
ve/ve2500.cpp
@ -1,8 +1,11 @@
|
||||
#include <automask.h>
|
||||
#include <defmask.h>
|
||||
#include <progind.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <relapp.h>
|
||||
|
||||
#include "../mg/anamag.h"
|
||||
#include "condv.h"
|
||||
#include "rcondv.h"
|
||||
|
||||
@ -14,12 +17,18 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class TGestione_listini_semplice_mask_genera: public TAutomask
|
||||
{
|
||||
|
||||
TMask* _main_mask; //puntatore maschera principale
|
||||
|
||||
protected:
|
||||
int find_art_in_sheet(const char tipo, const TString& cod, const TString& um, const int nscagl) const;
|
||||
void copia_listino();
|
||||
void crea_da_anamag();
|
||||
|
||||
public:
|
||||
void crea_listino();
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
TGestione_listini_semplice_mask_genera(TSheet_field& sf_righe);
|
||||
TGestione_listini_semplice_mask_genera(TMask* main_mask);
|
||||
};
|
||||
|
||||
|
||||
@ -28,16 +37,150 @@ bool TGestione_listini_semplice_mask_genera::on_field_event(TOperable_field& o,
|
||||
return true;
|
||||
}
|
||||
|
||||
TGestione_listini_semplice_mask_genera::TGestione_listini_semplice_mask_genera(TSheet_field& sf_righe) : TAutomask("ve2500b")
|
||||
TGestione_listini_semplice_mask_genera::TGestione_listini_semplice_mask_genera(TMask* main_mask)
|
||||
: TAutomask("ve2500b"), _main_mask(main_mask)
|
||||
{
|
||||
const bool gesliscv = ini_get_bool(CONFIG_DITTA, "ve", "GESLISCV");
|
||||
const bool gesliscv = _main_mask->field(F_L_CATVEN).enabled();
|
||||
enable(F_CATVEN, gesliscv);
|
||||
enable(F_DESVEN, gesliscv);
|
||||
}
|
||||
|
||||
// COPIA LISTINO
|
||||
//--------------
|
||||
//metodo che restituisce l'indice della riga dello sheet che contiene
|
||||
//la coppia tipo-articolo desiderata (-1 se non lo trova)
|
||||
int TGestione_listini_semplice_mask_genera::find_art_in_sheet(const char tipo, const TString& cod,
|
||||
const TString& um, const int nscagl) const
|
||||
{
|
||||
TSheet_field& s = _main_mask->sfield(F_L_RIGHE);
|
||||
int i = -1;
|
||||
FOR_EACH_SHEET_ROW(s, r, row)
|
||||
{
|
||||
const char tiporiga = row->get_char(0);
|
||||
const TString& codart = row->get(1);
|
||||
TString4 umis = row->get(4);
|
||||
umis.trim();
|
||||
const int numscagl = row->get_int(5);
|
||||
if (tipo == tiporiga && cod == codart && um == umis && nscagl == numscagl)
|
||||
{
|
||||
i = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
//metodo per la copia da un listino esistente
|
||||
void TGestione_listini_semplice_mask_genera::copia_listino()
|
||||
{
|
||||
//parametri listino origine
|
||||
const TString& ori_catven = get(F_CATVEN);
|
||||
const TString& ori_codlis = get(F_COD);
|
||||
const real ricarico = get_real(F_RICARICO);
|
||||
|
||||
//TESTATA
|
||||
//se richiesto mette nei campi della maschera principale i dati di testata
|
||||
if (get_bool(F_COPIATESTA))
|
||||
{
|
||||
TToken_string key;
|
||||
key.add("L");
|
||||
key.add(ori_catven);
|
||||
key.add("");
|
||||
key.add("");
|
||||
key.add(ori_codlis);
|
||||
const TRectype& rec_ori_testata = cache().get(LF_CONDV, key);
|
||||
|
||||
//magico metodino per scrivere sui campi della maschera principale (testata nuovo listino) i dati della testata..
|
||||
//..del listino originale (senza usare una lunghissima serie di set su ogni campo!)
|
||||
FOR_EACH_MASK_FIELD((*_main_mask), i, f)
|
||||
{
|
||||
const TFieldref* fld_file = f->field();
|
||||
if (fld_file != NULL && !f->in_key(0) && f->enabled() && f->empty())
|
||||
f->set(fld_file->read(rec_ori_testata));
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHE
|
||||
//prende il recordset delle righe del listino origine e lo mette sullo sheet
|
||||
TString query;
|
||||
query << "USE RCONDV\n";
|
||||
query << "FROM TIPO=L CATVEN=#CATVEN COD=#COD\n";
|
||||
query << "TO TIPO=L CATVEN=#CATVEN COD=#COD\n";
|
||||
|
||||
TISAM_recordset righe_listino(query);
|
||||
righe_listino.set_var("#CATVEN", ori_catven);
|
||||
righe_listino.set_var("#COD", ori_codlis);
|
||||
|
||||
const long righe_listino_items = righe_listino.items();
|
||||
TProgind pi(righe_listino_items, TR("Copia righe listino origine..."), true, true);
|
||||
|
||||
//sheet righe listino da riempire nella maschera principale
|
||||
TSheet_field& sf_righe = _main_mask->sfield(F_L_RIGHE);
|
||||
TMask& msk = sf_righe.sheet_mask();
|
||||
//record corrente del recordset
|
||||
const TRectype& riga_corrente = righe_listino.cursor()->curr();
|
||||
TString80 val;
|
||||
//scorre tutte le righe listino del recordset e le sbatte nello sheet della maschera principale
|
||||
for (bool ok = righe_listino.move_first(); ok; ok = righe_listino.move_next())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
//controlla che il record non esista per caso già nel listino di destinazione (caso della copia listino in più..
|
||||
//..fasi separate: un lavoro da mica normali!). Prende quindi la chiave di riga e cerca nello sheet...
|
||||
const char tiporiga = riga_corrente.get_char(RCONDV_TIPORIGA);
|
||||
const TString& codice = riga_corrente.get(RCONDV_CODRIGA);
|
||||
const TString& um = riga_corrente.get(RCONDV_UM);
|
||||
const int nscagl = riga_corrente.get_int(RCONDV_NSCAGL);
|
||||
//se il record non esiste può aggiungerlo allo sheet
|
||||
if (find_art_in_sheet(tiporiga, codice, um, nscagl) < 0)
|
||||
{
|
||||
TToken_string& row = sf_righe.row(-1);
|
||||
//per ogni campo della maschera setta all'interno del record corrente di file
|
||||
//il valore di quei campi che hanno un field
|
||||
FOR_EACH_MASK_FIELD(msk, i, f)
|
||||
{
|
||||
const TFieldref* fr = f->field();
|
||||
if (fr != NULL)
|
||||
{
|
||||
val = fr->read(riga_corrente);
|
||||
if (fr->name() == RCONDV_PREZZO && !ricarico.is_zero()) //gestione del ricarico sul listino
|
||||
{
|
||||
const real prezzo = riga_corrente.get_real(RCONDV_PREZZO) * (1 + ricarico / CENTO);
|
||||
val = prezzo.string();
|
||||
}
|
||||
row.add(val, sf_righe.cid2index(f->dlg()));
|
||||
}
|
||||
}
|
||||
//forza una check_row
|
||||
sf_righe.check_row(sf_righe.items()-1, 3);
|
||||
}
|
||||
}
|
||||
sf_righe.force_update();
|
||||
}
|
||||
|
||||
|
||||
//CREA DA ANAGRAFICA ARTICOLI
|
||||
//----------------------------
|
||||
void TGestione_listini_semplice_mask_genera::crea_da_anamag()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TGestione_listini_semplice_mask_genera::crea_listino()
|
||||
{
|
||||
|
||||
//per prima cosa controlla se deve copiare da un listino esistente o generare da nuovo
|
||||
const int f_tipo_gen = get_int(F_SELECT);
|
||||
switch (f_tipo_gen)
|
||||
{
|
||||
case 1:
|
||||
copia_listino();
|
||||
break;
|
||||
case 2:
|
||||
crea_da_anamag();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -89,23 +232,26 @@ int TGestione_listini_semplice_mask::guess_art(TSheet_field& s, const char tipo,
|
||||
|
||||
//metodo che restituisce l'indice della riga dello sheet che contiene
|
||||
//la coppia tipo-articolo desiderata (-1 se non lo trova)
|
||||
int TGestione_listini_semplice_mask::find_art(TSheet_field& s, const char tipo, const TString& art, const int tranne) const
|
||||
int TGestione_listini_semplice_mask::find_art(TSheet_field& s, const char tipo, const TString& art,
|
||||
const int tranne) const
|
||||
{
|
||||
int r = -1;
|
||||
//scorro le righe dello sheet partendo dall'ultima
|
||||
int i = -1;
|
||||
//tranne serve per evitare una riga specifica;di default è posto =-1 perchè non si usa
|
||||
for (r = s.items() - 1; r >= 0; r--)
|
||||
FOR_EACH_SHEET_ROW(s, r, row)
|
||||
{
|
||||
if (r != tranne)
|
||||
{
|
||||
const char* tiporiga = s.row(r).get(0);
|
||||
const char* codart = s.row(r).get(1);
|
||||
const char tiporiga = row->get_char(0);
|
||||
const char* codart = row->get(1);
|
||||
|
||||
if (tipo == tiporiga[0] && art == codart)
|
||||
if (tipo == tiporiga && art == codart)
|
||||
{
|
||||
i = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +282,7 @@ bool TGestione_listini_semplice_mask::on_field_event(TOperable_field &o, TField_
|
||||
case F_L_DESRIGA_G:
|
||||
case F_L_DESRIGA_S:
|
||||
case F_L_DESRIGA_R:
|
||||
if (e == fe_edit || e == fe_modify)
|
||||
if (!o.empty() && e == fe_edit)
|
||||
{
|
||||
const char tiporiga = get(F_L_TIPORIGA)[0];
|
||||
const TString& desriga = ((TEditable_field&)o).get_window_data();
|
||||
@ -207,9 +353,8 @@ bool TGestione_listini_semplice_mask::on_field_event(TOperable_field &o, TField_
|
||||
case DLG_CREA:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TSheet_field& sf_righe = sfield(F_L_RIGHE);
|
||||
TGestione_listini_semplice_mask_genera mask_gen(sf_righe);
|
||||
if (mask_gen.run())
|
||||
TGestione_listini_semplice_mask_genera mask_gen(this); //gli passa la maschera principale
|
||||
if (mask_gen.run() == K_ENTER)
|
||||
mask_gen.crea_listino();
|
||||
}
|
||||
break;
|
||||
@ -243,8 +388,11 @@ protected:
|
||||
virtual bool protected_record(TRectype& rec);
|
||||
|
||||
virtual int read(TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
virtual bool remove();
|
||||
|
||||
const TString80 find_descr(TToken_string& row);
|
||||
|
||||
public:
|
||||
virtual TRelation *get_relation() const { return _rel; }
|
||||
@ -320,6 +468,29 @@ void TGestione_listini_semplice::save_rows()
|
||||
}
|
||||
}
|
||||
|
||||
const TString80 TGestione_listini_semplice::find_descr(TToken_string& row)
|
||||
{
|
||||
TString80 descr;
|
||||
const char tiporiga = row.get_char(0);
|
||||
const TString& codriga = row.get(1);
|
||||
switch (tiporiga)
|
||||
{
|
||||
case 'A':
|
||||
descr = cache().get(LF_ANAMAG, codriga, ANAMAG_DESCR);
|
||||
break;
|
||||
case 'G':
|
||||
case 'S':
|
||||
descr = cache().get("GMC", codriga, "S0");
|
||||
break;
|
||||
case 'R':
|
||||
descr = cache().get("RFA", codriga, "S0");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return descr;
|
||||
}
|
||||
|
||||
bool TGestione_listini_semplice::protected_record(TRectype& rec)
|
||||
{
|
||||
@ -368,25 +539,32 @@ int TGestione_listini_semplice::read(TMask& m)
|
||||
TMask& msk = sf_righe.sheet_mask();
|
||||
sf_righe.destroy();
|
||||
|
||||
//per ogni riga dello sheet
|
||||
int pos = -1;
|
||||
//per ogni riga del recordset va ad aggiornare lo sheet sulla maschera (aggiunge la riga)
|
||||
for (bool ok = righelist.move_first(); ok; ok = righelist.move_next())
|
||||
{
|
||||
++pos;
|
||||
TToken_string& row = sf_righe.row(-1);
|
||||
//per ogni campo della maschera setta all'interno del record corrente di file
|
||||
//il valore di quei campi che hanno un field
|
||||
FOR_EACH_MASK_FIELD(msk,i,f)
|
||||
FOR_EACH_MASK_FIELD(msk, i, f)
|
||||
{
|
||||
const TFieldref* fr = f->field();
|
||||
if (fr != NULL)
|
||||
row.add(fr->read(rec),sf_righe.cid2index(f->dlg()));
|
||||
}
|
||||
{
|
||||
row.add(fr->read(rec), sf_righe.cid2index(f->dlg()));
|
||||
|
||||
//forzo una check_row
|
||||
sf_righe.check_row(sf_righe.items()-1, 3);
|
||||
}
|
||||
}
|
||||
//creatore delle descrizioni al posto della check_row; quest'ultima non si può usare..
|
||||
//..perchè al cambio di tipo riga impazzisce; si fa solo con il campo codice
|
||||
const int codice = f->dlg();
|
||||
if (codice == F_CODRIGA_A || codice == F_CODRIGA_G || codice == F_CODRIGA_S || codice == F_CODRIGA_R)
|
||||
{
|
||||
const TString80 descr = find_descr(row);
|
||||
row.add(descr, 2);
|
||||
}
|
||||
} //if(fr!=NULL)
|
||||
} //FOR_EACH_MASK_FIELD
|
||||
|
||||
} //for(bool ok=...
|
||||
} //if(err==NOERR)
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -410,6 +588,29 @@ int TGestione_listini_semplice::write(const TMask& m)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
bool TGestione_listini_semplice::remove()
|
||||
{
|
||||
//vanno rimosse prima le righe poi la testata (nucleare?)
|
||||
const TRectype& rec_head = get_relation()->curr();
|
||||
|
||||
TISAM_recordset righelist(build_query());
|
||||
righelist.set_var("#CATVEN", rec_head.get(RCONDV_CATVEN));
|
||||
righelist.set_var("#COD", rec_head.get(RCONDV_COD));
|
||||
const long righelist_items = righelist.items();
|
||||
TProgind pi(righelist_items, TR("Eliminazione righe listino..."), true, true);
|
||||
//strage di righe!
|
||||
for (bool ok = righelist.move_first(); ok; ok = righelist.move_next())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
righelist.cursor()->relation()->remove();
|
||||
}
|
||||
|
||||
//questa rimuove la testata
|
||||
return (TRelation_application::remove());
|
||||
}
|
||||
|
||||
|
||||
void TGestione_listini_semplice::init_query_mode(TMask& m)
|
||||
{
|
||||
m.disable(DLG_CREA);
|
||||
|
40
ve/ve2500.h
40
ve/ve2500.h
@ -1,40 +0,0 @@
|
||||
#define F_GESTUM 101
|
||||
#define F_GESTSCAGL 102
|
||||
#define F_GESTSCONTI 103
|
||||
#define F_SEQRICRIG 104
|
||||
#define F_SELARCRIG 105
|
||||
#define F_TIPOIMM 106
|
||||
|
||||
#define FS_CODVAL 101
|
||||
#define FS_CODVAL1 102
|
||||
#define FS_CODART 103
|
||||
#define FS_CODART1 104
|
||||
#define FS_UM 105
|
||||
#define FS_SCAGL 106
|
||||
#define FS_QLIM 107
|
||||
#define FS_PREZZONETTO 108
|
||||
#define FS_PREZZOLORDO 109
|
||||
#define FS_PROVV 110
|
||||
#define FS_SCONTO 111
|
||||
#define FS_DATAINI 112
|
||||
#define FS_DATAFIN 113
|
||||
#define FS_APPLPREZZO 114
|
||||
#define FS_APPLSCONTO 115
|
||||
#define FS_APPLPROVV 116
|
||||
#define FS_ARTESAURIM 117
|
||||
#define FS_UMOMAGGI 118
|
||||
#define FS_ADDIVA 119
|
||||
#define FS_CODIVA 120
|
||||
#define FS_CODIVA1 121
|
||||
#define FS_PREZZOMAGGI 122
|
||||
#define FS_QMERCESCON 123
|
||||
#define FS_QBASE 124
|
||||
#define FS_CODTAGLIE 125
|
||||
#define FS_TAGLIE 126
|
||||
#define FS_COLORE 127
|
||||
#define FS_QUALIT 128
|
||||
#define FS_CODLOTTO 129
|
||||
|
||||
|
||||
|
||||
|
@ -522,7 +522,6 @@ LIST F_TIPORIGA 1 16
|
||||
BEGIN
|
||||
PROMPT 1 0 "Tipo riga "
|
||||
FIELD TIPORIGA
|
||||
FLAGS "P"
|
||||
ITEM "A|Articolo"
|
||||
MESSAGE HIDE,2@|HIDE,3@|HIDE,4@|SHOW,1@
|
||||
ITEM "G|Gruppo merc."
|
||||
@ -666,7 +665,6 @@ BEGIN
|
||||
DISPLAY "Descrizione@50" %UMS->S0
|
||||
OUTPUT F_UM UM
|
||||
CHECKTYPE FORCED
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 76 3
|
||||
|
@ -84,11 +84,9 @@ BEGIN
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
NUMBER F_RICARICO 5 2
|
||||
NUMBER F_RICARICO 6 2
|
||||
BEGIN
|
||||
PROMPT 2 10 "Ricarico "
|
||||
NUM_EXPR (#F_RICARICO>=-100)&&(#F_RICARICO<=100)
|
||||
WARNING "La percentuale di ricarico deve essere compresa tra -100 e 100"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user