//加载XML内容 bool MainWindow::load_xmlFile(const QString &strFilePath, QDomDocument &domDoc) { QString errorStr; int errorLine,errorColumn; QFile file(strFilePath); if(!file.open(QIODevice::ReadOnly | QFile::Text)) { showInformationBox(QString::fromUtf8("error: load_xml open")); file.close(); return false ; } if (!domDoc.setContent(&file, false, &errorStr, &errorLine, &errorColumn)) { showInformationBox("error: load_xml:"+errorStr); file.close(); return false ; } file.close(); return true; }
/****************************************************************************************** *通过检定任务单号搜索检定任务 *****************************************************************************************/ void MainWindow::down_MT_DETECT_TASK(QString barCode,QString detectTaskNo) { QSqlRecord sqlRec; QSqlQuery sqlQuery; QString strExec; int rowCount; strExec = QString("select * from mt_detect_task where DETECT_TASK_NO ='%1' order by WRITE_DATE desc").arg(detectTaskNo); if(!sqlQuery.exec(strExec)) { showInformationBox(sqlQuery.lastError().databaseText()); return ; } sqlRec = sqlQuery.record(); while(sqlQuery.next()) { if(isTaskNoExist(barCode,ui->EM_DETECT_TASK_TblWidget,0)) { rowCount = ui->EM_DETECT_TASK_TblWidget->rowCount(); ui->EM_DETECT_TASK_TblWidget->insertRow(rowCount); ui->EM_DETECT_TASK_TblWidget->setItem(rowCount,0,new QTableWidgetItem(barCode)); for(int i=0;i<sqlRec.count()+1;i++) { ui->EM_DETECT_TASK_TblWidget->setItem(rowCount,i+1,new QTableWidgetItem(sqlQuery.value(i).toString())); } return; } } }
void MainWindow::on_MU_options_deleteLocalSqlAll_PsBtn_clicked() { switch(QMessageBox::question(this,QString::fromUtf8("信息提醒"),QString::fromUtf8("是否清空从电能表获取的数据库?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)) { case QMessageBox::Yes: { QString strExec; int intResult; strExec ="delete from sampleInfo"; intResult= sql_exec(strExec.toLatin1().data()); if(intResult!=SQLITE_OK) { showInformationBox(QString::fromUtf8("delete sampleInfo error")); return; } strExec ="delete from MT_METER"; intResult= sql_exec(strExec.toLatin1().data()); if(intResult!=SQLITE_OK) { showInformationBox(QString::fromUtf8("delete MT_METER error")); return; } showInformationBox(QString::fromUtf8("已经清空")); break; } case QMessageBox::No: break; default: break; } }
//检定线台编号 void MainWindow::on_EM_options_detectEquipNo_PsBtn_clicked() { QString strTemp=ui->EM_options_detectEquipNo_LnEdit->text(); switch(QMessageBox::question(this,QString::fromUtf8("信息提醒"),QString::fromUtf8("是否修改编号?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)) { case QMessageBox::Yes: { writeIni("localSql/DETECT_QEUIP_NO",strTemp); showInformationBox(QString::fromUtf8("已经修改,重新启动软件生效")); break; } case QMessageBox::No: break; default: break; } }
//保存校验数据库的地址 void MainWindow::on_EM_options_setArg_localSqlPath_PsBtn_clicked() { QString strTemp=ui->EM_options_setArg_localSqlPath_LnEdit->text(); strTemp=strTemp.replace("\\","/"); switch(QMessageBox::question(this,QString::fromUtf8("信息提醒"),QString::fromUtf8("是否修改路径?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)) { case QMessageBox::Yes: { writeIni("localSql/Path",strTemp); showInformationBox(QString::fromUtf8("已经修改,重新启动软件生效")); break; } case QMessageBox::No: break; default: break; } }
//将XML保存为文档形式.格式为UTF-8 bool MainWindow::save_xmlFile(const QString &strFilePath, const QDomDocument domDoc) { QFile file(strFilePath); if(!file.open(QIODevice::ReadWrite | QFile::Text)) { showInformationBox(QString::fromUtf8("error :save_xmlFile")); file.close(); return false; } QTextStream out(&file); out.setCodec("UTF-8"); domDoc.save(out,4,QDomNode::EncodingFromTextStream); file.close(); return true; }
void MainWindow::on_EM_options_setArg_Oracle_PsBtn_clicked() { QString strTemp; switch(QMessageBox::question(this,QString::fromUtf8("信息提醒"),QString::fromUtf8("是否修改配置?"), QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)) { case QMessageBox::Yes: { strTemp = ui->EM_options_appKey_LnEdit->text(); writeIni("sysParams/appKey",strTemp); strTemp = ui->EM_options_appSecret_LnEdit->text(); writeIni("sysParams/appSecret",strTemp); showInformationBox(QString::fromUtf8("已经修改,重新启动软件生效")); break; } case QMessageBox::No: break; default: break; } }
/** * Slot to wrap the protected showInformationBox method defined * in UserSubWindow and provide access to composed tabs. * * @param message The message to display in the message box */ void IndirectDataAnalysis::showMessageBox(const QString &message) { showInformationBox(message); }