更新sqlite3,更改参数数据库初始化机制,更改main函数。

This commit is contained in:
2018-06-15 14:35:27 +08:00
parent 8de9c8cc36
commit 207f8f211f
175 changed files with 79 additions and 558103 deletions

View File

@@ -13,6 +13,7 @@ Parameters::Parameters(void)
Parameters::Parameters(const string & strFilePath)
{
sqlite3 * pdbParameter;
string path;
int returnCode;
int nRowCount;
@@ -21,13 +22,14 @@ Parameters::Parameters(const string & strFilePath)
char ** result;
char * pszMessage;
char szSQL[] =
"select name, value from sys_parameter ";
"select name, value from sys_parameters ";
returnCode = sqlite3_open( strFilePath.c_str(), &pdbParameter );
if ( returnCode != SQLITE_OK )
{
throw runtime_error( sqlite3_errmsg(pdbParameter) );
const char * pszMessage = sqlite3_errmsg(pdbParameter);
throw runtime_error( pszMessage );
}
//查询
@@ -35,7 +37,8 @@ Parameters::Parameters(const string & strFilePath)
if ( returnCode != SQLITE_OK )
{
throw runtime_error( sqlite3_errmsg( pdbParameter ));
const char * pszMessage = sqlite3_errmsg(pdbParameter);
throw runtime_error(pszMessage);
}
for ( int nRowIndex = nColCount; nRowIndex < nColCount*(nRowCount+1); nRowIndex += nColCount )
@@ -77,7 +80,7 @@ void Parameters::setParameter(const string & strParaName, const string & strPara
int iReturnCode;
char * szMsg;
string strSQL =
"update sys_parameter set value = '";
"update sys_parameters set value = '";
strSQL.append( strParaValue );
strSQL.append( "' where name = '" );

View File

@@ -41,7 +41,7 @@ void QConfigurationWidget::initSignal()
void QConfigurationWidget::initData()
{
pEditAutoTraderCode->setText( QString::fromLocal8Bit( parameters.getParameter("默认车商代码").c_str() ));
pEditAutoTraderCode->setText( QString::fromLocal8Bit( pParameters->getParameter("默认车商代码").c_str() ));
emit pEditAutoTraderCode->editingFinished();
}
@@ -75,7 +75,7 @@ void QConfigurationWidget::onSave()
return;
}
parameters.setParameter( "默认车商代码", pEditAutoTraderCode->text().toLocal8Bit().data() );
pParameters->setParameter( "默认车商代码", pEditAutoTraderCode->text().toLocal8Bit().data() );
}
void QConfigurationWidget::onReset()

View File

@@ -59,7 +59,7 @@ void QTelSalePolicyInfoInputWidget::initSignal()
void QTelSalePolicyInfoInputWidget::initData()
{
//默认的车商代码
pEditAutoTraderCode->setText( QString::fromLocal8Bit( parameters.getParameter( "默认车商代码" ).c_str() ) );
pEditAutoTraderCode->setText( QString::fromLocal8Bit( pParameters->getParameter( "默认车商代码" ).c_str() ) );
emit pEditAutoTraderCode->editingFinished();

View File

@@ -1,17 +1,19 @@
#include <QtCore/QtCore>
#include "SystemData.h"
//hash_map<string, string> parameters; //存放参数的hashmap
//版本号
const string cstrVersion = "0.99";
const string cstrVersion = "0.99";
const string DB_FILE_NAME = "config.db";
string strUserCode;
string strUserName;
string strUserPassword;
//参数
Parameters parameters( "config.db" );
//Parameters parameters( "config.db" );
Parameters* pParameters;
//bool checkVersion()
//{
@@ -26,6 +28,16 @@ Parameters parameters( "config.db" );
// return result;
//}
void init_parameters()
{
QString dbFilePath = QCoreApplication::applicationDirPath();
dbFilePath.append( QString::fromLocal8Bit( "/" ) );
dbFilePath.append( QString::fromLocal8Bit( DB_FILE_NAME.c_str() ) );
pParameters = new Parameters( dbFilePath.toStdString() );
}
string getUserCode()
{
return strUserCode;
@@ -36,17 +48,17 @@ string getUserName()
return strUserName;
}
void setUserCode(const string & cstrUserCode)
void setUserCode( const string& cstrUserCode )
{
strUserCode = cstrUserCode;
}
void setUserName(const string & cstrUserName)
void setUserName( const string& cstrUserName )
{
strUserName = cstrUserName;
}
string getVersion()
{
return parameters.getParameter("版本号");
}
return pParameters->getParameter( "version" );
}

View File

@@ -22,10 +22,12 @@
using namespace std;
//extern hash_map<string, string> parameters;
extern Parameters parameters;
extern Parameters * pParameters;
//bool checkVersion();
void init_parameters();
string getUserCode();
string getUserName();

View File

@@ -5,61 +5,71 @@
#include <exception>
#include "QMainFrame.h"
#include "QLoginWidget.h"
#include "SystemData.h"
using namespace std;
int main( int argc, char * argv[] )
{
//用于编码转换
//QTextCodec * pCodecLocal = QTextCodec::codecForLocale();
QApplication a( argc, argv );
QLoginWidget login;
QApplication * pApp = NULL;
QLoginWidget * pLogin = NULL;
QMainFrame * pMainFrame = NULL;
//返回值
int iReturnCode = 0;
/*try
try
{
initConnectionPool();
queryParameters();
if ( checkVersion() == false )
{
QMessageBox::warning( NULL,
pCodecLocal->toUnicode( "版本错误" ),
pCodecLocal->toUnicode( "程序版本过低!\n请联系信息技术部更新程序" ) );
return 0;
}
//初始化参数数据库
init_parameters();
}
catch ( std::runtime_error & error )
{
releaseConnectionPool();
QMessageBox::critical( NULL,
"错误",
pCodecLocal->toUnicode( error.what() ) );
QString::fromLocal8Bit( "参数读取错误" ),
QString::fromLocal8Bit( error.what() ) );
return iReturnCode;
}
catch ( std::exception & error )
try
{
pLogin = new QLoginWidget();
pApp = new QApplication( argc, argv );
pLogin->exec();
if ( pLogin->isLogin() == true )
{
pMainFrame = new QMainFrame();
pMainFrame->showMaximized();
iReturnCode = pApp->exec();
}
}
catch ( runtime_error & error )
{
releaseConnectionPool();
QMessageBox::critical( NULL,
"未知错误",
pCodecLocal->toUnicode( error.what() ) );
return iReturnCode;
}*/
login.exec();
if ( login.isLogin() == true )
{
QMainFrame w;
w.showMaximized();
iReturnCode = a.exec();
QString::fromLocal8Bit( "错误" ),
QString::fromLocal8Bit( error.what() ) );
}
//releaseConnectionPool();
//清理
if ( pLogin != NULL )
{
delete pLogin;
}
if ( pApp != NULL )
{
delete pApp;
}
if ( pMainFrame != NULL )
{
delete pMainFrame;
}
return iReturnCode;
}