|
WContainerWidget * w2 = new WContainerWidget;
|
|
WWidget * Usun::UsunPolonczenie()
|
|
{
|
|
|
|
WTable * tabela = new WTable(w2);
|
|
w2->setStyleClass("dol2");
|
|
Session session ;
|
|
Sqlite3 sqlite3("bazadanych.db");
|
|
session.setConnection(sqlite3);
|
|
session.mapClass<Polonczenie>("polonczenie");
|
|
Transaction transaction(session);
|
|
typedef collection< ptr<Polonczenie> > Polonczenia;
|
|
Polonczenia polonczenie = session.find<Polonczenie>();
|
|
int j=0;
|
|
tabela->elementAt(j,0)->addWidget(new WText("Z miasta :",w2));
|
|
tabela->elementAt(j,1)->addWidget(new WText("Do miasta :",w2));
|
|
tabela->elementAt(j,2)->addWidget(new WText("Dzien:",w2));
|
|
tabela->elementAt(j,3)->addWidget(new WText("Miesiac:",w2));
|
|
tabela->elementAt(j,4)->addWidget(new WText("Rok:",w2));
|
|
tabela->elementAt(j,5)->addWidget(new WText("Godzina:",w2));
|
|
tabela->elementAt(j,6)->addWidget(new WText("Minuta:",w2));
|
|
tabela->elementAt(j,7)->addWidget(new WText("Niepelnosprawni:",w2));
|
|
tabela->elementAt(j,8)->addWidget(new WText("Rowery:",w2));
|
|
for (Polonczenia::const_iterator i = polonczenie.begin(); i != polonczenie.end(); ++i)
|
|
{
|
|
j++;
|
|
tabela->elementAt(j,0)->addWidget(new WText( (*i)->z,w2));
|
|
tabela->elementAt(j,1)->addWidget(new WText((*i)->d,w2));
|
|
tabela->elementAt(j,2)->addWidget(new WText(boost::lexical_cast<string>((*i)->dzien),w2));
|
|
tabela->elementAt(j,3)->addWidget(new WText(boost::lexical_cast<string>((*i)->miesiac),w2));
|
|
tabela->elementAt(j,4)->addWidget(new WText(boost::lexical_cast<string>((*i)->rok),w2));
|
|
tabela->elementAt(j,5)->addWidget(new WText(boost::lexical_cast<string>((*i)->godzina),w2));
|
|
tabela->elementAt(j,6)->addWidget(new WText(boost::lexical_cast<string>((*i)->minuta),w2));
|
|
tabela->elementAt(j,7)->addWidget(new WText((*i)->niepelnosprawni,w2));
|
|
tabela->elementAt(j,8)->addWidget(new WText((*i)->rowery,w2));
|
|
int k = (*i)->id1;
|
|
WPushButton *b = new WPushButton("Usun", w2);
|
|
tabela->elementAt(j,9)->addWidget(b);
|
|
b->clicked().connect(boost::bind(&Usun::buttonClicked, this, k));
|
|
}
|
|
transaction.commit();
|
|
|
|
|
|
return w2;
|
|
|
|
}
|
|
|
|
void Usun::buttonClicked(int k)
|
|
{
|
|
|
|
Session session ;
|
|
Sqlite3 sqlite3("bazadanych.db");
|
|
session.setConnection(sqlite3);
|
|
session.mapClass<Polonczenie>("polonczenie");
|
|
Transaction transaction(session);
|
|
ptr<Polonczenie> rekord = session.find<Polonczenie>().where("id1 = ?").bind(boost::lexical_cast<std::string>(k));
|
|
rekord.remove();
|
|
transaction.commit();
|
|
new WText(boost::lexical_cast<std::string>(k),w2);
|
|
}
|