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

View File

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

View File

@ -87,7 +87,8 @@ public: // Absolutely needed methods
virtual char text_separator() const { return _text_separator;} virtual char text_separator() const { return _text_separator;}
virtual void set_text_separator(char sep) { _text_separator = sep;} 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_prev() { return move_to(current_row()-1); }
virtual bool move_next() { 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); } virtual bool move_last() { return move_to(items()-1); }