telsale-management/代码/cpp/telsale_aux_kit/source/QLoginWidget.cpp

87 lines
1.7 KiB
C++
Raw Normal View History

//#include <occi.h>
2018-06-02 09:47:28 +00:00
//#include <QTextCodec>
#include <QtWidgets/QMessageBox>
#include "QLoginWidget.h"
#include "SystemData.h"
#include "SystemDataQuery.h"
2018-06-15 07:32:41 +00:00
QLoginWidget::QLoginWidget( QWidget * parent )
: QDialog( parent )
{
2018-06-15 07:32:41 +00:00
ui.setupUi( this );
init();
}
QLoginWidget::~QLoginWidget()
{
}
void QLoginWidget::init()
{
initWidget();
initSignal();
2018-06-15 07:32:41 +00:00
doesLoginSuccess = false;
}
void QLoginWidget::initWidget()
{
setLayout( ui.pLayoutMain );
}
void QLoginWidget::initSignal()
{
connect( ui.pButtonLogin, SIGNAL(clicked()), this, SLOT(login()) );
connect( ui.pButtonCancel, SIGNAL(clicked()), this, SLOT(cancel()) );
connect( ui.pEditUserCode, SIGNAL(editingFinished()), this, SLOT(getUserName()) );
}
2018-06-15 07:32:41 +00:00
void QLoginWidget::onLogin()
{
2018-06-15 07:32:41 +00:00
string strPassword( static_cast<char *>(ui.pEditPassword->text().toLocal8Bit().data()) );
if ( strPassword == userPassword )
{
2018-06-15 07:32:41 +00:00
doesLoginSuccess = true;
//保存用户名和密码
2018-06-15 07:32:41 +00:00
setUserCode( userCode );
setUserName( userName );
close();
}
else
{
2018-06-15 07:32:41 +00:00
QMessageBox::warning( this, QString::fromLocal8Bit( "错误" ), QString::fromLocal8Bit( "密码错误!" ) );
}
}
2018-06-15 07:32:41 +00:00
void QLoginWidget::onCancel()
{
2018-06-15 07:32:41 +00:00
doesLoginSuccess = false;
close();
}
2018-06-15 07:32:41 +00:00
void QLoginWidget::onQueryUserInfo()
{
2018-06-15 07:32:41 +00:00
userCode = ui.pEditUserCode->text().toLocal8Bit().data();
try
{
2018-06-15 07:32:41 +00:00
//根据用户填入的工号,查询名称和密码
query_user_info( userCode,
userName,
userPassword );
2018-06-15 07:32:41 +00:00
ui.pEditUserName->setText( QString::fromLocal8Bit( userName.c_str() ) );
}
2018-06-15 07:32:41 +00:00
catch ( runtime_error & error )
{
2018-06-15 07:32:41 +00:00
QMessageBox::critical( this,
QString::fromLocal8Bit( "查询用户信息出错" ),
QString::fromLocal8Bit( error.what() ) );
}
}