...
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
|
||||
#include "AppParameters.h"
|
||||
|
||||
UserInfo * pStaffInfo = nullptr;
|
@@ -0,0 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include "../Datastructure/UserInfo/UserInfo.h"
|
||||
|
||||
extern UserInfo * pStaffInfo;
|
@@ -21,12 +21,12 @@ UserInfo queryUserInfo( const string & userName,
|
||||
int returnCode = 0;
|
||||
|
||||
|
||||
otext szSqlQueryStaff[] =
|
||||
string sqlQueryStaff =
|
||||
"SELECT a.staff_p13, a.staff_name, b.staff_post \n"
|
||||
"FROM staff_info a, \n"
|
||||
"staff_post_code b \n"
|
||||
"WHERE a.staff_post_code = b.staff_post_code \n"
|
||||
"AND a.staff_p13 = :p13 ";
|
||||
"AND a.staff_p13 = :p13";
|
||||
|
||||
returnCode = OCI_Initialize( l_error_handler, nullptr, OCI_ENV_DEFAULT );
|
||||
|
||||
@@ -56,16 +56,16 @@ UserInfo queryUserInfo( const string & userName,
|
||||
{
|
||||
pStmt = OCI_StatementCreate( pConn );
|
||||
|
||||
OCI_Prepare(pStmt, sqlQueryStaff.c_str());
|
||||
OCI_AllowRebinding( pStmt, true );
|
||||
OCI_Prepare( pStmt, szSqlQueryStaff );
|
||||
|
||||
OCI_BindString( pStmt, ":p13", const_cast<otext*>(staffP13.c_str()), staffP13.size() );
|
||||
|
||||
OCI_Execute( pStmt );
|
||||
|
||||
|
||||
pResult = OCI_GetResultset( pStmt );
|
||||
|
||||
//检查结果集,如果没有返回,则说明没有此用户
|
||||
if ( OCI_FetchFirst( pResult ) == false )
|
||||
if ( OCI_FetchNext( pResult ) == false )
|
||||
{
|
||||
throw runtime_error( "用户不存在!" );
|
||||
}
|
||||
|
@@ -2,4 +2,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include "../Datastructure/UserInfo/UserInfo.h"
|
||||
|
||||
UserInfo queryUserInfo( const std::string & userName,
|
||||
const std::string & password,
|
||||
const std::string & tnsName,
|
||||
const std::string & staffP13 );
|
||||
|
@@ -1,5 +1,12 @@
|
||||
#include "QLoginDialog.h"
|
||||
#include <iostream>
|
||||
#include "QLoginDialog.h"
|
||||
#include "../../system/system_util.h"
|
||||
#include "../../data/Datastructure/UserInfo/UserInfo.h"
|
||||
#include "../../data/query/query_user.h"
|
||||
#include "../../data/AppParameters/AppParameters.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace std;
|
||||
|
||||
QLoginDialog::QLoginDialog( QWidget * parent )
|
||||
: QDialog( parent )
|
||||
@@ -24,26 +31,40 @@ void QLoginDialog::initData()
|
||||
{
|
||||
returnCode = EXIT;
|
||||
|
||||
systemUserName = QString::fromStdWString(getUserName());
|
||||
systemUserName = QString::fromStdWString( getUserName() );
|
||||
}
|
||||
|
||||
void QLoginDialog::initSignal()
|
||||
{
|
||||
connect(ui.pButtonOK, SIGNAL(clicked()), this, SLOT(onOK()));
|
||||
connect(ui.pButtonExit, SIGNAL(clicked()), this, SLOT(onExit()));
|
||||
connect( ui.pButtonOK, SIGNAL( clicked() ), this, SLOT( onOK() ) );
|
||||
connect( ui.pButtonExit, SIGNAL( clicked() ), this, SLOT( onExit() ) );
|
||||
}
|
||||
|
||||
void QLoginDialog::initWidgets()
|
||||
{
|
||||
setLayout( ui.pLayoutMain );
|
||||
|
||||
ui.pEditSystemUserName->setText(systemUserName);
|
||||
ui.pEditSystemUserName->setText( systemUserName );
|
||||
|
||||
try
|
||||
{
|
||||
queryStaffInfo( systemUserName );
|
||||
}
|
||||
catch ( runtime_error & error )
|
||||
{
|
||||
//如果出现异常,就不让用户继续登录
|
||||
QMessageBox::critical( nullptr,
|
||||
"错误,请联系管理员!",
|
||||
QString::fromLocal8Bit( error.what() ) );
|
||||
|
||||
ui.pButtonOK->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
void QLoginDialog::onOK()
|
||||
{
|
||||
returnCode = OK;
|
||||
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
@@ -53,3 +74,19 @@ void QLoginDialog::onExit()
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
void QLoginDialog::queryStaffInfo( const QString & systemUserName )
|
||||
{
|
||||
string userName = "car_dealer";
|
||||
string password = "cpic123456";
|
||||
string tnsName = "xmcx1";
|
||||
|
||||
string staffP13 = systemUserName.toLocal8Bit();
|
||||
|
||||
UserInfo && info = queryUserInfo( userName,
|
||||
password,
|
||||
tnsName,
|
||||
staffP13 );
|
||||
|
||||
pStaffInfo = new UserInfo( info );
|
||||
}
|
||||
|
@@ -27,6 +27,9 @@ protected Q_SLOTS:
|
||||
void onOK();
|
||||
void onExit();
|
||||
|
||||
private:
|
||||
void queryStaffInfo( const QString & systemUserName );
|
||||
|
||||
private:
|
||||
Ui::QLoginDialog ui;
|
||||
ReturnCode returnCode;
|
||||
|
Reference in New Issue
Block a user