19
|
1 // Filename : ccnframe.cpp
|
22
|
2 // Last Change: 27-Jul-2011.
|
17
|
3 //
|
|
4
|
19
|
5 #include "common.h"
|
21
|
6 #include "main.h"
|
19
|
7 #include "ccnframe.h"
|
21
|
8 #include "wx/wxsqlite3.h"
|
17
|
9
|
19
|
10 FrameCcn::FrameCcn( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
11 : wxFrame( parent, id, title, pos, size, style )
|
17
|
12 {
|
|
13 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
19
|
14 m_Panel = new wxPanel( this );
|
17
|
15
|
|
16 wxBoxSizer* bSizer;
|
|
17 bSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
18
|
19
|
19 // DB表示
|
22
|
20 wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 2, 6, 0, 0 );
|
19
|
21 fgSizer->AddGrowableRow(1);
|
17
|
22
|
19
|
23 m_staticText1 = new wxStaticText( m_Panel, wxID_ANY, wxT("開催年月日"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
24 fgSizer->Add( m_staticText1, 0, wxALL, 5 );
|
|
25 fgSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
17
|
26
|
19
|
27 m_staticText2 = new wxStaticText( m_Panel, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
28 fgSizer->Add( m_staticText2, 0, wxALL, 5 );
|
|
29 fgSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
17
|
30
|
19
|
31 m_staticText3 = new wxStaticText( m_Panel, wxID_ANY, wxT("被保険者"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
32 fgSizer->Add( m_staticText3, 0, wxALL, 5 );
|
22
|
33 fgSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
17
|
34
|
22
|
35 m_listCtrlYmd = new wxListCtrl( m_Panel, ID_YMD, wxDefaultPosition, wxSize( 300, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL );
|
19
|
36 fgSizer->Add( m_listCtrlYmd, 1, wxALL|wxEXPAND, 5 );
|
17
|
37
|
19
|
38 m_staticText4 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
39 fgSizer->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
17
|
40
|
21
|
41 m_listCtrlCcn = new wxListCtrl( m_Panel, ID_CCN, wxDefaultPosition, wxSize( 220, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL );
|
19
|
42 fgSizer->Add( m_listCtrlCcn, 1, wxALL|wxEXPAND, 5 );
|
17
|
43
|
19
|
44 m_staticText5 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
45 fgSizer->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
17
|
46
|
21
|
47 m_listCtrlHhs = new wxListCtrl( m_Panel, ID_HHS, wxDefaultPosition, wxSize( 220, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL );
|
19
|
48 fgSizer->Add( m_listCtrlHhs, 1, wxALL|wxEXPAND, 5 );
|
17
|
49
|
22
|
50 m_btnClose = new wxButton( m_Panel, ID_CLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
51 fgSizer->Add( m_btnClose, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5 );
|
|
52 m_btnClose->SetFocus();
|
17
|
53
|
22
|
54 bSizer->Add( fgSizer, 1, wxEXPAND|wxALL, 5 );
|
17
|
55
|
19
|
56 m_Panel->SetSizer( bSizer );
|
|
57 m_Panel->Layout();
|
17
|
58
|
22
|
59 this->SetSize( 1000, 500 );
|
17
|
60 this->Centre( wxBOTH );
|
19
|
61 InitListCtrl();
|
17
|
62 }
|
|
63
|
19
|
64 // Destructor
|
17
|
65 FrameCcn::~FrameCcn()
|
|
66 {
|
|
67 }
|
19
|
68
|
|
69 // Event Table
|
|
70 BEGIN_EVENT_TABLE( FrameCcn, wxFrame )
|
21
|
71 EVT_LIST_ITEM_SELECTED( ID_YMD, FrameCcn::OnSelectYmd )
|
|
72 EVT_LIST_ITEM_SELECTED( ID_CCN, FrameCcn::OnSelectCcn )
|
|
73 EVT_BUTTON( ID_CLOSE, FrameCcn::OnClose )
|
19
|
74 END_EVENT_TABLE()
|
|
75
|
|
76 // Event Handlers
|
22
|
77 void FrameCcn::OnSelectYmd(wxListEvent& event)
|
21
|
78 {
|
22
|
79 long i = event.GetIndex();
|
|
80 wxString ymd = m_listCtrlYmd->GetItemText( i );
|
|
81 ymd.Replace( wxT("-"), wxEmptyString, true );
|
21
|
82
|
|
83 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db");
|
|
84 wxSQLite3Database ccndb;
|
|
85 ccndb.Open( gszFile );
|
|
86
|
22
|
87 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT hhsno, path FROM path WHERE path LIKE ?");
|
|
88 stmt.Bind( 1, wxT("08") );
|
21
|
89 wxSQLite3ResultSet q = stmt.ExecuteQuery();
|
|
90 if ( q.IsNull(0) ) {
|
|
91 return;
|
|
92 }
|
22
|
93
|
21
|
94 long r=0;
|
|
95 while ( q.NextRow() ) {
|
22
|
96 wxMessageBox(wxT("aaa"));
|
|
97 wxString hhsno = q.GetString(0);
|
21
|
98 //wxString cnt = q.GetString(1);
|
22
|
99 m_listCtrlHhs->InsertItem( r, hhsno );
|
21
|
100 //m_listCtrlCcn->SetItem( r, 1, cnt, -1 );
|
|
101 r++;
|
|
102 }
|
|
103 stmt.Finalize();
|
|
104 ccndb.Close();
|
|
105 }
|
|
106
|
|
107 void FrameCcn::OnSelectCcn(wxListEvent& WXUNUSED(event))
|
|
108 {
|
|
109 m_listCtrlHhs->DeleteAllItems();
|
|
110
|
|
111 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db");
|
|
112 wxSQLite3Database ccndb;
|
|
113 ccndb.Open( gszFile );
|
|
114
|
|
115 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT ymd, MAX(time) FROM ccn GROUP BY ymd ORDER BY ymd DESC, time DESC");
|
|
116 wxSQLite3ResultSet q = stmt.ExecuteQuery();
|
|
117 long r=0;
|
|
118 while ( q.NextRow() ) {
|
|
119 wxString ymd = q.GetString(0);
|
|
120 wxString time = q.GetString(1);
|
|
121 m_listCtrlHhs->InsertItem( r, wxEmptyString );
|
|
122 m_listCtrlHhs->SetItemText( r, ymd );
|
|
123 r++;
|
|
124 }
|
|
125
|
|
126 stmt.Finalize();
|
|
127 ccndb.Close();
|
|
128 }
|
|
129
|
|
130 // 閉じる
|
|
131 void FrameCcn::OnClose(wxCommandEvent& WXUNUSED(event))
|
|
132 {
|
|
133 this->Close();
|
|
134 }
|
19
|
135
|
|
136 // Functions
|
|
137 void FrameCcn::InitListCtrl()
|
|
138 {
|
|
139 wxListItem itemCol;
|
|
140 itemCol.SetText( wxT("年-月-日") );
|
|
141 m_listCtrlYmd->InsertColumn( 0, itemCol );
|
|
142 m_listCtrlYmd->SetColumnWidth( 0, 100 );
|
21
|
143 itemCol.SetText( wxT("更新時刻") );
|
|
144 m_listCtrlYmd->InsertColumn( 1, itemCol );
|
22
|
145 m_listCtrlYmd->SetColumnWidth( 1, 180 );
|
19
|
146
|
|
147 itemCol.SetText( wxT("合議体名") );
|
|
148 m_listCtrlCcn->InsertColumn( 0, itemCol );
|
|
149 m_listCtrlCcn->SetColumnWidth( 0, 100 );
|
|
150 itemCol.SetText( wxT("件数") );
|
|
151 m_listCtrlCcn->InsertColumn( 1, itemCol );
|
|
152 m_listCtrlCcn->SetColumnWidth( 1, 100 );
|
|
153
|
|
154 itemCol.SetText( wxT("被保険者番号") );
|
|
155 m_listCtrlHhs->InsertColumn( 0, itemCol );
|
|
156 m_listCtrlHhs->SetColumnWidth( 0, 100 );
|
|
157 itemCol.SetText( wxT("氏名") );
|
|
158 m_listCtrlHhs->InsertColumn( 1, itemCol );
|
|
159 m_listCtrlHhs->SetColumnWidth( 1, 100 );
|
|
160
|
22
|
161 // Ymd: read from db
|
21
|
162 m_listCtrlCcn->DeleteAllItems();
|
|
163
|
|
164 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db");
|
|
165 wxSQLite3Database ccndb;
|
|
166 ccndb.Open( gszFile );
|
|
167
|
|
168 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT ymd, MAX(time) FROM ccn GROUP BY ymd ORDER BY ymd DESC, time DESC");
|
|
169 wxSQLite3ResultSet q = stmt.ExecuteQuery();
|
|
170 long r=0;
|
|
171 while ( q.NextRow() ) {
|
|
172 wxString ymd = q.GetString(0);
|
|
173 wxString time = q.GetString(1);
|
|
174 m_listCtrlYmd->InsertItem( r, ymd );
|
|
175 m_listCtrlYmd->SetItem( r, 1, time, -1 );
|
22
|
176 if ( r % 2 )
|
|
177 m_listCtrlYmd->SetItemBackgroundColour( r, wxColour(wxT("WHEAT")) );
|
21
|
178 r++;
|
|
179 }
|
|
180
|
|
181 stmt.Finalize();
|
|
182 ccndb.Close();
|
22
|
183
|
|
184 // Ccn
|
|
185 m_listCtrlCcn->InsertItem( 0, wxT("六郷1") );
|
|
186 m_listCtrlCcn->InsertItem( 1, wxT("六郷2") );
|
|
187 m_listCtrlCcn->InsertItem( 2, wxT("六郷3") );
|
|
188 m_listCtrlCcn->InsertItem( 3, wxT("千畑1") );
|
|
189 m_listCtrlCcn->InsertItem( 4, wxT("千畑2") );
|
|
190 m_listCtrlCcn->InsertItem( 5, wxT("千畑3") );
|
|
191 m_listCtrlCcn->InsertItem( 6, wxT("大曲1") );
|
|
192 m_listCtrlCcn->InsertItem( 7, wxT("大曲2") );
|
|
193 m_listCtrlCcn->InsertItem( 8, wxT("大曲3") );
|
|
194 m_listCtrlCcn->InsertItem( 9, wxT("大曲4") );
|
|
195 m_listCtrlCcn->InsertItem( 10, wxT("大曲5") );
|
|
196 m_listCtrlCcn->InsertItem( 11, wxT("大曲6") );
|
|
197 m_listCtrlCcn->InsertItem( 12, wxT("西仙1") );
|
|
198 m_listCtrlCcn->InsertItem( 13, wxT("西仙2") );
|
|
199 m_listCtrlCcn->InsertItem( 14, wxT("西仙3") );
|
|
200 m_listCtrlCcn->InsertItem( 15, wxT("角館1") );
|
|
201 m_listCtrlCcn->InsertItem( 16, wxT("角館2") );
|
|
202 m_listCtrlCcn->InsertItem( 17, wxT("角館3") );
|
|
203 m_listCtrlCcn->InsertItem( 18, wxT("角館4") );
|
|
204 m_listCtrlCcn->InsertItem( 19, wxT("合計") );
|
19
|
205 }
|
|
206
|