From 55f8095eaae0abd9ab3b3d8404c49afb851b4708 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 24 Oct 2005 15:16:13 +0000 Subject: [PATCH] Patch level : 2.2 Files correlati : query e report Ricompilazione Demo : [ ] Commento : Aggiunto supporto ODBC alle query ed ai report Aggiunta scelta tramite calendario ai campi data git-svn-id: svn://10.65.10.50/trunk@13446 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/maskfld.cpp | 17 +++++++++++++++++ include/recset.cpp | 8 +++++--- include/recset.h | 5 +++-- include/report.cpp | 29 ++++++----------------------- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 2eef284aa..9d74bf328 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -4021,6 +4021,23 @@ bool TDate_field::on_key(KEY key) } else { + if (key == K_F9 && browse() == NULL) + { + RCT rct; get_rect(rct); + const PNT pos = { rct.top, rct.right }; + + TDate olddate; + const TString& data = get_window_data(); + if (TDate::isdate(data)) + olddate = TDate(data); + + long ansidate = olddate.date2ansi(); + ansidate = xvt_dm_post_choose_date(parent(), pos, ansidate); + const TDate newdate(ansidate); + if (newdate != olddate) + set(newdate.string()); + return true; + } if (_ctl->is_edit_key(key)) { const bool ok = strchr("-0123456789ADEGILMNOPRSTUadegilmnoprstu", key) != NULL; diff --git a/include/recset.cpp b/include/recset.cpp index f5dacdcc2..7e8cc2622 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -1281,6 +1281,8 @@ TSQLite::~TSQLite() void TSQL_recordset::reset() { _items = 0; + _first_row = 0; + _current_row = -1; _pagesize = 512; _page.destroy(); _column.destroy(); @@ -1374,7 +1376,7 @@ const TRecordset_column_info& TSQL_recordset::column_info(unsigned int c) const } // Funzione chiamata per riempire la pagina corrente delle righe della query -int TSQL_recordset::on_get_rows(int argc, char** values, char** columns) +int TSQL_recordset::on_get_rows(int argc, char** values) { TArray* a = new TArray; for (int c = 0; c < argc; c++) @@ -1406,10 +1408,10 @@ int TSQL_recordset::on_get_rows(int argc, char** values, char** columns) return SQLITE_OK; } -static int query_get_rows(void* jolly, int argc, char** values, char** columns) +static int query_get_rows(void* jolly, int argc, char** values, char** /*columns*/) { TSQL_recordset* rs = (TSQL_recordset*)jolly; - return rs->on_get_rows(argc, values, columns); + return rs->on_get_rows(argc, values); } bool TSQL_recordset::move_to(TRecnotype n) diff --git a/include/recset.h b/include/recset.h index 0d4bf7865..15dba50ab 100755 --- a/include/recset.h +++ b/include/recset.h @@ -48,6 +48,7 @@ public: // Absolutely needed methods virtual TRecnotype current_row() const pure; virtual void requery() pure; bool empty() const { return items() == 0; } + virtual const TString& query_text() const pure; virtual bool move_first() { return move_to(0); } virtual bool move_prev() { return move_to(current_row()-1); } @@ -65,7 +66,6 @@ public: // Absolutely needed methods virtual bool set_var(const char* name, const TVariant& var, bool create = false); virtual bool ask_variables(bool all); - virtual const TString& query_text() const; virtual int find_column(const char* column_name) const; virtual const TVariant& get(const char* column_name) const; virtual const TToken_string& sheet_head() const; @@ -107,7 +107,7 @@ public: // Internal use only virtual int on_get_items(int argc, char** values, char** columns); - virtual int on_get_rows(int argc, char** values, char** columns); + virtual int on_get_rows(int argc, char** values); const TArray* row(TRecnotype n); TSQL_recordset(const char* sql); @@ -174,6 +174,7 @@ bool list_custom_files(const char* ext, const char* library, TString_array& file bool select_custom_file(TFilename& path, const char* ext, const char* library = NULL); const TString& logic2table(int logic_num); int table2logic(const TString& name); +TRecordset* create_recordset(const TString& sql); #endif diff --git a/include/report.cpp b/include/report.cpp index 1a4211c30..da17b36fd 100755 --- a/include/report.cpp +++ b/include/report.cpp @@ -815,17 +815,9 @@ bool TReport_section::set_recordset(TRecordset* rs) bool TReport_section::set_recordset(const TString& sql) { - bool ok = !sql.blank(); - if (ok) - { - if (sql.compare("SELECT ", 7, true) == 0) - ok = set_recordset(new TSQL_recordset(sql)); - else - ok = set_recordset(new TISAM_recordset(sql)); - } - else - set_recordset(NULL); - return ok; + TRecordset* rex = create_recordset(sql); + set_recordset(rex); + return rex != NULL; } bool TReport_section::get_record_field(const char* name, TVariant& var) const @@ -1917,20 +1909,11 @@ bool TReport::set_recordset(TRecordset* rs) return _recordset != NULL; } - bool TReport::set_recordset(const TString& sql) { - bool ok = !sql.blank(); - if (ok) - { - if (sql.compare("SELECT ", 7, true) == 0) - ok = set_recordset(new TSQL_recordset(sql)); - else - ok = set_recordset(new TISAM_recordset(sql)); - } - else - set_recordset(NULL); - return ok; + TRecordset* rex = create_recordset(sql); + set_recordset(rex); + return rex != NULL; } TReport_section& TReport::section(char type, int level)