Patch level : 4.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Autocreazione righe vuote


git-svn-id: svn://10.65.10.50/trunk@14835 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2007-02-01 15:19:17 +00:00
parent 8dc0cd8c57
commit c28332be48
5 changed files with 104 additions and 85 deletions

View File

@ -134,13 +134,15 @@ void TMotore_application::init_insert_mode( TMask& m )
tp.set_defaults(m); tp.set_defaults(m);
m.disable(DLG_ELABORA); m.disable(DLG_ELABORA);
dm.mask2doc();
if (curdo.tipo().auto_add()) if (curdo.tipo().auto_add())
{ {
for (int i = 1; i <= 10; i++) TSheet_field& ss = dm.sfield(F_SHEET);
curdo.new_row("01"); for (int i = 0; i < 10; i++)
dm.doc2mask(false); ss.insert(-1, false, true);
} }
dm.mask2doc();
} }
void TMotore_application::init_modify_mode( TMask& m ) void TMotore_application::init_modify_mode( TMask& m )
@ -303,8 +305,22 @@ bool TMotore_application::menu(MENU_TAG mt)
int TMotore_application::write( const TMask& m ) // C 90 int TMotore_application::write( const TMask& m ) // C 90
{ {
TDocumento& d = (TDocumento&) _rel->curr(); TDocumento& d = (TDocumento&)_rel->curr();
d = ((TDocumento_mask&)m).doc(); d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
// Se ho attivato la creazione automatica delle righe allora cancello quelle vuote finali
if (d.tipo().auto_add())
{
for (int r = d.rows(); r > 0; r--)
{
const TRiga_documento& dr = d[r];
if (dr.get(RDOC_CODART).empty() && dr.get(RDOC_DESCR).empty())
d.destroy_row(r);
else
break;
}
}
return TRelation_application::write(m); return TRelation_application::write(m);
} }
@ -312,8 +328,8 @@ int TMotore_application::rewrite( const TMask& m ) // C 90
{ {
TDocumento& d = (TDocumento &) _rel->curr(); TDocumento& d = (TDocumento &) _rel->curr();
if (d.bloccato()) if (d.bloccato())
return 0; return NOERR;
d = ((TDocumento_mask&)m).doc(); d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
return TRelation_application::rewrite(m); return TRelation_application::rewrite(m);
} }

View File

@ -1,8 +1,7 @@
#include <applicat.h> #include <applicat.h>
#include <isam.h> #include <reputils.h>
#include <log.h> #include <reprint.h>
#include <progind.h> #include <progind.h>
#include <recset.h>
#include <defmask.h> #include <defmask.h>
#include "velib.h" #include "velib.h"
@ -19,8 +18,7 @@ protected:
void TRecupera_doc::recupera(bool create) void TRecupera_doc::recupera(bool create)
{ {
TError_log log; TLog_report log(TR("Recupero testate documento"));
log.set_header("Recupero testate documento");
TISAM_recordset rdoc("USE RDOC SELECT NRIGA=1"); TISAM_recordset rdoc("USE RDOC SELECT NRIGA=1");
TLocalisamfile doc(LF_DOC); TLocalisamfile doc(LF_DOC);
@ -69,7 +67,9 @@ void TRecupera_doc::recupera(bool create)
else else
warning_box("%ld documenti senza testata", tot); warning_box("%ld documenti senza testata", tot);
log.show(); TReport_book book;
book.add(log);
book.preview();
} }
void TRecupera_doc::main_loop() void TRecupera_doc::main_loop()

View File

@ -485,9 +485,9 @@ public:
virtual void zero(const char * fieldname); virtual void zero(const char * fieldname);
virtual void zero(char c = '\0'); virtual void zero(char c = '\0');
// row -> sheet // row -> sheet
void autoload( TSheet_field& f); void autoload(TSheet_field& f);
// sheet -> row // sheet -> row
void autosave( TSheet_field& f); void autosave(TSheet_field& f);
const TTipo_riga_documento & tipo() const; const TTipo_riga_documento & tipo() const;
const TSpesa_prest & spesa() const; const TSpesa_prest & spesa() const;
@ -817,8 +817,6 @@ protected:
void insert_anal_page(); void insert_anal_page();
void configura_sheet(TSheet_field& sheet); void configura_sheet(TSheet_field& sheet);
static bool ss_notify(TSheet_field& ss, int r, KEY key);
static bool ss_handler(TMask_field& f, KEY key);
static TMask* ss_getmask(int numriga, TMask& fullmask); static TMask* ss_getmask(int numriga, TMask& fullmask);
void set_field_handler(short fieldid, CONTROL_HANDLER handler); void set_field_handler(short fieldid, CONTROL_HANDLER handler);
@ -835,6 +833,8 @@ protected:
static bool codcamp_handler( TMask_field& f, KEY key ); static bool codcamp_handler( TMask_field& f, KEY key );
static bool datacambio_handler( TMask_field& f, KEY key ); static bool datacambio_handler( TMask_field& f, KEY key );
static bool codval_handler( TMask_field& f, KEY key ); static bool codval_handler( TMask_field& f, KEY key );
static bool ss_notify(TSheet_field& ss, int r, KEY key);
static bool ss_handler(TMask_field& f, KEY key);
void user_set_handler( int fieldid, int index); void user_set_handler( int fieldid, int index);
void reset_masks(const TString& tipo_doc); void reset_masks(const TString& tipo_doc);
@ -871,8 +871,8 @@ public:
void highlight(COLOR high_back_color, COLOR high_color); void highlight(COLOR high_back_color, COLOR high_color);
bool TDocumento_mask::is_calculated_page(int p) { return _calculated_pages[p]; } bool is_calculated_page(int p) const { return _calculated_pages[p]; }
TSmart_card * smartcard() const { return _smartcard;} TSmart_card* smartcard() const { return _smartcard;}
TDocumento_mask(const char* tipodoc); TDocumento_mask(const char* tipodoc);
virtual ~TDocumento_mask(); virtual ~TDocumento_mask();

View File

@ -859,7 +859,7 @@ void TRiga_documento::zero(char c)
TAuto_variable_rectype::zero(c); TAuto_variable_rectype::zero(c);
} }
void TRiga_documento::autosave(TSheet_field & f) void TRiga_documento::autosave(TSheet_field& f)
{ {
const int num = numero() - 1; const int num = numero() - 1;

View File

@ -1274,22 +1274,23 @@ bool TDocumento_mask::ss_handler(TMask_field& f, KEY key)
bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key ) bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
{ {
static bool selecting = false;
TDocumento_mask& m = (TDocumento_mask&)ss.mask(); TDocumento_mask& m = (TDocumento_mask&)ss.mask();
TDocumento& doc = m.doc(); TDocumento& doc = m.doc();
if ( key == K_ENTER ) // modifica switch (key)
{ {
static int calculated = 3; case K_ENTER: // modifica
TRiga_documento & riga = doc[r + 1]; {
riga.autosave(ss); TRiga_documento& riga = doc[r + 1];
riga.autosave(ss);
if (calculated == 3) if (m.is_calculated_page(m.curr_page()))
calculated = m.is_calculated_page(m.curr_page()); m.update_progs();
if (calculated == (int) true) }
m.update_progs(); break;
} case K_DEL: // Cancellazione
else
if ( key == K_DEL ) // Cancellazione
{ {
doc.destroy_row(r + 1, TRUE); doc.destroy_row(r + 1, TRUE);
if (r < doc.rows()) if (r < doc.rows())
@ -1302,64 +1303,66 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
} }
} }
} }
else case K_INS: // Inserimento
if (key == K_INS) // Inserimento {
if (r < doc.rows())
{
TRiga_documento & riga = doc[r + 1];
if (riga.is_omaggio() && riga.is_generata())
return FALSE;
}
doc.insert_row(r + 1, m.get( F_LBTIPORIGA ));
}
break;
case K_CTRL + K_INS:
{
const TRectype& ven_rec = doc.clifor().vendite();
TString8 s = ven_rec.get(CFV_CODMAG);
if (s.full())
{ {
s.left_just(3);
if (r < doc.rows()) s << ven_rec.get(CFV_CODDEP);
{
TRiga_documento & riga = doc[r + 1];
if (riga.is_omaggio() && riga.is_generata())
return FALSE;
}
doc.insert_row(r + 1, m.get( F_LBTIPORIGA ));
} }
else else
if (key == K_CTRL + K_INS) {
s = m.get(F_CAUSMAG);
if (s.full())
{ {
TRiga_documento & riga = doc[r + 1]; s = cache().get("%CAU", s, "S10");
const TRectype & ven_rec = doc.clifor().vendite(); if (s.blank())
TString16 s(ven_rec.get(CFV_CODMAG));
const TTipo_riga_documento & t = riga.tipo();
if (s.not_empty())
{ {
s = m._std_mag;
s.left_just(3); s.left_just(3);
s << ven_rec.get(CFV_CODDEP); s << m._std_dep;
} }
else
{
s = m.get(F_CAUSMAG);
if (!s.blank())
{
const TRectype & c=cache().get("%CAU", s);
if (!c.empty() && !c.get("S10").blank())
s = c.get("S10");
else
{
s = m._std_mag;
s.left_just(3);
s << m._std_dep;
}
}
}
riga.put("CODMAG", s);
riga.autoload(ss);
ss.check_row(r);
t.set_defaults(ss, r + 1);
} }
else }
if ( key == K_TAB ) // ingresso nella riga TRiga_documento& riga = doc[r + 1];
{ riga.put(RDOC_CODMAG, s);
m.update_giacenza(); riga.autoload(ss);
const TRectype& rdoc = doc[r + 1]; ss.check_row(r);
set_curr_um(rdoc.get(RDOC_UMQTA)); riga.tipo().set_defaults(ss, r + 1);
const bool on = rdoc.get(RDOC_DACODNUM).not_empty(); }
ss.sheet_mask().enable(DLG_USER, on); break;
} case K_TAB: // ingresso nella riga
if (!selecting && m.is_running())
{
m.update_giacenza();
const TRectype& rdoc = doc[r + 1];
set_curr_um(rdoc.get(RDOC_UMQTA));
const bool on = rdoc.get(RDOC_DACODNUM).not_empty();
ss.sheet_mask().enable(DLG_USER, on);
if (rdoc.get(RDOC_CODART).empty() && rdoc.get(RDOC_DESCR).empty())
{
selecting = true; // semaforo per impedire l'evento di selezione doppio
ss.select(r, 1, false);
selecting = false;
}
}
default:
break;
}
return TRUE; return TRUE;
} }