| | |
| | | #include "ui_clientmainwindow.h" |
| | | #include <QDebug> |
| | | #include <QFileDialog> |
| | | #include <QMessageBox> |
| | | #include <QSqlQuery> |
| | | #include <QSqlRecord> |
| | | |
| | | extern int g_comId; |
| | | |
| | | ClientMainWindow::ClientMainWindow(QWidget *parent) : |
| | | QMainWindow(parent), |
| | |
| | | |
| | | void ClientMainWindow::initUi() |
| | | { |
| | | m_searchInfo = new SearchInfo(this); |
| | | ui->tabWidget->addTab(m_searchInfo,"信息查询"); |
| | | |
| | | m_coverInfo = new CoverInfo(this); |
| | | m_coverInfo->setParent(ui->tab); |
| | | |
| | | m_auditPro = new AuditProject(this); |
| | | m_auditworkload = new AuditWorkload(this); |
| | | m_problemMon = new ProblemMoney(this); |
| | |
| | | |
| | | ui->stackedWidget->setCurrentIndex(0); |
| | | |
| | | m_coverInfo = new CoverInfo(this); |
| | | m_coverInfo->setParent(ui->tab); |
| | | // m_searchInfo = new SearchInfo(this); |
| | | // ui->tabWidget->addTab(m_searchInfo,"信息查询"); |
| | | |
| | | // m_coverInfo = new CoverInfo(this); |
| | | // m_coverInfo->setParent(ui->tab); |
| | | |
| | | // 隐藏掉某个选项 |
| | | ui->tabWidget->removeTab(3); // OK |
| | | |
| | | // 关联各个功能槽 |
| | | connect(m_coverInfo,SIGNAL(sendComName(QString)),m_searchInfo,SLOT(addComName(QString))); |
| | | |
| | | connect(this,SIGNAL(sendDataToAuditProject(QVariantList)),m_auditPro,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToAuditWorkLoad(QVariantList)),m_auditworkload,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToProblemMoney(QVariantList)),m_problemMon,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToProblemCount(QVariantList)),m_problemCnt,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToProblemRectification(QVariantList)),m_probleRect,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToProblemNoMoney(QVariantList)),m_problemNotMon,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToPunish(QVariantList)),m_punish,SLOT(showData(QVariantList))); |
| | | connect(this,SIGNAL(sendDataToCaseClue(QVariantList)),m_caseClue,SLOT(showData(QVariantList))); |
| | | |
| | | |
| | | } |
| | | |
| | | void ClientMainWindow::readDataFromExcel(QString path) |
| | | { |
| | | QAxObject excel("Excel.Application"); |
| | | excel.setProperty("Visible",false); |
| | | excel.setProperty("DisplayAlerts",false); |
| | | qDebug()<<"open:"<<path; |
| | | qDebug()<<"excel:"<<excel.className(); |
| | | QAxObject * wbs = excel.querySubObject("WorkBooks"); |
| | | QAxObject * wb = wbs->querySubObject("Open(QString&)",path); |
| | | //QAxObject* pWorkBook = excel.querySubObject("ActiveWorkBook"); |
| | | //QAxObject* pWorkSheets = pWorkBook->querySubObject("Sheets");//获取工作表 |
| | | QAxObject * shs = wb->querySubObject("Sheets"); // WorkSheets 也可以 |
| | | int cnt = shs->property("Count").toInt(); |
| | | qDebug()<<"cnt="<<cnt; |
| | | for(int i=0;i<cnt;++i){ |
| | | QAxObject * sheet = shs->querySubObject("Item(int)", i+1); |
| | | QString sheetName = sheet->property("Name").toString(); |
| | | qDebug()<<"sh name:"<<sheetName; |
| | | QAxObject *usedRange = sheet->querySubObject("UsedRange"); |
| | | int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); |
| | | int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); |
| | | qDebug()<<"r--c:"<<rows<<columns; |
| | | QVariant val = usedRange->dynamicCall("Value"); // 拿到二维表格 |
| | | QVariantList valRows = val.toList(); |
| | | // 公司名、统一信用代码 |
| | | QVariant uniCode = valRows[5].toList().at(1); |
| | | QVariant comName = valRows[6].toList().at(1); |
| | | if(comName.isValid()){ |
| | | if(!readDataFromSQL(comName.toString())){ |
| | | QMessageBox::information(this,"导入中断","请确认公司基本信息已经存在"); |
| | | return; |
| | | } |
| | | qDebug()<<comName<<g_comId; |
| | | } |
| | | |
| | | // 审计项目 |
| | | QVariantList audit_project; |
| | | for(int i=10;i<20;++i){ |
| | | audit_project.append(valRows[i].toList().at(4)); |
| | | } |
| | | qDebug()<<audit_project; |
| | | |
| | | // 审计工作量 |
| | | QVariantList audit_workload; |
| | | for(int i=20;i<21;++i){ |
| | | audit_workload.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 问题金额 |
| | | QVariantList problem_money; |
| | | for(int i=21;i<32;++i){ |
| | | problem_money.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 问题个数 |
| | | QVariantList problem_count; |
| | | for(int i=32;i<39;++i){ |
| | | problem_count.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 问题整改(金额类) |
| | | QVariantList problem_rectification; |
| | | for(int i=39;i<46;++i){ |
| | | problem_rectification.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 问题整改(非金额类) |
| | | QVariantList problem_nomoney; |
| | | for(int i=46;i<51;++i){ |
| | | problem_nomoney.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 处分 |
| | | QVariantList punish; |
| | | for(int i=51;i<55;++i){ |
| | | punish.append(valRows[i].toList().at(4)); |
| | | } |
| | | |
| | | // 案件线索 |
| | | QVariantList case_clue; |
| | | for(int i=55;i<57;++i){ |
| | | case_clue.append(valRows[i].toList().at(4)); |
| | | } |
| | | qDebug()<<case_clue; |
| | | |
| | | emit sendDataToAuditProject(audit_project); |
| | | emit sendDataToAuditWorkLoad(audit_workload); |
| | | emit sendDataToProblemMoney(problem_money); |
| | | emit sendDataToProblemCount(problem_count); |
| | | emit sendDataToProblemRectification(problem_rectification); |
| | | emit sendDataToProblemNoMoney(problem_nomoney); |
| | | emit sendDataToPunish(punish); |
| | | emit sendDataToCaseClue(case_clue); |
| | | |
| | | } |
| | | wbs->dynamicCall("Close()"); |
| | | excel.dynamicCall("Quit(void)"); |
| | | } |
| | | |
| | | void ClientMainWindow::on_pushButton_auditPro_clicked() |
| | |
| | | ui->listWidget->addItem(f); |
| | | } |
| | | } |
| | | |
| | | void ClientMainWindow::on_pushButton_importExcel_clicked() |
| | | { |
| | | QString path = QFileDialog::getOpenFileName(this,"选择表格:单位内部审计业务情况表","./","excel(*业务情况表*.xls)"); |
| | | qDebug()<<"path:"<<path; |
| | | if(path.size() > 1){ |
| | | readDataFromExcel(path); |
| | | } |
| | | } |
| | | |
| | | bool ClientMainWindow::readDataFromSQL(QString name) |
| | | { |
| | | QSqlQuery query; |
| | | QString sql; |
| | | if(name.size() > 1){ |
| | | sql = QString("select id,name from company_info where name='%1'").arg(name); |
| | | qDebug()<<"查询公司sql:"<<sql; |
| | | if(query.exec(sql)){ |
| | | qDebug()<<"OK sql"<<__FUNCTION__; |
| | | QSqlRecord res = query.record(); |
| | | qDebug()<<query.size()<<query.numRowsAffected()<<res.count(); |
| | | if(!query.next()){ |
| | | QMessageBox::information(this,"导入失败","公司名不存在库中,请先导入基本信息表"); |
| | | }else{ |
| | | g_comId = query.value(0).toInt(); |
| | | return true; |
| | | } |
| | | }else{ |
| | | qDebug()<<"fail sql"<<__FUNCTION__; |
| | | } |
| | | } |
| | | return false; |
| | | |
| | | } |