Mercurial > mercurial > hgweb_searcher03.cgi
diff src/index.cpp @ 2:c066fde99517
Added Batch Print Mode.
author | pyon@macmini |
---|---|
date | Fri, 23 Aug 2013 18:32:09 +0900 |
parents | 0c0701a935f8 |
children | 7ac7d28699af |
line wrap: on
line diff
--- a/src/index.cpp Sun Aug 04 21:42:49 2013 +0900 +++ b/src/index.cpp Fri Aug 23 18:32:09 2013 +0900 @@ -1,8 +1,10 @@ // Filename : index.cpp -// Last Change: 21-Jul-2013. +// Last Change: 23-Aug-2013. // #include "index.h" +#include "db.h" +#include "wx/wxsqlite3.h" IndexDialog::IndexDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) @@ -14,7 +16,7 @@ m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); wxListItem itemCol; - itemCol.SetText( wxT("歴番") ); + itemCol.SetText( wxT("通番") ); m_listCtrl->InsertColumn( 0, itemCol ); m_listCtrl->SetColumnWidth( 0, 50 ); itemCol.SetText( wxT("年月日") ); @@ -22,13 +24,13 @@ m_listCtrl->SetColumnWidth( 1, 80 ); itemCol.SetText( wxT("合議体") ); m_listCtrl->InsertColumn( 2, itemCol ); - m_listCtrl->SetColumnWidth( 2, 80 ); + m_listCtrl->SetColumnWidth( 2, 60 ); itemCol.SetText( wxT("被保険者番号") ); m_listCtrl->InsertColumn( 3, itemCol ); m_listCtrl->SetColumnWidth( 3, 100 ); itemCol.SetText( wxT("氏名") ); m_listCtrl->InsertColumn( 4, itemCol ); - m_listCtrl->SetColumnWidth( 4, 100 ); + m_listCtrl->SetColumnWidth( 4, 120 ); bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); @@ -37,15 +39,16 @@ m_calendar = new wxCalendarCtrl( this, ID_CALNENDER, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxCAL_SHOW_HOLIDAYS ); bSizerR->Add( m_calendar, 0, wxALL, 5 ); - wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL ); - m_buttonMake = new wxButton( this, ID_MKINDEX, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBtn->Add( m_buttonMake, 0, wxALL, 5 ); + bSizerR->Add( m_buttonMake, 0, wxALIGN_RIGHT|wxALL, 5 ); + bSizerR->Add( 0, 300, 1, wxEXPAND, 5 ); + + m_richText = new wxRichTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 100 ), wxVSCROLL|wxBORDER_NONE|wxWANTS_CHARS ); + bSizerR->Add( m_richText, 0, wxEXPAND|wxALL, 5 ); + m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBtn->Add( m_buttonClose, 0, wxALL, 5 ); - - bSizerR->Add( bSizerBtn, 1, wxALIGN_RIGHT, 5 ); + bSizerR->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxALL, 5 ); bSizerTop->Add( bSizerR, 0, wxALIGN_RIGHT, 5 ); @@ -53,6 +56,8 @@ this->Layout(); this->Centre( wxBOTH ); + + CheckHhs(); } IndexDialog::~IndexDialog() @@ -61,7 +66,83 @@ // Event Table BEGIN_EVENT_TABLE( IndexDialog, wxDialog ) - //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) - //EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) + EVT_CALENDAR_PAGE_CHANGED( ID_CALNENDER, IndexDialog::OnPage ) + EVT_CALENDAR( ID_CALNENDER, IndexDialog::OnSelect ) + EVT_BUTTON( ID_MKINDEX, IndexDialog::OnMakeIndex ) END_EVENT_TABLE() +// Event Handlers & Functions +void IndexDialog::OnSelect( wxCalendarEvent& WXUNUSED(event) ) +{ + UpdateList(); +} + +void IndexDialog::OnMakeIndex( wxCommandEvent& WXUNUSED(event) ) +{ + wxDateTime dt = m_calendar->GetDate(); + wxString month = dt.Format( wxT("%m") ); + wxString year = dt.Format( wxT("%Y") ); + if ( month.IsSameAs( wxT("01") ) || month.IsSameAs( wxT("02") ) || month.IsSameAs( wxT("03") ) ) { + long y; + year.ToLong( &y, 10 ); + y--; + year = wxString::Format( wxT("%d"), y ); + } + + + wxString date = dt.Format( wxT("%Y%m%d") ); + wxString datedir = m_rootdir + wxFILE_SEP_PATH + year + wxFILE_SEP_PATH + date; + if ( !wxDir::Exists( datedir ) ) { + wxMessageBox( wxT("フォルダが存在しません.") + datedir ); + return; + } + + UpdateIndex( datedir, date ); + + UpdateList(); + wxMessageBox( wxT("インデックス作成が終了しました.") ); +} + +void IndexDialog::OnPage( wxCalendarEvent& WXUNUSED(event) ) {} + +void IndexDialog::UpdateList( void ) +{ + wxDateTime dt = m_calendar->GetDate(); + wxString ymd = dt.Format( wxT("%Y%m%d") ); + + wxArrayString ccn = GetCcnByDate( ymd ); + + m_listCtrl->DeleteAllItems(); + + wxString buf; + for ( int i = 0; i < ccn.GetCount(); i++ ) { + m_listCtrl->InsertItem( i, -1 ); + buf.Printf( wxT("%02d"), i + 1 ); + m_listCtrl->SetItem( i, 0, buf, -1 ); // No + + wxArrayString ary = wxSplit( ccn[i], '_', '\\' ); // hhsno, path, date + buf = GetHhsInfoByHhsNo( ary[0] ); + wxString name = buf.BeforeFirst( '_' ); + wxString ccnn = ary[1].Mid( 17, 3 ); + + m_listCtrl->SetItem( i, 1, ary[2], -1 ); // date + m_listCtrl->SetItem( i, 2, ccnn, -1 ); // ccn + m_listCtrl->SetItem( i, 3, ary[0], -1 ); // hhsno + m_listCtrl->SetItem( i, 4, name, -1 ); // name + + if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); + } +} + +void IndexDialog::CheckHhs( void ) +{ + wxArrayString result = CheckDBs(); + + for ( int i = 0; i < result.GetCount(); i++ ) { + m_richText->WriteText( wxT("チェック対象 : ") ); + m_richText->WriteText( result[i] ); + m_richText->Newline(); + } + m_richText->SetEditable( false ); +} +