Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : isam.cpp Corretta packfile e load maskfld.* Corretta gestione TBrowse sulle directory msksheet.* Aggiunto parametro alla check_row multirec.cpp Aggiunstata indentazione e commenti git-svn-id: svn://10.65.10.50/trunk@6948 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
bcaa4baf58
commit
011286b521
@ -715,16 +715,20 @@ int TBaseisamfile::_read(TRectype& rec, word op, word lockop)
|
|||||||
{
|
{
|
||||||
const TCodeb_handle fhnd = handle();
|
const TCodeb_handle fhnd = handle();
|
||||||
rec.setdirty();
|
rec.setdirty();
|
||||||
|
|
||||||
_lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno);
|
_lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno);
|
||||||
|
|
||||||
if(rec.has_memo())
|
if(rec.has_memo())
|
||||||
rec.init_memo(_recno);
|
rec.init_memo(_recno);
|
||||||
if (lockop && _lasterr == NOERR)
|
|
||||||
|
if (_lasterr == NOERR)
|
||||||
{
|
{
|
||||||
if (lockop == _lock)
|
if (lockop == _lock)
|
||||||
prefix().lock_record(_isam_handle, _recno);
|
prefix().lock_record(_isam_handle, _recno);
|
||||||
if (lockop == _unlock)
|
if (lockop == _unlock)
|
||||||
prefix().unlock_record(_isam_handle, _recno);
|
prefix().unlock_record(_isam_handle, _recno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _lasterr;
|
return _lasterr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1664,17 +1668,20 @@ int TSystemisamfile::update(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
nrec.zero();
|
nrec.zero();
|
||||||
for (j = outfld.first(); j < nflds; j = outfld.succ(j))
|
for (j = outfld.last(); j >= 0; j = outfld.pred(j))
|
||||||
{
|
{
|
||||||
TRecfield& in_fld = (TRecfield&)infld[j];
|
TRecfield* in_fld = (TRecfield*)infld.objptr(j);
|
||||||
TRecfield& out_fld = (TRecfield&)outfld[j];
|
TRecfield* out_fld = (TRecfield*)outfld.objptr(j);
|
||||||
const char* fld_val = in_fld;
|
if (in_fld != NULL && out_fld != NULL)
|
||||||
out_fld = fld_val;
|
{
|
||||||
|
const char* fld_val = *in_fld;
|
||||||
|
*out_fld = fld_val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lcf)
|
if (lcf)
|
||||||
makelc((TRectype &)nrec);
|
makelc((TRectype &)nrec);
|
||||||
browse_null(nrec.string(),lenr/*DB_reclen(fhnd)*/);
|
browse_null(nrec.string(),lenr);
|
||||||
memcpy(DB_getrecord(fhnd),nrec.string(),lenr/*DB_reclen(fhnd)*/);
|
memcpy(DB_getrecord(fhnd),nrec.string(),lenr);
|
||||||
err=DB_add(fhnd);
|
err=DB_add(fhnd);
|
||||||
if ( err == NOERR && nrec.has_memo())
|
if ( err == NOERR && nrec.has_memo())
|
||||||
nrec.write_memo(fhnd, DB_recno(fhnd));
|
nrec.write_memo(fhnd, DB_recno(fhnd));
|
||||||
@ -1784,15 +1791,13 @@ int TSystemisamfile::packfile(
|
|||||||
// @xref <mf TSystemisamfile::packindex>
|
// @xref <mf TSystemisamfile::packindex>
|
||||||
|
|
||||||
{
|
{
|
||||||
int err=NOERR;
|
|
||||||
TDir d;
|
TDir d;
|
||||||
|
d.get(num(),_nolock, _nordir,_sysdirop); // Chi commenta muore!
|
||||||
// d.get(num(),_nolock, _nordir,_sysdirop);
|
|
||||||
d.get(num(),_nolock, (d.is_com()) ? _comdir : _nordir);
|
d.get(num(),_nolock, (d.is_com()) ? _comdir : _nordir);
|
||||||
|
|
||||||
// CHECKS(filehnd() == NULL, "Can't pack open file", (const char*)filename());
|
// CHECKS(filehnd() == NULL, "Can't pack open file", (const char*)filename());
|
||||||
|
|
||||||
err=DB_packfile(vis, d.name(), zap ? 0L : d.eod());
|
int err = DB_packfile(vis, d.name(), zap ? 0L : d.eod());
|
||||||
|
|
||||||
if (zap && err == NOERR)
|
if (zap && err == NOERR)
|
||||||
err = packindex(vis, FALSE);
|
err = packindex(vis, FALSE);
|
||||||
@ -1848,8 +1853,8 @@ int TSystemisamfile::packindex(
|
|||||||
|
|
||||||
int TSystemisamfile::pack(bool vis, bool ask)
|
int TSystemisamfile::pack(bool vis, bool ask)
|
||||||
{
|
{
|
||||||
int err=NOERR;
|
int err = packfile(vis);
|
||||||
if ((err=packfile(vis))==NOERR)
|
if (err == NOERR)
|
||||||
err = packindex(vis, ask);
|
err = packindex(vis, ask);
|
||||||
setstatus(err);
|
setstatus(err);
|
||||||
return err;
|
return err;
|
||||||
@ -1882,7 +1887,7 @@ int TSystemisamfile::load(
|
|||||||
error_box("Impossibile aprire il file %s",from);
|
error_box("Impossibile aprire il file %s",from);
|
||||||
return err = 2;
|
return err = 2;
|
||||||
}
|
}
|
||||||
TRecnotype r = 0, e = 0, nitems = 0, nread = 0;
|
TRecnotype r = 0, e = 0, nitems = 0;
|
||||||
TString16 firm, year, attprev("00000");
|
TString16 firm, year, attprev("00000");
|
||||||
|
|
||||||
if (extended)
|
if (extended)
|
||||||
@ -1897,32 +1902,16 @@ int TSystemisamfile::load(
|
|||||||
if (ditte.read() == NOERR)
|
if (ditte.read() == NOERR)
|
||||||
attprev = ditte.get("CODATTPREV");
|
attprev = ditte.get("CODATTPREV");
|
||||||
}
|
}
|
||||||
if (fl == NULL)
|
|
||||||
{ // Come fa' ad arrivare qui, se fl non puo' essere NULL????
|
|
||||||
clearerr(fl);
|
|
||||||
setstatus(err);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
char w[80];
|
|
||||||
while ((fgets(w, 80, fl) != NULL))
|
|
||||||
{
|
|
||||||
if (strncmp(w, "[Data]", 6) == 0)
|
|
||||||
{
|
|
||||||
nitems = ftell(fl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fseek(fl, 0L, SEEK_END);
|
fseek(fl, 0L, SEEK_END);
|
||||||
nitems = ftell(fl) - nitems;
|
nitems = ftell(fl);
|
||||||
fclose(fl);
|
fclose(fl);
|
||||||
|
|
||||||
TFilename filename;
|
err = _open_ex();
|
||||||
TIsam_handle isam_handle = prefix().open_isamfile(_logicnum, filename);
|
if (err != NOERR)
|
||||||
int fhnd = handle(isam_handle);
|
|
||||||
if (fhnd < 0)
|
|
||||||
{
|
{
|
||||||
error_box("Impossibile aprire il file %s", (const char*)filename);
|
error_box("Impossibile aprire il file %d", _logicnum);
|
||||||
return _isnotopen;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
TScanner f(from);
|
TScanner f(from);
|
||||||
@ -1997,7 +1986,7 @@ int TSystemisamfile::load(
|
|||||||
if (fd) sfd << fd;
|
if (fd) sfd << fd;
|
||||||
int last = NOERR;
|
int last = NOERR;
|
||||||
|
|
||||||
s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", (const char*)filename, r, e, last);
|
s1.format("Imp. archivio %d\n%6ld records %6ld errori - %3d", _logicnum, r, e, last);
|
||||||
TProgind p(nitems, s1, TRUE, TRUE, 70);
|
TProgind p(nitems, s1, TRUE, TRUE, 70);
|
||||||
for (s = f.line(); s.not_empty() && !p.iscancelled(); s = f.line())
|
for (s = f.line(); s.not_empty() && !p.iscancelled(); s = f.line())
|
||||||
{
|
{
|
||||||
@ -2014,11 +2003,10 @@ int TSystemisamfile::load(
|
|||||||
}
|
}
|
||||||
if ((r + e) % 50 == 0)
|
if ((r + e) % 50 == 0)
|
||||||
{
|
{
|
||||||
s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", (const char*)filename, r, e, last);
|
s1.format("Imp. archivio %d\n%6ld records %6ld errori - %3d", _logicnum, r, e, last);
|
||||||
p.set_text(s1);
|
p.set_text(s1);
|
||||||
}
|
}
|
||||||
p.setstatus(nread + 1);
|
p.setstatus(f.tellg());
|
||||||
nread += s.len() + 1;
|
|
||||||
zero();
|
zero();
|
||||||
if (fixedlen)
|
if (fixedlen)
|
||||||
{
|
{
|
||||||
@ -2060,10 +2048,10 @@ int TSystemisamfile::load(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", (const char*)filename, r, e, last);
|
s1.format("Imp. archivio %d\n%6ld records %6ld errori - %3d", _logicnum, r, e, last);
|
||||||
p.set_text(s1);
|
p.set_text(s1);
|
||||||
|
|
||||||
prefix().close_isamfile(isam_handle);
|
close();
|
||||||
|
|
||||||
setstatus(err);
|
setstatus(err);
|
||||||
return err;
|
return err;
|
||||||
@ -2808,7 +2796,8 @@ TRectype& TRectype::operator =(const TBaseisamfile& f)
|
|||||||
// Certified 50%
|
// Certified 50%
|
||||||
int TRectype::read(TBaseisamfile& f, word op, word lockop)
|
int TRectype::read(TBaseisamfile& f, word op, word lockop)
|
||||||
{
|
{
|
||||||
return f._read(*this,op,lockop) ;
|
int err = f._read(*this,op,lockop);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TRectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
int TRectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
||||||
|
@ -2542,10 +2542,15 @@ KEY TFile_select::run()
|
|||||||
|
|
||||||
if (good)
|
if (good)
|
||||||
{
|
{
|
||||||
TString str = fs.name;
|
const TFixed_string str(fs.name);
|
||||||
good = _filter.not_empty() && str.match(_filter);
|
good = _filter.empty() || str.match(_filter);
|
||||||
if (good)
|
if (good)
|
||||||
field().set(str);
|
{
|
||||||
|
TFilename path;
|
||||||
|
xvt_fsys_convert_dir_to_str(&fs.dir, path.get_buffer(), path.size());
|
||||||
|
path.add(fs.name);
|
||||||
|
field().set(path);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
field().error_box("Il nome del file non corrisponde alla maschera %s", _filter.get_buffer());
|
field().error_box("Il nome del file non corrisponde alla maschera %s", _filter.get_buffer());
|
||||||
}
|
}
|
||||||
@ -2555,8 +2560,8 @@ KEY TFile_select::run()
|
|||||||
|
|
||||||
// CHECK_NONE Nessun controllo
|
// CHECK_NONE Nessun controllo
|
||||||
// CHECK_NORMAL Se non e' vuoto deve esistere
|
// CHECK_NORMAL Se non e' vuoto deve esistere
|
||||||
// CHECK_REQUIRED Deve esistere
|
// CHECK_REQUIRED Non puo' essere vuoto e deve esistere
|
||||||
// CHECK_SEARCH Puo' essere vuoto altrimenti deve matchare il filtro
|
// CHECK_SEARCH Puo' essere vuoto e puo' non matchare il filtro
|
||||||
|
|
||||||
bool TFile_select::check(CheckTime)
|
bool TFile_select::check(CheckTime)
|
||||||
{
|
{
|
||||||
@ -3099,9 +3104,7 @@ bool TEdit_field::on_key(KEY key)
|
|||||||
// check consistency
|
// check consistency
|
||||||
if (ok && _browse)
|
if (ok && _browse)
|
||||||
{
|
{
|
||||||
if (sheet())
|
if (browse())
|
||||||
ok = sheet()->check(FINAL_CHECK);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (ok && check_enabled() && vf != 21) // 21 = NOT_EMPTY_CHECK_FIELD
|
if (ok && check_enabled() && vf != 21) // 21 = NOT_EMPTY_CHECK_FIELD
|
||||||
{
|
{
|
||||||
@ -3109,6 +3112,9 @@ bool TEdit_field::on_key(KEY key)
|
|||||||
else ok = browse()->empty_check();
|
else ok = browse()->empty_check();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
ok = _browse->check(FINAL_CHECK);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!ok) return default_error_box();
|
if (!ok) return default_error_box();
|
||||||
}
|
}
|
||||||
|
@ -904,6 +904,11 @@ public:
|
|||||||
// @cmember Ritorna il valore di <p _insert>
|
// @cmember Ritorna il valore di <p _insert>
|
||||||
const TString& get_insert() const
|
const TString& get_insert() const
|
||||||
{ return _insert;}
|
{ return _insert;}
|
||||||
|
|
||||||
|
// @cmember Setta il valore di <p _filter>
|
||||||
|
void set_filter(const char* f)
|
||||||
|
{ _filter = f;}
|
||||||
|
|
||||||
// @cmember Ritorna il valore di <p _filter>
|
// @cmember Ritorna il valore di <p _filter>
|
||||||
const TString& get_filter() const
|
const TString& get_filter() const
|
||||||
{ return _filter;}
|
{ return _filter;}
|
||||||
|
@ -2648,7 +2648,7 @@ void TSheet_field::mask2row(int n, TToken_string & rec)
|
|||||||
|
|
||||||
|
|
||||||
// Ricopia i campi del record dato nella maschera
|
// Ricopia i campi del record dato nella maschera
|
||||||
void TSheet_field::row2mask(int n, TToken_string & r)
|
void TSheet_field::row2mask(int n, TToken_string & r, int mode)
|
||||||
{
|
{
|
||||||
TString val(80);
|
TString val(80);
|
||||||
|
|
||||||
@ -2672,6 +2672,8 @@ void TSheet_field::row2mask(int n, TToken_string & r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode > 0)
|
||||||
|
{
|
||||||
for (i = 0; i < campi; i++)
|
for (i = 0; i < campi; i++)
|
||||||
{
|
{
|
||||||
TMask_field& f = m.fld(i);
|
TMask_field& f = m.fld(i);
|
||||||
@ -2681,12 +2683,14 @@ void TSheet_field::row2mask(int n, TToken_string & r)
|
|||||||
!f.is_kind_of(CLASS_BUTTON_FIELD) &&
|
!f.is_kind_of(CLASS_BUTTON_FIELD) &&
|
||||||
(f.active() || f.ghost()))
|
(f.active() || f.ghost()))
|
||||||
{
|
{
|
||||||
if (f.has_check())
|
if (f.has_check() && (mode & 0x1))
|
||||||
f.check(STARTING_CHECK);
|
f.check(STARTING_CHECK);
|
||||||
f.set_dirty(FALSE);
|
f.set_dirty(FALSE);
|
||||||
|
if (mode & 0x2)
|
||||||
f.on_hit();
|
f.on_hit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < campi; i++)
|
for (i = 0; i < campi; i++)
|
||||||
{
|
{
|
||||||
@ -2718,7 +2722,7 @@ void TSheet_field::save_columns_order()
|
|||||||
s.save_columns_order();
|
s.save_columns_order();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSheet_field::check_row(int n)
|
void TSheet_field::check_row(int n, int mode)
|
||||||
{
|
{
|
||||||
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
||||||
const int current = s->_cur_rec;
|
const int current = s->_cur_rec;
|
||||||
@ -2739,7 +2743,7 @@ void TSheet_field::check_row(int n)
|
|||||||
if (f.has_check())
|
if (f.has_check())
|
||||||
f.set_dirty();
|
f.set_dirty();
|
||||||
}
|
}
|
||||||
row2mask(n, r);
|
row2mask(n, r, mode);
|
||||||
mask2row(n, r);
|
mask2row(n, r);
|
||||||
m.set_mode(mask_mode);
|
m.set_mode(mask_mode);
|
||||||
s->_cur_rec = current;
|
s->_cur_rec = current;
|
||||||
@ -2796,10 +2800,14 @@ bool TSheet_field::autoload_line(int i,TRectype & rec)
|
|||||||
TMask_field& mf = sheet_mask().fld(j);
|
TMask_field& mf = sheet_mask().fld(j);
|
||||||
const short id = mf.dlg();
|
const short id = mf.dlg();
|
||||||
TFieldref const *dbfield=mf.field();
|
TFieldref const *dbfield=mf.field();
|
||||||
if (dbfield) {
|
if (dbfield)
|
||||||
if (id>=FIRST_FIELD && id<=_last_column_id) {
|
{
|
||||||
|
if (id>=FIRST_FIELD && id<=_last_column_id)
|
||||||
|
{
|
||||||
row.add(dbfield->read(rec),cid2index(id));
|
row.add(dbfield->read(rec),cid2index(id));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mf.set(dbfield->read(rec));
|
mf.set(dbfield->read(rec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ protected:
|
|||||||
// @cmember Ricopia i campi della maschera nel record <p n>-esimo
|
// @cmember Ricopia i campi della maschera nel record <p n>-esimo
|
||||||
virtual void mask2row(int n, TToken_string & rec);
|
virtual void mask2row(int n, TToken_string & rec);
|
||||||
// @cmember Ricopia i campi del record <p n>-esimo nella maschera
|
// @cmember Ricopia i campi del record <p n>-esimo nella maschera
|
||||||
virtual void row2mask(int n, TToken_string & rec);
|
virtual void row2mask(int n, TToken_string & rec, int mode = 0x3);
|
||||||
|
|
||||||
// @cmember Permette di mettere il focus su una cella
|
// @cmember Permette di mettere il focus su una cella
|
||||||
void set_focus_cell(int riga, int colonna);
|
void set_focus_cell(int riga, int colonna);
|
||||||
@ -221,7 +221,7 @@ public:
|
|||||||
virtual void post_insert(int) { }
|
virtual void post_insert(int) { }
|
||||||
|
|
||||||
// @cmember Esegue tutti i check iniziali sulla riga <p n>
|
// @cmember Esegue tutti i check iniziali sulla riga <p n>
|
||||||
void check_row(int n);
|
void check_row(int n, int mode = 0x3);
|
||||||
|
|
||||||
// @cmember Trasferisce i valori dalla maschera alla riga <p n>
|
// @cmember Trasferisce i valori dalla maschera alla riga <p n>
|
||||||
void update_row(int n) { mask2row(n, row(n)); }
|
void update_row(int n) { mask2row(n, row(n)); }
|
||||||
|
@ -18,15 +18,16 @@ void TMultiple_rectype::set_body_key(TRectype & rowrec)
|
|||||||
void TMultiple_rectype::load_rows_file(int logicnum)
|
void TMultiple_rectype::load_rows_file(int logicnum)
|
||||||
{
|
{
|
||||||
const int index = log2ind(logicnum);
|
const int index = log2ind(logicnum);
|
||||||
TRectype * rec = new_body_record(logicnum);
|
TRecord_array* r = (TRecord_array*)_files.objptr(index);
|
||||||
set_body_key(*rec);
|
if (r == NULL)
|
||||||
if (_files.objptr(index) == NULL)
|
|
||||||
{
|
{
|
||||||
// crea
|
// crea
|
||||||
TRecord_array * r = new TRecord_array(logicnum, (TString &) _numfields[index]);
|
r = new TRecord_array(logicnum, (TString &) _numfields[index]);
|
||||||
_files.add(r, index);
|
_files.add(r, index);
|
||||||
}
|
}
|
||||||
((TRecord_array &)_files[index]).read(rec); // rilegge
|
TRectype* rec = new_body_record(logicnum);
|
||||||
|
set_body_key(*rec);
|
||||||
|
r->read(rec); // rilegge
|
||||||
_changed.reset(index);
|
_changed.reset(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,18 +223,22 @@ int TMultiple_rectype::read(TBaseisamfile & f, word op, word lockop)
|
|||||||
_nuovo = FALSE;
|
_nuovo = FALSE;
|
||||||
if (op == _isequal)
|
if (op == _isequal)
|
||||||
{
|
{
|
||||||
TRectype r(*this);
|
const TRectype oldr(*this);
|
||||||
|
|
||||||
err = TRectype::read(f, op, lockop);
|
err = TRectype::read(f, op, lockop);
|
||||||
if (err != NOERR)
|
if (err != NOERR)
|
||||||
{
|
{
|
||||||
*this = r;
|
*this = oldr;
|
||||||
_nuovo = TRUE;
|
_nuovo = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
err = TRectype::read(f, op, lockop);
|
err = TRectype::read(f, op, lockop);
|
||||||
|
}
|
||||||
|
|
||||||
synchronize_bodies();
|
synchronize_bodies();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user