...
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//如果文件是utf-8编码存放,要注意sql语句编码和ocilib库版本的问题。
|
||||
//如果文件是utf-8编码存放,要注意sql语句编码和ocilib库版本的问题。
|
||||
#include <ocilib.hpp>
|
||||
#include <stdexcept>
|
||||
#include <QString>
|
||||
@@ -39,7 +39,7 @@ void ImportCarDealerAchievementToOracleCpp( const std::string &
|
||||
{
|
||||
Environment::Initialize();
|
||||
}
|
||||
catch ( exception & error )
|
||||
catch ( Exception & error )
|
||||
{
|
||||
string errorMessage = "ocilib初始化失败!";
|
||||
errorMessage.append( error.what() );
|
||||
@@ -98,7 +98,7 @@ void ImportCarDealerAchievementToOracleCpp( const std::string &
|
||||
pStmt->ExecutePrepared();
|
||||
}
|
||||
}
|
||||
catch ( exception & error )
|
||||
catch ( Exception & error )
|
||||
{
|
||||
string errorMessage = "语句执行失败!";
|
||||
errorMessage.append( error.what() );
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "../../Data/DataManipulation/Excel/LoadFromExcel.h"
|
||||
#include "../../Data/DataManipulation/oracle/ImportToOracle.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -60,6 +61,25 @@ void QNewRepairMonitorWidget::onImport()
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//写入数据库
|
||||
try
|
||||
{
|
||||
//以后要改掉
|
||||
string userName = "car_dealer";
|
||||
string password = "cpic123456";
|
||||
string tnsName = "xmcx1";
|
||||
|
||||
ImportNewRepairMonitorToOracle( userName, password, tnsName, recordVector );
|
||||
}
|
||||
catch ( runtime_error & error )
|
||||
{
|
||||
QMessageBox::critical( nullptr,
|
||||
"保存失败!",
|
||||
error.what() );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QNewRepairMonitorWidget::init()
|
||||
@@ -85,4 +105,12 @@ void QNewRepairMonitorWidget::initSignal()
|
||||
|
||||
void QNewRepairMonitorWidget::showNewRepairMonitorRecords()
|
||||
{
|
||||
ui.pTableWidgeRepairOrder->clearContents();
|
||||
ui.pTableWidgeRepairOrder->setRowCount( recordVector.size() );
|
||||
|
||||
int rowIndex = 0;
|
||||
int columnIndex = 0;
|
||||
QTableWidgetItem * pItem = nullptr;
|
||||
|
||||
for ( )
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
#include <ocilib.h>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <QDebug>
|
||||
@@ -8,27 +8,27 @@ const int ERROR_MESSAGE_LENGTH = 1001;
|
||||
|
||||
using namespace std;
|
||||
|
||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length);
|
||||
void get_error_message( OCI_Error * pError, char * pszMessage, size_t length );
|
||||
|
||||
void initOciLib()
|
||||
{
|
||||
int returnCode = 0;
|
||||
char * pszErrorMessage = (char *)malloc(sizeof(char) * ERROR_MESSAGE_LENGTH);
|
||||
int returnCode = 0;
|
||||
char * pszErrorMessage = (char*)malloc( sizeof( char ) * ERROR_MESSAGE_LENGTH );
|
||||
|
||||
returnCode = OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
|
||||
returnCode = OCI_Initialize( NULL, NULL, OCI_ENV_DEFAULT );
|
||||
|
||||
if (!returnCode )
|
||||
if ( !returnCode )
|
||||
{
|
||||
get_error_message(OCI_GetLastError(), pszErrorMessage, ERROR_MESSAGE_LENGTH - 1);
|
||||
get_error_message( OCI_GetLastError(), pszErrorMessage, ERROR_MESSAGE_LENGTH - 1 );
|
||||
|
||||
string message("OCILIB初始化失败!\n");
|
||||
string message( "OCILIB初始化失败!\n" );
|
||||
|
||||
message += pszErrorMessage;
|
||||
|
||||
throw runtime_error(message);
|
||||
throw runtime_error( message );
|
||||
}
|
||||
|
||||
free(pszErrorMessage);
|
||||
free( pszErrorMessage );
|
||||
}
|
||||
|
||||
void releaseOciLib()
|
||||
@@ -36,47 +36,47 @@ void releaseOciLib()
|
||||
OCI_Cleanup();
|
||||
}
|
||||
|
||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length)
|
||||
void get_error_message( OCI_Error * pError, char * pszMessage, size_t length )
|
||||
{
|
||||
//防御性验证
|
||||
if (pError == NULL)
|
||||
if ( pError == NULL )
|
||||
{
|
||||
pszMessage[0] = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const otext * psz = OCI_ErrorGetString(pError);
|
||||
const otext * psz = OCI_ErrorGetString( pError );
|
||||
|
||||
strcpy_s(pszMessage, length, psz);
|
||||
strcpy_s( pszMessage, length, psz );
|
||||
}
|
||||
|
||||
void error_handler(OCI_Error * pError)
|
||||
void error_handler( OCI_Error * pError )
|
||||
{
|
||||
std::runtime_error error(OCI_ErrorGetString(pError));
|
||||
std::runtime_error error( OCI_ErrorGetString( pError ) );
|
||||
|
||||
OCI_Cleanup();
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
void l_error_handler(OCI_Error* pError)
|
||||
void l_error_handler( OCI_Error * pError )
|
||||
{
|
||||
string errorString = OCI_ErrorGetString(pError);
|
||||
string errorString = OCI_ErrorGetString( pError );
|
||||
|
||||
std::runtime_error error(OCI_ErrorGetString(pError));
|
||||
std::runtime_error error( OCI_ErrorGetString( pError ) );
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
void output_error_message( const std::string & errorMessage )
|
||||
{
|
||||
qDebug() << QString::fromLocal8Bit(errorMessage.c_str());
|
||||
qDebug() << QString::fromLocal8Bit( errorMessage.c_str() );
|
||||
}
|
||||
|
||||
std::string get_last_error_message()
|
||||
{
|
||||
OCI_Error * pError = OCI_GetLastError();
|
||||
|
||||
return std::string(OCI_ErrorGetString(pError));
|
||||
return std::string( OCI_ErrorGetString( pError ) );
|
||||
}
|
||||
|
Reference in New Issue
Block a user