3 #include <Wtx/Dbo/QueryModel.h> 4 #include <Wtx/Core/Core.h> 7 #include "ItemDelegate.h" 11 Wtx::Sys::Lookup::Item::MapClass( session );
36 auto item = ifind( key, session );
44 Wt::Dbo::Transaction t(session);
57 auto v = item-> cfyField().value();
58 if( v.find(group) == std::string::npos )
63 Wt::Dbo::Transaction t(session);
64 item.modify()-> cfyField().setValue( v );
73 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::load(
int id,
Wtx::Dbo::Session & session )
75 return find(
id, session );
78 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::load(
const std::string &
id,
Wtx::Dbo::Session & session )
83 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::load(
const Wt::WString &
id,
Wtx::Dbo::Session & session )
85 return load(
id.toUTF8() , session );
88 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::find(
int id,
Wtx::Dbo::Session & session )
91 Wt::Dbo::Transaction t(session);
92 auto retVal = session.template load<Wtx::Sys::Lookup::Item>(id);
97 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::find(
const std::string & key,
Wtx::Dbo::Session & session )
99 Wtx::Sys::Lookup::Item::Ptr retVal;
101 if( key !=
"" && key !=
"[null]" )
103 if( key.at(0) ==
'[' )
105 auto v = Wtx::Core::split( key,
':' );
106 int idVal = std::stoi(v.at(1));
110 Wt::Dbo::Transaction t(session);
111 retVal = session.template load<Wtx::Sys::Lookup::Item>(idVal);
120 Wt::Dbo::Transaction t(session);
123 .where(
"\"keyField\" = ?")
136 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::ifind(
const std::string & key,
Wtx::Dbo::Session & session )
138 Wtx::Sys::Lookup::Item::Ptr retVal;
144 Wt::Dbo::Transaction t(session);
147 .where(
"UPPER(\"keyField\") = UPPER(?)")
158 Wtx::Sys::Lookup::Item::Ptr Wtx::Sys::Lookup::xfind(
const std::string & xid,
Wtx::Dbo::Session & session )
160 Wtx::Sys::Lookup::Item::Ptr retVal;
164 Wt::Dbo::Transaction t(session);
167 .where(
"UPPER(\"xid\") = UPPER(?)")
178 Wtx::Sys::Lookup::Item::Vector Wtx::Sys::Lookup::vectorGroup(
const std::string & group,
Wtx::Dbo::Session & session )
180 Wt::Dbo::Transaction t(session);
185 Wt::WString(
"\"cfyField\" LIKE '%{1}%'")
189 .orderBy(
"id desc" )
193 Wtx::Sys::Lookup::Item::Vector retVal( items.begin(), items.end() );
215 auto retVal = std::make_shared< Wtx::Dbo::QueryModel< Wtx::Sys::Lookup::Item::Ptr > >();
217 Wt::Dbo::Transaction t(session);
223 typedef std::tuple< int, std::string > Tuple;
225 auto retVal = std::make_shared< Wtx::Dbo::QueryModel< Tuple > >();
228 Wt::WString::tr(
"Wtx.sysLookup.combobox.sql" )
233 session.query< Tuple >( sql )
236 retVal-> setQuery( query );
238 retVal-> addAllFieldsAsColumns();
247 .where(
"\"isActive\" is true AND (UPPER(\"cfyField\") LIKE UPPER(?) OR \"cfyField\" LIKE '%%*%%')")
248 .bind( Wt::WString(
"%%{1}%%").arg(group) )
249 .orderBy(
"\"keyField\"")
252 retVal-> setQuery( query );
253 retVal-> addColumn(
"id");
254 retVal-> addColumn(
"keyField");
267 retVal-> setQuery( query );
268 retVal-> addColumn(
"id");
269 retVal-> addColumn(
"keyField");
279 auto retVal = Wtx::Sys::Lookup::ItemDelegate::create(s);
static void PostCreateTable(Wt::Dbo::Session &session)
Post Table Create.
double stof(const std::string &value)
Convert a String to Float.
std::shared_ptr< Wt::WAbstractItemModel > getComboBoxModel(int tid, const std::string &group, Wtx::Dbo::Session &session, bool includeBlank=false)
Get a Combo-Box Model.
Wtx::Sys::Lookup::Item::Ptr add(const std::string &key, const std::string &group, Wtx::Dbo::Session &session)
Add an item to the lookup table.