//////////////////////////////////////////////////////////////////////////////// //to obtain a storage home instance, it raises NotFound if it cannot find a //storage home that matches the given storage_home_id //////////////////////////////////////////////////////////////////////////////// StorageHomeBase_ptr CatalogBaseImpl::find_storage_home(const char* storage_home_id) { DEBUG_OUT("CatalogBaseImpl::find_storage_home() is called"); //find it in the list StorageHomeBase_var pHomeBase = StorageHomeBase::_nil(); for( homeBaseIter_=lHomeBases_.begin(); homeBaseIter_!=lHomeBases_.end(); homeBaseIter_++ ) { const char* szHomeName = (*homeBaseIter_)->getStorageHomeName(); if(strcmp(szHomeName, storage_home_id)==0) { pHomeBase = StorageHomeBase::_duplicate((*homeBaseIter_)); return pHomeBase._retn(); } } //check it whether in the database std::string strHomeID = storage_home_id; strHomeID = convert2Lowercase(strHomeID); if( IsConnected()==FALSE || IsTableExist(strHomeID.c_str())==FALSE ) throw CosPersistentState::NotFound(); //if not in the list, new one. StorageHomeFactory factory = NULL; factory = pConnector_->register_storage_home_factory(storage_home_id, factory); if( factory==NULL ) throw CosPersistentState::NotFound(); StorageHomeBaseImpl* pHomeBaseImpl = factory->create(); //factory->_remove_ref(); pHomeBaseImpl->Init(this, storage_home_id); lHomeBases_.push_back(pHomeBaseImpl); // deep copy or? pHomeBase = StorageHomeBase::_duplicate(pHomeBaseImpl); return pHomeBase._retn(); }
BOOL CMorphaResDlg::OnInitDialog() { CPropertyPage::OnInitDialog(); CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd(); CMorphaDataRetriveDlg& dlg = *(pMainFrm->m_pWndMorphadlg); CString strSQLCRMfi("select morpharesult.* into morphafordisplay \ from morpharesult,basicinfo,morphaimage,spermchait,morpharesultratio \ where morpharesult.pdetectno = basicinfo.pdetectno \ and morpharesult.pdetectno = morphaimage.pdetectno \ and morpharesult.pdetectno = spermchait.pdetectno \ and morpharesult.pdetectno = morpharesultratio.pdetectno"); try { if(IsTableExist(theConnection, "morphafordisplay") == true) { theConnection->Execute((LPCTSTR)"drop table morphafordisplay",NULL,adCmdText); } theConnection->Execute((LPCTSTR)strSQLCRMfi,NULL,adCmdText); CString strGetN("select count(*) from morphafordisplay"); _RecordsetPtr rs=theConnection->Execute((LPCSTR)strGetN,NULL,adCmdText); dlg.m_dp[0].nCurPage = 1; dlg.m_dp[0].nTotalRecord=rs->GetCollect((long)0).iVal; dlg.m_dp[0].nPageRecord = NUMPERPAGE; dlg.m_dp[0].nTotalPage = dlg.m_dp[0].nTotalRecord / dlg.m_dp[0].nPageRecord + (dlg.m_dp[0].nTotalRecord % dlg.m_dp[0].nPageRecord!=0); CString queryinfo; queryinfo.Format("共查询到%d条记录",dlg.m_dp[0].nTotalRecord); dlg.SetDlgItemText(IDC_STATIC_QUERY,queryinfo); if(dlg.m_dp[0].nTotalRecord == 0 ) { CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd(); pMainFrm->m_pWndMorphadlg->GetDlgItem(IDC_BTN_FIRSTPAGE)->EnableWindow(FALSE); pMainFrm->m_pWndMorphadlg->GetDlgItem(IDC_BTN_PREPAGE)->EnableWindow(FALSE); pMainFrm->m_pWndMorphadlg->GetDlgItem(IDC_BTN_NEXTPAGE)->EnableWindow(FALSE); pMainFrm->m_pWndMorphadlg->GetDlgItem(IDC_BTN_LASTPAGE)->EnableWindow(FALSE); pMainFrm->m_pWndMorphadlg->GetDlgItem(IDC_PAGENUM)->EnableWindow(FALSE); return FALSE; } int lowRow, upRow; dlg.GetPageBound(1,lowRow,upRow,dlg.m_dp[0]); GetRecordSet(rs,lowRow,upRow); int n=dlg.m_resdlg.m_wndMorphaDataList.SetData(rs); queryinfo.Format("第 %d / %d 页",dlg.m_dp[0].nCurPage,dlg.m_dp[0].nTotalPage); dlg.SetDlgItemText(IDC_PAGENUM,queryinfo); dlg.GetDlgItem(IDC_BTN_FIRSTPAGE)->EnableWindow(dlg.m_dp[dlg.IsInqueryState()].nCurPage != 1); dlg.GetDlgItem(IDC_BTN_PREPAGE)->EnableWindow(dlg.m_dp[dlg.IsInqueryState()].nCurPage != 1); dlg.GetDlgItem(IDC_BTN_NEXTPAGE)->EnableWindow(dlg.m_dp[dlg.IsInqueryState()].nCurPage != dlg.m_dp[dlg.IsInqueryState()].nTotalPage); dlg.GetDlgItem(IDC_BTN_LASTPAGE)->EnableWindow(dlg.m_dp[dlg.IsInqueryState()].nCurPage != dlg.m_dp[dlg.IsInqueryState()].nTotalPage ); } catch (_com_error& e) { MessageBox(e.Description()); return FALSE; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }