//查询数据 void CAffinityQuery::OnOK() { UpdateData(); CString strSql; CComFunc::GetSql(strSql,46);//查询语句 strSql.Replace("[XT001]",m_date1.Format("%Y%m%d") ); strSql.Replace("[XT002]",m_date2.Format("%Y%m%d") ); int iCbSel=m_cbType.GetCurSel(); if( !(iCbSel ==CB_ERR || iCbSel == 0) ) { CString strType; m_cbType.GetLBText(iCbSel,strType); strSql+=" AND l1.dechargetype='"+strType+"'"; } if( ! m_strKh.IsEmpty() ) { m_strKh.Replace("'","");//过滤掉单引号 m_strKh.Replace(";","");//过滤分号 strSql+=" AND l1.kahao1 like '"+m_strKh+"%'"; } if( ! m_strXm.IsEmpty() ) { m_strXm.Replace("'","");//过滤掉单引号 m_strXm.Replace(";","");//过滤分号 strSql+=" AND l2.xm like '"+m_strXm+"%'"; } iCbSel=m_cbDepart.GetCurSel(); if( !(iCbSel ==CB_ERR || iCbSel == 0) ) { strSql+=" AND l3.部门编码='"+m_aryDepart[iCbSel]+"'"; } strSql+=" ORDER By l1.riqi,l2.xm"; //排序方式 vector<int> vtCols; vtCols.push_back(14); vtCols.push_back(16); vtCols.push_back(17); vtCols.push_back(18); //账户余额列 vector<double> vtCount(vtCols.size(),0); //初化为0 CComFunc::ReadDataForGrid(m_grid,strSql,m_grid.GetColumnCount(),vtCols,vtCount,0); m_grid.AutoSize(); }
IDispatchPtr ExcelControllerImpl08::DoOpenDocument(const CStdString& sDocumentPath, bool bReadOnly) { if(sDocumentPath.IsEmpty()) throw Workshare::ArgumentException(_T("sDocumentPath"), _T("An empty filename is not allowed.")); if(!::PathFileExists(sDocumentPath)) throw Workshare::System::IO::FileNotFoundException(sDocumentPath, _T("Expected an existing excel workbook filename to open.")); //TODO: (EW/WS) Refer to CloseDocument for a description of a latent defect which may be caused by the following line. SetScreenUpdating(false); Excel::_WorkbookPtr spDocument = FindOpenDocument(sDocumentPath); if(spDocument) { if (!bReadOnly) { if (spDocument->ReadOnly) throw Workshare::Com::ComException(_T("Failed to open a READ-ONLY document for write access."), E_FAIL); if (!spDocument->Saved) spDocument->Save(); } } else { Excel::_ApplicationPtr spApplication = GetApplication(); spApplication->EnableEvents = VARIANT_FALSE; //The events are on by default, so no need to store the original value LONG_PTR nNewDocumentCount = spApplication->Workbooks->Count + 1; try { _variant_t vtReadOnly = bReadOnly; _variant_t vtUpdateLinks(false); spDocument = spApplication->Workbooks->Open(sDocumentPath.c_str(), vtUpdateLinks, vtReadOnly); WaitForWorkbookOpened(sDocumentPath); } catch (const Workshare::Com::ComException&) { if(nNewDocumentCount != spApplication->Workbooks->Count) throw; _variant_t vtCount(static_cast<long>(nNewDocumentCount)); spDocument = spApplication->Workbooks->GetItem(&vtCount); } } DisableUnwantedOptions(); spDocument->put_Saved(LocaleHelper::GetLocaleIDForInstalledExcel(spDocument), VARIANT_TRUE); return spDocument; }
void CGhQuery::OnClassify() //人员汇总明细 { CFormGhList *pf=(CFormGhList*)theApp.pParentGrid.pGrid; CComFunc::SetGridHeader(pf->m_grid,GRID_ID/* 表格头部ID*/,vtAlign); UpdateData(); pf->m_grid.SetRowCount(2); CString strConstruct(BLANKSTR); vector<string> vtSz; vtSz.push_back( MYSQL_PRC_RPT); //存储过程名 vtSz.push_back("1"); //查询 vtSz.push_back("E"); //返回结果集 unsigned long iStart(0),iEnd(0); int iSel(0); CString strSql; // if( ! m_strStart.IsEmpty() ){ //期号范围 strSql.Format("%ld",atol(m_strStart) ); //开始期号 vtSz.push_back( (LPCSTR)strSql); strSql.Format("%ld",atol(m_strEnd) ); //结束期号 vtSz.push_back( (LPCSTR)strSql); // } vtSz.push_back( (LPCSTR)m_date.Format("%Y-%m-%d") ); vtSz.push_back( (LPCSTR)m_date2.Format("%Y-%m-%d") ); iSel=m_Factory.GetCurSel(); if( !(iSel == CB_ERR || iSel == 0 )) strConstruct.Format("%ld",atol(arrFactory[iSel] ) ); else strConstruct=BLANKSTR; vtSz.push_back((LPCSTR)strConstruct); vtSz.push_back((LPCSTR) m_strEditor); iSel= m_Type.GetCurSel(); if( !(iSel == CB_ERR || iSel == 0 )) strConstruct.Format("%ld",atol(arrType[iSel] ) ); else strConstruct=BLANKSTR; vtSz.push_back( (LPCSTR)strConstruct ); _RecordsetPtr rec; CComFunc::callSqlPro(vtSz,rec); vector<int> vtCol; vtCol.push_back(3); vector<double> vtCount(1,0); CComFunc::ReadDataForGrid(pf->m_grid,rec,vtCol,vtCount,vtAlign); }
// 查询操作 改为存储过程调用 UINT CGhQuery::QueryGhList(LPVOID ps) { CFormGhList *pf=(CFormGhList*)theApp.pParentGrid.pGrid; CGhQuery * pd =(CGhQuery *) ((CProgressIndicate *) ps )->pDialog ; CComFunc::SetGridHeader(pf->m_grid,CFormGhList::GRID_ID/* 表格头部ID*/,pf->vtAlign); pd->UpdateData(); pf->m_grid.SetRowCount(2); int iSel(0); vector<string> vtSz; vtSz.push_back(MYSQL_PRC_RPT); //存储过程名 vtSz.push_back("1"); //查询 vtSz.push_back("7"); //稿费查询 CString str(""); //日期 vtSz.push_back((LPCSTR)pd->m_date.Format("%Y-%m-%d")); vtSz.push_back((LPCSTR)pd->m_date2.Format("%Y-%m-%d")); //报刊类型 iSel= pd->m_Type.GetCurSel(); if( !(iSel == CB_ERR || iSel == 0 )) str=pd->arrType[iSel] ; vtSz.push_back((LPCSTR)str); //姓名 pd->m_strEditor.TrimRight(); vtSz.push_back((LPCSTR)pd->m_strEditor ); //起止期号 vtSz.push_back((LPCSTR)pd->m_strStart); vtSz.push_back((LPCSTR)pd->m_strEnd); //单位ID iSel=pd->m_Factory.GetCurSel(); str=""; if( !(iSel == CB_ERR || iSel == 0 )) str=pd->arrFactory[iSel] ; vtSz.push_back((LPCSTR)str); //文章类型 iSel= pd->m_articleType.GetCurSel(); str=""; if( !(iSel == CB_ERR || iSel == 0 )) str=pd->arrArticleType[iSel] ; vtSz.push_back((LPCSTR)str); //标题 pd->m_strTitle.TrimRight(); vtSz.push_back((LPCSTR)pd->m_strTitle); //版面号 pd->m_strLayoutNum.TrimRight(); vtSz.push_back((LPCSTR) pd->m_strLayoutNum); _RecordsetPtr rec; CComFunc::callSqlPro(vtSz,rec); vector<int> vtCol; vtCol.push_back(10); vector<double> vtCount(1,0); CComFunc::ReadDataForGrid(pf->m_grid,rec,vtCol,vtCount,pf->vtAlign); ((CProgressIndicate *)ps)->ConnectFlag =1; ((CProgressIndicate *)ps)->SendMessage(WM_CLOSE,NULL,NULL); pd->SendMessage(WM_CLOSE,NULL,NULL); return true; }