一点点重构
This commit is contained in:
		@@ -433,9 +433,9 @@ void QueryPolicyGifts(const string& strPolicyNo, string& strGifts, double dGiftP
 | 
			
		||||
 | 
			
		||||
		policy.strOperatorCode = getUserCode();
 | 
			
		||||
 | 
			
		||||
		queryAutoTraderInfo( policy.strAutoTraderCode, policy.strAutoTraderName );
 | 
			
		||||
		query_auto_trader_info( policy.strAutoTraderCode, policy.strAutoTraderName );
 | 
			
		||||
 | 
			
		||||
		queryStaffInfo( policy.strSalerCode, 
 | 
			
		||||
		query_staff_info( policy.strSalerCode, 
 | 
			
		||||
			            policy.strSalerName, 
 | 
			
		||||
						policy.strSalerDeptCode,
 | 
			
		||||
						policy.strSalerDeptName,
 | 
			
		||||
@@ -582,7 +582,7 @@ void readTelsaleXlsxFile(const wstring& filePath, vector<SPolicyRecord>& listPol
 | 
			
		||||
 | 
			
		||||
		policy.strOperatorCode = getUserCode();
 | 
			
		||||
 | 
			
		||||
		queryStaffInfo(
 | 
			
		||||
		query_staff_info(
 | 
			
		||||
		               policy.strSalerCode,
 | 
			
		||||
		               policy.strSalerName,
 | 
			
		||||
		               policy.strSalerDeptCode,
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ void QConfigurationWidget::onAutoTraderCodeEdited()
 | 
			
		||||
	string strAutoTraderCode = pEditAutoTraderCode->text().trimmed().toUpper().toLocal8Bit().data();
 | 
			
		||||
	string strAutoTraderName;
 | 
			
		||||
 | 
			
		||||
	queryAutoTraderInfo( strAutoTraderCode, strAutoTraderName );
 | 
			
		||||
	query_auto_trader_info( strAutoTraderCode, strAutoTraderName );
 | 
			
		||||
 | 
			
		||||
	pEditAutoTraderName->setText( QString::fromLocal8Bit( strAutoTraderName.c_str() ));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
 | 
			
		||||
//#include <occi.h>
 | 
			
		||||
//#include <QTextCodec>
 | 
			
		||||
#include <QtWidgets/QMessageBox>
 | 
			
		||||
@@ -6,17 +5,16 @@
 | 
			
		||||
#include "SystemData.h"
 | 
			
		||||
#include "SystemDataQuery.h"
 | 
			
		||||
 | 
			
		||||
QLoginWidget::QLoginWidget(QWidget *parent)
 | 
			
		||||
	: QDialog(parent)
 | 
			
		||||
QLoginWidget::QLoginWidget( QWidget * parent )
 | 
			
		||||
	: QDialog( parent )
 | 
			
		||||
{
 | 
			
		||||
	ui.setupUi(this);
 | 
			
		||||
	ui.setupUi( this );
 | 
			
		||||
 | 
			
		||||
	init();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QLoginWidget::~QLoginWidget()
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QLoginWidget::init()
 | 
			
		||||
@@ -24,10 +22,7 @@ void QLoginWidget::init()
 | 
			
		||||
	initWidget();
 | 
			
		||||
	initSignal();
 | 
			
		||||
 | 
			
		||||
	//pCodecLocal = QTextCodec::codecForLocale();
 | 
			
		||||
	//pCodecUTF8 = QTextCodec::codecForName( "UTF-8" );
 | 
			
		||||
 | 
			
		||||
	m_isLoginSuccess = false;
 | 
			
		||||
	doesLoginSuccess = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QLoginWidget::initWidget()
 | 
			
		||||
@@ -42,45 +37,50 @@ void QLoginWidget::initSignal()
 | 
			
		||||
	connect( ui.pEditUserCode, SIGNAL(editingFinished()), this, SLOT(getUserName()) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QLoginWidget::login()
 | 
			
		||||
void QLoginWidget::onLogin()
 | 
			
		||||
{
 | 
			
		||||
	string strPassword( (char *)ui.pEditPassword->text().toLocal8Bit().data() );
 | 
			
		||||
	string strPassword( static_cast<char *>(ui.pEditPassword->text().toLocal8Bit().data()) );
 | 
			
		||||
 | 
			
		||||
	if ( strPassword == m_userPassword )
 | 
			
		||||
	if ( strPassword == userPassword )
 | 
			
		||||
	{
 | 
			
		||||
		m_isLoginSuccess = true;
 | 
			
		||||
		doesLoginSuccess = true;
 | 
			
		||||
 | 
			
		||||
		//保存用户名和密码
 | 
			
		||||
		setUserCode( m_userCode );
 | 
			
		||||
		setUserName( m_userName );
 | 
			
		||||
		setUserCode( userCode );
 | 
			
		||||
		setUserName( userName );
 | 
			
		||||
 | 
			
		||||
		close();
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		QMessageBox::warning( this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("密码错误!") );
 | 
			
		||||
		QMessageBox::warning( this, QString::fromLocal8Bit( "错误" ), QString::fromLocal8Bit( "密码错误!" ) );
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QLoginWidget::cancel()
 | 
			
		||||
void QLoginWidget::onCancel()
 | 
			
		||||
{
 | 
			
		||||
	m_isLoginSuccess = false;
 | 
			
		||||
	doesLoginSuccess = false;
 | 
			
		||||
 | 
			
		||||
	close();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QLoginWidget::getUserName()
 | 
			
		||||
void QLoginWidget::onQueryUserInfo()
 | 
			
		||||
{
 | 
			
		||||
	m_userCode = ui.pEditUserCode->text().toLocal8Bit().data();
 | 
			
		||||
	userCode = ui.pEditUserCode->text().toLocal8Bit().data();
 | 
			
		||||
 | 
			
		||||
	try
 | 
			
		||||
	{
 | 
			
		||||
		QueryUserInfo( m_userCode, m_userName, m_userPassword );
 | 
			
		||||
		//根据用户填入的工号,查询名称和密码
 | 
			
		||||
		query_user_info( userCode,
 | 
			
		||||
		               userName,
 | 
			
		||||
		               userPassword );
 | 
			
		||||
 | 
			
		||||
		ui.pEditUserName->setText( QString::fromLocal8Bit(m_userName.c_str()));
 | 
			
		||||
		ui.pEditUserName->setText( QString::fromLocal8Bit( userName.c_str() ) );
 | 
			
		||||
	}
 | 
			
		||||
	catch ( runtime_error & exp )
 | 
			
		||||
	catch ( runtime_error & error )
 | 
			
		||||
	{
 | 
			
		||||
		QMessageBox::critical( this, "错误", QString::fromUtf8( exp.what() ));
 | 
			
		||||
		QMessageBox::critical( this,
 | 
			
		||||
		                       QString::fromLocal8Bit( "查询用户信息出错" ),
 | 
			
		||||
		                       QString::fromLocal8Bit( error.what() ) );
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,8 @@
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <QtWidgets/QtWidgets>
 | 
			
		||||
//#include <QDialog>
 | 
			
		||||
//#include <QTextCodec>
 | 
			
		||||
#include "ui_QLoginWidget.h"
 | 
			
		||||
//#include "DataManipulate.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
@@ -18,7 +16,7 @@ public:
 | 
			
		||||
	QLoginWidget(QWidget *parent = 0);
 | 
			
		||||
	~QLoginWidget();
 | 
			
		||||
 | 
			
		||||
	bool isLogin() const { return m_isLoginSuccess; }
 | 
			
		||||
	bool isLogin() const { return doesLoginSuccess; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	void init();
 | 
			
		||||
@@ -26,10 +24,10 @@ private:
 | 
			
		||||
	void initSignal();
 | 
			
		||||
 | 
			
		||||
protected Q_SLOTS:
 | 
			
		||||
	void login();
 | 
			
		||||
	void cancel();
 | 
			
		||||
	void onLogin();
 | 
			
		||||
	void onCancel();
 | 
			
		||||
 | 
			
		||||
	void getUserName();
 | 
			
		||||
	void onQueryUserInfo();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	Ui::QLoginWidget ui;
 | 
			
		||||
@@ -37,11 +35,11 @@ private:
 | 
			
		||||
	QTextCodec * pCodecUTF8;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	string m_userCode;
 | 
			
		||||
	string m_userName;
 | 
			
		||||
	string m_userPassword;
 | 
			
		||||
	string userCode;
 | 
			
		||||
	string userName;
 | 
			
		||||
	string userPassword;
 | 
			
		||||
 | 
			
		||||
	bool m_isLoginSuccess;
 | 
			
		||||
	bool doesLoginSuccess;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // QLOGINWIDGET_H
 | 
			
		||||
 
 | 
			
		||||
@@ -201,7 +201,7 @@ void QTelSalePolicyInfoInputWidget::onQuerySalerName()
 | 
			
		||||
{
 | 
			
		||||
	salerCode = pEditSalerCode->text().trimmed().toUpper().toLocal8Bit().data();
 | 
			
		||||
 | 
			
		||||
	queryStaffInfo( salerCode,
 | 
			
		||||
	query_staff_info( salerCode,
 | 
			
		||||
	                salerName,
 | 
			
		||||
	                salerDeptCode,
 | 
			
		||||
	                salerDeptName,
 | 
			
		||||
@@ -434,7 +434,7 @@ void QTelSalePolicyInfoInputWidget::onQueryAutoTraderName()
 | 
			
		||||
{
 | 
			
		||||
	autoTraderCode = pEditAutoTraderCode->text().trimmed().toUpper().toLocal8Bit().data();
 | 
			
		||||
 | 
			
		||||
	queryAutoTraderInfo( autoTraderCode, autoTraderName );
 | 
			
		||||
	query_auto_trader_info( autoTraderCode, autoTraderName );
 | 
			
		||||
 | 
			
		||||
	pEditAutoTraderName->setText( QString::fromLocal8Bit( autoTraderName.c_str() ) );
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ void QTelSalePolicyInfoQuery::onOperatorCodeEdited()
 | 
			
		||||
	string strStaffCode = pEditOperatorCode->text().toLocal8Bit().data();
 | 
			
		||||
	string strStaffName;
 | 
			
		||||
 | 
			
		||||
	queryStaffInfo( strStaffCode, strStaffName );
 | 
			
		||||
	query_staff_info( strStaffCode, strStaffName );
 | 
			
		||||
 | 
			
		||||
	pEditOperatorName->setText( QString::fromLocal8Bit( strStaffName.c_str() ));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ const static char g_cszConnstringYwgl[] =
 | 
			
		||||
const static char g_cszUserNameYwgl[] = "ccx99";
 | 
			
		||||
const static char g_cszPasswordYwgl[] = "c92IT09";
 | 
			
		||||
 | 
			
		||||
void QueryUserInfo(const string & strCode, string & strName, string & strPassword)
 | 
			
		||||
void query_user_info(const string & strCode, string & strName, string & strPassword)
 | 
			
		||||
{
 | 
			
		||||
	SAConnection conn;
 | 
			
		||||
	SACommand command;
 | 
			
		||||
@@ -107,7 +107,7 @@ void QueryUserInfo(const string & strCode, string & strName, string & strPasswor
 | 
			
		||||
	conn.Disconnect();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void queryStaffInfo(const string & strOperatorCode, string & strOperatorName, string & strDeptCode, string & strDeptName, string & strOfficeCode, string & strOfficeName)
 | 
			
		||||
void query_staff_info(const string & strOperatorCode, string & strOperatorName, string & strDeptCode, string & strDeptName, string & strOfficeCode, string & strOfficeName)
 | 
			
		||||
{
 | 
			
		||||
	SAConnection connection;
 | 
			
		||||
	SACommand    command;
 | 
			
		||||
@@ -163,7 +163,7 @@ void queryStaffInfo(const string & strOperatorCode, string & strOperatorName, st
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void queryAutoTraderInfo(const string & strAutoTraderCode, string & strAutoTraderName)
 | 
			
		||||
void query_auto_trader_info(const string & strAutoTraderCode, string & strAutoTraderName)
 | 
			
		||||
{
 | 
			
		||||
	SAConnection connection;
 | 
			
		||||
	SACommand    command;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
 | 
			
		||||
#ifndef DataQuery_h__
 | 
			
		||||
#define DataQuery_h__
 | 
			
		||||
 | 
			
		||||
@@ -16,7 +15,7 @@ using std::string;
 | 
			
		||||
// Parameter: string & strName       名字
 | 
			
		||||
// Parameter: string & strPassword   密码
 | 
			
		||||
//************************************
 | 
			
		||||
void QueryUserInfo( const string & strCode,
 | 
			
		||||
void query_user_info( const string & strCode,
 | 
			
		||||
                      string &       strName,
 | 
			
		||||
                      string &       strPassword );
 | 
			
		||||
 | 
			
		||||
@@ -34,23 +33,23 @@ void QueryUserInfo( const string & strCode,
 | 
			
		||||
// Parameter: string & strOfficeCode 科室代码
 | 
			
		||||
// Parameter: string & strOfficeName 科室名称
 | 
			
		||||
//************************************
 | 
			
		||||
void queryStaffInfo( const string & strOperatorCode,
 | 
			
		||||
void query_staff_info( const string & strOperatorCode,
 | 
			
		||||
                       string &       strOperatorName,
 | 
			
		||||
                       string &       strDeptCode   = string(),
 | 
			
		||||
                       string &       strDeptName   = string(),
 | 
			
		||||
                       string &       strOfficeCode = string(),
 | 
			
		||||
						   string & strOfficeName = string());
 | 
			
		||||
                       string &       strOfficeName = string() );
 | 
			
		||||
 | 
			
		||||
//************************************
 | 
			
		||||
// Method:    queryAutoTraderInfo
 | 
			
		||||
// FullName:  queryAutoTraderInfo
 | 
			
		||||
// Method:    query_auto_trader_info
 | 
			
		||||
// FullName:  query_auto_trader_info
 | 
			
		||||
// Access:    public 
 | 
			
		||||
// Returns:   void
 | 
			
		||||
// Qualifier: 查询车商信息
 | 
			
		||||
// Parameter: const string & strAutoTraderCode
 | 
			
		||||
// Parameter: string & strAutoTraderName
 | 
			
		||||
//************************************
 | 
			
		||||
void queryAutoTraderInfo( const string & strAutoTraderCode,
 | 
			
		||||
void query_auto_trader_info( const string & strAutoTraderCode,
 | 
			
		||||
                             string &       strAutoTraderName );
 | 
			
		||||
 | 
			
		||||
#endif // DataQuery_h__
 | 
			
		||||
		Reference in New Issue
	
	Block a user