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();
|
||||
rec.setdirty();
|
||||
_lasterr=cisread(fhnd, getkey(), rec, op + lockop, _recno);
|
||||
|
||||
_lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno);
|
||||
|
||||
if(rec.has_memo())
|
||||
rec.init_memo(_recno);
|
||||
if (lockop && _lasterr == NOERR)
|
||||
|
||||
if (_lasterr == NOERR)
|
||||
{
|
||||
if (lockop == _lock)
|
||||
prefix().lock_record(_isam_handle, _recno);
|
||||
if (lockop == _unlock)
|
||||
prefix().unlock_record(_isam_handle, _recno);
|
||||
}
|
||||
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -1664,17 +1668,20 @@ int TSystemisamfile::update(
|
||||
continue;
|
||||
|
||||
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& out_fld = (TRecfield&)outfld[j];
|
||||
const char* fld_val = in_fld;
|
||||
out_fld = fld_val;
|
||||
TRecfield* in_fld = (TRecfield*)infld.objptr(j);
|
||||
TRecfield* out_fld = (TRecfield*)outfld.objptr(j);
|
||||
if (in_fld != NULL && out_fld != NULL)
|
||||
{
|
||||
const char* fld_val = *in_fld;
|
||||
*out_fld = fld_val;
|
||||
}
|
||||
}
|
||||
if (lcf)
|
||||
makelc((TRectype &)nrec);
|
||||
browse_null(nrec.string(),lenr/*DB_reclen(fhnd)*/);
|
||||
memcpy(DB_getrecord(fhnd),nrec.string(),lenr/*DB_reclen(fhnd)*/);
|
||||
browse_null(nrec.string(),lenr);
|
||||
memcpy(DB_getrecord(fhnd),nrec.string(),lenr);
|
||||
err=DB_add(fhnd);
|
||||
if ( err == NOERR && nrec.has_memo())
|
||||
nrec.write_memo(fhnd, DB_recno(fhnd));
|
||||
@ -1784,15 +1791,13 @@ int TSystemisamfile::packfile(
|
||||
// @xref <mf TSystemisamfile::packindex>
|
||||
|
||||
{
|
||||
int err=NOERR;
|
||||
TDir d;
|
||||
|
||||
// d.get(num(),_nolock, _nordir,_sysdirop);
|
||||
d.get(num(),_nolock, _nordir,_sysdirop); // Chi commenta muore!
|
||||
d.get(num(),_nolock, (d.is_com()) ? _comdir : _nordir);
|
||||
|
||||
// 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)
|
||||
err = packindex(vis, FALSE);
|
||||
@ -1848,9 +1853,9 @@ int TSystemisamfile::packindex(
|
||||
|
||||
int TSystemisamfile::pack(bool vis, bool ask)
|
||||
{
|
||||
int err=NOERR;
|
||||
if ((err=packfile(vis))==NOERR)
|
||||
err=packindex(vis,ask);
|
||||
int err = packfile(vis);
|
||||
if (err == NOERR)
|
||||
err = packindex(vis, ask);
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
@ -1882,7 +1887,7 @@ int TSystemisamfile::load(
|
||||
error_box("Impossibile aprire il file %s",from);
|
||||
return err = 2;
|
||||
}
|
||||
TRecnotype r = 0, e = 0, nitems = 0, nread = 0;
|
||||
TRecnotype r = 0, e = 0, nitems = 0;
|
||||
TString16 firm, year, attprev("00000");
|
||||
|
||||
if (extended)
|
||||
@ -1897,32 +1902,16 @@ int TSystemisamfile::load(
|
||||
if (ditte.read() == NOERR)
|
||||
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);
|
||||
nitems = ftell(fl) - nitems;
|
||||
nitems = ftell(fl);
|
||||
fclose(fl);
|
||||
|
||||
TFilename filename;
|
||||
TIsam_handle isam_handle = prefix().open_isamfile(_logicnum, filename);
|
||||
int fhnd = handle(isam_handle);
|
||||
if (fhnd < 0)
|
||||
err = _open_ex();
|
||||
if (err != NOERR)
|
||||
{
|
||||
error_box("Impossibile aprire il file %s", (const char*)filename);
|
||||
return _isnotopen;
|
||||
error_box("Impossibile aprire il file %d", _logicnum);
|
||||
return err;
|
||||
}
|
||||
|
||||
TScanner f(from);
|
||||
@ -1997,7 +1986,7 @@ int TSystemisamfile::load(
|
||||
if (fd) sfd << fd;
|
||||
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);
|
||||
for (s = f.line(); s.not_empty() && !p.iscancelled(); s = f.line())
|
||||
{
|
||||
@ -2014,11 +2003,10 @@ int TSystemisamfile::load(
|
||||
}
|
||||
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.setstatus(nread + 1);
|
||||
nread += s.len() + 1;
|
||||
p.setstatus(f.tellg());
|
||||
zero();
|
||||
if (fixedlen)
|
||||
{
|
||||
@ -2060,10 +2048,10 @@ int TSystemisamfile::load(
|
||||
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);
|
||||
|
||||
prefix().close_isamfile(isam_handle);
|
||||
close();
|
||||
|
||||
setstatus(err);
|
||||
return err;
|
||||
@ -2808,7 +2796,8 @@ TRectype& TRectype::operator =(const TBaseisamfile& f)
|
||||
// Certified 50%
|
||||
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)
|
||||
|
@ -2542,10 +2542,15 @@ KEY TFile_select::run()
|
||||
|
||||
if (good)
|
||||
{
|
||||
TString str = fs.name;
|
||||
good = _filter.not_empty() && str.match(_filter);
|
||||
const TFixed_string str(fs.name);
|
||||
good = _filter.empty() || str.match(_filter);
|
||||
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
|
||||
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_NORMAL Se non e' vuoto deve esistere
|
||||
// CHECK_REQUIRED Deve esistere
|
||||
// CHECK_SEARCH Puo' essere vuoto altrimenti deve matchare il filtro
|
||||
// CHECK_REQUIRED Non puo' essere vuoto e deve esistere
|
||||
// CHECK_SEARCH Puo' essere vuoto e puo' non matchare il filtro
|
||||
|
||||
bool TFile_select::check(CheckTime)
|
||||
{
|
||||
@ -3099,9 +3104,7 @@ bool TEdit_field::on_key(KEY key)
|
||||
// check consistency
|
||||
if (ok && _browse)
|
||||
{
|
||||
if (sheet())
|
||||
ok = sheet()->check(FINAL_CHECK);
|
||||
else
|
||||
if (browse())
|
||||
{
|
||||
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->check(FINAL_CHECK);
|
||||
|
||||
}
|
||||
if (!ok) return default_error_box();
|
||||
}
|
||||
|
@ -904,6 +904,11 @@ public:
|
||||
// @cmember Ritorna il valore di <p _insert>
|
||||
const TString& get_insert() const
|
||||
{ return _insert;}
|
||||
|
||||
// @cmember Setta il valore di <p _filter>
|
||||
void set_filter(const char* f)
|
||||
{ _filter = f;}
|
||||
|
||||
// @cmember Ritorna il valore di <p _filter>
|
||||
const TString& get_filter() const
|
||||
{ return _filter;}
|
||||
|
@ -2648,7 +2648,7 @@ void TSheet_field::mask2row(int n, TToken_string & rec)
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
@ -2671,22 +2671,26 @@ void TSheet_field::row2mask(int n, TToken_string & r)
|
||||
f.enable(on);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < campi; i++)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
const short id = f.dlg();
|
||||
|
||||
if (id >= FIRST_FIELD &&
|
||||
!f.is_kind_of(CLASS_BUTTON_FIELD) &&
|
||||
(f.active() || f.ghost()))
|
||||
if (mode > 0)
|
||||
{
|
||||
for (i = 0; i < campi; i++)
|
||||
{
|
||||
if (f.has_check())
|
||||
f.check(STARTING_CHECK);
|
||||
f.set_dirty(FALSE);
|
||||
f.on_hit();
|
||||
TMask_field& f = m.fld(i);
|
||||
const short id = f.dlg();
|
||||
|
||||
if (id >= FIRST_FIELD &&
|
||||
!f.is_kind_of(CLASS_BUTTON_FIELD) &&
|
||||
(f.active() || f.ghost()))
|
||||
{
|
||||
if (f.has_check() && (mode & 0x1))
|
||||
f.check(STARTING_CHECK);
|
||||
f.set_dirty(FALSE);
|
||||
if (mode & 0x2)
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < campi; i++)
|
||||
{
|
||||
@ -2718,7 +2722,7 @@ void TSheet_field::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;
|
||||
const int current = s->_cur_rec;
|
||||
@ -2739,7 +2743,7 @@ void TSheet_field::check_row(int n)
|
||||
if (f.has_check())
|
||||
f.set_dirty();
|
||||
}
|
||||
row2mask(n, r);
|
||||
row2mask(n, r, mode);
|
||||
mask2row(n, r);
|
||||
m.set_mode(mask_mode);
|
||||
s->_cur_rec = current;
|
||||
@ -2796,10 +2800,14 @@ bool TSheet_field::autoload_line(int i,TRectype & rec)
|
||||
TMask_field& mf = sheet_mask().fld(j);
|
||||
const short id = mf.dlg();
|
||||
TFieldref const *dbfield=mf.field();
|
||||
if (dbfield) {
|
||||
if (id>=FIRST_FIELD && id<=_last_column_id) {
|
||||
if (dbfield)
|
||||
{
|
||||
if (id>=FIRST_FIELD && id<=_last_column_id)
|
||||
{
|
||||
row.add(dbfield->read(rec),cid2index(id));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mf.set(dbfield->read(rec));
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ protected:
|
||||
// @cmember Ricopia i campi della maschera nel record <p n>-esimo
|
||||
virtual void mask2row(int n, TToken_string & rec);
|
||||
// @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
|
||||
void set_focus_cell(int riga, int colonna);
|
||||
@ -221,7 +221,7 @@ public:
|
||||
virtual void post_insert(int) { }
|
||||
|
||||
// @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>
|
||||
void update_row(int n) { mask2row(n, row(n)); }
|
||||
|
@ -5,7 +5,7 @@ void TMultiple_rectype::set_body_key(TRectype & rowrec)
|
||||
const RecDes* recd = rowrec.rec_des(); // Descrizione del record della testata
|
||||
const KeyDes& kd = recd->Ky[0]; // Elenco dei campi della chiave 1
|
||||
|
||||
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
|
||||
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
|
||||
for (int i = kd.NkFields-2; i >= 0; i--)
|
||||
{
|
||||
const int nf = kd.FieldSeq[i] % MaxFields;
|
||||
@ -18,15 +18,16 @@ void TMultiple_rectype::set_body_key(TRectype & rowrec)
|
||||
void TMultiple_rectype::load_rows_file(int logicnum)
|
||||
{
|
||||
const int index = log2ind(logicnum);
|
||||
TRectype * rec = new_body_record(logicnum);
|
||||
set_body_key(*rec);
|
||||
if (_files.objptr(index) == NULL)
|
||||
TRecord_array* r = (TRecord_array*)_files.objptr(index);
|
||||
if (r == NULL)
|
||||
{
|
||||
// crea
|
||||
TRecord_array * r = new TRecord_array(logicnum, (TString &) _numfields[index]);
|
||||
_files.add( r, index);
|
||||
r = new TRecord_array(logicnum, (TString &) _numfields[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);
|
||||
}
|
||||
|
||||
@ -222,18 +223,22 @@ int TMultiple_rectype::read(TBaseisamfile & f, word op, word lockop)
|
||||
_nuovo = FALSE;
|
||||
if (op == _isequal)
|
||||
{
|
||||
TRectype r(*this);
|
||||
const TRectype oldr(*this);
|
||||
|
||||
err = TRectype::read(f, op, lockop);
|
||||
if (err != NOERR)
|
||||
{
|
||||
*this = r;
|
||||
*this = oldr;
|
||||
_nuovo = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = TRectype::read(f, op, lockop);
|
||||
}
|
||||
|
||||
synchronize_bodies();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user