Ejemplo n.º 1
0
void AdsEditor::novoAnuncio() {
  AdsApplication *app = AdsApplication::adsApplication();
  cppdb::session &db = app->db_;
    
  Wt::WDialog dialog("novo Anuncio");
  Wt::WPushButton *ok = new WPushButton("Ok");
  ok->setStyleClass("btn btn-primary");
  ok->clicked().connect(&dialog, &Wt::WDialog::accept);
  Wt::WPushButton *cancel = new WPushButton("Cancela");
  cancel->setStyleClass("btn");
  cancel->clicked().connect(&dialog, &Wt::WDialog::reject);

  WLineEdit *lTitulo = new WLineEdit();
  WLineEdit *lURL = new WLineEdit();
  WLineEdit *lTexto = new WLineEdit();

  WTemplate *t = new WTemplate(dialog.contents());
  t->setTemplateText("<form>"
		     " <fieldset>"
		     "  <legend>Dados do anuncio</legend>"
		     "  <table border=0>"
		     "   <tr><td>Titulo</td> <td>${titulo}</td></tr>"
		     "   <tr><td>URL</td>    <td>${url}</td></tr>"
		     "   <tr><td>Texto</td>  <td>${texto}</td></tr>"
		     "  </table>"
		     "  </fieldset>"
		     "  ${ok}${cancel}"			       
		     "</form>"
		     , XHTMLUnsafeText);
  t->bindWidget("titulo", lTitulo);
  t->bindWidget("url", lURL);
  t->bindWidget("texto", lTexto);
  t->bindWidget("ok", ok);
  t->bindWidget("cancel", cancel);
  if (dialog.exec() == Wt::WDialog::Accepted) {
    db << "insert into anuncio (id, titulo, url, texto, imagem) values "
      "(NULL, ?,?,?, '/img/cabure.png')" 
       << lTitulo->text().narrow() << lURL->text().narrow()
       << lTexto->text().narrow() << cppdb::exec;
  }
  renderUI();
}
Ejemplo n.º 2
0
AlunoList::AlunoList(Wt::Dbo::Session& dbSession, Wt::Dbo::ptr<SiconfModel::Disciplina> disciplina):
	_dbSession(dbSession), _disciplina(disciplina){

	_table = new Wt::WTable(this);

	setTable();

	Wt::WPushButton* close = new Wt::WPushButton("Voltar", this);
	close->setStyleClass("btn btn-primary");
	close->clicked().connect(std::bind([this](){
		delete this;
	}));
}
Ejemplo n.º 3
0
void ChamadaForm::_initialize(){
	Wt::Dbo::Transaction transaction(_dbSession);

	Wt::WText* title = new Wt::WText("<h3>Diario de Classe: " + Wt::WDate::currentDate().toString("dd/MM/yyyy").toUTF8() + "</h3> <br></br><br></br>");

		addWidget(title);
		Wt::WPushButton* fazerChamada = new Wt::WPushButton("Percorrer turma", this);

		fazerChamada->setStyleClass("btn btn-primary");

		fazerChamada->clicked().connect(std::bind([=](){
			new AutoChamada(_dbSession, sortList);
		}));

		fazerChamada->setMargin(20, Wt::Bottom);
		_list =  new Wt::WTable(this);


		Wt::WPushButton* save = new Wt::WPushButton("Salvar", this);
		save->setStyleClass("btn btn-success");
		save->setMargin(10, Wt::Right);
		save->clicked().connect(std::bind([=](){
			_save();
			delete this;
		}));

		Wt::WPushButton* cancel = new Wt::WPushButton("Cancelar", this);
		cancel->setStyleClass("btn btn-primary");
		cancel->clicked().connect(std::bind([=](){
			delete this;
		}));

	_list->setWidth(Wt::WLength("100%"));
	_list->addStyleClass("table-striped table-hover");
	_list->setMargin(50, Wt::Bottom);
	new Wt::WText("Aluno", _list->elementAt(0,0));
	new Wt::WText("Presente", _list->elementAt(0,1));
	_list->setHeaderCount(1);


	for(auto i : _disciplina->turma()->alunos()){
		Wt::WCheckBox* checkbox = new Wt::WCheckBox();
		sortList.push_back(std::make_pair(checkbox, i));
	}

	auto sortAlg = [](std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>> par1, std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>>par2){
		return par1.second->usuario()->nome() < par2.second->usuario()->nome();
	};

	std::sort(std::begin(sortList), std::end(sortList), sortAlg);

	for(auto i : sortList){
		int row = _list->rowCount();
		Wt::WText* name = new Wt::WText(i.second->usuario()->nome() + " " + i.second->usuario()->sobrenome(), _list->elementAt(row, 0));
		name->setMargin(10, Wt::Right);
		_list->elementAt(row, 1)->addWidget(i.first);
		_list->elementAt(row, 1)->setHeight(40);
		_list->elementAt(row, 1)->setWidth(100);

	}
}