mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-08 02:54:56 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
56
examples/SQLApp/book.cpp
Normal file
56
examples/SQLApp/book.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "SQLApp.h"
|
||||
|
||||
struct BookDlg : public WithBookLayout<TopWindow> {
|
||||
SqlCtrls ctrls;
|
||||
|
||||
BookDlg() {
|
||||
CtrlLayoutOKCancel(*this, "Book");
|
||||
ctrls
|
||||
(AUTHOR, author)
|
||||
(TITLE, title)
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
void SQLApp::NewBook()
|
||||
{
|
||||
BookDlg dlg;
|
||||
if(dlg.Run() != IDOK)
|
||||
return;
|
||||
SQL * dlg.ctrls.Insert(BOOK);
|
||||
Query(SQL.GetInsertedId());
|
||||
}
|
||||
|
||||
void SQLApp::EditBook()
|
||||
{
|
||||
if(!book.IsCursor())
|
||||
return;
|
||||
BookDlg dlg;
|
||||
int q = book.GetKey();
|
||||
SQL * Select(dlg.ctrls).From(BOOK).Where(ID == q);
|
||||
if(!dlg.ctrls.Fetch(SQL))
|
||||
return;
|
||||
if(dlg.Run() != IDOK)
|
||||
return;
|
||||
SQL * dlg.ctrls.Update(BOOK).Where(ID == q);
|
||||
Query(q);
|
||||
}
|
||||
|
||||
void SQLApp::DeleteBook()
|
||||
{
|
||||
if(book.IsCursor() && PromptYesNo("Delete the book?")) {
|
||||
SQL * Delete(BORROW_RECORD).Where(BOOK_ID == book.GetKey());
|
||||
SQL * Delete(BOOK).Where(ID == book.GetKey());
|
||||
Query();
|
||||
}
|
||||
}
|
||||
|
||||
void SQLApp::BookMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("New book..", THISBACK(NewBook));
|
||||
bar.Add(book.IsCursor(), "Edit book..", THISBACK(EditBook));
|
||||
bar.Add(book.IsCursor(), "Delete book..", THISBACK(DeleteBook));
|
||||
bar.Separator();
|
||||
bar.Add("Query..", THISBACK(SetupQuery))
|
||||
.Key(K_CTRL_F);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue