0
|
1 // Filename : kana.cpp
|
2
|
2 // Last Change: 22-Aug-2013.
|
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 );
|
|
23 bSizerSearch->Add( m_searchCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
24
|
1
|
25 m_checkBox = new wxCheckBox( this, ID_FUZZY, wxT("部分一致"), wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
26 bSizerSearch->Add( m_checkBox, 0, wxALL|wxEXPAND, 5 );
|
|
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
|
|
74 m_searchCtrl->SetFocus();
|
|
75 m_searchCtrl->SetValue( wxT("全角で入力してネ! (性と名の間は全角スペースで)") );
|
|
76 m_searchCtrl->SelectAll();
|
0
|
77 }
|
|
78
|
|
79 KanaDialog::~KanaDialog()
|
|
80 {
|
|
81 }
|
|
82
|
|
83 // Event Table
|
|
84 BEGIN_EVENT_TABLE( KanaDialog, wxDialog )
|
1
|
85 EVT_TEXT_ENTER( ID_SEARCHKANA, KanaDialog::OnSearch )
|
|
86 EVT_CHECKBOX( ID_FUZZY, KanaDialog::OnFuzzyCheck )
|
|
87 EVT_LIST_ITEM_ACTIVATED( ID_LISTKANA, KanaDialog::OnSelectItem )
|
|
88 EVT_BUTTON( ID_SETKANA, KanaDialog::OnSet )
|
0
|
89 END_EVENT_TABLE()
|
|
90
|
|
91 // Event Handlers & Functions
|
1
|
92 void KanaDialog::OnSearch( wxCommandEvent& WXUNUSED(event) )
|
|
93 {
|
|
94 UpdateList();
|
|
95 }
|
|
96
|
|
97 void KanaDialog::OnFuzzyCheck( wxCommandEvent& WXUNUSED(event) )
|
|
98 {
|
|
99 UpdateList();
|
|
100 }
|
0
|
101
|
2
|
102 void KanaDialog::OnSelectItem( wxListEvent& event )
|
1
|
103 {
|
2
|
104 int i = event.GetIndex();
|
|
105 wxListItem item;
|
|
106 item.SetId( i );
|
|
107
|
|
108 item.SetColumn( 1 );
|
|
109 item.SetMask( wxLIST_MASK_TEXT );
|
|
110 m_listCtrl->GetItem( item );
|
|
111 m_hhsno = item.GetText();
|
|
112
|
1
|
113 if ( IsModal() )
|
|
114 EndModal( wxID_OK );
|
|
115 else {
|
|
116 SetReturnCode( wxID_OK );
|
|
117 Show( false );
|
|
118 }
|
|
119 }
|
0
|
120
|
1
|
121 void KanaDialog::OnSet( wxCommandEvent& WXUNUSED(event) )
|
|
122 {
|
2
|
123 long i = -1;
|
|
124 for ( ;; ) {
|
|
125 i = m_listCtrl->GetNextItem( i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
126 if ( i == -1 ) break;
|
|
127
|
|
128 wxListItem item;
|
|
129 item.SetId( i );
|
|
130
|
|
131 item.SetColumn( 1 );
|
|
132 item.SetMask( wxLIST_MASK_TEXT );
|
|
133 m_listCtrl->GetItem( item );
|
|
134 m_hhsno = item.GetText();
|
|
135 }
|
|
136
|
1
|
137 if ( IsModal() )
|
|
138 EndModal( wxID_OK );
|
|
139 else {
|
|
140 SetReturnCode( wxID_OK );
|
|
141 Show( false );
|
|
142 }
|
|
143 }
|
0
|
144
|
1
|
145 void KanaDialog::UpdateList( void )
|
|
146 {
|
|
147 m_listCtrl->DeleteAllItems();
|
0
|
148
|
1
|
149 wxString s = m_searchCtrl->GetValue();
|
|
150 if ( s.Len() < 3 ) {
|
|
151 wxMessageBox( wxT("指定する文字列は 3文字以上としてください.") );
|
|
152 return;
|
|
153 }
|
|
154
|
|
155 /*
|
|
156 wxRegEx reKana( "^[アイウエオカキクケコサシスセソナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョ ]+$" );
|
|
157 if ( !reKana.Matches( s ) ) {
|
|
158 wxMessageBox( wxT("カタカナで入力してください.") );
|
|
159 return;
|
|
160 }
|
|
161 */
|
|
162
|
|
163 bool fuzzy = m_checkBox->IsChecked();
|
2
|
164 wxArrayString hhs = GetHhsInfoByKana( s, fuzzy );
|
0
|
165
|
2
|
166 if ( hhs.GetCount() > 200 ) {
|
1
|
167 wxMessageBox( wxT("該当件数が 200 件を超えました.\n条件を変えてみてください.") );
|
|
168 return;
|
|
169 }
|
2
|
170 else if ( hhs.IsEmpty() ){
|
1
|
171 wxMessageBox( wxT("該当なし.") );
|
|
172 return;
|
|
173 }
|
|
174
|
|
175 wxString buf;
|
2
|
176 for ( int i = 0; i < hhs.GetCount(); i++ ) {
|
1
|
177 int col = 0;
|
|
178 m_listCtrl->InsertItem( i, -1 );
|
|
179 buf.Printf( wxT("%02d"), i + 1 );
|
|
180 m_listCtrl->SetItem( i, col, buf, -1 ); // No
|
|
181
|
2
|
182 wxStringTokenizer tkz( hhs[i], wxT("_") ); // hhsno, kana, name, birth, addr
|
1
|
183 while ( tkz.HasMoreTokens() ) {
|
|
184 col++;
|
|
185 wxString token = tkz.GetNextToken();
|
|
186 m_listCtrl->SetItem( i, col, token, -1 );
|
2
|
187 if ( col == 1 ) { // ccn
|
|
188 if ( IsHhsJudged( token ) ) {
|
|
189 m_listCtrl->SetItem( i, 6, wxT("○"), -1 );
|
|
190 }
|
|
191 }
|
0
|
192 }
|
2
|
193 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) );
|
0
|
194 }
|
|
195 }
|
|
196
|