#include "converinfo2.h" #include "ui_converinfo2.h" #include #include #include #include #include #pragma execution_character_set("utf-8") ConverInfo2::ConverInfo2(QWidget *parent) : QMainWindow(parent), ui(new Ui::ConverInfo2) { ui->setupUi(this); m_menu = nullptr; //initUi(); //readInfo(); // 加载表格 addMenu(); // 增加菜单 disableWheelEvent(); // 禁用下拉框的滚轮事件 // 自适应处理 ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); } ConverInfo2::~ConverInfo2() { delete ui; } void ConverInfo2::initUi() { // 查询表中所有的公司名字,放到树形菜单中 QStringList comInfo; comInfo<<"码蚁软件"<<"C++课程体系"<<"嵌入式课程体系"; QTreeWidgetItem *top = new QTreeWidgetItem(ui->treeWidget,comInfo); ui->treeWidget->addTopLevelItem(top); ui->treeWidget->expandAll(); QTreeWidgetItem *it1 = new QTreeWidgetItem(top); it1->setText(0,"开发部1"); QTreeWidgetItem *it2 = new QTreeWidgetItem(top); it2->setText(0,"开发部2"); QTreeWidgetItem *it3 = new QTreeWidgetItem(top); it3->setText(0,"开发部3"); QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); top1->setText(0,"码蚁集团"); QTreeWidgetItem *it4 = new QTreeWidgetItem(top1); it4->setText(0,"开发部4"); top1->setCheckState(0,Qt::Checked); it4->setCheckState(0,Qt::Checked); // 复选框状态处理 connect(ui->treeWidget,QOverload::of(&QTreeWidget::itemClicked),this,[=](QTreeWidgetItem* it,int index){ qDebug()<childCount();++i){ top1->child(i)->setCheckState(0,top1->checkState(0)); } } }); // 设置菜单:添加单位、删除单位 m_menu = new QMenu(this); m_menu->addAction("删除"); m_menu->addAction("增加"); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showMenu(QPoint))); connect(m_menu->actions().at(0),SIGNAL(triggered(bool)),this,SLOT(deleteInfo())); connect(m_menu->actions().at(1),SIGNAL(triggered(bool)),this,SLOT(addInfo())); // 单位内容修改 // 右边可编辑内容 //ui->scrollArea->setWidget(ui->frame); } void ConverInfo2::showMenu(QPoint p) { QTreeWidgetItem * item = ui->treeWidget->itemAt(p); if(item==nullptr)return; m_curItem = item; qDebug()<<"当前节点:"<text(0); m_menu->exec(QCursor::pos()); } void ConverInfo2::addInfo() { if(m_curItem==nullptr)return; qDebug()<<"添加公司信息,在节点:"<text(0); on_pushButton_laodFile_clicked(); } void ConverInfo2::deleteInfo() { if(m_curItem==nullptr)return; qDebug()<<"删除公司信息,节点:"<text(0); auto resList = m_curItem->takeChildren(); qDebug()<<"删除数量:"<data(index).toString(); qDebug()<<"双击"<lineEdit_creditCode->setText(curCominfo.creditCode); ui->lineEdit_name->setText(QString::fromLocal8Bit( curCominfo.name)); qDebug()<<"name:"<comboBox_comType->setCurrentText(QString::fromLocal8Bit(curCominfo.comType)); ui->lineEdit_business->setText(QString::fromLocal8Bit(curCominfo.business)); ui->lineEdit_businessCode->setText(curCominfo.businessCode); ui->lineEdit_addr->setText(QString::fromLocal8Bit(curCominfo.addr)); ui->lineEdit_areaCode->setText(curCominfo.areaCode); ui->lineEdit_townCode->setText(curCominfo.townCode); ui->comboBox_scale->setCurrentText(QString::fromLocal8Bit(curCominfo.scale)); ui->lineEdit_people->setText(QString::number(curCominfo.people)); ui->lineEdit_representative->setText(QString::fromLocal8Bit(curCominfo.representative)); ui->comboBox_standardType->setCurrentText(QString::fromLocal8Bit(curCominfo.standardType)); ui->lineEdit_trunkCode->setText(curCominfo.trunkCode); ui->lineEdit_fixedTel->setText(curCominfo.fixedTel); ui->lineEdit_postCode->setText(curCominfo.postCode); ui->lineEdit_email->setText(curCominfo.email); ui->lineEdit_webSite->setText(curCominfo.webSite); // 二、单位组织结构情况 ui->comboBox_hasUpLegal->setCurrentText(QString::fromLocal8Bit(curCominfo.hasUpLegal)); ui->lineEdit_upCreditCode->setText(QString::fromLocal8Bit(curCominfo.upCreditCode)); ui->lineEdit_oldCreditCode->setText(curCominfo.oldCreditCode); ui->lineEdit_upName->setText(QString::fromLocal8Bit(curCominfo.upName)); // 三、总审计师与内审机构基本情况 ui->comboBox_hasChiefDesigner->setCurrentText(QString::fromLocal8Bit(curCominfo.hasChiefDesigner)); ui->comboBox_ChiefDesignerLevel->setCurrentText(QString::fromLocal8Bit(curCominfo.ChiefDesignerLevel)); ui->comboBox_employmentMode->setCurrentText(QString::fromLocal8Bit(curCominfo.employmentMode)); ui->comboBox_hasSetIntervalAudit->setCurrentText(QString::fromLocal8Bit(curCominfo.hasSetIntervalAudit)); ui->lineEdit_internalName->setText(QString::fromLocal8Bit(curCominfo.internalName)); ui->comboBox_leadingOrganization->setCurrentText(QString::fromLocal8Bit(curCominfo.leadingOrganization)); ui->comboBox_hasSetSeparateIA->setCurrentText(QString::fromLocal8Bit(curCominfo.hasSetSeparateIA)); ui->checkBox_financeDepartment->setChecked(curCominfo.financeDepartment); ui->checkBox_legalDepartment->setChecked(curCominfo.legalDepartment); ui->checkBox_internalConDepart->setChecked(curCominfo.internalConDepart); ui->checkBox_disceplineInDepart->setChecked(curCominfo.disceplineInDepart); ui->checkBox_otherDepart->setChecked(curCominfo.otherDepart); ui->comboBox_intavalAuditLeval->setCurrentText(QString::fromLocal8Bit(curCominfo.intavalAuditLeval)); // 四、内审人员配备基本情况 ui->lineEdit_organazationNum->setText(QString::number(curCominfo.organazationNum)); ui->lineEdit_realNum->setText(QString::number(curCominfo.realNum)); ui->lineEdit_professionalNum->setText(QString::number(curCominfo.professionalNum)); ui->lineEdit_CIANum->setText(QString::number(curCominfo.CIANum)); ui->lineEdit_masterNum->setText(QString::number(curCominfo.masterNum)); ui->lineEdit_undergraduatesNum->setText(QString::number(curCominfo.undergraduatesNum)); ui->lineEdit_juniorNum->setText(QString::number(curCominfo.juniorNum)); ui->lineEdit_seniorNum->setText(QString::number(curCominfo.seniorNum)); ui->lineEdit_intermediateNum->setText(QString::number(curCominfo.intermediateNum)); ui->lineEdit_primaryNum->setText(QString::number(curCominfo.primaryNum)); ui->lineEdit_noTitleNum->setText(QString::number(curCominfo.noTitleNum)); ui->lineEdit_upFiftyOldNum->setText(QString::number(curCominfo.upFiftyOldNum)); ui->lineEdit_upThirtyOldNum->setText(QString::number(curCominfo.upThirtyOldNum)); ui->lineEdit_downThirtyOldNum->setText(QString::number(curCominfo.downThirtyOldNum)); ui->lineEdit_auditNum->setText(QString::number(curCominfo.auditNum)); ui->lineEdit_accountingNum->setText(QString::number(curCominfo.accountingNum)); ui->lineEdit_economyNum->setText(QString::number(curCominfo.economyNum)); ui->lineEdit_lawNum->setText(QString::number(curCominfo.lawNum)); ui->lineEdit_managerNum->setText(QString::number(curCominfo.managerNum)); ui->lineEdit_itNum->setText(QString::number(curCominfo.itNum)); ui->lineEdit_engineeringNum->setText(QString::number(curCominfo.engineeringNum)); ui->lineEdit_otherNum->setText(QString::number(curCominfo.otherNum)); // 其他的4个信息 ui->lineEdit_statisticalConOfficer->setText(QString::fromLocal8Bit(curCominfo.statisticalConOfficer)); ui->lineEdit_personFilling->setText(QString::fromLocal8Bit(curCominfo.personFilling)); ui->lineEdit_officerTel->setText(QString::fromLocal8Bit(curCominfo.officerTel)); ui->lineEdit_fillingDateTime->setText(QString::fromLocal8Bit(curCominfo.fillingDateTime)); } void ConverInfo2::readInfo() { // QXlsx::Document doc("./debug/Data/test.xlsx"); // QString cc = doc.read("A1").toString(); // qDebug()<<"cc"<label_creditCode->setText(cc); extern QString g_dataRootPath; QString dirPath = "./debug/Data"; QString dirPathRelease = "./release/Data"; QString dirPathData = "./Data"; QDir dir(dirPathData); if(dir.exists()){ dirPath = dirPathData; // 存在则覆盖 } QDir dirRe(dirPathRelease); if(dirRe.exists()){ dirPath = dirPathRelease; } g_dataRootPath = dirPath; // 将根目录保存起来 QStringList list; QDirIterator it(dirPath, {"*.xls","*.xlsx"}, QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); while(it.hasNext()) { it.next(); list.append(it.fileInfo().absoluteFilePath()); } int allSize = list.size(); float cntIdx=1.0; foreach(QString str, list) { qDebug() << str; int index = str.indexOf("内审统01表"); qDebug()<<"index:"< 0){ QAxObject excel("ket.Application"); if(!excel.setControl("ket" ".Application")){ // windows内核 excel.setControl("Excel.Application"); // wps内核 } excel.setProperty("Visible",false); excel.setProperty("DisplayAlerts",false); qDebug()<<"open:"<className(); QAxObject * wb = wbs->querySubObject("Open(QString&)",str); //QAxObject* pWorkBook = excel.querySubObject("ActiveWorkBook"); //QAxObject* pWorkSheets = pWorkBook->querySubObject("Sheets");//获取工作表 //QAxObject * shs = wb->querySubObject("Sheets"); // WorkSheets 也可以 QAxObject * shs = wb->querySubObject("WorkSheets"); // WorkSheets 也可以 // // 指定单元格拿 // QAxObject *cell = shs->querySubObject("Cells(int, int)",82,1); // qDebug()<<"Cells:82-0:"<querySubObject("Cells(int, int)",82,0)->dynamicCall("Value()").toString(); // qDebug()<<"Cells:82-1:"<dynamicCall("Value()").toString(); int cnt = shs->property("Count").toInt(); qDebug()<<"cnt="<querySubObject("Item(int)", i+1); QString sheetName = sheet->property("Name").toString(); qDebug()<<"sh name:"<querySubObject("UsedRange"); int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); qDebug()<<"r--c:"<dynamicCall("Value"); // 拿到二维表格 QVariantList valRows = val.toList(); // 遍历每一项 // for(int i=0;ilabel_creditCode->setText(uniCode.toString()); strcpy(curComInfo.creditCode,uniCode.toString().toLocal8Bit().data()); } // 单位名称 QVariant name = valRows[9].toList().at(8); if(name.isValid()){ ui->label_name->setText(name.toString()); //QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); //top1->setText(0,name.toString()); strcpy(curComInfo.name,name.toString().toLocal8Bit().data()); }else{ ui->label_name->setText(""); } // 机构类型 QVariant comType = valRows[12].toList().at(3); if(comType.isValid()){ ui->label_comType->setText(comType.toString()); strcpy(curComInfo.comType,comType.toString().toLocal8Bit().data()); }else{ ui->label_comType->setText(""); } // 主要业务活动 QString business; QVariant first = valRows[18].toList().at(2); if(first.isValid()){ business.append(first.toString()); } QVariant sec = valRows[18].toList().at(5); if(sec.isValid()){ business += "、"; business.append(sec.toString()); } QVariant third = valRows[18].toList().at(8); if(third.isValid()){ business += "、"; business.append(third.toString()); } if(business.size() > 0){ ui->label_business->setText(business); ui->label_business->setToolTip(business); strcpy(curComInfo.business,business.toLocal8Bit().data()); }else{ ui->label_business->setText(""); } // 业务代码 QVariant busCode = valRows[19].toList().at(4); if(busCode.isValid()){ ui->label_businessCode->setText(busCode.toString()); strcpy(curComInfo.businessCode,busCode.toString().toLocal8Bit().data()); }else{ ui->label_businessCode->setText(""); } // 注册地址 QString addr=""; QVariant province = valRows[21].toList().at(1); // 省份 QVariant city = valRows[21].toList().at(4); // 城市 QVariant district = valRows[21].toList().at(7); // 管辖区 QVariant village = valRows[22].toList().at(2); // 乡镇 QVariant street = valRows[22].toList().at(4); // 街道 QVariant Sub = valRows[23].toList().at(2); // 街道办事处 QVariant committee = valRows[25].toList().at(3); // 居委会 //qDebug()<10){ ui->label_addr->setText(addr); strcpy(curComInfo.addr,addr.toLocal8Bit().data()); }else{ ui->label_addr->setText(""); } // 区域代码 QVariant areaCode = valRows[24].toList().at(2); if(areaCode.isValid()){ ui->label_areaCode->setText(areaCode.toString()); strcpy(curComInfo.areaCode,areaCode.toString().toLocal8Bit().data()); }else{ ui->label_areaCode->setText(""); } // 城乡代码 QVariant townCode = valRows[24].toList().at(6); if(townCode.isValid()) { ui->label_townCode->setText(townCode.toString()); strcpy(curComInfo.townCode,townCode.toString().toLocal8Bit().data()); }else{ ui->label_townCode->setText(""); } // 单位规模 QVariant scale = valRows[25].toList().at(3); if(scale.isValid()){ ui->label_scale->setText(scale.toString()); strcpy(curComInfo.scale,scale.toString().toLocal8Bit().data()); }else{ ui->label_scale->setText(""); } // 从业人数 QVariant people = valRows[26].toList().at(6); if(people.isValid()) { ui->label_people->setText(people.toString()); //strcpy(curComInfo.people,people.toString().toLocal8Bit().data()); curComInfo.people = people.toInt(); }else{ ui->label_people->setText(""); } // 法人 QVariant representative = valRows[27].toList().at(4); if(representative.isValid()) { ui->label_representative->setText(representative.toString()); strcpy(curComInfo.representative,representative.toString().toLocal8Bit().data()); }else{ ui->label_representative->setText(""); } // 会计标准类别 standardType QVariant standardType = valRows[27].toList().at(8); if(standardType.isValid()){ ui->label_standardType->setText(standardType.toString()); strcpy(curComInfo.standardType,standardType.toString().toLocal8Bit()); }else{ ui->label_standardType->setText(""); } // 长途区号 QVariant trunkCode = valRows[31].toList().at(2); if(trunkCode.isValid()){ ui->label_trunkCode->setText(trunkCode.toString()); strcpy(curComInfo.trunkCode,trunkCode.toString().toLocal8Bit().data()); }else{ ui->label_trunkCode->setText(""); } // 固定电话 QVariant fixedTel = valRows[32].toList().at(2); if(fixedTel.isValid()) { ui->label_fixedTel->setText(fixedTel.toString()); strcpy(curComInfo.fixedTel,fixedTel.toString().toLocal8Bit().data()); }else{ ui->label_fixedTel->setText(""); } // 邮政编码 QVariant postCode = valRows[33].toList().at(2); if(postCode.isValid()){ ui->label_postCode->setText(postCode.toString()); strcpy(curComInfo.postCode,postCode.toString().toLocal8Bit().data()); }else{ ui->label_postCode->setText(""); } // 电子邮箱 QVariant email = valRows[30].toList().at(5); if(email.isValid()) { ui->label_email->setText(email.toString()); strcpy(curComInfo.email,email.toString().toLocal8Bit().data()); }else{ ui->label_email->setText(""); } // 网址 QVariant webSite = valRows[32].toList().at(5); if(webSite.isValid()) { ui->label_webSite->setText(webSite.toString()); strcpy(curComInfo.webSite,webSite.toString().toLocal8Bit().data()); }else{ ui->label_webSite->setText(""); } // 二、单位组织结构情况 // 是否有上一级法人 QVariant hasUpLegal = valRows[35].toList().at(4); if(hasUpLegal.isValid()){ strcpy(curComInfo.hasUpLegal,hasUpLegal.toString().toLocal8Bit().data()); qDebug()<<"has up legal"<dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); qDebug()<<"单位信息数量:"<addAction("删除"); m_menu->addAction("增加"); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showMenu(QPoint))); connect(m_menu->actions().at(0),SIGNAL(triggered(bool)),this,SLOT(deleteInfo())); connect(m_menu->actions().at(1),SIGNAL(triggered(bool)),this,SLOT(addInfo())); } void ConverInfo2::on_pushButton_commit_clicked() { // 将编辑框的数据更新到map中和数据库中,后期可以更新到文件中 // 单位基本情况 QString creditCode = ui->lineEdit_creditCode->text(); QString name = ui->lineEdit_name->text(); QString comType = ui->comboBox_comType->currentText(); QString business = ui->lineEdit_business->text(); QString businessCode = ui->lineEdit_businessCode->text(); QString addr = ui->lineEdit_addr->text(); QString areaCode = ui->lineEdit_areaCode->text(); QString townCode = ui->lineEdit_townCode->text(); QString scale = ui->comboBox_scale->currentText(); QString people = ui->lineEdit_people->text(); QString representative = ui->lineEdit_representative->text(); QString standardType = ui->comboBox_standardType->currentText(); QString trunkCode = ui->lineEdit_trunkCode->text(); QString fixedTel = ui->lineEdit_fixedTel->text(); QString postCode = ui->lineEdit_postCode->text(); QString email = ui->lineEdit_email->text(); QString webSite = ui->lineEdit_webSite->text(); // 单位组织结构情况 QString hasUpLegal = ui->comboBox_hasUpLegal->currentText(); QString upCreditCode = ui->lineEdit_upCreditCode->text(); QString oldCreditCode = ui->lineEdit_oldCreditCode->text(); QString upName = ui->lineEdit_upName->text(); // 总审计师与内审机构基本情况 QString hasChiefDesigner = ui->comboBox_hasChiefDesigner->currentText(); QString ChiefDesignerLevel = ui->comboBox_ChiefDesignerLevel->currentText(); QString employmentMode = ui->comboBox_employmentMode->currentText(); QString hasSetIntervalAudit = ui->comboBox_hasSetIntervalAudit->currentText(); QString internalName = ui->lineEdit_internalName->text(); QString leadingOrganization = ui->comboBox_leadingOrganization->currentText(); QString hasSetSeparateIA = ui->comboBox_hasSetSeparateIA->currentText(); bool financeDepartment = ui->checkBox_financeDepartment->isChecked(); bool legalDepartment = ui->checkBox_legalDepartment->isChecked(); bool internalConDepart = ui->checkBox_internalConDepart->isChecked(); bool disceplineInDepart = ui->checkBox_disceplineInDepart->isChecked(); bool otherDepart = ui->checkBox_otherDepart->isChecked(); QString intavalAuditLeval = ui->comboBox_intavalAuditLeval->currentText(); // 四、内审人员配备基本情况 int organazationNum = ui->lineEdit_organazationNum->text().toInt(); int realNum = ui->lineEdit_realNum->text().toInt(); int professionalNum = ui->lineEdit_professionalNum->text().toInt(); int CIANum = ui->lineEdit_CIANum->text().toInt(); int masterNum = ui->lineEdit_masterNum->text().toInt(); int undergraduatesNum = ui->lineEdit_undergraduatesNum->text().toInt(); int juniorNum = ui->lineEdit_juniorNum->text().toInt(); int seniorNum = ui->lineEdit_seniorNum->text().toInt(); int intermediateNum = ui->lineEdit_intermediateNum->text().toInt(); int primaryNum = ui->lineEdit_primaryNum->text().toInt(); int noTitleNum = ui->lineEdit_noTitleNum->text().toInt(); int upFiftyOldNum = ui->lineEdit_upFiftyOldNum->text().toInt(); int upThirtyOldNum = ui->lineEdit_upThirtyOldNum->text().toInt(); int downThirtyOldNum = ui->lineEdit_downThirtyOldNum->text().toInt(); int auditNum = ui->lineEdit_auditNum->text().toInt(); int accountingNum = ui->lineEdit_accountingNum->text().toInt(); int economyNum = ui->lineEdit_economyNum->text().toInt(); int lawNum = ui->lineEdit_lawNum->text().toInt(); int managerNum = ui->lineEdit_managerNum->text().toInt(); int itNum = ui->lineEdit_itNum->text().toInt(); int engineeringNum = ui->lineEdit_engineeringNum->text().toInt(); int otherNum = ui->lineEdit_otherNum->text().toInt(); // 后面的4个信息 QString statisticalConOfficer = ui->lineEdit_statisticalConOfficer->text(); QString personFilling = ui->lineEdit_personFilling->text(); QString officerTel = ui->lineEdit_officerTel->text(); QString fillingDateTime = ui->lineEdit_fillingDateTime->text(); qDebug()<<"统计负责人"<treeWidget); top1->setText(0,name); } auto &curComInfo = m_nameAndComInfos[name]; strcpy(curComInfo.creditCode,creditCode.toLocal8Bit().data()); strcpy(curComInfo.name,name.toLocal8Bit().data()); strcpy(curComInfo.comType,comType.toLocal8Bit().data()); strcpy(curComInfo.business,business.toLocal8Bit().data()); strcpy(curComInfo.businessCode,businessCode.toLocal8Bit().data()); strcpy(curComInfo.addr,addr.toLocal8Bit().data()); strcpy(curComInfo.areaCode,areaCode.toLocal8Bit().data()); strcpy(curComInfo.townCode,townCode.toLocal8Bit().data()); strcpy(curComInfo.scale,scale.toLocal8Bit().data()); curComInfo.people = people.toInt(); // index 10 strcpy(curComInfo.representative,representative.toLocal8Bit().data()); strcpy(curComInfo.standardType,standardType.toLocal8Bit().data()); strcpy(curComInfo.trunkCode,trunkCode.toLocal8Bit().data()); strcpy(curComInfo.fixedTel,fixedTel.toLocal8Bit().data()); strcpy(curComInfo.postCode,postCode.toLocal8Bit().data()); strcpy(curComInfo.email,email.toLocal8Bit().data()); strcpy(curComInfo.webSite,webSite.toLocal8Bit().data()); // index 17 // 二 strcpy(curComInfo.hasUpLegal,hasUpLegal.toLocal8Bit().data()); strcpy(curComInfo.upCreditCode,upCreditCode.toLocal8Bit().data()); strcpy(curComInfo.oldCreditCode,oldCreditCode.toLocal8Bit().data()); strcpy(curComInfo.upName,upName.toLocal8Bit().data()); // index 21 // 三 strcpy(curComInfo.hasChiefDesigner,hasChiefDesigner.toLocal8Bit().data()); strcpy(curComInfo.ChiefDesignerLevel,ChiefDesignerLevel.toLocal8Bit().data()); strcpy(curComInfo.employmentMode,employmentMode.toLocal8Bit().data()); strcpy(curComInfo.hasSetIntervalAudit,hasSetIntervalAudit.toLocal8Bit().data()); strcpy(curComInfo.internalName,internalName.toLocal8Bit().data()); strcpy(curComInfo.leadingOrganization,leadingOrganization.toLocal8Bit().data()); strcpy(curComInfo.hasSetSeparateIA,hasSetSeparateIA.toLocal8Bit().data()); curComInfo.financeDepartment = financeDepartment; // index 29 curComInfo.legalDepartment = legalDepartment; curComInfo.internalConDepart = internalConDepart; curComInfo.disceplineInDepart = disceplineInDepart; curComInfo.otherDepart = otherDepart; strcpy(curComInfo.intavalAuditLeval,intavalAuditLeval.toLocal8Bit().data()); // index 34 // 四 curComInfo.organazationNum = organazationNum; // index 35 curComInfo.realNum = realNum; curComInfo.professionalNum = professionalNum; curComInfo.CIANum = CIANum; curComInfo.masterNum = masterNum; curComInfo.undergraduatesNum = undergraduatesNum; curComInfo.juniorNum = juniorNum; curComInfo.seniorNum = seniorNum; curComInfo.intermediateNum = intermediateNum; curComInfo.primaryNum = primaryNum; curComInfo.noTitleNum = noTitleNum; curComInfo.upFiftyOldNum = upFiftyOldNum; curComInfo.upThirtyOldNum = upThirtyOldNum; curComInfo.downThirtyOldNum = downThirtyOldNum; curComInfo.auditNum = auditNum; curComInfo.accountingNum = accountingNum; curComInfo.economyNum = economyNum; curComInfo.lawNum = lawNum; curComInfo.managerNum = managerNum; curComInfo.itNum = itNum; curComInfo.engineeringNum = engineeringNum; curComInfo.otherNum = otherNum; // index 56 // 后4个信息 strcpy(curComInfo.statisticalConOfficer,statisticalConOfficer.toLocal8Bit().data()); strcpy(curComInfo.personFilling,personFilling.toLocal8Bit().data()); strcpy(curComInfo.officerTel,officerTel.toLocal8Bit().data()); strcpy(curComInfo.fillingDateTime,fillingDateTime.toLocal8Bit().data()); // index 60 // 更新到数据库 // 先判断是不是已经存在公司名了,若已存在,则更新,不存在则插入 QString sql = QString("select id,name from all_company_info where name='%1'").arg(name); qDebug()<<"sql:"<className(); QAxObject * wb = wbs->querySubObject("Open(QString&)",path); // 哪个对象是Open的返回值,哪个就可以保存 //QAxObject* pWorkBook = excel.querySubObject("ActiveWorkBook"); //QAxObject* pWorkSheets = pWorkBook->querySubObject("Sheets");//获取工作表 //QAxObject * shs = wb->querySubObject("Sheets"); // WorkSheets 也可以 QAxObject * shs = wb->querySubObject("WorkSheets"); // WorkSheets 也可以 // // 指定单元格拿 // QAxObject *cell = shs->querySubObject("Cells(int, int)",82,1); // qDebug()<<"Cells:82-0:"<querySubObject("Cells(int, int)",82,0)->dynamicCall("Value()").toString(); // qDebug()<<"Cells:82-1:"<dynamicCall("Value()").toString(); int cnt = shs->property("Count").toInt(); qDebug()<<"cnt="<querySubObject("Item(int)", i+1); QString sheetName = sheet->property("Name").toString(); qDebug()<<"sh name:"<querySubObject("UsedRange"); int rows = usedRange->querySubObject("Rows")->property("Count").toInt(); int columns = usedRange->querySubObject("Columns")->property("Count").toInt(); qDebug()<<"r--c:"<dynamicCall("Value"); // 拿到二维表格 QVariantList valRows = val.toList(); // 遍历每一项 // for(int i=0;ilabel_creditCode->setText(uniCode.toString()); strcpy(curComInfo.creditCode,uniCode.toString().toLocal8Bit().data()); } // 单位名称 QVariant name = valRows[9].toList().at(8); if(name.isValid()){ ui->label_name->setText(name.toString()); // // 菜单相关 当上级公司为空上级时,自己当自己的上级,并且罗列进去当 本级 // QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); // top1->setText(0,name.toString()); strcpy(curComInfo.name,name.toString().toLocal8Bit().data()); }else{ ui->label_name->setText(""); } // 机构类型 QVariant comType = valRows[12].toList().at(3); if(comType.isValid()){ ui->label_comType->setText(comType.toString()); strcpy(curComInfo.comType,comType.toString().toLocal8Bit().data()); }else{ ui->label_comType->setText(""); } // 主要业务活动 QString business; QVariant first = valRows[18].toList().at(2); if(first.isValid()){ business.append(first.toString()); } QVariant sec = valRows[18].toList().at(5); if(sec.isValid()){ business += "、"; business.append(sec.toString()); } QVariant third = valRows[18].toList().at(8); if(third.isValid()){ business += "、"; business.append(third.toString()); } if(business.size() > 0){ ui->label_business->setText(business); ui->label_business->setToolTip(business); strcpy(curComInfo.business,business.toLocal8Bit().data()); }else{ ui->label_business->setText(""); } // 业务代码 QVariant busCode = valRows[19].toList().at(4); if(busCode.isValid()){ ui->label_businessCode->setText(busCode.toString()); strcpy(curComInfo.businessCode,busCode.toString().toLocal8Bit().data()); }else{ ui->label_businessCode->setText(""); } // 注册地址 QString addr=""; QVariant province = valRows[21].toList().at(1); // 省份 QVariant city = valRows[21].toList().at(4); // 城市 QVariant district = valRows[21].toList().at(7); // 管辖区 QVariant village = valRows[22].toList().at(2); // 乡镇 QVariant street = valRows[22].toList().at(4); // 街道 QVariant Sub = valRows[23].toList().at(2); // 街道办事处 QVariant committee = valRows[25].toList().at(3); // 居委会 //qDebug()<10){ ui->label_addr->setText(addr); strcpy(curComInfo.addr,addr.toLocal8Bit().data()); }else{ ui->label_addr->setText(""); } // 区域代码 QVariant areaCode = valRows[24].toList().at(2); if(areaCode.isValid()){ ui->label_areaCode->setText(areaCode.toString()); strcpy(curComInfo.areaCode,areaCode.toString().toLocal8Bit().data()); }else{ ui->label_areaCode->setText(""); } // 城乡代码 QVariant townCode = valRows[24].toList().at(6); if(townCode.isValid()) { ui->label_townCode->setText(townCode.toString()); strcpy(curComInfo.townCode,townCode.toString().toLocal8Bit().data()); }else{ ui->label_townCode->setText(""); } // 单位规模 QVariant scale = valRows[25].toList().at(3); if(scale.isValid()){ ui->label_scale->setText(scale.toString()); strcpy(curComInfo.scale,scale.toString().toLocal8Bit().data()); }else{ ui->label_scale->setText(""); } // 从业人数 QVariant people = valRows[26].toList().at(6); if(people.isValid()) { ui->label_people->setText(people.toString()); //strcpy(curComInfo.people,people.toString().toLocal8Bit().data()); curComInfo.people = people.toInt(); }else{ ui->label_people->setText(""); } // 法人 QVariant representative = valRows[27].toList().at(4); if(representative.isValid()) { ui->label_representative->setText(representative.toString()); strcpy(curComInfo.representative,representative.toString().toLocal8Bit().data()); }else{ ui->label_representative->setText(""); } // 会计标准类别 standardType QVariant standardType = valRows[27].toList().at(8); if(standardType.isValid()){ ui->label_standardType->setText(standardType.toString()); strcpy(curComInfo.standardType,standardType.toString().toLocal8Bit()); }else{ ui->label_standardType->setText(""); } // 长途区号 QVariant trunkCode = valRows[31].toList().at(2); if(trunkCode.isValid()){ ui->label_trunkCode->setText(trunkCode.toString()); strcpy(curComInfo.trunkCode,trunkCode.toString().toLocal8Bit().data()); }else{ ui->label_trunkCode->setText(""); } // 固定电话 QVariant fixedTel = valRows[32].toList().at(2); if(fixedTel.isValid()) { ui->label_fixedTel->setText(fixedTel.toString()); strcpy(curComInfo.fixedTel,fixedTel.toString().toLocal8Bit().data()); }else{ ui->label_fixedTel->setText(""); } // 邮政编码 QVariant postCode = valRows[33].toList().at(2); if(postCode.isValid()){ ui->label_postCode->setText(postCode.toString()); strcpy(curComInfo.postCode,postCode.toString().toLocal8Bit().data()); }else{ ui->label_postCode->setText(""); } // 电子邮箱 QVariant email = valRows[30].toList().at(5); if(email.isValid()) { ui->label_email->setText(email.toString()); strcpy(curComInfo.email,email.toString().toLocal8Bit().data()); }else{ ui->label_email->setText(""); } // 网址 QVariant webSite = valRows[32].toList().at(5); if(webSite.isValid()) { ui->label_webSite->setText(webSite.toString()); strcpy(curComInfo.webSite,webSite.toString().toLocal8Bit().data()); }else{ ui->label_webSite->setText(""); } // 二、单位组织结构情况 // 是否有上一级法人 QVariant hasUpLegal = valRows[35].toList().at(4); if(hasUpLegal.isValid()){ strcpy(curComInfo.hasUpLegal,hasUpLegal.toString().toLocal8Bit().data()); qDebug()<<"has up legal"<querySubObject("CheckBoxes(const QString&)", QString::fromLocal8Bit("财务部门")); if(checkBox){ qDebug()<<"取到财务部门"<property("Value2").toInt()<property("Value").toInt()<property("Value2").toBool(); if(checkBox->property("Value").toBool()){ qDebug()<<"财务部门勾选"; }else{ qDebug()<<"财务部门未勾选"; } }else{ qDebug()<<"未取到财务部门"; } QAxObject *checkBox1 = sheet->querySubObject("CheckBoxes(const QString&)", QString::fromLocal8Bit("法务部门")); if(checkBox1){ qDebug()<<"取到法务部门"<property("Value").toInt(); if(checkBox1->property("Value").toBool()){ qDebug()<<"法务部门勾选"; }else{ qDebug()<<"法务部门未勾选"; } }else{ qDebug()<<"未取到法务部门"; } // 内审机构层级 QVariant intavalAuditLeval = valRows[56].toList().at(4); if(intavalAuditLeval.isValid()){ strcpy(curComInfo.intavalAuditLeval,intavalAuditLeval.toString().toLocal8Bit().data()); qDebug()<<"intavalAuditLeval"<dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); qDebug()<<"单位信息数量:"<comboBox_ChiefDesignerLevel->installEventFilter(this); ui->comboBox_comType->installEventFilter(this); ui->comboBox_employmentMode->installEventFilter(this); ui->comboBox_hasChiefDesigner->installEventFilter(this); ui->comboBox_hasSetIntervalAudit->installEventFilter(this); ui->comboBox_hasSetSeparateIA->installEventFilter(this); ui->comboBox_hasUpLegal->installEventFilter(this); ui->comboBox_intavalAuditLeval->installEventFilter(this); ui->comboBox_leadingOrganization->installEventFilter(this); ui->comboBox_scale->installEventFilter(this); ui->comboBox_standardType->installEventFilter(this); } bool ConverInfo2::eventFilter(QObject *watched, QEvent *event) { QString cls = watched->metaObject()->className(); if(cls == "QComboBox"){ //qDebug()<<"发现下拉框"; if(event->type() == QEvent::Wheel){ //qDebug()<<"使用了滚轮"; return true; // 返回真表示禁用,返回假则能用 } }else{ qDebug()<<"其他类型:"<treeWidget->topLevelItemCount();++k){ QTreeWidgetItem *tmp = ui->treeWidget->topLevelItem(k); qDebug()<text(0)<text(0).indexOf(upName.toString()+"(汇总)"); if(upName.toString()+"(汇总)" == tmp->text(0) || pos != -1){ top = tmp; break; } } if(name.isValid()){ if(top){ // 存在,则添加到孩子列表中 QTreeWidgetItem *top1 = new QTreeWidgetItem(top); top1->setText(0,name.toString()); top->setText(0,upName.toString()+"(汇总)下级数:"+QString::number(top->childCount()-1)); }else{ // 不存在,则新建一个列表 QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); top1->setText(0,name.toString()+"(汇总)"); QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); top2->setText(0,name.toString()+"(本级)"); top1->setText(0,name.toString()+"(汇总)下级数:"+QString::number(top1->childCount()-1)); } } }else{ qDebug()<<"没发现上一级,只能自己当"<treeWidget); top1->setText(0,name.toString()+"(汇总)"); QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); top2->setText(0,name.toString()+"(本级)"); top1->setText(0,name.toString()+"(汇总)下级数:"+QString::number(top1->childCount()-1)); } } } void ConverInfo2::on_pushButton_laodFile_clicked() { QString path = QFileDialog::getOpenFileName(this,"选择表格:单位及内部审计机构基本情况表","./","excel(*基本情况表*.xls)"); qDebug()<<"path:"< 1){ readExcelFromPath(path); } } void ConverInfo2::showExcelSlot() { readInfo(); // 加载表格 } void ConverInfo2::on_pushButton_save_to_file_clicked() { QString name = ui->lineEdit_name->text(); if(name.size()== 0){ QMessageBox::information(this,"单位名称为空,请先选中一家单位","请先选中一家单位"); return; } ExportToFile etf(this); ComInfo cif = m_nameAndComInfos[name]; etf.saveToExcelFromComInfo(cif); }