0
|
1 // Filename : kana.cpp
|
21
|
2 // Last Change: 12-Dec-2014.
|
0
|
3 //
|
|
4
|
|
5 #include "kana.h"
|
|
6 #include "db.h"
|
|
7
|
|
8 KanaDialog::KanaDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
9 : wxDialog( parent, id, title, pos, size, style )
|
|
10 {
|
|
11 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
12
|
|
13 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
14
|
|
15 //
|
|
16 wxBoxSizer* bSizerSearch = new wxBoxSizer( wxHORIZONTAL );
|
|
17
|
1
|
18 m_searchCtrl = new wxSearchCtrl( this, ID_SEARCHKANA, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
0
|
19 #ifndef __WXMAC__
|
|
20 m_searchCtrl->ShowSearchButton( true );
|
|
21 #endif
|
|
22 m_searchCtrl->ShowCancelButton( false );
|
21
|
23 bSizerSearch->Add( m_searchCtrl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
24
|
1
|
25 m_checkBox = new wxCheckBox( this, ID_FUZZY, wxT("部分一致"), wxDefaultPosition, wxDefaultSize, 0 );
|
21
|
26 bSizerSearch->Add( m_checkBox, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
0
|
27
|
|
28 bSizerTop->Add( bSizerSearch, 0, wxALL|wxEXPAND, 5 );
|
|
29
|
|
30 //
|
|
31 m_listCtrl = new wxListCtrl( this, ID_LISTKANA, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
|
|
32
|
|
33 wxListItem itemCol;
|
1
|
34 itemCol.SetText( wxT("通番") );
|
0
|
35 m_listCtrl->InsertColumn( 0, itemCol );
|
1
|
36 m_listCtrl->SetColumnWidth( 0, 40 );
|
|
37 itemCol.SetText( wxT("被保険者番号") );
|
|
38 m_listCtrl->InsertColumn( 1, itemCol );
|
|
39 m_listCtrl->SetColumnWidth( 1, 90 );
|
0
|
40 itemCol.SetText( wxT("カナ") );
|
|
41 m_listCtrl->InsertColumn( 2, itemCol );
|
|
42 m_listCtrl->SetColumnWidth( 2, 100 );
|
1
|
43 itemCol.SetText( wxT("氏名") );
|
0
|
44 m_listCtrl->InsertColumn( 3, itemCol );
|
1
|
45 m_listCtrl->SetColumnWidth( 3, 100 );
|
|
46 itemCol.SetText( wxT("生年月日") );
|
|
47 m_listCtrl->InsertColumn( 4, itemCol );
|
|
48 m_listCtrl->SetColumnWidth( 4, 60 );
|
0
|
49 itemCol.SetText( wxT("住所") );
|
1
|
50 m_listCtrl->InsertColumn( 5, itemCol );
|
|
51 m_listCtrl->SetColumnWidth( 5, 180 );
|
2
|
52 itemCol.SetText( wxT("認定") );
|
|
53 m_listCtrl->InsertColumn( 6, itemCol );
|
|
54 m_listCtrl->SetColumnWidth( 6, 40 );
|
0
|
55
|
2
|
56 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
0
|
57
|
|
58 //
|
2
|
59 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
|
|
60
|
|
61 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
62 bSizerBtn->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
63
|
|
64 m_buttonSet = new wxButton( this, ID_SETKANA, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
65 bSizerBtn->Add( m_buttonSet, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
66
|
|
67 bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT|wxALL, 5 );
|
|
68
|
|
69 this->SetSizer( bSizerTop );
|
|
70 this->Layout();
|
|
71
|
|
72 this->Centre( wxBOTH );
|
1
|
73
|
21
|
74 wxString message = wxT("全角で入力してネ! (性と名の間は全角スペースで)");
|
|
75 m_searchCtrl->SetDescriptiveText( message );
|
|
76 m_searchCtrl->SetValue( message );
|
|
77 m_searchCtrl->SelectAll();
|
1
|
78 m_searchCtrl->SetFocus();
|
0
|
79 }
|
|
80
|
|
81 KanaDialog::~KanaDialog()
|
|
82 {
|
|
83 }
|
|
84
|
|
85 // Event Table
|
|
86 BEGIN_EVENT_TABLE( KanaDialog, wxDialog )
|
1
|
87 EVT_TEXT_ENTER( ID_SEARCHKANA, KanaDialog::OnSearch )
|
|
88 EVT_CHECKBOX( ID_FUZZY, KanaDialog::OnFuzzyCheck )
|
|
89 EVT_LIST_ITEM_ACTIVATED( ID_LISTKANA, KanaDialog::OnSelectItem )
|
|
90 EVT_BUTTON( ID_SETKANA, KanaDialog::OnSet )
|
0
|
91 END_EVENT_TABLE()
|
|
92
|
|
93 // Event Handlers & Functions
|
1
|
94 void KanaDialog::OnSearch( wxCommandEvent& WXUNUSED(event) )
|
|
95 {
|
|
96 UpdateList();
|
|
97 }
|
|
98
|
|
99 void KanaDialog::OnFuzzyCheck( wxCommandEvent& WXUNUSED(event) )
|
|
100 {
|
|
101 UpdateList();
|
|
102 }
|
0
|
103
|
2
|
104 void KanaDialog::OnSelectItem( wxListEvent& event )
|
1
|
105 {
|
2
|
106 int i = event.GetIndex();
|
|
107 wxListItem item;
|
|
108 item.SetId( i );
|
|
109
|
|
110 item.SetColumn( 1 );
|
|
111 item.SetMask( wxLIST_MASK_TEXT );
|
|
112 m_listCtrl->GetItem( item );
|
|
113 m_hhsno = item.GetText();
|
|
114
|
1
|
115 if ( IsModal() )
|
|
116 EndModal( wxID_OK );
|
|
117 else {
|
|
118 SetReturnCode( wxID_OK );
|
|
119 Show( false );
|
|
120 }
|
|
121 }
|
0
|
122
|
1
|
123 void KanaDialog::OnSet( wxCommandEvent& WXUNUSED(event) )
|
|
124 {
|
2
|
125 long i = -1;
|
|
126 for ( ;; ) {
|
|
127 i = m_listCtrl->GetNextItem( i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
128 if ( i == -1 ) break;
|
|
129
|
|
130 wxListItem item;
|
|
131 item.SetId( i );
|
|
132
|
|
133 item.SetColumn( 1 );
|
|
134 item.SetMask( wxLIST_MASK_TEXT );
|
|
135 m_listCtrl->GetItem( item );
|
|
136 m_hhsno = item.GetText();
|
|
137 }
|
|
138
|
1
|
139 if ( IsModal() )
|
|
140 EndModal( wxID_OK );
|
|
141 else {
|
|
142 SetReturnCode( wxID_OK );
|
|
143 Show( false );
|
|
144 }
|
|
145 }
|
0
|
146
|
1
|
147 void KanaDialog::UpdateList( void )
|
|
148 {
|
|
149 m_listCtrl->DeleteAllItems();
|
0
|
150
|
1
|
151 wxString s = m_searchCtrl->GetValue();
|
|
152 if ( s.Len() < 3 ) {
|
|
153 wxMessageBox( wxT("指定する文字列は 3文字以上としてください.") );
|
|
154 return;
|
|
155 }
|
|
156
|
|
157 /*
|
|
158 wxRegEx reKana( "^[アイウエオカキクケコサシスセソナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョ ]+$" );
|
|
159 if ( !reKana.Matches( s ) ) {
|
|
160 wxMessageBox( wxT("カタカナで入力してください.") );
|
|
161 return;
|
|
162 }
|
|
163 */
|
|
164
|
|
165 bool fuzzy = m_checkBox->IsChecked();
|
2
|
166 wxArrayString hhs = GetHhsInfoByKana( s, fuzzy );
|
0
|
167
|
2
|
168 if ( hhs.GetCount() > 200 ) {
|
1
|
169 wxMessageBox( wxT("該当件数が 200 件を超えました.\n条件を変えてみてください.") );
|
|
170 return;
|
|
171 }
|
2
|
172 else if ( hhs.IsEmpty() ){
|
1
|
173 wxMessageBox( wxT("該当なし.") );
|
|
174 return;
|
|
175 }
|
|
176
|
|
177 wxString buf;
|
2
|
178 for ( int i = 0; i < hhs.GetCount(); i++ ) {
|
1
|
179 int col = 0;
|
|
180 m_listCtrl->InsertItem( i, -1 );
|
|
181 buf.Printf( wxT("%02d"), i + 1 );
|
|
182 m_listCtrl->SetItem( i, col, buf, -1 ); // No
|
|
183
|
2
|
184 wxStringTokenizer tkz( hhs[i], wxT("_") ); // hhsno, kana, name, birth, addr
|
1
|
185 while ( tkz.HasMoreTokens() ) {
|
|
186 col++;
|
|
187 wxString token = tkz.GetNextToken();
|
|
188 m_listCtrl->SetItem( i, col, token, -1 );
|
2
|
189 if ( col == 1 ) { // ccn
|
|
190 if ( IsHhsJudged( token ) ) {
|
|
191 m_listCtrl->SetItem( i, 6, wxT("○"), -1 );
|
|
192 }
|
|
193 }
|
0
|
194 }
|
2
|
195 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) );
|
0
|
196 }
|
|
197 }
|
|
198
|