Patch level : 10.0 270

Files correlati     :  ca2.exe ca2500a.msk
Ricompilazione Demo : [ ]
Commento            :

Aggiunto programma di invio a Board.
Ripristinate funzioni di visualizzazione e salvataggio ripartizione temporale delle righe nella modifica movimenti analitici

git-svn-id: svn://10.65.10.50/branches/R_10_00@23201 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
bonazzi 2016-06-24 16:36:18 +00:00
parent 7078caba13
commit 8a7486d866
3 changed files with 42 additions and 23 deletions

View File

@ -192,7 +192,7 @@ static int query_get_items(void* jolly, int argc, char** values, char** columns)
TRecnotype TODBC_recordset::items() const
{
if (_items == 0)
if (!_loaded && _items == 0)
{
TString sql; parsed_text(sql);
XVT_ODBC oc = connection();
@ -246,7 +246,7 @@ int TODBC_recordset::on_get_rows(int argc, char** values, char** columns)
if (!_columns_loaded)
on_get_columns(argc, values, columns);
if (_page.items() >= _pagesize)
if (!_freezed && _page.items() >= _pagesize)
return -1;
if (_cursor_pos++ < _first_row)
@ -291,7 +291,17 @@ static int query_get_rows(void* jolly, int argc, char** values, char** columns)
bool TODBC_recordset::move_to(TRecnotype n)
{
const TRecnotype tot = items();
_current_row = n;
if (_freezed && _loaded)
{
if (n < 0)
_current_row = 0L;
if (n >= tot)
_current_row = tot - 1L;
return true;
}
if (n < 0 || n >= tot)
{
_page.destroy(); // Forza rilettura la prossima volta
@ -299,7 +309,7 @@ bool TODBC_recordset::move_to(TRecnotype n)
return false;
}
if (n < _first_row || n >= _first_row+_page.items())
if ((n < _first_row || n >= _first_row+_page.items()) || _freezed && !_loaded)
{
TString sql; parsed_text(sql);
XVT_ODBC oc = connection();
@ -313,17 +323,21 @@ bool TODBC_recordset::move_to(TRecnotype n)
sql.cut(semicolon);
sql.trim();
_page.destroy();
if (n >= _pagesize)
_first_row = n-32; // Prendo qualche riga dalla pagina precedente, per velocizzare il pagina su
else
_first_row = n;
if (_freezed)
_first_row = 0;
else
if (n >= _pagesize)
_first_row = n-32; // Prendo qualche riga dalla pagina precedente, per velocizzare il pagina su
else
_first_row = n;
}
TPerformance_profiler prof("ODBC query");
_cursor_pos = 0;
xvt_odbc_execute(oc, sql, query_get_rows, this);
if (!_columns_loaded)
_loaded = _freezed;
if (!_columns_loaded)
_columns_loaded = true; // Brutto posto ma necessario
}
@ -536,13 +550,11 @@ int TODBC_recordset::create_rec(const TISAM_recordset& dbfset)
}
}
query << ");";
// END;";
TRecnotype row = current_row();
const int err = exec(query);
TODBC_recordset upd("");
int err = 0;
move_to(row);
// while (compare_key(dbfset) != 0 && move_next());
if (upd.connect(dsn()))
err = upd.exec(query);
return err;
}
@ -610,11 +622,10 @@ void TODBC_recordset::update_rec(const TISAM_recordset& dbfset)
else
query << curr.get(fname);
}
TRecnotype row = current_row();
const int err = exec(query);
TODBC_recordset upd("");
move_to(row);
// while (compare_key(dbfset) != 0 && move_next());
if (upd.connect(dsn()))
upd.exec(query);
}
void TODBC_recordset::remove_rec(const TISAM_recordset& dbfset)
@ -659,19 +670,23 @@ void TODBC_recordset::remove_rec(const TISAM_recordset& dbfset)
}
}
query << ';';
exec(query);
TODBC_recordset upd("");
if (upd.connect(dsn()))
upd.exec(query);
}
void TODBC_recordset::set(const char* sql)
{
reset();
if (!_freezed || !_loaded || _sql != sql)
reset();
_sql = sql;
if (_sql.find("SELECT") >= 0 || _sql.find("select") >= 0)
find_and_reset_vars();
}
TODBC_recordset::TODBC_recordset(const char* sql)
TODBC_recordset::TODBC_recordset(const char* sql, const bool freezed) : _freezed(freezed), _loaded(false)
{
set(sql);
}

View File

@ -21,6 +21,8 @@ class TODBC_recordset : public TRecordset
TArray _column;
bool _columns_loaded;
bool _freezed;
bool _loaded;
protected:
@ -39,6 +41,7 @@ public:
virtual void requery();
virtual const TString& query_text() const;
virtual const TString& driver_version() const;
virtual void freeze(const bool on) { _freezed = on; }
virtual const TVariant& get(unsigned int c) const;
virtual const TVariant& get(const char* name) const;
@ -65,7 +68,7 @@ public:
const TString& dsn() const { return _dsn; }
TODBC_recordset(const char* sql);
TODBC_recordset(const char* sql, const bool freezed = false);
virtual ~TODBC_recordset();
};

View File

@ -87,7 +87,8 @@ public: // Absolutely needed methods
virtual char text_separator() const { return _text_separator;}
virtual void set_text_separator(char sep) { _text_separator = sep;}
virtual bool move_first() { return move_to(0); }
virtual void freeze() {}
virtual bool move_first() { return move_to(0); }
virtual bool move_prev() { return move_to(current_row()-1); }
virtual bool move_next() { return move_to(current_row()+1); }
virtual bool move_last() { return move_to(items()-1); }