YATiSh
Yet Another TIme SHeet
yatishDlgProject.cpp
Go to the documentation of this file.
1 #include "wx_pch.h"
2 #include "yatishDlgProject.h"
3 
4 #ifndef WX_PRECOMP
5  //(*InternalHeadersPCH(yatishDlgProject)
6  #include <wx/string.h>
7  #include <wx/intl.h>
8  //*)
9 #endif
10 //(*InternalHeaders(yatishDlgProject)
11 //*)
12 
13 //(*IdInit(yatishDlgProject)
14 const long yatishDlgProject::idTextCtrlName = wxNewId();
15 const long yatishDlgProject::idChoiceClient = wxNewId();
16 //*)
17 
18 BEGIN_EVENT_TABLE (yatishDlgProject, wxDialog)
19  //(*EventTable(yatishDlgProject)
20  //*)
21 END_EVENT_TABLE()
22 
23 
25  BuildContent();
26  pdb = p_db;
27  id = sql_id;
28  name = pdb->ReadName (project_tid, id);
29  textCtrlName->SetValidator ( wxTextValidator (wxFILTER_ASCII, &name) );
30  if ( !pdb->FillChoice (choiceClient, client_tid) )
31  wxLogError ("Initialization of choiceClient failed (yatishDlgProject)");
32  choice = pdb->ChoiceSelector (client_tid, id);
33  choiceClient->SetValidator ( wxGenericValidator (&choice) );
34  Fit(); SetMaxSize ( GetSize() );
35 }
36 
39  BuildContent();
40  staticBoxSizer->GetStaticBox()->SetLabel (_("New row") );
41  pdb = p_db;
42  buttonSave->Disable();
43  name = wxEmptyString;
44  textCtrlName->SetValidator ( wxTextValidator (wxFILTER_ASCII, &name) );
46  wxLogError ("Initialization of choiceClient failed (yatishDlgProject)");
47  choice = 0;
48  choiceClient->SetValidator ( wxGenericValidator (&choice) );
49  Fit(); SetMaxSize ( GetSize() );
50  // in case we get here while the database is still empty
51  if ( choiceClient->IsEmpty() ) buttonNew->Disable();
52 }
53 
55  //(*Initialize(yatishDlgProject)
56  wxBoxSizer* BoxSizer1;
57  wxBoxSizer* BoxSizer2;
58  wxButton* buttonCancel;
59  wxFlexGridSizer* FlexGridSizer1;
60  wxStaticText* StaticText1;
61  wxStaticText* StaticText2;
62 
63  Create(0, wxID_ANY, _("Table: yatish_project"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
64  BoxSizer1 = new wxBoxSizer(wxVERTICAL);
65  staticBoxSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("(previously selected row)"));
66  FlexGridSizer1 = new wxFlexGridSizer(2, 2, 0, 0);
67  StaticText1 = new wxStaticText(this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
68  FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
69  textCtrlName = new wxTextCtrl(this, idTextCtrlName, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idTextCtrlName"));
70  FlexGridSizer1->Add(textCtrlName, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
71  StaticText2 = new wxStaticText(this, wxID_ANY, _("Client:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
72  FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
73  choiceClient = new wxChoice(this, idChoiceClient, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("idChoiceClient"));
74  FlexGridSizer1->Add(choiceClient, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
75  staticBoxSizer->Add(FlexGridSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
76  BoxSizer1->Add(staticBoxSizer, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
77  BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
78  buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_CANCEL"));
79  BoxSizer2->Add(buttonCancel, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
80  buttonSave = new wxButton(this, wxID_SAVE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_SAVE"));
81  BoxSizer2->Add(buttonSave, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
82  buttonNew = new wxButton(this, wxID_NEW, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_NEW"));
83  BoxSizer2->Add(buttonNew, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
84  BoxSizer1->Add(BoxSizer2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
85  SetSizer(BoxSizer1);
86  BoxSizer1->Fit(this);
87  BoxSizer1->SetSizeHints(this);
88 
89  Connect(wxID_SAVE,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&yatishDlgProject::OnButtonSaveClick);
90  Connect(wxID_NEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&yatishDlgProject::OnButtonNewClick);
91  //*)
92 }
93 
95  //(*Destroy(yatishDlgProject)
96  //*)
97 }
98 
99 void yatishDlgProject::OnButtonSaveClick (wxCommandEvent& event) {
100  TransferDataFromWindow();
101  if ( pdb->RecordProject (id, name, choice) )
102  EndModal (wxID_SAVE);
103  else
104  EndModal (wxID_CANCEL);
105 }
106 
107 void yatishDlgProject::OnButtonNewClick (wxCommandEvent& event) {
108  TransferDataFromWindow();
109  if ( pdb->RecordProject (wxNOT_FOUND, name, choice) )
110  EndModal (wxID_NEW);
111  else
112  EndModal (wxID_CANCEL);
113 }
Interacts with yatish tables in a SQLite database.
bool FillChoice(wxChoice *, tableID)
Fills a wxChoice.
bool RecordProject(long, const wxString &, int)
Modifies or creates a record in the yatish_project table.
void OnButtonSaveClick(wxCommandEvent &event)
static const long idChoiceClient
void OnButtonNewClick(wxCommandEvent &event)
static const long idTextCtrlName
wxStaticBoxSizer * staticBoxSizer
wxTextCtrl * textCtrlName
wxButton * buttonNew
wxButton * buttonSave
yatishDlgProject(yatishDBsqlite *, long)
This constructor initializes the dialog box with data from the SQL record identified by sql_id.
wxChoice * choiceClient
yatishDBsqlite * pdb
@ client_tid
Definition: yatishDB.h:14
@ project_tid
Definition: yatishDB.h:17