comparison src/myframe.cpp @ 30:e4d585cbd172 v2.3 v2.4

add auto make ccndir
author pyon@macmini
date Sun, 06 Nov 2011 14:08:42 +0900
parents 24283d3a9592
children 112cd4d27f1f
comparison
equal deleted inserted replaced
29:24283d3a9592 30:e4d585cbd172
1 // Filename : myframe.cpp 1 // Filename : myframe.cpp
2 // Last Change: 05-Nov-2011. 2 // Last Change: 06-Nov-2011.
3 // 3 //
4 4
5 #include "main.h" 5 #include "main.h"
6 #include "myframe.h" 6 #include "myframe.h"
7 #include "param.h" 7 #include "param.h"
104 bSizerDist->Add( m_buttonNextThu, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); 104 bSizerDist->Add( m_buttonNextThu, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
105 105
106 m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 ); 106 m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 );
107 bSizerDist->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); 107 bSizerDist->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
108 108
109 wxArrayString ccns; 109 wxArrayString ccns; wxString dummy;
110 ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4")); 110 GetCCnArrayInfo( ccns, -1, dummy, dummy );
111 ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
112 ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
113 ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6"));
114 ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3"));
115 m_comboBoxCcn = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), ccns, 0 ); 111 m_comboBoxCcn = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), ccns, 0 );
116 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 ); 112 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 );
117 113
118 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 ); 114 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 );
119 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 ); 115 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 );
241 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo ) 237 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo )
242 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir ) 238 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir )
243 EVT_CLOSE( MyFrame::SaveConfig ) 239 EVT_CLOSE( MyFrame::SaveConfig )
244 END_EVENT_TABLE() 240 END_EVENT_TABLE()
245 241
246 // Event Handlers 242 // Event Handlers & Functions
243 void MyFrame::GetCCnArrayInfo(wxArrayString& array , int n, wxString& nName, wxString& nDir)
244 {
245 if ( n == -1 ) {
246 array.Add(wxT("角館1")); array.Add(wxT("角館2")); array.Add(wxT("角館3")); array.Add(wxT("角館4"));
247 array.Add(wxT("西仙1")); array.Add(wxT("西仙2")); array.Add(wxT("西仙3"));
248 array.Add(wxT("千畑1")); array.Add(wxT("千畑2")); array.Add(wxT("千畑3"));
249 array.Add(wxT("大曲1")); array.Add(wxT("大曲2")); array.Add(wxT("大曲3")); array.Add(wxT("大曲4")); array.Add(wxT("大曲5")); array.Add(wxT("大曲6"));
250 array.Add(wxT("六郷1")); array.Add(wxT("六郷2")); array.Add(wxT("六郷3"));
251 }
252 else {
253 wxArrayString ccndir;
254 ccndir.Add(wxT("0000000031")); ccndir.Add(wxT("0000000032")); ccndir.Add(wxT("0000000033")); ccndir.Add(wxT("0000000034"));
255 ccndir.Add(wxT("0000000021")); ccndir.Add(wxT("0000000022")); ccndir.Add(wxT("0000000023"));
256 ccndir.Add(wxT("0000000041")); ccndir.Add(wxT("0000000042")); ccndir.Add(wxT("0000000043"));
257 ccndir.Add(wxT("0000000001")); ccndir.Add(wxT("0000000002")); ccndir.Add(wxT("0000000003")); ccndir.Add(wxT("0000000004")); ccndir.Add(wxT("0000000005")); ccndir.Add(wxT("0000000006"));
258 ccndir.Add(wxT("00000000x1")); ccndir.Add(wxT("00000000x2")); ccndir.Add(wxT("00000000x3"));
259 nDir = ccndir[n];
260 }
261 }
247 /* 次の木曜日 */ 262 /* 次の木曜日 */
248 void MyFrame::OnNextThursday(wxCommandEvent& WXUNUSED(event)) 263 void MyFrame::OnNextThursday(wxCommandEvent& WXUNUSED(event))
249 { 264 {
250 wxDateTime dt = m_datePicker->GetValue(); 265 wxDateTime dt = m_datePicker->GetValue();
251 wxDateSpan ds( 0, 0, 0, 1 ); 266 wxDateSpan ds( 0, 0, 0, 1 );
256 271
257 /* 移動先フォルダ作成 */ 272 /* 移動先フォルダ作成 */
258 void MyFrame::OnMakeDir(wxCommandEvent& WXUNUSED(event)) 273 void MyFrame::OnMakeDir(wxCommandEvent& WXUNUSED(event))
259 { 274 {
260 wxString to; 275 wxString to;
261 to.Append( m_comboBoxDrive->GetValue() ); 276 to.Append( m_comboBoxDrive->GetValue() ); // C:
262 to.Append( wxFILE_SEP_PATH ); 277 to.Append( wxFILE_SEP_PATH ); // C:/
263 wxDateTime dt = m_datePicker->GetValue(); 278 wxDateTime dt = m_datePicker->GetValue();
264 to.Append( dt.Format(wxT("%Y%m%d")) ); 279 wxString month = dt.Format(wxT("%m"));
265 to.Append( wxFILE_SEP_PATH ); 280 wxString year = dt.Format(wxT("%Y"));
266 to.Append( m_comboBoxCcn->GetValue() ); 281 if ( month.IsSameAs(wxT("01")) || month.IsSameAs(wxT("02")) || month.IsSameAs(wxT("03")) ) {
282 long y;
283 year.ToLong( &y, 10 );
284 y--;
285 year = wxString::Format(wxT("%d"),y);
286 }
287 to.Append( year ); // C:/20xx
288 to.Append( wxFILE_SEP_PATH ); // C:/20xx/
289 to.Append( dt.Format(wxT("%Y%m%d")) ); // C:/20xx/20yymmdd
290 to.Append( wxFILE_SEP_PATH ); // C:/20xx/20yymmdd/
291 to.Append( m_comboBoxCcn->GetValue() ); // C:/20xx/20yymmdd/XXN
267 m_textCtrlDist->SetValue( to ); 292 m_textCtrlDist->SetValue( to );
293
268 294
269 wxString ccn = m_comboBoxCcn->GetValue(); 295 wxString ccn = m_comboBoxCcn->GetValue();
270 if ( to.Len() < 15 || ccn.IsEmpty() ) { 296 if ( to.Len() < 15 || ccn.IsEmpty() ) {
271 wxMessageBox(wxT("フォルダを指定してください.")); 297 wxMessageBox(wxT("フォルダを指定してください."));
272 return; 298 return;
273 } 299 }
274 300
301 // いったんバラして,各階層のフォルダがあるかチェック.なければ作成
275 wxStringTokenizer tkz( to, wxFILE_SEP_PATH ); 302 wxStringTokenizer tkz( to, wxFILE_SEP_PATH );
276 wxString d; 303 wxString d;
277 while ( tkz.HasMoreTokens() ) { 304 while ( tkz.HasMoreTokens() ) {
278 d.Append( tkz.GetNextToken() ); 305 d.Append( tkz.GetNextToken() );
279 d.Append( wxFILE_SEP_PATH ); 306 d.Append( wxFILE_SEP_PATH );
280 if ( !wxDirExists( d ) ) wxMkdir( d ); 307 if ( !wxDirExists( d ) ) wxMkdir( d );
281 } 308 }
309
310 // 申請書フォルダ作成
311 int n = m_comboBoxCcn->GetCurrentSelection();
312 wxString ccndir, dummy; wxArrayString array;
313 GetCCnArrayInfo( array, n, dummy, ccndir );
314 d.Append( ccndir );
315 d.Append( wxFILE_SEP_PATH );
316 if ( !wxDirExists( d ) ) wxMkdir( d );
317
282 m_buttonMove->Enable(true); 318 m_buttonMove->Enable(true);
283
284 // TODO.
285 // make 申請書ふぉるだ
286 319
287 wxMessageBox(wxT("移動先フォルダ準備完了")); 320 wxMessageBox(wxT("移動先フォルダ準備完了"));
288 wxString cmd = wxT("explorer ") + to; 321 wxString cmd = wxT("explorer ") + to;
289 wxExecute( cmd ); 322 wxExecute( cmd );
290 } 323 }