From 10457ff67b999e9cc99624801c635e7f25e0d5ef Mon Sep 17 00:00:00 2001 From: wumu <mayi@mayi.com> Date: 星期四, 31 八月 2023 23:36:05 +0800 Subject: [PATCH] 0831 --- internal_system_v1/coverinfo.cpp | 90 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 87 insertions(+), 3 deletions(-) diff --git a/internal_system_v1/coverinfo.cpp b/internal_system_v1/coverinfo.cpp index d8722ea..90569ed 100644 --- a/internal_system_v1/coverinfo.cpp +++ b/internal_system_v1/coverinfo.cpp @@ -2,6 +2,10 @@ #include "ui_coverinfo.h" #include <QDebug> #include <QDirIterator> +#include <QSqlQuery> +#include <QSqlRecord> + +int g_comId = 0; // 鍏ㄥ眬鍙橀噺锛屼繚瀛樺崟浣峣d CoverInfo::CoverInfo(QWidget *parent) : QMainWindow(parent), @@ -9,6 +13,8 @@ { ui->setupUi(this); readInfo(); + readDataFromSQL(); // 浠庢暟鎹簱璇诲彇鏁版嵁 + } CoverInfo::~CoverInfo() @@ -161,9 +167,6 @@ // 缃戝潃 QVariant webSite = valRows[32].toList().at(5); if(webSite.isValid()) ui->label_webSite->setText(webSite.toString()); - - - } wbs->dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); @@ -176,3 +179,84 @@ // excel.setProperty("DisplayAlerts",false); } + +void CoverInfo::readDataFromSQL() +{ + QSqlQuery query; + QString sql; + if(ui->label_name->text().size() > 1){ + sql = QString("select id,name from company_info where name='%1'").arg(ui->label_name->text()); + 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()){ + // 鎻掑叆涓�鏉″崟浣嶄俊鎭細 + sql = QString("insert into company_info (name,code,鏈烘瀯绫诲瀷,涓昏涓氬姟娲诲姩,琛屼笟浠g爜,鍗曚綅娉ㄥ唽鍦板強鍖哄煙," + "鍖哄煙浠g爜,鍩庝埂浠g爜,鍗曚綅瑙勬ā,浠庝笟鏈熸湯浜烘暟,娉曞畾浠h〃浜�,鎵ц浼氳鏍囧噯绫诲埆,闀块�斿尯鍙�,鍥哄畾鐢佃瘽,閭斂缂栫爜," + "鐢靛瓙閭,缃戝潃) values ('%1','%2','%3','%4','%5','%6','%7','%8','%9','%10','%11','%12','%13','%14','%15','%16','%17')").arg(ui->label_name->text()) + .arg(ui->label_creditCode->text()).arg(ui->label_comType->text()).arg(ui->label_business->text()).arg(ui->label_businessCode->text()).arg(ui->label_addr->text()) + .arg(ui->label_areaCode->text()).arg(ui->label_townCode->text()).arg(ui->label_scale->text()).arg(ui->label_people->text()).arg(ui->label_representative->text()) + .arg(ui->label_standardType->text()).arg(ui->label_trunkCode->text()).arg(ui->label_fixedTel->text()).arg(ui->label_postCode->text()).arg(ui->label_email->text()) + .arg(ui->label_webSite->text()); + qDebug()<<"com_insert sql:"<<sql; + if(query.exec(sql)){ + qDebug()<<"insert com ok"; + }else{ + qDebug()<<"insert com fail"; + } + + }else{ + g_comId = query.value(0).toInt(); + } + }else{ + qDebug()<<"fail sql"<<__FUNCTION__; + } + } + sql = QString("select id,name from company_info"); + if(query.exec(sql)){ + qDebug()<<"size:"<<query.size(); + while(query.next()){ + int id = query.value(0).toInt(); + QString name = query.value(1).toString(); + qDebug()<<"com select:"<<id<<name; + m_com[name] = id; + ui->comboBox->addItem(name); + } + } + +} + +void CoverInfo::on_comboBox_currentIndexChanged(const QString &arg1) +{ + QString sql = QString("select * from company_info where name='%1'").arg(arg1); + QSqlQuery query; + if(query.exec(sql)){ + qDebug()<<"鍒囨崲鏌ヨ鎴愬姛:"<<arg1; + while (query.next()) { + qDebug()<<"鍒囨崲鏌ヨ鎴愬姛鏌ヨ鍒扮洰鏍囧崟浣�:"<<arg1; + g_comId = query.value(0).toInt(); + ui->label_name->setText(query.value(1).toString()); + ui->label_creditCode->setText(query.value(2).toString()); + ui->label_comType->setText(query.value(3).toString()); + ui->label_business->setText(query.value(4).toString()); + ui->label_businessCode->setText(query.value(5).toString()); + ui->label_addr->setText(query.value(6).toString()); + ui->label_areaCode->setText(query.value(7).toString()); + ui->label_townCode->setText(query.value(8).toString()); + ui->label_scale->setText(query.value(9).toString()); + ui->label_people->setText(query.value(10).toString()); + ui->label_representative->setText(query.value(11).toString()); + ui->label_standardType->setText(query.value(12).toString()); + ui->label_trunkCode->setText(query.value(13).toString()); + ui->label_fixedTel->setText(query.value(14).toString()); + ui->label_postCode->setText(query.value(15).toString()); + ui->label_email->setText(query.value(16).toString()); + ui->label_webSite->setText(query.value(17).toString()); + break; + } + }else{ + qDebug()<<"鍒囨崲鏌ヨ澶辫触:"<<arg1; + } +} -- Gitblit v1.8.0