Patch level :4.0 648
Files correlati : Ricompilazione Demo : [ ] Commento :modifiche per far funzionare cg3900 git-svn-id: svn://10.65.10.50/trunk@14990 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b993886271
commit
a76e3743ac
@ -2114,7 +2114,7 @@ long TRecordset_sheet::get_items() const
|
||||
return _query.items();
|
||||
}
|
||||
|
||||
TRecordset_sheet::TRecordset_sheet(TRecordset& query)
|
||||
: TSheet(-1, -1, -2, -4, "Query", query.sheet_head()), _query(query)
|
||||
TRecordset_sheet::TRecordset_sheet(TRecordset& query, const char* title, byte buttons)
|
||||
: TSheet(-1, -1, -2, -4, title, query.sheet_head(), buttons), _query(query)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ protected:
|
||||
virtual long get_items() const;
|
||||
|
||||
public:
|
||||
TRecordset_sheet(TRecordset& sql);
|
||||
TRecordset_sheet(TRecordset& sql, const char* title = "Query", byte buttons = 0);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
void reset();
|
||||
bool log(int severity, const char* msg); // severity: 0=normal; 1=warning; 2=error
|
||||
void set_title(const char* title);
|
||||
const TString& title() const { return _title; }
|
||||
TLog_report(const char* title, const char* name = "bagn010a");
|
||||
};
|
||||
|
||||
|
@ -193,6 +193,14 @@ bool TText_recordset::save_as(const char* path, TRecordsetExportFormat fmt)
|
||||
return TRecordset::save_as(path, fmt);
|
||||
}
|
||||
|
||||
void TText_recordset::sort(COMPARE_FUNCTION f)
|
||||
{
|
||||
if (f == NULL)
|
||||
_rec.sort(true); // Ordina alfabeticamante
|
||||
else
|
||||
_rec.TArray::sort(f); // Usa la funzione definita dall'utente
|
||||
}
|
||||
|
||||
TText_recordset::TText_recordset(const char* query) : _query(query), _curr(-1)
|
||||
{
|
||||
_info._name = "A";
|
||||
@ -393,6 +401,13 @@ bool TAS400_recordset::set_field(const TAS400_column_info& fi, const TVariant& v
|
||||
r.overwrite(str, fi._pos);
|
||||
}
|
||||
break;
|
||||
case _datefld:
|
||||
if (fi._width == 8)
|
||||
{
|
||||
TString8 str; str << var.as_date().date2ansi();
|
||||
r.overwrite(str, fi._pos, fi._width);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
r.overwrite(var.as_string(), fi._pos, fi._width);
|
||||
break;
|
||||
@ -432,6 +447,11 @@ TAS400_column_info* TAS400_recordset::parse_field(const char* column, int& c, bo
|
||||
{
|
||||
ci = new TAS400_column_info;
|
||||
ci->_name = fld;
|
||||
if (info->items() > 0)
|
||||
{
|
||||
const TAS400_column_info& last = *(const TAS400_column_info*)info->objptr(info->last());
|
||||
ci->_pos = last._pos+last._width;
|
||||
}
|
||||
c = info->add(ci);
|
||||
}
|
||||
else
|
||||
@ -450,6 +470,27 @@ TAS400_column_info* TAS400_recordset::parse_field(const char* column, int& c, bo
|
||||
return ci;
|
||||
}
|
||||
|
||||
unsigned int TAS400_recordset::columns() const
|
||||
{
|
||||
const TArray* info = (const TArray*)_trc.objptr(rec_type());
|
||||
if (info)
|
||||
return info->items();
|
||||
return TText_recordset::columns();
|
||||
}
|
||||
|
||||
const TRecordset_column_info& TAS400_recordset::column_info(unsigned int c) const
|
||||
{
|
||||
const TArray* info = (const TArray*)_trc.objptr(rec_type());
|
||||
if (info)
|
||||
{
|
||||
TRecordset_column_info* i = (TRecordset_column_info*)info->objptr(c);
|
||||
if (i != NULL)
|
||||
return *i;
|
||||
}
|
||||
return TText_recordset::column_info(c);
|
||||
}
|
||||
|
||||
|
||||
int TAS400_recordset::find_column(const char* column) const
|
||||
{
|
||||
int c = -1;
|
||||
@ -462,28 +503,45 @@ const TRecordset_column_info& TAS400_recordset::column_info(const char* column)
|
||||
int c = -1;
|
||||
TRecordset_column_info* ci = ((TAS400_recordset*)this)->parse_field(column, c, false);
|
||||
if (ci != NULL)
|
||||
{
|
||||
return *ci;
|
||||
}
|
||||
return TText_recordset::column_info(column);
|
||||
}
|
||||
|
||||
const TVariant& TAS400_recordset::get_field(const TAS400_column_info& ci) const
|
||||
{
|
||||
const TRecnotype n = current_row();
|
||||
if (n >= 0 && n < items())
|
||||
{
|
||||
const TString& str = row(n).mid(ci._pos, ci._width);
|
||||
TVariant& var = get_tmp_var();
|
||||
var.set(str); var.convert_to(ci._type);
|
||||
return var;
|
||||
}
|
||||
return ci._default;
|
||||
}
|
||||
|
||||
const TVariant& TAS400_recordset::get(unsigned int column) const
|
||||
{
|
||||
const TArray* info = (const TArray*)_trc.objptr(rec_type());
|
||||
if (info)
|
||||
{
|
||||
const TAS400_column_info* ci = (const TAS400_column_info*)info->objptr(column);
|
||||
if (ci != NULL)
|
||||
return get_field(*ci);
|
||||
}
|
||||
return TText_recordset::get(column);
|
||||
}
|
||||
|
||||
const TVariant& TAS400_recordset::get(const char* column) const
|
||||
{
|
||||
int c = -1;
|
||||
if (column && column[1] != '\0')
|
||||
{
|
||||
TAS400_column_info* ci = ((TAS400_recordset*)this)->parse_field(column, c, false);
|
||||
const TAS400_column_info* ci = ((TAS400_recordset*)this)->parse_field(column, c, false);
|
||||
if (ci != NULL)
|
||||
{
|
||||
const TRecnotype n = current_row();
|
||||
if (n >= 0 && n < items())
|
||||
{
|
||||
const TString& str = row(n).mid(ci->_pos, ci->_width);
|
||||
TVariant& var = get_tmp_var();
|
||||
var.set(str);
|
||||
return var;
|
||||
}
|
||||
return ci->_default;
|
||||
}
|
||||
return get_field(*ci);
|
||||
}
|
||||
c = TText_recordset::find_column(column);
|
||||
return TText_recordset::get(c);
|
||||
@ -519,27 +577,33 @@ TRecnotype TAS400_recordset::new_rec(const char* trc)
|
||||
|
||||
const TString& TAS400_recordset::rec_type(TRecnotype r) const
|
||||
{
|
||||
const TToken_string& riga = row(r);
|
||||
return riga.mid(key_position(), key_length());
|
||||
if (key_length() > 0)
|
||||
{
|
||||
const TToken_string& riga = row(r);
|
||||
return riga.mid(key_position(), key_length());
|
||||
}
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
bool TAS400_recordset::create_field(const char* nam, int pos, int len,
|
||||
TFieldtypes typ, bool req, const TVariant& def)
|
||||
{
|
||||
CHECK(nam && *nam, "Null field name");
|
||||
CHECKD(pos >= 0 && pos < record_length(), "Invalid field position ", pos);
|
||||
CHECKD(len > 0 && pos+len <= record_length(), "Invalid field lenght ", len);
|
||||
CHECK(nam && *nam > ' ', "Null field name");
|
||||
|
||||
int c = -1;
|
||||
TAS400_column_info* ci = parse_field(nam, c, true);
|
||||
const bool ok = ci != NULL;
|
||||
if (ok)
|
||||
{
|
||||
ci->_pos = pos;
|
||||
if (pos >= 0) // Se l'utente fissa una posizione impostala, altrimenti tieni quella automatica
|
||||
ci->_pos = pos;
|
||||
ci->_width = len;
|
||||
ci->_type = typ;
|
||||
ci->_required = req;
|
||||
ci->_default = def;
|
||||
|
||||
CHECKS(ci->_pos >= 0 && ci->_pos < record_length(), "Invalid position for field ", nam);
|
||||
CHECKS(ci->_width > 0 && ci->_pos+ci->_width <= record_length(), "Invalid lenght for field ", nam);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
@ -38,8 +38,11 @@ public:
|
||||
virtual void requery();
|
||||
virtual const TVariant& get(unsigned int column) const;
|
||||
|
||||
TRecnotype last() const { return items() - 1;}
|
||||
|
||||
public:
|
||||
virtual const TString& query_text() const { return _query; }
|
||||
virtual void sort(COMPARE_FUNCTION f = NULL);
|
||||
|
||||
virtual bool destroy(TRecnotype r = -1);
|
||||
virtual TRecnotype new_rec(const char* buf = NULL);
|
||||
@ -106,13 +109,17 @@ protected:
|
||||
|
||||
TAS400_column_info* parse_field(const char* column, int& c, bool create);
|
||||
bool set_field(const TAS400_column_info& fi, const TVariant& var);
|
||||
const TVariant& get_field(const TAS400_column_info& fi) const;
|
||||
|
||||
|
||||
public:
|
||||
virtual TRecnotype new_rec(const char* buf = NULL);
|
||||
virtual bool set(const char* column, const TVariant& var);
|
||||
|
||||
virtual unsigned int columns() const;
|
||||
virtual const TRecordset_column_info& column_info(unsigned int column) const;
|
||||
virtual const TRecordset_column_info& column_info(const char* colunmn) const;
|
||||
virtual const TVariant& get(unsigned int column) const;
|
||||
virtual const TVariant& get(const char* colunmn) const;
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user