代码文件编码修改成utf-8。

This commit is contained in:
Kane Wang 2018-06-01 18:21:26 +08:00
parent d59b437f86
commit 1e383920be
18 changed files with 303 additions and 271 deletions

View File

@ -9,7 +9,7 @@
#include "SystemDataQuery.h" #include "SystemDataQuery.h"
#include "StringCodeConverter.h" #include "StringCodeConverter.h"
#pragma comment( lib, "user32.lib") #pragma comment( lib, "user32.lib")
#pragma comment( lib, "version.lib") #pragma comment( lib, "version.lib")
#pragma comment( lib, "oleaut32.lib") #pragma comment( lib, "oleaut32.lib")
@ -89,18 +89,18 @@ void SaveTelSalePolicyInfo(const SPolicyRecord & policy, const vector<TelSalePol
{ {
if ( policy.strPolicySerial.empty() == true ) if ( policy.strPolicySerial.empty() == true )
{ {
throw invalid_argument( "保单号为空!" ); throw invalid_argument( "保单号为空!" );
} }
if ( policy.strSalerCode.empty() == true ) if ( policy.strSalerCode.empty() == true )
{ {
throw invalid_argument( "保单号为空!" ); throw invalid_argument( "保单号为空!" );
} }
ostringstream ostrCommand; ostringstream ostrCommand;
string strAutotraderCall; string strAutotraderCall;
//车店联呼 //车店联呼
if ( policy.bIsAutotraderCall == true ) if ( policy.bIsAutotraderCall == true )
{ {
strAutotraderCall = "1"; strAutotraderCall = "1";
@ -186,12 +186,12 @@ void SaveTelSalePolicyInfo(const SPolicyRecord & policy, const vector<TelSalePol
g_cszUserNameYwgl, g_cszUserNameYwgl,
g_cszPasswordYwgl, g_cszPasswordYwgl,
SA_Informix_Client ); SA_Informix_Client );
//conn.setAutoCommit( SA_AutoCommitOff ); //导致锁表 //conn.setAutoCommit( SA_AutoCommitOff ); //导致锁表
//保存保单 //保存保单
command.Execute(); command.Execute();
//保存礼品列表,先删除旧数据 //保存礼品列表,先删除旧数据
command.setCommandText( "delete w_dxbd_gift_i where bdh = :1 " ); command.setCommandText( "delete w_dxbd_gift_i where bdh = :1 " );
command.Param( 1 ).setAsString() = policy.strPolicySerial.c_str(); command.Param( 1 ).setAsString() = policy.strPolicySerial.c_str();
command.Execute(); command.Execute();
@ -231,7 +231,7 @@ void QueryTelSalePolicyInfo( const string & strPolicyNo,
SPolicyQuery policy; SPolicyQuery policy;
string strSQL = string strSQL =
"select trim(bdh) bdh, trim(zhjywy) zhjywy, to_char(czrq, '%Y年%m月%d日') czrq, trim(czydm) czydm, chdlh, zhjywybmm, kshmc, chshdm, chshmc " "select trim(bdh) bdh, trim(zhjywy) zhjywy, to_char(czrq, '%Y年%m月%d日') czrq, trim(czydm) czydm, chdlh, zhjywybmm, kshmc, chshdm, chshmc "
" from w_dxbd_i " " from w_dxbd_i "
" where 1=1 "; " where 1=1 ";
@ -340,7 +340,7 @@ void QueryPolicyGifts(const string & strPolicyNo, string & strGifts, double dGif
strGifts.append( command.Field("gift_name").asString() ); strGifts.append( command.Field("gift_name").asString() );
strGifts.append( " " ); strGifts.append( " " );
strGifts.append( command.Field("gift_price").asString() ); strGifts.append( command.Field("gift_price").asString() );
strGifts.append( "" ); strGifts.append( "" );
dGiftPriceSum += command.Field("gift_price").asDouble(); dGiftPriceSum += command.Field("gift_price").asDouble();
} }
@ -396,7 +396,7 @@ void readTelsaleXlsFile(const string strFilePath, vector<SPolicyRecord> & listPo
if ( pSheet == NULL ) if ( pSheet == NULL )
{ {
throw string( "读取sheet失败" ); throw string( "读取sheet失败" );
} }
iRowCount = pSheet->lastRow(); iRowCount = pSheet->lastRow();
@ -406,7 +406,7 @@ void readTelsaleXlsFile(const string strFilePath, vector<SPolicyRecord> & listPo
iRowIndex = 1; iRowIndex = 1;
} }
//读取数据 //读取数据
while ( iRowIndex < iRowCount ) while ( iRowIndex < iRowCount )
{ {
SPolicyRecord policy; SPolicyRecord policy;
@ -421,7 +421,7 @@ void readTelsaleXlsFile(const string strFilePath, vector<SPolicyRecord> & listPo
//policy.strAutoTraderName = readXlsCell( pSheet, iRowIndex, 5 ); //policy.strAutoTraderName = readXlsCell( pSheet, iRowIndex, 5 );
policy.strAutoTraderCode = readXlsCell( pSheet, iRowIndex, 6 ); policy.strAutoTraderCode = readXlsCell( pSheet, iRowIndex, 6 );
//补齐工号 //补齐工号
if ( policy.strSalerCode.length() == 1 ) if ( policy.strSalerCode.length() == 1 )
{ {
policy.strSalerCode = string("00") + policy.strSalerCode; policy.strSalerCode = string("00") + policy.strSalerCode;
@ -539,14 +539,14 @@ void readTelsaleXlsxFile(wchar_t * wszFilePath, vector<SPolicyRecord> & listPoli
if ( pBook->load(L"D:/1111.xlsx") == false ) if ( pBook->load(L"D:/1111.xlsx") == false )
{ {
throw string("打开文件失败!" ); throw string("打开文件失败!" );
} }
pSheet = pBook->getSheet( 0 ); pSheet = pBook->getSheet( 0 );
if ( pSheet == NULL ) if ( pSheet == NULL )
{ {
throw string( "读取sheet失败" ); throw string( "读取sheet失败" );
} }
iRowCount = pSheet->lastRow(); iRowCount = pSheet->lastRow();
@ -556,7 +556,7 @@ void readTelsaleXlsxFile(wchar_t * wszFilePath, vector<SPolicyRecord> & listPoli
iRowIndex = 1; iRowIndex = 1;
} }
//读取数据 //读取数据
while ( iRowIndex < iRowCount ) while ( iRowIndex < iRowCount )
{ {
SPolicyRecord policy; SPolicyRecord policy;
@ -570,7 +570,7 @@ void readTelsaleXlsxFile(wchar_t * wszFilePath, vector<SPolicyRecord> & listPoli
policy.strSalerCode = readXlsxCell( pSheet, iRowIndex, 4 ); policy.strSalerCode = readXlsxCell( pSheet, iRowIndex, 4 );
policy.strAutoTraderName = readXlsxCell( pSheet, iRowIndex, 6 ); policy.strAutoTraderName = readXlsxCell( pSheet, iRowIndex, 6 );
//补齐工号 //补齐工号
if ( policy.strSalerCode.length() == 1 ) if ( policy.strSalerCode.length() == 1 )
{ {
policy.strSalerCode = string("00") + policy.strSalerCode; policy.strSalerCode = string("00") + policy.strSalerCode;

View File

@ -5,12 +5,12 @@
* \author Kane * \author Kane
* Contact: user@company.com * Contact: user@company.com
* *
* \brief * \brief
* *
* TODO: long description * TODO: long description
* *
* \note * \note
*/ */
#ifndef DataManipulation_h__ #ifndef DataManipulation_h__
#define DataManipulation_h__ #define DataManipulation_h__
@ -86,8 +86,8 @@ private:
// FullName: queryTelsalePolicyGifts // FullName: queryTelsalePolicyGifts
// Access: public // Access: public
// Returns: void // Returns: void
// Qualifier: 查询礼品信息 // Qualifier: 查询礼品信息
// Parameter: vector<TelSalePolicyGift> & giftList 礼品列表 // Parameter: vector<TelSalePolicyGift> & giftList 礼品列表
//************************************ //************************************
void queryTelsalePolicyGifts( vector<TelSalePolicyGift> &giftList ); void queryTelsalePolicyGifts( vector<TelSalePolicyGift> &giftList );
@ -125,7 +125,7 @@ void QueryTelSalePolicyInfo( const string & strPolicyNo,
// FullName: QueryPolicyGifts // FullName: QueryPolicyGifts
// Access: public // Access: public
// Returns: void // Returns: void
// Qualifier: 查询礼品列表,生成字符串 // Qualifier: 查询礼品列表,生成字符串
// Parameter: const string & strPolicyNo // Parameter: const string & strPolicyNo
// Parameter: string & strGifts // Parameter: string & strGifts
//************************************ //************************************

View File

@ -29,7 +29,7 @@ Parameters::Parameters(const string & strFilePath)
throw runtime_error( sqlite3_errmsg(pdbParameter) ); throw runtime_error( sqlite3_errmsg(pdbParameter) );
} }
//查询 //查询
returnCode = sqlite3_get_table( pdbParameter, szSQL, &result, &nRowCount, &nColCount, &pszMessage ); returnCode = sqlite3_get_table( pdbParameter, szSQL, &result, &nRowCount, &nColCount, &pszMessage );
if ( returnCode != SQLITE_OK ) if ( returnCode != SQLITE_OK )
@ -45,11 +45,11 @@ Parameters::Parameters(const string & strFilePath)
m_parameters[strName] = strValue; m_parameters[strName] = strValue;
} }
//清理 //清理
sqlite3_free_table( result ); sqlite3_free_table( result );
sqlite3_close( pdbParameter ); sqlite3_close( pdbParameter );
//保存文件路径 //保存文件路径
m_strDbFilePath = strFilePath; m_strDbFilePath = strFilePath;
} }
@ -67,7 +67,7 @@ void Parameters::setParameter(const string & strParaName, const string & strPara
{ {
if ( m_parameters.find( strParaName) == m_parameters.end() ) if ( m_parameters.find( strParaName) == m_parameters.end() )
{ {
throw runtime_error( "参数名称错误!" ); throw runtime_error( "参数名称错误!" );
} }
m_parameters[strParaName] = strParaValue; m_parameters[strParaName] = strParaValue;

View File

@ -41,7 +41,7 @@ void QConfigurationWidget::initSignal()
void QConfigurationWidget::initData() void QConfigurationWidget::initData()
{ {
pEditAutoTraderCode->setText( QString::fromLocal8Bit( parameters.getParameter("默认车商代码").c_str() )); pEditAutoTraderCode->setText( QString::fromLocal8Bit( parameters.getParameter("默认车商代码").c_str() ));
emit pEditAutoTraderCode->editingFinished(); emit pEditAutoTraderCode->editingFinished();
} }
@ -70,12 +70,12 @@ void QConfigurationWidget::onSave()
if ( pEditAutoTraderName->text().isEmpty() ) if ( pEditAutoTraderName->text().isEmpty() )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("错误!"), QString::fromLocal8Bit("车商代码错误!") ); QMessageBox::critical( this, QString::fromLocal8Bit("错误!"), QString::fromLocal8Bit("车商代码错误!") );
return; return;
} }
parameters.setParameter( "默认车商代码", pEditAutoTraderCode->text().toLocal8Bit().data() ); parameters.setParameter( "默认车商代码", pEditAutoTraderCode->text().toLocal8Bit().data() );
} }
void QConfigurationWidget::onReset() void QConfigurationWidget::onReset()

View File

@ -5,7 +5,7 @@
#include <string> #include <string>
#include "ui_QConfigurationWidget.h" #include "ui_QConfigurationWidget.h"
using std::string; using std::string;
class QConfigurationWidget : public QWidget, public Ui::QConfigurationWidget class QConfigurationWidget : public QWidget, public Ui::QConfigurationWidget
{ {

View File

@ -5,7 +5,7 @@
QMainFrame::QMainFrame(QWidget *parent) QMainFrame::QMainFrame(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
setupUi(this); setupUi(this);
init(); init();
@ -25,29 +25,29 @@ void QMainFrame::init()
void QMainFrame::initWidget() void QMainFrame::initWidget()
{ {
//标题栏 //标题栏
setWindowTitle( windowTitle() + QString::fromLocal8Bit(" - 版本号v") + QString::fromLocal8Bit( getVersion().c_str()) ); setWindowTitle( windowTitle() + QString::fromLocal8Bit(" - 版本号v") + QString::fromLocal8Bit( getVersion().c_str()) );
//工具栏 //工具栏
//ui.pActionDataManage->setEnabled( false ); //ui.pActionDataManage->setEnabled( false );
//层叠窗口 //层叠窗口
m_pWidgetStack = new QMyStackedWidget( this ); m_pWidgetStack = new QMyStackedWidget( this );
setCentralWidget( m_pWidgetStack ); setCentralWidget( m_pWidgetStack );
//加入信息录入窗口 //加入信息录入窗口
m_pWidgetInfoInput = new QTelSalePolicyInfoInputWidget(); m_pWidgetInfoInput = new QTelSalePolicyInfoInputWidget();
m_pWidgetStack->addWidget( m_pWidgetInfoInput, QString::fromLocal8Bit("电销转介绍信息录入窗口") ); m_pWidgetStack->addWidget( m_pWidgetInfoInput, QString::fromLocal8Bit("电销转介绍信息录入窗口") );
m_pWidgetStack->showWidget( QString::fromLocal8Bit("电销转介绍信息录入窗口") ); m_pWidgetStack->showWidget( QString::fromLocal8Bit("电销转介绍信息录入窗口") );
//加入查询窗口 //加入查询窗口
m_pWidgetQuery = new QTelSalePolicyInfoQuery(); m_pWidgetQuery = new QTelSalePolicyInfoQuery();
m_pWidgetStack->addWidget( m_pWidgetQuery, QString::fromLocal8Bit("信息查询窗口") ); m_pWidgetStack->addWidget( m_pWidgetQuery, QString::fromLocal8Bit("信息查询窗口") );
//加入参数设置窗口 //加入参数设置窗口
QScrollArea * pScrollArea = new QScrollArea(); QScrollArea * pScrollArea = new QScrollArea();
m_pWidgetConfiguration = new QConfigurationWidget(); m_pWidgetConfiguration = new QConfigurationWidget();
@ -57,7 +57,7 @@ void QMainFrame::initWidget()
pScrollArea->setObjectName( QString::fromLocal8Bit("pScrollAreaInput") ); pScrollArea->setObjectName( QString::fromLocal8Bit("pScrollAreaInput") );
pScrollArea->setStyleSheet( QString::fromLocal8Bit( "#pScrollAreaInput\n{\n border: none;\n}" )); pScrollArea->setStyleSheet( QString::fromLocal8Bit( "#pScrollAreaInput\n{\n border: none;\n}" ));
m_pWidgetStack->addWidget( pScrollArea, QString::fromLocal8Bit("参数配置窗口") ); m_pWidgetStack->addWidget( pScrollArea, QString::fromLocal8Bit("参数配置窗口") );
} }
void QMainFrame::initSignal() void QMainFrame::initSignal()
@ -74,7 +74,7 @@ void QMainFrame::resizeEvent( QResizeEvent * pEvent )
void QMainFrame::initStatusBar() void QMainFrame::initStatusBar()
{ {
//验证 //验证
QStatusBar * pStatusBar = this->statusBar(); QStatusBar * pStatusBar = this->statusBar();
if ( pStatusBar == NULL ) if ( pStatusBar == NULL )
@ -82,9 +82,9 @@ void QMainFrame::initStatusBar()
return; return;
} }
QString strDate = QDate::currentDate().toString( QString::fromLocal8Bit("当前日期yyyy年MM月dd日 ") ); QString strDate = QDate::currentDate().toString( QString::fromLocal8Bit("当前日期yyyy年MM月dd日 ") );
QString strUserName = QString::fromLocal8Bit("操作员:") + QString::fromLocal8Bit( getUserName().c_str() ) + QString(" "); QString strUserName = QString::fromLocal8Bit("操作员:") + QString::fromLocal8Bit( getUserName().c_str() ) + QString(" ");
QString strUserCode = QString::fromLocal8Bit("工号:") + QString::fromLocal8Bit( getUserCode().c_str() ) + QString(" "); QString strUserCode = QString::fromLocal8Bit("工号:") + QString::fromLocal8Bit( getUserCode().c_str() ) + QString(" ");
//strUser. //strUser.
@ -95,15 +95,15 @@ void QMainFrame::initStatusBar()
void QMainFrame::onShowInputWidget() void QMainFrame::onShowInputWidget()
{ {
m_pWidgetStack->showWidget( QString::fromLocal8Bit("电销转介绍信息录入窗口") ); m_pWidgetStack->showWidget( QString::fromLocal8Bit("电销转介绍信息录入窗口") );
} }
void QMainFrame::onShowQueryWidget() void QMainFrame::onShowQueryWidget()
{ {
m_pWidgetStack->showWidget( QString::fromLocal8Bit("信息查询窗口") ); m_pWidgetStack->showWidget( QString::fromLocal8Bit("信息查询窗口") );
} }
void QMainFrame::onShowSetParameterWidget() void QMainFrame::onShowSetParameterWidget()
{ {
m_pWidgetStack->showWidget( QString::fromLocal8Bit("参数配置窗口") ); m_pWidgetStack->showWidget( QString::fromLocal8Bit("参数配置窗口") );
} }

View File

@ -7,7 +7,7 @@
#include "QTelSalePolicyInfoInputWidget.h" #include "QTelSalePolicyInfoInputWidget.h"
#include "QTelSalePolicyInfoQuery.h" #include "QTelSalePolicyInfoQuery.h"
#include "QConfigurationWidget.h" #include "QConfigurationWidget.h"
#include "ui_QMainFrame.h" #include "ui_QMainFrame.h"
class QMainFrame : public QMainWindow, public Ui::QMainFrame class QMainFrame : public QMainWindow, public Ui::QMainFrame
{ {

View File

@ -53,7 +53,7 @@ void QRapidInputWidget::dropEvent(QDropEvent * pEvent)
QList<QUrl> listURL = pEvent->mimeData()->urls(); QList<QUrl> listURL = pEvent->mimeData()->urls();
QString strFilePath; QString strFilePath;
//正则表达式判断文件类型 //正则表达式判断文件类型
QRegularExpression regXlsx( QString::fromLocal8Bit(".xlsx$"), QRegularExpression::PatternOption::CaseInsensitiveOption ); QRegularExpression regXlsx( QString::fromLocal8Bit(".xlsx$"), QRegularExpression::PatternOption::CaseInsensitiveOption );
QRegularExpression regXls( QString::fromLocal8Bit(".xls$"), QRegularExpression::PatternOption::CaseInsensitiveOption ); QRegularExpression regXls( QString::fromLocal8Bit(".xls$"), QRegularExpression::PatternOption::CaseInsensitiveOption );
QRegularExpressionMatch match; QRegularExpressionMatch match;
@ -65,7 +65,7 @@ void QRapidInputWidget::dropEvent(QDropEvent * pEvent)
strFilePath = listURL[0].toLocalFile(); strFilePath = listURL[0].toLocalFile();
//是xlsx文件 //是xlsx文件
match = regXlsx.match( strFilePath ); match = regXlsx.match( strFilePath );
if ( match.hasMatch() ) if ( match.hasMatch() )
@ -73,7 +73,7 @@ void QRapidInputWidget::dropEvent(QDropEvent * pEvent)
readTelsaleXlsFile( strFilePath.toLocal8Bit().data(), m_vPolicy, ui.pCheckBoxHasTitle->isChecked(), true ); readTelsaleXlsFile( strFilePath.toLocal8Bit().data(), m_vPolicy, ui.pCheckBoxHasTitle->isChecked(), true );
} }
//是xls文件 //是xls文件
match = regXls.match( strFilePath ); match = regXls.match( strFilePath );
if ( match.hasMatch() ) if ( match.hasMatch() )
@ -94,63 +94,63 @@ void QRapidInputWidget::showPolicy()
for ( int iRowIndex = 0; iRowIndex < iRowCount; iRowIndex++ ) for ( int iRowIndex = 0; iRowIndex < iRowCount; iRowIndex++ )
{ {
//保单号 //保单号
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strPolicySerial.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strPolicySerial.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 0, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 0, pItem );
//签单日期 //签单日期
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSignDate.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSignDate.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 1, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 1, pItem );
//车牌号 //车牌号
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strPlateSerial.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strPlateSerial.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 2, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 2, pItem );
//被保险人 //被保险人
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strCustomerName.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strCustomerName.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 3, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 3, pItem );
//车商代码 //车商代码
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strAutoTraderCode.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strAutoTraderCode.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 4, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 4, pItem );
//经办人代码 //经办人代码
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerCode.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerCode.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
ui.pTableWidgetPolicy->setItem( iRowIndex, 5, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 5, pItem );
//经办人名称 //经办人名称
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerName.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerName.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 6, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 6, pItem );
//部门 //部门
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerDeptName.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerDeptName.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
ui.pTableWidgetPolicy->setItem( iRowIndex, 7, pItem ); ui.pTableWidgetPolicy->setItem( iRowIndex, 7, pItem );
//科室 //科室
pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerOfficeName.c_str()) ); pItem = new QTableWidgetItem( QString::fromLocal8Bit( m_vPolicy[iRowIndex].strSalerOfficeName.c_str()) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
@ -177,10 +177,10 @@ void QRapidInputWidget::onSaveTelSalePolicy()
{ {
m_vErrorPolicy.push_back( *iter ); m_vErrorPolicy.push_back( *iter );
QString strInfo = QString::fromLocal8Bit("保单") + QString::fromLocal8Bit( (*iter).strPolicySerial.c_str() ) + QString::fromLocal8Bit("保存错误!\n") + QString strInfo = QString::fromLocal8Bit("保单") + QString::fromLocal8Bit( (*iter).strPolicySerial.c_str() ) + QString::fromLocal8Bit("保存错误!\n") +
QString::fromLocal8Bit("错误信息:") + QString::fromLocal8Bit( excpt.what() ); QString::fromLocal8Bit("错误信息:") + QString::fromLocal8Bit( excpt.what() );
QMessageBox::critical( this, QString::fromLocal8Bit("保存错误"), strInfo ); QMessageBox::critical( this, QString::fromLocal8Bit("保存错误"), strInfo );
} }
} }
@ -201,33 +201,33 @@ void QRapidInputWidget::onCleanTable()
void QRapidInputWidget::onOpenFile() void QRapidInputWidget::onOpenFile()
{ {
QSettings reg( "HKEY_CURRENT_USER\\Software\\TelsalePolicyInfoManager", QSettings::NativeFormat); QSettings reg( "HKEY_CURRENT_USER\\Software\\TelsalePolicyInfoManager", QSettings::NativeFormat);
QString strPath = reg.value( QString::fromLocal8Bit("打开地址") ).toString(); QString strPath = reg.value( QString::fromLocal8Bit("打开地址") ).toString();
QStringList listFileNames = QFileDialog::getOpenFileNames( this, QStringList listFileNames = QFileDialog::getOpenFileNames( this,
QString::fromLocal8Bit("打开Excel文件"), QString::fromLocal8Bit("打开Excel文件"),
strPath, strPath,
QString::fromLocal8Bit("Excel文件 (*.xls *.xlsx)") ); QString::fromLocal8Bit("Excel文件 (*.xls *.xlsx)") );
//记录一下打开的路径 //记录一下打开的路径
if ( listFileNames.size() > 0 ) if ( listFileNames.size() > 0 )
{ {
strPath = listFileNames[0].left( listFileNames[0].lastIndexOf( QString::fromLocal8Bit("/") ) + 1 ); strPath = listFileNames[0].left( listFileNames[0].lastIndexOf( QString::fromLocal8Bit("/") ) + 1 );
reg.setValue( QString::fromLocal8Bit("打开地址"), strPath ); reg.setValue( QString::fromLocal8Bit("打开地址"), strPath );
} }
else else
{ {
return; return;
} }
//正则表达式判断文件类型 //正则表达式判断文件类型
QRegularExpression regXlsx( QString::fromLocal8Bit(".xlsx$"), QRegularExpression::PatternOption::CaseInsensitiveOption ); QRegularExpression regXlsx( QString::fromLocal8Bit(".xlsx$"), QRegularExpression::PatternOption::CaseInsensitiveOption );
QRegularExpression regXls( QString::fromLocal8Bit(".xls$"), QRegularExpression::PatternOption::CaseInsensitiveOption ); QRegularExpression regXls( QString::fromLocal8Bit(".xls$"), QRegularExpression::PatternOption::CaseInsensitiveOption );
QRegularExpressionMatch match; QRegularExpressionMatch match;
strPath = listFileNames[0]; strPath = listFileNames[0];
//是xlsx文件 //是xlsx文件
match = regXlsx.match( strPath ); match = regXlsx.match( strPath );
if ( match.hasMatch() ) if ( match.hasMatch() )
@ -235,7 +235,7 @@ void QRapidInputWidget::onOpenFile()
readTelsaleXlsFile( strPath.toLocal8Bit().data(), m_vPolicy, ui.pCheckBoxHasTitle->isChecked(), true ); readTelsaleXlsFile( strPath.toLocal8Bit().data(), m_vPolicy, ui.pCheckBoxHasTitle->isChecked(), true );
} }
//是xls文件 //是xls文件
match = regXls.match( strPath ); match = regXls.match( strPath );
if ( match.hasMatch() ) if ( match.hasMatch() )

View File

@ -4,10 +4,10 @@
#include "SystemDataQuery.h" #include "SystemDataQuery.h"
#include "SystemData.h" #include "SystemData.h"
QTelSalePolicyInfoInputWidget::QTelSalePolicyInfoInputWidget(QWidget *parent) QTelSalePolicyInfoInputWidget::QTelSalePolicyInfoInputWidget( QWidget * parent )
: QWidget(parent) : QWidget( parent )
{ {
setupUi(this); setupUi( this );
init(); init();
initWidget(); initWidget();
@ -17,19 +17,17 @@ QTelSalePolicyInfoInputWidget::QTelSalePolicyInfoInputWidget(QWidget *parent)
QTelSalePolicyInfoInputWidget::~QTelSalePolicyInfoInputWidget() QTelSalePolicyInfoInputWidget::~QTelSalePolicyInfoInputWidget()
{ {
} }
void QTelSalePolicyInfoInputWidget::init() void QTelSalePolicyInfoInputWidget::init()
{ {
} }
void QTelSalePolicyInfoInputWidget::initWidget() void QTelSalePolicyInfoInputWidget::initWidget()
{ {
setLayout( pLayoutMain ); setLayout( pLayoutMain );
//单笔录入窗口 //单笔录入窗口
pTabWidget->widget( 0 )->setLayout( pLayoutInputMain ); pTabWidget->widget( 0 )->setLayout( pLayoutInputMain );
pScrollAreaInput->setWidget( pWidgetInput ); pScrollAreaInput->setWidget( pWidgetInput );
@ -38,20 +36,19 @@ void QTelSalePolicyInfoInputWidget::initWidget()
pWidgetInput->setMaximumWidth( 820 ); pWidgetInput->setMaximumWidth( 820 );
pWidgetInput->setMinimumWidth( 820 ); pWidgetInput->setMinimumWidth( 820 );
//批量录入 //批量录入
QRapidInputWidget * pWidgetRapid = new QRapidInputWidget; QRapidInputWidget * pWidgetRapid = new QRapidInputWidget;
pScrollAreaRapid->setWidget( pWidgetRapid ); pScrollAreaRapid->setWidget( pWidgetRapid );
pTabWidget->widget( 1 )->setLayout( pLayoutRapid ); pTabWidget->widget( 1 )->setLayout( pLayoutRapid );
} }
void QTelSalePolicyInfoInputWidget::initSignal() void QTelSalePolicyInfoInputWidget::initSignal()
{ {
connect( pEditSalerCode, SIGNAL(editingFinished()), this, SLOT(onQuerySalerName())); connect( pEditSalerCode, SIGNAL(editingFinished()), this, SLOT(onQuerySalerName()) );
connect( pEditSalerCode, SIGNAL(textChanged(const QString &)), this, SLOT(onSalerCodeChanged()) ); connect( pEditSalerCode, SIGNAL(textChanged(const QString &)), this, SLOT(onSalerCodeChanged()) );
connect( pEditAutoTraderCode, SIGNAL(editingFinished()), this, SLOT(onQueryAutoTraderName())); connect( pEditAutoTraderCode, SIGNAL(editingFinished()), this, SLOT(onQueryAutoTraderName()) );
connect( pEditAutoTraderCode, SIGNAL(textChanged(const QString &)), this, SLOT(onAutoTraderCodeChanged()) ); connect( pEditAutoTraderCode, SIGNAL(textChanged(const QString &)), this, SLOT(onAutoTraderCodeChanged()) );
connect( pButtonSave, SIGNAL(clicked()), this, SLOT(onSavePolicy()) ); connect( pButtonSave, SIGNAL(clicked()), this, SLOT(onSavePolicy()) );
connect( pButtonResetGift, SIGNAL(clicked()), this, SLOT(onResetGiftsTable()) ); connect( pButtonResetGift, SIGNAL(clicked()), this, SLOT(onResetGiftsTable()) );
@ -61,12 +58,12 @@ void QTelSalePolicyInfoInputWidget::initSignal()
void QTelSalePolicyInfoInputWidget::initData() void QTelSalePolicyInfoInputWidget::initData()
{ {
//默认的车商代码 //默认的车商代码
pEditAutoTraderCode->setText( QString::fromLocal8Bit(parameters.getParameter("默认车商代码").c_str() )); pEditAutoTraderCode->setText( QString::fromLocal8Bit( parameters.getParameter( "默认车商代码" ).c_str() ) );
emit pEditAutoTraderCode->editingFinished(); emit pEditAutoTraderCode->editingFinished();
//初始化礼品列表 //初始化礼品列表
InitGiftTable(); InitGiftTable();
pEditQjxPolicySerial->clear(); pEditQjxPolicySerial->clear();
@ -78,12 +75,11 @@ void QTelSalePolicyInfoInputWidget::initData()
pEditOfficeCode->clear(); pEditOfficeCode->clear();
pEditOfficeName->clear(); pEditOfficeName->clear();
pComboBoxAutotraderCall->setCurrentIndex( 0 ); pComboBoxAutotraderCall->setCurrentIndex( 0 );
} }
void QTelSalePolicyInfoInputWidget::InitGiftTable() void QTelSalePolicyInfoInputWidget::InitGiftTable()
{ {
//设置标志位 //设置标志位
m_initing = true; m_initing = true;
m_giftsList.clear(); m_giftsList.clear();
@ -92,9 +88,9 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
{ {
queryTelsalePolicyGifts( m_giftsList ); queryTelsalePolicyGifts( m_giftsList );
} }
catch ( runtime_error &error ) catch ( runtime_error & error )
{ {
QMessageBox::critical( this, "获取礼品列表出错!", error.what() ); QMessageBox::critical( this, QString::fromLocal8Bit( "获取礼品列表出错!" ), error.what() );
return; return;
} }
@ -107,11 +103,11 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
for ( unsigned int rowIndex = 0; iter != m_giftsList.end(); rowIndex++ ) for ( unsigned int rowIndex = 0; iter != m_giftsList.end(); rowIndex++ )
{ {
QTableWidgetItem *pItem = new QTableWidgetItem(); QTableWidgetItem * pItem = new QTableWidgetItem();
pItem->setCheckState( Qt::Unchecked ); pItem->setCheckState( Qt::Unchecked );
pItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); pItem->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
pItem->setText( QString::fromLocal8Bit(iter->GiftName().c_str()) ); pItem->setText( QString::fromLocal8Bit( iter->GiftName().c_str() ) );
pItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter );
pTableGifts->setItem( rowIndex, 0, pItem ); pTableGifts->setItem( rowIndex, 0, pItem );
@ -119,7 +115,7 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
pItem = new QTableWidgetItem(); pItem = new QTableWidgetItem();
pItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable ); pItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable );
pItem->setText( QString::fromLocal8Bit(iter->GiftDefaultPrice().c_str()) ); pItem->setText( QString::fromLocal8Bit( iter->GiftDefaultPrice().c_str() ) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableGifts->setItem( rowIndex, 1, pItem ); pTableGifts->setItem( rowIndex, 1, pItem );
@ -127,13 +123,13 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
++iter; ++iter;
} }
//其他 //其他
QTableWidgetItem * pItemOther = new QTableWidgetItem(); QTableWidgetItem * pItemOther = new QTableWidgetItem();
QTableWidgetItem * pItemOtherPrice = new QTableWidgetItem(); QTableWidgetItem * pItemOtherPrice = new QTableWidgetItem();
pItemOther->setText( QString::fromLocal8Bit("其他") ); pItemOther->setText( QString::fromLocal8Bit( "其他" ) );
pItemOther->setCheckState( Qt::Unchecked ); pItemOther->setCheckState( Qt::Unchecked );
pItemOther->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); pItemOther->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
pItemOther->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); pItemOther->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter );
pItemOtherPrice->setText( "0" ); pItemOtherPrice->setText( "0" );
@ -143,16 +139,16 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
pTableGifts->setItem( m_giftsList.size(), 0, pItemOther ); pTableGifts->setItem( m_giftsList.size(), 0, pItemOther );
pTableGifts->setItem( m_giftsList.size(), 1, pItemOtherPrice ); pTableGifts->setItem( m_giftsList.size(), 1, pItemOtherPrice );
//礼品总价值 //礼品总价值
QTableWidgetItem * pItemTotalPrice = new QTableWidgetItem(); QTableWidgetItem * pItemTotalPrice = new QTableWidgetItem();
QTableWidgetItem * pItemTotalPriceAmount = new QTableWidgetItem(); QTableWidgetItem * pItemTotalPriceAmount = new QTableWidgetItem();
pItemTotalPrice->setText( QString::fromLocal8Bit("礼品总价值") ); pItemTotalPrice->setText( QString::fromLocal8Bit( "礼品总价值" ) );
pItemTotalPrice->setTextColor( Qt::red ); pItemTotalPrice->setTextColor( Qt::red );
pItemTotalPrice->setFlags( Qt::ItemIsEnabled ); pItemTotalPrice->setFlags( Qt::ItemIsEnabled );
pItemTotalPrice->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItemTotalPrice->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pItemTotalPriceAmount->setText( QString::fromLocal8Bit("0 元") ); pItemTotalPriceAmount->setText( QString::fromLocal8Bit( "0 元" ) );
pItemTotalPriceAmount->setTextColor( Qt::red ); pItemTotalPriceAmount->setTextColor( Qt::red );
pItemTotalPriceAmount->setFlags( Qt::ItemIsEnabled ); pItemTotalPriceAmount->setFlags( Qt::ItemIsEnabled );
pItemTotalPriceAmount->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItemTotalPriceAmount->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
@ -165,13 +161,13 @@ void QTelSalePolicyInfoInputWidget::InitGiftTable()
m_initing = false; m_initing = false;
} }
void QTelSalePolicyInfoInputWidget::readGiftTable(vector<TelSalePolicyGift> & giftList) void QTelSalePolicyInfoInputWidget::readGiftTable( vector<TelSalePolicyGift> & giftList )
{ {
int rowCount = pTableGifts->rowCount(); int rowCount = pTableGifts->rowCount();
for ( int rowIndex = 0; rowIndex < rowCount; rowIndex++ ) for ( int rowIndex = 0; rowIndex < rowCount; rowIndex++ )
{ {
QTableWidgetItem * pItemName = pTableGifts->item( rowIndex, 0 ); QTableWidgetItem * pItemName = pTableGifts->item( rowIndex, 0 );
QTableWidgetItem * pItemPrice = pTableGifts->item( rowIndex, 1 ); QTableWidgetItem * pItemPrice = pTableGifts->item( rowIndex, 1 );
if ( pItemName->checkState() == Qt::Unchecked ) if ( pItemName->checkState() == Qt::Unchecked )
@ -179,7 +175,9 @@ void QTelSalePolicyInfoInputWidget::readGiftTable(vector<TelSalePolicyGift> & gi
continue; continue;
} }
TelSalePolicyGift gift( rowIndex, string(pItemName->text().toLocal8Bit().data()), string( pItemPrice->text().toLocal8Bit().data() )); TelSalePolicyGift gift( rowIndex,
string( pItemName->text().toLocal8Bit().data() ),
string( pItemPrice->text().toLocal8Bit().data() ) );
giftList.push_back( gift ); giftList.push_back( gift );
} }
@ -203,13 +201,18 @@ void QTelSalePolicyInfoInputWidget::onQuerySalerName()
{ {
m_strSalerCode = pEditSalerCode->text().trimmed().toUpper().toLocal8Bit().data(); m_strSalerCode = pEditSalerCode->text().trimmed().toUpper().toLocal8Bit().data();
queryStaffInfo( m_strSalerCode, m_strSalerName, m_strSalerDeptCode, m_strSalerDeptName, m_strSalerOfficeCode, m_strSalerOfficeName ); queryStaffInfo( m_strSalerCode,
m_strSalerName,
m_strSalerDeptCode,
m_strSalerDeptName,
m_strSalerOfficeCode,
m_strSalerOfficeName );
pEditSalerName->setText( QString::fromLocal8Bit( m_strSalerName.c_str() )); pEditSalerName->setText( QString::fromLocal8Bit( m_strSalerName.c_str() ) );
pEditOfficeCode->setText( QString::fromLocal8Bit( m_strSalerOfficeCode.c_str() )); pEditOfficeCode->setText( QString::fromLocal8Bit( m_strSalerOfficeCode.c_str() ) );
pEditOfficeName->setText( QString::fromLocal8Bit( m_strSalerOfficeName.c_str() )); pEditOfficeName->setText( QString::fromLocal8Bit( m_strSalerOfficeName.c_str() ) );
pEditDeptCode->setText( QString::fromLocal8Bit( m_strSalerDeptCode.c_str() )); pEditDeptCode->setText( QString::fromLocal8Bit( m_strSalerDeptCode.c_str() ) );
pEditDeptName->setText( QString::fromLocal8Bit( m_strSalerDeptName.c_str() )); pEditDeptName->setText( QString::fromLocal8Bit( m_strSalerDeptName.c_str() ) );
} }
void QTelSalePolicyInfoInputWidget::onSavePolicy() void QTelSalePolicyInfoInputWidget::onSavePolicy()
@ -217,79 +220,95 @@ void QTelSalePolicyInfoInputWidget::onSavePolicy()
string strJqxPolicySerial = pEditQjxPolicySerial->text().trimmed().toLocal8Bit().data(); string strJqxPolicySerial = pEditQjxPolicySerial->text().trimmed().toLocal8Bit().data();
string strBizPolicySerial = pEditBizPolicySerial->text().trimmed().toLocal8Bit().data(); string strBizPolicySerial = pEditBizPolicySerial->text().trimmed().toLocal8Bit().data();
int iAutotraderCallIndex = pComboBoxAutotraderCall->currentIndex(); int iAutotraderCallIndex = pComboBoxAutotraderCall->currentIndex();
vector<TelSalePolicyGift> giftsList; //用户选择的礼品清单 vector<TelSalePolicyGift> giftsList; //用户选择的礼品清单
//触发信号 //触发信号
emit pEditSalerCode->editingFinished(); emit pEditSalerCode->editingFinished();
emit pEditAutoTraderCode->editingFinished(); emit pEditAutoTraderCode->editingFinished();
if ( strJqxPolicySerial.empty() && strBizPolicySerial.empty() ) if ( strJqxPolicySerial.empty() && strBizPolicySerial.empty() )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("必须输入保单号"), QString::fromLocal8Bit("交强险、商业险保单号皆为空,\n必须输入一个保单号!"), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "必须输入保单号" ),
QString::fromLocal8Bit( "交强险、商业险保单号皆为空,\n必须输入一个保单号!" ),
QMessageBox::Yes );
return; return;
} }
if ( m_strSalerName.empty() == true ) if ( m_strSalerName.empty() == true )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("必须输入经办人代码"), QString::fromLocal8Bit("经办人代码不正确!"), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "必须输入经办人代码" ),
QString::fromLocal8Bit( "经办人代码不正确!" ),
QMessageBox::Yes );
return; return;
} }
if ( iAutotraderCallIndex == 0 ) if ( iAutotraderCallIndex == 0 )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("输入错误"), QString::fromLocal8Bit("未选择是否车店联呼!"), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "输入错误" ),
QString::fromLocal8Bit( "未选择是否车店联呼!" ),
QMessageBox::Yes );
return; return;
} }
if ( pEditAutoTraderName->text().isEmpty() ) if ( pEditAutoTraderName->text().isEmpty() )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("输入错误"), QString::fromLocal8Bit("车商代码错误!"), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "输入错误" ),
QString::fromLocal8Bit( "车商代码错误!" ),
QMessageBox::Yes );
return; return;
} }
if ( pGroupBoxGift->isChecked() == true ) if ( pGroupBoxGift->isChecked() == true )
{ {
readGiftTable( giftsList ); readGiftTable( giftsList );
if ( giftsList.size() == 0 ) if ( giftsList.size() == 0 )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("输入错误"), QString::fromLocal8Bit("未选择礼品!"), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "输入错误" ),
QString::fromLocal8Bit( "未选择礼品!" ),
QMessageBox::Yes );
return; return;
} }
} }
SPolicyRecord policy;//保单信息 SPolicyRecord policy; //保单信息
policy.strSalerCode = m_strSalerCode; policy.strSalerCode = m_strSalerCode;
policy.strSalerName = m_strSalerName; policy.strSalerName = m_strSalerName;
policy.strSalerDeptCode = m_strSalerDeptCode; policy.strSalerDeptCode = m_strSalerDeptCode;
policy.strSalerDeptName = m_strSalerDeptName; policy.strSalerDeptName = m_strSalerDeptName;
policy.strSalerOfficeCode = m_strSalerOfficeCode; policy.strSalerOfficeCode = m_strSalerOfficeCode;
policy.strSalerOfficeName = m_strSalerOfficeName; policy.strSalerOfficeName = m_strSalerOfficeName;
policy.strOperatorCode = getUserCode(); policy.strOperatorCode = getUserCode();
policy.strCustomerName = pEditCustomerName->text().trimmed().toLocal8Bit().data(); policy.strCustomerName = pEditCustomerName->text().trimmed().toLocal8Bit().data();
policy.strPlateSerial = pEditPlateSerial->text().trimmed().toLocal8Bit().data(); policy.strPlateSerial = pEditPlateSerial->text().trimmed().toLocal8Bit().data();
policy.strFrameSerial = pEditFrameSerial->text().trimmed().toLocal8Bit().data(); policy.strFrameSerial = pEditFrameSerial->text().trimmed().toLocal8Bit().data();
policy.strEngineSerial = pEditEngineSerial->text().trimmed().toLocal8Bit().data(); policy.strEngineSerial = pEditEngineSerial->text().trimmed().toLocal8Bit().data();
policy.strOperatorDate = QDate::currentDate().toString( QString::fromLocal8Bit("MM/dd/yyyy")).toLocal8Bit().data(); policy.strOperatorDate = QDate::currentDate()
.toString( QString::fromLocal8Bit( "MM/dd/yyyy" ) ).toLocal8Bit().data();
if ( iAutotraderCallIndex == 2 ) if ( iAutotraderCallIndex == 2 )
{ {
policy.bIsAutotraderCall = true; policy.bIsAutotraderCall = true;
} }
else else
{ {
policy.bIsAutotraderCall = false; policy.bIsAutotraderCall = false;
} }
//车商代码 //车商代码
if ( m_strAutoTraderName.empty() == false ) if ( m_strAutoTraderName.empty() == false )
{ {
policy.strAutoTraderCode = m_strAutoTraderCode; policy.strAutoTraderCode = m_strAutoTraderCode;
@ -298,36 +317,48 @@ void QTelSalePolicyInfoInputWidget::onSavePolicy()
if ( strJqxPolicySerial.empty() == false ) if ( strJqxPolicySerial.empty() == false )
{ {
//处理交强险保单 //处理交强险保单
policy.strPolicySerial = strJqxPolicySerial; policy.strPolicySerial = strJqxPolicySerial;
try try
{ {
SaveTelSalePolicyInfo( policy, giftsList ); SaveTelSalePolicyInfo( policy, giftsList );
QMessageBox::information( this, QString::fromLocal8Bit("保存成功!"), QString::fromLocal8Bit("交强险保单保存成功!"), QMessageBox::Yes ); QMessageBox::information( this,
QString::fromLocal8Bit( "保存成功!" ),
QString::fromLocal8Bit( "交强险保单保存成功!" ),
QMessageBox::Yes );
} }
catch ( runtime_error & error ) catch ( runtime_error & error )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("保存交强险保单失败!"), QString::fromLocal8Bit(error.what()), QMessageBox::Yes ); QMessageBox::critical( this,
QString::fromLocal8Bit( "保存交强险保单失败!" ),
QString::fromLocal8Bit( error.what() ),
QMessageBox::Yes );
} }
} }
if ( strBizPolicySerial.empty() == false ) if ( strBizPolicySerial.empty() == false )
{ {
//处理交强险保单 //处理交强险保单
policy.strPolicySerial = strBizPolicySerial; policy.strPolicySerial = strBizPolicySerial;
try try
{ {
SaveTelSalePolicyInfo( policy, giftsList ); SaveTelSalePolicyInfo( policy, giftsList );
QMessageBox::information( this, QString::fromLocal8Bit("保存成功!"), QString::fromLocal8Bit("商业险保单保存成功!"), QMessageBox::Yes ); QMessageBox::information( this,
QString::fromLocal8Bit( "保存成功!" ),
QString::fromLocal8Bit( "商业险保单保存成功!" ),
QMessageBox::Yes );
} }
catch ( runtime_error & error ) catch ( runtime_error & error )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("保存商业险保单失败!"), QString::fromLocal8Bit(error.what()), QMessageBox::Yes ); QMessageBox::critical( this,
} QString::fromLocal8Bit( "保存商业险保单失败!" ),
QString::fromLocal8Bit( error.what() ),
QMessageBox::Yes );
}
} }
} }
@ -336,29 +367,31 @@ void QTelSalePolicyInfoInputWidget::onResetGiftsTable()
InitGiftTable(); InitGiftTable();
} }
void QTelSalePolicyInfoInputWidget::onGiftTableItemChanged(int row, int column) void QTelSalePolicyInfoInputWidget::onGiftTableItemChanged( int row, int column )
{ {
if ( m_initing == true ) if ( m_initing == true )
{ {
return; return;
} }
int rowCount = pTableGifts->rowCount() - 1; int rowCount = pTableGifts->rowCount() - 1;
QTableWidgetItem * pItem = NULL; QTableWidgetItem * pItem = NULL;
QTableWidgetItem * pItemPrice = NULL; QTableWidgetItem * pItemPrice = NULL;
bool isSuccess = false; bool isSuccess = false;
double giftPrice = 0.0l; double giftPrice = 0.0l;
if ( column == 1 && row != rowCount ) if ( column == 1 && row != rowCount )
{ {
pItem = pTableGifts->item( row, 0 ); pItem = pTableGifts->item( row, 0 );
pItemPrice = pTableGifts->item( row, column ); pItemPrice = pTableGifts->item( row, column );
pItemPrice->text().toDouble( &isSuccess ); pItemPrice->text().toDouble( &isSuccess );
if ( isSuccess == false ) if ( isSuccess == false )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("输入错误!"), pItem->text() + QString::fromLocal8Bit("价格有误!") ); QMessageBox::critical( this,
QString::fromLocal8Bit( "输入错误!" ),
pItem->text() + QString::fromLocal8Bit( "价格有误!" ) );
pItemPrice->setText( "0" ); pItemPrice->setText( "0" );
} }
@ -366,7 +399,7 @@ void QTelSalePolicyInfoInputWidget::onGiftTableItemChanged(int row, int column)
for ( int rowIndex = 0; rowIndex < rowCount; rowIndex++ ) for ( int rowIndex = 0; rowIndex < rowCount; rowIndex++ )
{ {
pItem = pTableGifts->item( rowIndex, 0 ); pItem = pTableGifts->item( rowIndex, 0 );
pItemPrice = pTableGifts->item( rowIndex, 1 ); pItemPrice = pTableGifts->item( rowIndex, 1 );
if ( pItem->checkState() == Qt::Unchecked ) if ( pItem->checkState() == Qt::Unchecked )
@ -378,13 +411,15 @@ void QTelSalePolicyInfoInputWidget::onGiftTableItemChanged(int row, int column)
if ( isSuccess == false ) if ( isSuccess == false )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("输入错误!"), pItem->text() + QString::fromLocal8Bit("价格有误!") ); QMessageBox::critical( this,
QString::fromLocal8Bit( "输入错误!" ),
pItem->text() + QString::fromLocal8Bit( "价格有误!" ) );
pItemPrice->setText( "0" ); pItemPrice->setText( "0" );
} }
} }
pTableGifts->item( pTableGifts->rowCount() - 1, 1 )->setText( QString::fromLocal8Bit("%1 元").arg(giftPrice) ); pTableGifts->item( pTableGifts->rowCount() - 1, 1 )->setText( QString::fromLocal8Bit( "%1 元" ).arg( giftPrice ) );
pTableGifts->resizeColumnsToContents(); pTableGifts->resizeColumnsToContents();
} }
@ -401,7 +436,7 @@ void QTelSalePolicyInfoInputWidget::onQueryAutoTraderName()
queryAutoTraderInfo( m_strAutoTraderCode, m_strAutoTraderName ); queryAutoTraderInfo( m_strAutoTraderCode, m_strAutoTraderName );
pEditAutoTraderName->setText( QString::fromLocal8Bit( m_strAutoTraderName.c_str() )); pEditAutoTraderName->setText( QString::fromLocal8Bit( m_strAutoTraderName.c_str() ) );
} }
void QTelSalePolicyInfoInputWidget::onReset() void QTelSalePolicyInfoInputWidget::onReset()

View File

@ -5,7 +5,6 @@
#include "SystemData.h" #include "SystemData.h"
#include "QTelSalePolicyInfoQuery.h" #include "QTelSalePolicyInfoQuery.h"
using namespace std; using namespace std;
QTelSalePolicyInfoQuery::QTelSalePolicyInfoQuery(QWidget *parent) QTelSalePolicyInfoQuery::QTelSalePolicyInfoQuery(QWidget *parent)
@ -32,7 +31,7 @@ void QTelSalePolicyInfoQuery::initWidget()
{ {
setLayout( pLayoutMain ); setLayout( pLayoutMain );
//录入时间 //录入时间
pDateEditStart->setDate( QDate::currentDate().addDays(-1) ); pDateEditStart->setDate( QDate::currentDate().addDays(-1) );
pDateEditEnd->setDate( QDate::currentDate() ); pDateEditEnd->setDate( QDate::currentDate() );
} }
@ -75,7 +74,7 @@ void QTelSalePolicyInfoQuery::onQuery()
} }
else else
{ {
//自动使用操作员的工号为条件 //自动使用操作员的工号为条件
strOperatorCode = getUserCode(); strOperatorCode = getUserCode();
} }
@ -97,13 +96,13 @@ void QTelSalePolicyInfoQuery::onQuery()
} }
catch ( runtime_error & error ) catch ( runtime_error & error )
{ {
QMessageBox::critical( this, QString::fromLocal8Bit("查询错误!"), QString::fromLocal8Bit(error.what()) ); QMessageBox::critical( this, QString::fromLocal8Bit("查询错误!"), QString::fromLocal8Bit(error.what()) );
} }
} }
void QTelSalePolicyInfoQuery::onReset() void QTelSalePolicyInfoQuery::onReset()
{ {
//录入时间 //录入时间
pDateEditStart->setDate( QDate::currentDate().addDays(-1) ); pDateEditStart->setDate( QDate::currentDate().addDays(-1) );
pDateEditEnd->setDate( QDate::currentDate() ); pDateEditEnd->setDate( QDate::currentDate() );
@ -122,69 +121,69 @@ void QTelSalePolicyInfoQuery::showData(std::vector<SPolicyQuery> & vPolicy)
for ( vector<SPolicyQuery>::iterator iter = vPolicy.begin(); iter != vPolicy.end(); ++iter ) for ( vector<SPolicyQuery>::iterator iter = vPolicy.begin(); iter != vPolicy.end(); ++iter )
{ {
//保单号 //保单号
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strPolicySerial.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strPolicySerial.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 0, pItem ); pTableWidgetInfo->setItem( nRowIndex, 0, pItem );
//经办人 //经办人
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strSalerCode.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strSalerCode.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 1, pItem ); pTableWidgetInfo->setItem( nRowIndex, 1, pItem );
//部门 //部门
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strDeptName.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strDeptName.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 2, pItem ); pTableWidgetInfo->setItem( nRowIndex, 2, pItem );
//科室 //科室
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strOfficeName.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strOfficeName.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 3, pItem ); pTableWidgetInfo->setItem( nRowIndex, 3, pItem );
//车店联呼 //车店联呼
if ( iter->strCDLH == "1" ) if ( iter->strCDLH == "1" )
{ {
pItem = new QTableWidgetItem( QString::fromLocal8Bit( "" )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( "" ));
} }
else else
{ {
pItem = new QTableWidgetItem( QString::fromLocal8Bit( "" )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( "" ));
} }
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 4, pItem ); pTableWidgetInfo->setItem( nRowIndex, 4, pItem );
//车商代码 //车商代码
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strAutoTraderCode.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strAutoTraderCode.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 5, pItem ); pTableWidgetInfo->setItem( nRowIndex, 5, pItem );
//车商名称 //车商名称
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strAutoTraderName.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strAutoTraderName.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 6, pItem ); pTableWidgetInfo->setItem( nRowIndex, 6, pItem );
//礼品总价值 //礼品总价值
pItem = new QTableWidgetItem( QString::number(iter->dGiftPriceSum, 'f', 2) ); pItem = new QTableWidgetItem( QString::number(iter->dGiftPriceSum, 'f', 2) );
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 7, pItem ); pTableWidgetInfo->setItem( nRowIndex, 7, pItem );
//礼品 //礼品
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strGifts.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strGifts.c_str() ));
pItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignLeft | Qt::AlignVCenter );
pTableWidgetInfo->setItem( nRowIndex, 8, pItem ); pTableWidgetInfo->setItem( nRowIndex, 8, pItem );
//录入日期 //录入日期
pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strInputDate.c_str() )); pItem = new QTableWidgetItem( QString::fromLocal8Bit( iter->strInputDate.c_str() ));
pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); pItem->setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter );

View File

@ -2,7 +2,7 @@
#define QTELSALEPOLICYINFOQUERY_H #define QTELSALEPOLICYINFOQUERY_H
#include <vector> #include <vector>
#include <QWidget> #include <QWidget>
#include "DataManipulation.h" #include "DataManipulation.h"
#include "ui_QTelSalePolicyInfoQuery.h" #include "ui_QTelSalePolicyInfoQuery.h"

View File

@ -5,7 +5,7 @@
//#include <stdio.h> //#include <stdio.h>
#include <string> #include <string>
#include <cstring> #include <cstring>
using namespace std; using namespace std;
size_t StringCodeConverter::mbslen( const char *pcszSource ) size_t StringCodeConverter::mbslen( const char *pcszSource )
@ -30,7 +30,7 @@ size_t StringCodeConverter::mbslen( const char *pcszSource )
wstring StringCodeConverter::mbs2unicode( const string &cstrSource ) wstring StringCodeConverter::mbs2unicode( const string &cstrSource )
{ {
string strCurLocale = setlocale( LC_ALL, NULL ); string strCurLocale = setlocale( LC_ALL, NULL );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
const char *pcszSource = cstrSource.c_str(); const char *pcszSource = cstrSource.c_str();
@ -43,7 +43,7 @@ wstring StringCodeConverter::mbs2unicode( const string &cstrSource )
if ( iConvertedCount == -1 ) if ( iConvertedCount == -1 )
{ {
delete [] pwszBuffer; delete [] pwszBuffer;
throw string( "mbs2unicode参数有非中英文字符" ); throw string( "mbs2unicode参数有非中英文字符" );
} }
wstring wstrDest( pwszBuffer ); wstring wstrDest( pwszBuffer );
@ -57,17 +57,17 @@ wstring StringCodeConverter::mbs2unicode( const string &cstrSource )
void StringCodeConverter::mbs2unicode(const string &strSource, wstring &wstrDest) void StringCodeConverter::mbs2unicode(const string &strSource, wstring &wstrDest)
{ {
const char *pcszSource = strSource.c_str(); const char *pcszSource = strSource.c_str();
string strCurLocale( setlocale(LC_ALL, NULL) );//先保存当前的locale设置 string strCurLocale( setlocale(LC_ALL, NULL) );//先保存当前的locale设置
setlocale( LC_ALL, "chs" );//设置为中文 setlocale( LC_ALL, "chs" );//设置为中文
size_t iCharCount = strSource.size() + 1;//unicode字符串所需要的字符数 size_t iCharCount = strSource.size() + 1;//unicode字符串所需要的字符数
wchar_t *pwszBuffer = new wchar_t[ iCharCount ]; wchar_t *pwszBuffer = new wchar_t[ iCharCount ];
wmemset( pwszBuffer, 0, iCharCount ); wmemset( pwszBuffer, 0, iCharCount );
mbstowcs( pwszBuffer, pcszSource, iCharCount ); mbstowcs( pwszBuffer, pcszSource, iCharCount );
setlocale( LC_ALL, strCurLocale.c_str() );//改回原来的locale设置 setlocale( LC_ALL, strCurLocale.c_str() );//改回原来的locale设置
wstrDest = pwszBuffer; wstrDest = pwszBuffer;
delete [] pwszBuffer; delete [] pwszBuffer;
@ -77,17 +77,17 @@ void StringCodeConverter::mbs2unicode( const char *pcszSource, wchar_t *pwszDest
{ {
if ( pcszSource == NULL || pwszDest == NULL ) if ( pcszSource == NULL || pwszDest == NULL )
{ {
throw string( "参数指针为NULL" ); throw string( "参数指针为NULL" );
} }
string strCurLocale = setlocale( LC_ALL, NULL ); string strCurLocale = setlocale( LC_ALL, NULL );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
size_t iCharCount = mbslen( pcszSource ) + 1; size_t iCharCount = mbslen( pcszSource ) + 1;
if ( iCharCount == -1 ) if ( iCharCount == -1 )
{ {
throw string( "源字符串的编码有非中英文字符" ); throw string( "源字符串的编码有非中英文字符" );
} }
wmemset( pwszDest, 0, iCharCount ); wmemset( pwszDest, 0, iCharCount );
@ -95,7 +95,7 @@ void StringCodeConverter::mbs2unicode( const char *pcszSource, wchar_t *pwszDest
if ( iConvertedCount == -1 ) if ( iConvertedCount == -1 )
{ {
throw string( "源字符串的编码有非中英文字符" ); throw string( "源字符串的编码有非中英文字符" );
} }
*( pwszDest + iConvertedCount ) = NULL; *( pwszDest + iConvertedCount ) = NULL;
@ -108,13 +108,13 @@ void StringCodeConverter::mbs2utf8( const string &cstrSource, char *pszDest )
const char *pcszSource = cstrSource.c_str(); const char *pcszSource = cstrSource.c_str();
string strCurLocale( setlocale( LC_ALL, NULL ) ); string strCurLocale( setlocale( LC_ALL, NULL ) );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
while ( *pcszSource != NULL ) while ( *pcszSource != NULL )
{ {
if ( *pcszSource > 0 ) if ( *pcszSource > 0 )
{ {
//英文字符,可以直接复制 //英文字符,可以直接复制
*pszDest = *pcszSource; *pszDest = *pcszSource;
pcszSource++; pcszSource++;
@ -122,12 +122,12 @@ void StringCodeConverter::mbs2utf8( const string &cstrSource, char *pszDest )
} }
else else
{ {
//非ascii英文字符,先转换成unicode再转换utf8 //非ascii英文字符,先转换成unicode再转换utf8
int iLen = 0; int iLen = 0;
wchar_t wUnicode = 0; wchar_t wUnicode = 0;
char *pcUnicode = (char *)&wUnicode; char *pcUnicode = (char *)&wUnicode;
//转换成unicode返回mb字符的长度 //转换成unicode返回mb字符的长度
iLen = mbtowc( &wUnicode, pcszSource, MB_CUR_MAX ); iLen = mbtowc( &wUnicode, pcszSource, MB_CUR_MAX );
pszDest[0] = (0xE0 | ((pcUnicode[1] & 0xF0) >> 4)); pszDest[0] = (0xE0 | ((pcUnicode[1] & 0xF0) >> 4));
@ -147,7 +147,7 @@ void StringCodeConverter::mbs2utf8( const string &cstrSource, char *pszDest )
string StringCodeConverter::unicode2mbs( const wstring &wstrSource ) string StringCodeConverter::unicode2mbs( const wstring &wstrSource )
{ {
string strCurLocale = setlocale( LC_ALL, NULL ); string strCurLocale = setlocale( LC_ALL, NULL );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
const wchar_t *pcwszSource = wstrSource.c_str(); const wchar_t *pcwszSource = wstrSource.c_str();
@ -159,7 +159,7 @@ string StringCodeConverter::unicode2mbs( const wstring &wstrSource )
if ( iConvertedCount == -1 ) if ( iConvertedCount == -1 )
{ {
throw string( "unicode2mbs源字符串的编码有非中英文字符" ); throw string( "unicode2mbs源字符串的编码有非中英文字符" );
} }
setlocale( LC_ALL, strCurLocale.c_str() ); setlocale( LC_ALL, strCurLocale.c_str() );
@ -185,7 +185,7 @@ void StringCodeConverter::unicode2mbs( const wstring &wstrSource, string &strDes
if ( iConvertedCount == -1 ) if ( iConvertedCount == -1 )
{ {
delete [] pszBuffer; delete [] pszBuffer;
throw string( "unicode2mbs转换失败字符串中有非中英文字符" ); throw string( "unicode2mbs转换失败字符串中有非中英文字符" );
} }
strDest = pszBuffer; strDest = pszBuffer;
@ -198,11 +198,11 @@ void StringCodeConverter::unicode2mbs( const wchar_t *pcwszSource, char *pszDest
{ {
if ( pcwszSource == NULL || pszDest == NULL ) if ( pcwszSource == NULL || pszDest == NULL )
{ {
throw string( "unicode2mbs函数参数值为NULL" ); throw string( "unicode2mbs函数参数值为NULL" );
} }
string strCurLocale = setlocale( LC_ALL, NULL ); string strCurLocale = setlocale( LC_ALL, NULL );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
size_t iCount = wcslen( pcwszSource )*2 + 1; size_t iCount = wcslen( pcwszSource )*2 + 1;
memset( pszDest, 0, iCount ); memset( pszDest, 0, iCount );
@ -211,7 +211,7 @@ void StringCodeConverter::unicode2mbs( const wchar_t *pcwszSource, char *pszDest
if ( iConvertedCount == -1 ) if ( iConvertedCount == -1 )
{ {
throw string( "unicode2mbs转换失败字符串中有非中英文字符" ); throw string( "unicode2mbs转换失败字符串中有非中英文字符" );
} }
setlocale( LC_ALL, strCurLocale.c_str() ); setlocale( LC_ALL, strCurLocale.c_str() );
@ -221,7 +221,7 @@ void StringCodeConverter::unicode2utf8( const wstring &cwstrSource, char *pszDes
{ {
if ( pszDest == NULL ) if ( pszDest == NULL )
{ {
throw string( "参数为NULL" ); throw string( "参数为NULL" );
} }
const wchar_t *pcwszSource = cwstrSource.c_str(); const wchar_t *pcwszSource = cwstrSource.c_str();
@ -232,14 +232,14 @@ void StringCodeConverter::unicode2utf8( const wstring &cwstrSource, char *pszDes
if ( iUnicode < 128 ) if ( iUnicode < 128 )
{ {
//小于128是英文字符不需要转换 //小于128是英文字符不需要转换
*pszDest = (char)iUnicode; *pszDest = (char)iUnicode;
pszDest++; pszDest++;
pcwszSource++; pcwszSource++;
} }
else else
{ {
//大于128是mbs字符需要转换 //大于128是mbs字符需要转换
const char *pcszUnicode = (const char *)pcwszSource; const char *pcszUnicode = (const char *)pcwszSource;
pszDest[0] = (0xE0 | ((pcszUnicode[1] & 0xF0) >> 4 )); pszDest[0] = (0xE0 | ((pcszUnicode[1] & 0xF0) >> 4 ));
@ -251,18 +251,18 @@ void StringCodeConverter::unicode2utf8( const wstring &cwstrSource, char *pszDes
} }
} }
*pszDest = NULL;//末尾的NULL字符 *pszDest = NULL;//末尾的NULL字符
} }
string StringCodeConverter::utf8tombs( const char *pcszSource ) string StringCodeConverter::utf8tombs( const char *pcszSource )
{ {
if ( pcszSource == NULL ) if ( pcszSource == NULL )
{ {
throw string( "参数为NULL" ); throw string( "参数为NULL" );
} }
string strCurLocale( setlocale( LC_ALL, NULL ) ); string strCurLocale( setlocale( LC_ALL, NULL ) );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
char *pszDest = new char[ strlen( pcszSource ) ]; char *pszDest = new char[ strlen( pcszSource ) ];
char *pszBuffer = pszDest; char *pszBuffer = pszDest;
@ -271,7 +271,7 @@ string StringCodeConverter::utf8tombs( const char *pcszSource )
{ {
if ( *pcszSource > 0 ) if ( *pcszSource > 0 )
{ {
//是ASCII字符 //是ASCII字符
*pszDest = *pcszSource; *pszDest = *pcszSource;
pszDest++; pszDest++;
@ -309,7 +309,7 @@ string StringCodeConverter::utf8tombs( const char *pcszSource )
*pszDest = NULL; *pszDest = NULL;
setlocale( LC_ALL, strCurLocale.c_str() ); setlocale( LC_ALL, strCurLocale.c_str() );
strCurLocale = pszBuffer; //废物利用 strCurLocale = pszBuffer; //废物利用
return strCurLocale; return strCurLocale;
} }
@ -318,11 +318,11 @@ wstring StringCodeConverter::utf8tounicode( const char *pcszSource )
{ {
if ( pcszSource == NULL ) if ( pcszSource == NULL )
{ {
throw string( "参数为NULL" ); throw string( "参数为NULL" );
} }
string strCurLocale = setlocale( LC_ALL, NULL ); string strCurLocale = setlocale( LC_ALL, NULL );
setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果 setlocale( LC_ALL, "chinese-simplified" ); //改成中文环境,如果接受的参数不是中文字符串,得注意结果
wchar_t *pwszBuffer = new wchar_t[ strlen( pcszSource ) ]; wchar_t *pwszBuffer = new wchar_t[ strlen( pcszSource ) ];
wchar_t *pwszDest = pwszBuffer; wchar_t *pwszDest = pwszBuffer;
@ -331,7 +331,7 @@ wstring StringCodeConverter::utf8tounicode( const char *pcszSource )
{ {
if ( *pcszSource > 0 ) if ( *pcszSource > 0 )
{ {
//是ASCII字符 //是ASCII字符
wchar_t wUnicode; wchar_t wUnicode;
mbtowc( &wUnicode, pcszSource, 1 ); mbtowc( &wUnicode, pcszSource, 1 );
@ -343,7 +343,7 @@ wstring StringCodeConverter::utf8tounicode( const char *pcszSource )
} }
else else
{ {
//中文字符3个字节 //中文字符3个字节
wchar_t wUnicode; wchar_t wUnicode;
char *pcUnicode = (char *)&wUnicode; char *pcUnicode = (char *)&wUnicode;
@ -359,7 +359,7 @@ wstring StringCodeConverter::utf8tounicode( const char *pcszSource )
setlocale( LC_ALL, strCurLocale.c_str() ); setlocale( LC_ALL, strCurLocale.c_str() );
*pwszDest = NULL;//末尾空字符 *pwszDest = NULL;//末尾空字符
wstring wstrDest( pwszBuffer ); wstring wstrDest( pwszBuffer );
return wstrDest; return wstrDest;

View File

@ -4,7 +4,7 @@
namespace StringCodeConverter namespace StringCodeConverter
{ {
using std::string; using std::string;
using std::wstring; using std::wstring;
size_t mbslen( const char *pcszSource ); size_t mbslen( const char *pcszSource );

View File

@ -1,22 +1,22 @@
#include "SystemData.h" #include "SystemData.h"
//hash_map<string, string> parameters; //存放参数的hashmap //hash_map<string, string> parameters; //存放参数的hashmap
//版本号 //版本号
const string cstrVersion = "0.99"; const string cstrVersion = "0.99";
string strUserCode; string strUserCode;
string strUserName; string strUserName;
string strUserPassword; string strUserPassword;
//参数 //参数
Parameters parameters( "config.db" ); Parameters parameters( "config.db" );
//bool checkVersion() //bool checkVersion()
//{ //{
// bool result = false; // bool result = false;
// hash_map<string,string>::iterator iter = parameters.find( string("版本号") ); // hash_map<string,string>::iterator iter = parameters.find( string("版本号") );
// //
// if ( iter != parameters.end() && iter->second == cstrVersion ) // if ( iter != parameters.end() && iter->second == cstrVersion )
// { // {
@ -48,5 +48,5 @@ void setUserName(const string & cstrUserName)
string getVersion() string getVersion()
{ {
return parameters.getParameter("版本号"); return parameters.getParameter("版本号");
} }

View File

@ -91,13 +91,13 @@ void QueryUserInfo(const string & strCode, string & strName, string & strPasswor
if ( command.FetchNext() == true ) if ( command.FetchNext() == true )
{ {
//名字 //名字
SAString sastrResult = command.Field("rymc").asString(); SAString sastrResult = command.Field("rymc").asString();
sastrResult.TrimRight(); sastrResult.TrimRight();
strName = (const char *)sastrResult; strName = (const char *)sastrResult;
//密码 //密码
sastrResult = command.Field("rymm").asString(); sastrResult = command.Field("rymm").asString();
sastrResult.TrimRight(); sastrResult.TrimRight();

View File

@ -11,10 +11,10 @@ using std::string;
// FullName: QueryOperatorInfo // FullName: QueryOperatorInfo
// Access: public // Access: public
// Returns: void // Returns: void
// Qualifier: 查询系统用户的信息 // Qualifier: 查询系统用户的信息
// Parameter: const string & strCode 工号 // Parameter: const string & strCode 工号
// Parameter: string & strName 名字 // Parameter: string & strName 名字
// Parameter: string & strPassword 密码 // Parameter: string & strPassword 密码
//************************************ //************************************
void QueryUserInfo( const string & strCode, void QueryUserInfo( const string & strCode,
string & strName, string & strName,
@ -26,13 +26,13 @@ void QueryUserInfo( const string & strCode,
// FullName: queryOperatorInfo // FullName: queryOperatorInfo
// Access: public // Access: public
// Returns: void // Returns: void
// Qualifier: 查询经办人的信息 // Qualifier: 查询经办人的信息
// Parameter: const string & strOperatorCode 经办人代码 // Parameter: const string & strOperatorCode 经办人代码
// Parameter: string & strOperatorName 经办人名称 // Parameter: string & strOperatorName 经办人名称
// Parameter: string & strDeptCode 部门代码 // Parameter: string & strDeptCode 部门代码
// Parameter: string & strDeptName 部门名称 // Parameter: string & strDeptName 部门名称
// Parameter: string & strOfficeCode 科室代码 // Parameter: string & strOfficeCode 科室代码
// Parameter: string & strOfficeName 科室名称 // Parameter: string & strOfficeName 科室名称
//************************************ //************************************
void queryStaffInfo( const string & strOperatorCode, void queryStaffInfo( const string & strOperatorCode,
string & strOperatorName, string & strOperatorName,
@ -46,7 +46,7 @@ void queryStaffInfo( const string & strOperatorCode,
// FullName: queryAutoTraderInfo // FullName: queryAutoTraderInfo
// Access: public // Access: public
// Returns: void // Returns: void
// Qualifier: 查询车商信息 // Qualifier: 查询车商信息
// Parameter: const string & strAutoTraderCode // Parameter: const string & strAutoTraderCode
// Parameter: string & strAutoTraderName // Parameter: string & strAutoTraderName
//************************************ //************************************

View File

@ -1,9 +1,9 @@
#include "check.h" #include "check.h"
hash_map<string, string> parameters; //存放参数的hashmap hash_map<string, string> parameters; //存放参数的hashmap
//版本号 //版本号
const string cstrVersion = "0.99"; const string cstrVersion = "0.99";
string strUserCode; string strUserCode;
@ -13,7 +13,7 @@ string strUserPassword;
bool checkVersion() bool checkVersion()
{ {
bool result = false; bool result = false;
hash_map<string,string>::iterator iter = parameters.find( string("版本号") ); hash_map<string,string>::iterator iter = parameters.find( string("版本号") );
if ( iter != parameters.end() && iter->second == cstrVersion ) if ( iter != parameters.end() && iter->second == cstrVersion )
{ {

View File

@ -1,54 +1,52 @@
//#include <QTextCodec>
#include <QTextCodec>
#include <QString> #include <QString>
#include <QtWidgets/QMessageBox.h> #include <QtWidgets/QtWidgets>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <exception> #include <exception>
#include "QMainFrame.h" #include "QMainFrame.h"
#include "QLoginWidget.h" #include "QLoginWidget.h"
int main(int argc, char *argv[]) int main( int argc, char * argv[] )
{ {
//用于编码转换 //用于编码转换
QTextCodec * pCodecLocal = QTextCodec::codecForLocale(); //QTextCodec * pCodecLocal = QTextCodec::codecForLocale();
QApplication a(argc, argv); QApplication a( argc, argv );
QLoginWidget login; QLoginWidget login;
int iReturnCode = 0; int iReturnCode = 0;
/*try /*try
{ {
initConnectionPool(); initConnectionPool();
queryParameters(); queryParameters();
if ( checkVersion() == false ) if ( checkVersion() == false )
{ {
QMessageBox::warning( NULL, QMessageBox::warning( NULL,
pCodecLocal->toUnicode( "版本错误" ), pCodecLocal->toUnicode( "版本错误" ),
pCodecLocal->toUnicode( "程序版本过低!\n请联系信息技术部更新程序!" )); pCodecLocal->toUnicode( "程序版本过低!\n请联系信息技术部更新程序!" ) );
return 0; return 0;
} }
} }
catch ( std::runtime_error & error ) catch ( std::runtime_error & error )
{ {
releaseConnectionPool(); releaseConnectionPool();
QMessageBox::critical( NULL, QMessageBox::critical( NULL,
"错误", "错误",
pCodecLocal->toUnicode(error.what()) ); pCodecLocal->toUnicode( error.what() ) );
return iReturnCode; return iReturnCode;
} }
catch ( std::exception &error ) catch ( std::exception & error )
{ {
releaseConnectionPool(); releaseConnectionPool();
QMessageBox::critical( NULL, QMessageBox::critical( NULL,
"未知错误", "未知错误",
pCodecLocal->toUnicode( error.what() )); pCodecLocal->toUnicode( error.what() ) );
return iReturnCode; return iReturnCode;
}*/ }*/
login.exec(); login.exec();