Mercurial > mercurial > hgweb_searcher03.cgi
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1:7b6dab24f4b8 | 2:c066fde99517 |
|---|---|
| 1 // Filename : index.cpp | 1 // Filename : index.cpp |
| 2 // Last Change: 21-Jul-2013. | 2 // Last Change: 23-Aug-2013. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "index.h" | 5 #include "index.h" |
| 6 #include "db.h" | |
| 7 #include "wx/wxsqlite3.h" | |
| 6 | 8 |
| 7 IndexDialog::IndexDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 9 IndexDialog::IndexDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 8 : wxDialog( parent, id, title, pos, size, style ) | 10 : wxDialog( parent, id, title, pos, size, style ) |
| 9 { | 11 { |
| 10 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | 12 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
| 12 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); | 14 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); |
| 13 | 15 |
| 14 m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); | 16 m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); |
| 15 | 17 |
| 16 wxListItem itemCol; | 18 wxListItem itemCol; |
| 17 itemCol.SetText( wxT("歴番") ); | 19 itemCol.SetText( wxT("通番") ); |
| 18 m_listCtrl->InsertColumn( 0, itemCol ); | 20 m_listCtrl->InsertColumn( 0, itemCol ); |
| 19 m_listCtrl->SetColumnWidth( 0, 50 ); | 21 m_listCtrl->SetColumnWidth( 0, 50 ); |
| 20 itemCol.SetText( wxT("年月日") ); | 22 itemCol.SetText( wxT("年月日") ); |
| 21 m_listCtrl->InsertColumn( 1, itemCol ); | 23 m_listCtrl->InsertColumn( 1, itemCol ); |
| 22 m_listCtrl->SetColumnWidth( 1, 80 ); | 24 m_listCtrl->SetColumnWidth( 1, 80 ); |
| 23 itemCol.SetText( wxT("合議体") ); | 25 itemCol.SetText( wxT("合議体") ); |
| 24 m_listCtrl->InsertColumn( 2, itemCol ); | 26 m_listCtrl->InsertColumn( 2, itemCol ); |
| 25 m_listCtrl->SetColumnWidth( 2, 80 ); | 27 m_listCtrl->SetColumnWidth( 2, 60 ); |
| 26 itemCol.SetText( wxT("被保険者番号") ); | 28 itemCol.SetText( wxT("被保険者番号") ); |
| 27 m_listCtrl->InsertColumn( 3, itemCol ); | 29 m_listCtrl->InsertColumn( 3, itemCol ); |
| 28 m_listCtrl->SetColumnWidth( 3, 100 ); | 30 m_listCtrl->SetColumnWidth( 3, 100 ); |
| 29 itemCol.SetText( wxT("氏名") ); | 31 itemCol.SetText( wxT("氏名") ); |
| 30 m_listCtrl->InsertColumn( 4, itemCol ); | 32 m_listCtrl->InsertColumn( 4, itemCol ); |
| 31 m_listCtrl->SetColumnWidth( 4, 100 ); | 33 m_listCtrl->SetColumnWidth( 4, 120 ); |
| 32 | 34 |
| 33 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); | 35 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); |
| 34 | 36 |
| 35 wxBoxSizer* bSizerR = new wxBoxSizer( wxVERTICAL ); | 37 wxBoxSizer* bSizerR = new wxBoxSizer( wxVERTICAL ); |
| 36 | 38 |
| 37 m_calendar = new wxCalendarCtrl( this, ID_CALNENDER, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxCAL_SHOW_HOLIDAYS ); | 39 m_calendar = new wxCalendarCtrl( this, ID_CALNENDER, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxCAL_SHOW_HOLIDAYS ); |
| 38 bSizerR->Add( m_calendar, 0, wxALL, 5 ); | 40 bSizerR->Add( m_calendar, 0, wxALL, 5 ); |
| 39 | 41 |
| 40 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL ); | 42 m_buttonMake = new wxButton( this, ID_MKINDEX, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 43 bSizerR->Add( m_buttonMake, 0, wxALIGN_RIGHT|wxALL, 5 ); | |
| 41 | 44 |
| 42 m_buttonMake = new wxButton( this, ID_MKINDEX, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); | 45 bSizerR->Add( 0, 300, 1, wxEXPAND, 5 ); |
| 43 bSizerBtn->Add( m_buttonMake, 0, wxALL, 5 ); | 46 |
| 44 | 47 m_richText = new wxRichTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 100 ), wxVSCROLL|wxBORDER_NONE|wxWANTS_CHARS ); |
| 48 bSizerR->Add( m_richText, 0, wxEXPAND|wxALL, 5 ); | |
| 49 | |
| 45 m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); | 50 m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 46 bSizerBtn->Add( m_buttonClose, 0, wxALL, 5 ); | 51 bSizerR->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxALL, 5 ); |
| 47 | |
| 48 bSizerR->Add( bSizerBtn, 1, wxALIGN_RIGHT, 5 ); | |
| 49 | 52 |
| 50 bSizerTop->Add( bSizerR, 0, wxALIGN_RIGHT, 5 ); | 53 bSizerTop->Add( bSizerR, 0, wxALIGN_RIGHT, 5 ); |
| 51 | 54 |
| 52 this->SetSizer( bSizerTop ); | 55 this->SetSizer( bSizerTop ); |
| 53 this->Layout(); | 56 this->Layout(); |
| 54 | 57 |
| 55 this->Centre( wxBOTH ); | 58 this->Centre( wxBOTH ); |
| 59 | |
| 60 CheckHhs(); | |
| 56 } | 61 } |
| 57 | 62 |
| 58 IndexDialog::~IndexDialog() | 63 IndexDialog::~IndexDialog() |
| 59 { | 64 { |
| 60 } | 65 } |
| 61 | 66 |
| 62 // Event Table | 67 // Event Table |
| 63 BEGIN_EVENT_TABLE( IndexDialog, wxDialog ) | 68 BEGIN_EVENT_TABLE( IndexDialog, wxDialog ) |
| 64 //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) | 69 EVT_CALENDAR_PAGE_CHANGED( ID_CALNENDER, IndexDialog::OnPage ) |
| 65 //EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) | 70 EVT_CALENDAR( ID_CALNENDER, IndexDialog::OnSelect ) |
| 71 EVT_BUTTON( ID_MKINDEX, IndexDialog::OnMakeIndex ) | |
| 66 END_EVENT_TABLE() | 72 END_EVENT_TABLE() |
| 67 | 73 |
| 74 // Event Handlers & Functions | |
| 75 void IndexDialog::OnSelect( wxCalendarEvent& WXUNUSED(event) ) | |
| 76 { | |
| 77 UpdateList(); | |
| 78 } | |
| 79 | |
| 80 void IndexDialog::OnMakeIndex( wxCommandEvent& WXUNUSED(event) ) | |
| 81 { | |
| 82 wxDateTime dt = m_calendar->GetDate(); | |
| 83 wxString month = dt.Format( wxT("%m") ); | |
| 84 wxString year = dt.Format( wxT("%Y") ); | |
| 85 if ( month.IsSameAs( wxT("01") ) || month.IsSameAs( wxT("02") ) || month.IsSameAs( wxT("03") ) ) { | |
| 86 long y; | |
| 87 year.ToLong( &y, 10 ); | |
| 88 y--; | |
| 89 year = wxString::Format( wxT("%d"), y ); | |
| 90 } | |
| 91 | |
| 92 | |
| 93 wxString date = dt.Format( wxT("%Y%m%d") ); | |
| 94 wxString datedir = m_rootdir + wxFILE_SEP_PATH + year + wxFILE_SEP_PATH + date; | |
| 95 if ( !wxDir::Exists( datedir ) ) { | |
| 96 wxMessageBox( wxT("フォルダが存在しません.") + datedir ); | |
| 97 return; | |
| 98 } | |
| 99 | |
| 100 UpdateIndex( datedir, date ); | |
| 101 | |
| 102 UpdateList(); | |
| 103 wxMessageBox( wxT("インデックス作成が終了しました.") ); | |
| 104 } | |
| 105 | |
| 106 void IndexDialog::OnPage( wxCalendarEvent& WXUNUSED(event) ) {} | |
| 107 | |
| 108 void IndexDialog::UpdateList( void ) | |
| 109 { | |
| 110 wxDateTime dt = m_calendar->GetDate(); | |
| 111 wxString ymd = dt.Format( wxT("%Y%m%d") ); | |
| 112 | |
| 113 wxArrayString ccn = GetCcnByDate( ymd ); | |
| 114 | |
| 115 m_listCtrl->DeleteAllItems(); | |
| 116 | |
| 117 wxString buf; | |
| 118 for ( int i = 0; i < ccn.GetCount(); i++ ) { | |
| 119 m_listCtrl->InsertItem( i, -1 ); | |
| 120 buf.Printf( wxT("%02d"), i + 1 ); | |
| 121 m_listCtrl->SetItem( i, 0, buf, -1 ); // No | |
| 122 | |
| 123 wxArrayString ary = wxSplit( ccn[i], '_', '\\' ); // hhsno, path, date | |
| 124 buf = GetHhsInfoByHhsNo( ary[0] ); | |
| 125 wxString name = buf.BeforeFirst( '_' ); | |
| 126 wxString ccnn = ary[1].Mid( 17, 3 ); | |
| 127 | |
| 128 m_listCtrl->SetItem( i, 1, ary[2], -1 ); // date | |
| 129 m_listCtrl->SetItem( i, 2, ccnn, -1 ); // ccn | |
| 130 m_listCtrl->SetItem( i, 3, ary[0], -1 ); // hhsno | |
| 131 m_listCtrl->SetItem( i, 4, name, -1 ); // name | |
| 132 | |
| 133 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); | |
| 134 } | |
| 135 } | |
| 136 | |
| 137 void IndexDialog::CheckHhs( void ) | |
| 138 { | |
| 139 wxArrayString result = CheckDBs(); | |
| 140 | |
| 141 for ( int i = 0; i < result.GetCount(); i++ ) { | |
| 142 m_richText->WriteText( wxT("チェック対象 : ") ); | |
| 143 m_richText->WriteText( result[i] ); | |
| 144 m_richText->Newline(); | |
| 145 } | |
| 146 m_richText->SetEditable( false ); | |
| 147 } | |
| 148 |
