11/25
This commit is contained in:
40
ZBD_IIIDL_S_Project/Src/UserManager/currentuserdata.cpp
Normal file
40
ZBD_IIIDL_S_Project/Src/UserManager/currentuserdata.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "currentuserdata.h"
|
||||
#include <QDebug>
|
||||
|
||||
CurrentUserData* CurrentUserData::m_currentUserData = NULL;
|
||||
|
||||
CurrentUserData::CurrentUserData(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CurrentUserData* CurrentUserData::getInstace()
|
||||
{
|
||||
if(!m_currentUserData)
|
||||
{
|
||||
m_currentUserData = new CurrentUserData();
|
||||
}
|
||||
return m_currentUserData;
|
||||
}
|
||||
|
||||
//获取患者信息
|
||||
ST_PatientMsg CurrentUserData::getCurrentPatientMsg()
|
||||
{
|
||||
return st_CurrentUserData;
|
||||
}
|
||||
|
||||
void CurrentUserData::updateTrainUser()
|
||||
{
|
||||
emit signalUserChanged();
|
||||
}
|
||||
|
||||
void CurrentUserData::setCurrentUserMsg(ST_PatientMsg st_patientMsg)
|
||||
{
|
||||
st_CurrentUserData = st_patientMsg;
|
||||
updateTrainUser();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
32
ZBD_IIIDL_S_Project/Src/UserManager/currentuserdata.h
Normal file
32
ZBD_IIIDL_S_Project/Src/UserManager/currentuserdata.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef CURRENTUSERDATA_H
|
||||
#define CURRENTUSERDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include "dbforrmate.h"
|
||||
|
||||
|
||||
class CurrentUserData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CurrentUserData* getInstace();
|
||||
//获取患者信息
|
||||
ST_PatientMsg getCurrentPatientMsg();
|
||||
void setCurrentUserMsg(ST_PatientMsg);
|
||||
|
||||
//更新训练用户
|
||||
void updateTrainUser();
|
||||
signals:
|
||||
//当前用户显示发生变化
|
||||
void signalUserChanged();
|
||||
|
||||
private:
|
||||
explicit CurrentUserData(QObject *parent = nullptr);
|
||||
|
||||
static CurrentUserData* m_currentUserData;
|
||||
//当前用户信息
|
||||
ST_PatientMsg st_CurrentUserData;
|
||||
|
||||
};
|
||||
|
||||
#endif // CURRENTUSERDATA_H
|
||||
210
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.cpp
Normal file
210
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
#include "userdialog.h"
|
||||
#include "ui_userdialog.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include "cdatabaseinterface.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QListView>
|
||||
#include <QPainter>
|
||||
UserDialog::UserDialog(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::UserDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框
|
||||
setAttribute(Qt::WA_TranslucentBackground,true); //设置透明
|
||||
ui->ID_LineEdit->setReadOnly(true);
|
||||
|
||||
//添加此语句是为了使样式生效
|
||||
ui->sex_ComboBox->setView(new QListView());
|
||||
ui->bodyIndex_ComboBox->setView(new QListView());
|
||||
// ui->bodyIndex_ComboBox->setStyleSheet("#bodyIndex_ComboBox{text-align:left;}");
|
||||
// ui->bodyIndex_ComboBox->lineEdit()->setAlignment(Qt::AlignLeft);
|
||||
|
||||
initWidget();
|
||||
}
|
||||
|
||||
UserDialog::~UserDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void UserDialog::setDialogTitle(USER_ENUM type,int ID )
|
||||
{
|
||||
m_type = type;
|
||||
switch(type)
|
||||
{
|
||||
case E_NEW_USER:
|
||||
setNewUserType();
|
||||
break;
|
||||
case E_EDIT_USER:
|
||||
setEditUserType(ID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserDialog::on_cancel_Btn_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void UserDialog::on_save_Btn_clicked()
|
||||
{
|
||||
ST_PatientMsg st_patientMsg;
|
||||
st_patientMsg.ID = ui->ID_LineEdit->text().toUInt();
|
||||
st_patientMsg.age =QDate::currentDate().year() - ui->dateEdit->date().year();
|
||||
st_patientMsg.birthday = ui->dateEdit->date();
|
||||
st_patientMsg.bodyIndex = ui->bodyIndex_ComboBox->currentIndex();
|
||||
st_patientMsg.markMsg = ui->textEdit->toPlainText();
|
||||
st_patientMsg.name = ui->name_LineEdit->text();
|
||||
st_patientMsg.phone = ui->phone_LineEdit->text();
|
||||
st_patientMsg.sex = ui->sex_ComboBox->currentIndex();
|
||||
|
||||
QString tableName("PatientTable");
|
||||
QVariantMap vMap = patientMsgToVariantMap(st_patientMsg);
|
||||
|
||||
//删除所有空格
|
||||
if(st_patientMsg.name.remove(QRegExp("\\s")).isEmpty())
|
||||
{
|
||||
QMessageBox::information(NULL,tr("提示"),tr("用户名不能为空"));
|
||||
}
|
||||
else if(E_NEW_USER == m_type)
|
||||
{
|
||||
if(!CDatabaseInterface::getInstance()->insertRowTable(tableName,vMap))
|
||||
{
|
||||
QString str = CDatabaseInterface::getInstance()->getLastError();
|
||||
QMessageBox::information(NULL,tr("提示"),str);
|
||||
this->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit signalUpdateUserTable();
|
||||
QMessageBox::information(NULL,tr("提示"),tr("添加成功"));
|
||||
this->close();
|
||||
}
|
||||
}
|
||||
else if(E_EDIT_USER == m_type)
|
||||
{
|
||||
if(!CDatabaseInterface::getInstance()->updateRowTable(tableName,"ID",vMap))
|
||||
{
|
||||
QString str = CDatabaseInterface::getInstance()->getLastError();
|
||||
QMessageBox::information(NULL,tr("提示"),str);
|
||||
this->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit signalUpdateUserTable();
|
||||
QMessageBox::information(NULL,tr("提示"),tr("更新成功"));
|
||||
this->close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UserDialog::setEditUserType(int ID)
|
||||
{
|
||||
ui->title_Label->setText(tr("编辑用户"));
|
||||
//根据ID查找用户
|
||||
QString queryStr(QString("select * from PatientTable where ID = '%1'").arg(ID));
|
||||
ST_PatientMsg st_PatientMsg;
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
|
||||
{
|
||||
QList<QVariantMap> valueMapList;
|
||||
valueMapList = CDatabaseInterface::getInstance()->getValues(0,1);
|
||||
st_PatientMsg = variantMapToPatientMsg(valueMapList.at(0));
|
||||
|
||||
ui->name_LineEdit->setText(st_PatientMsg.name);
|
||||
ui->sex_ComboBox->setCurrentIndex(st_PatientMsg.sex);
|
||||
ui->bodyIndex_ComboBox->setCurrentIndex(st_PatientMsg.bodyIndex);
|
||||
ui->textEdit->setText(st_PatientMsg.markMsg);
|
||||
ui->phone_LineEdit->setText(st_PatientMsg.phone);
|
||||
ui->dateEdit->setDate(st_PatientMsg.birthday);
|
||||
ui->ID_LineEdit->setText(QString::number(st_PatientMsg.ID));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"未查询到符合条件的数据";
|
||||
}
|
||||
}
|
||||
this->show();
|
||||
}
|
||||
void UserDialog::setNewUserType()
|
||||
{
|
||||
ui->title_Label->setText(tr("新建用户"));
|
||||
ui->name_LineEdit->clear();
|
||||
ui->sex_ComboBox->setCurrentIndex(0);
|
||||
ui->bodyIndex_ComboBox->setCurrentIndex(0);
|
||||
ui->textEdit->clear();
|
||||
ui->phone_LineEdit->clear();
|
||||
QDate defaultDate(1990,1,1);
|
||||
ui->dateEdit->setDate(defaultDate);
|
||||
//自动生成ID
|
||||
int ID(100000);
|
||||
//先查询数据库查找出最大的ID
|
||||
QString query(QString("select * from PatientTable order by ID DESC"));
|
||||
CDatabaseInterface *dataBase = CDatabaseInterface::getInstance();
|
||||
if(dataBase->exec(query))
|
||||
{
|
||||
int size = dataBase->getValuesSize();
|
||||
if(size > 0)
|
||||
{
|
||||
QVariantMap varMap =dataBase->getValues(0,1).at(0);
|
||||
ST_PatientMsg st_patient = variantMapToPatientMsg(varMap);
|
||||
ID = st_patient.ID+1;
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug()<<dataBase->getLastError();
|
||||
ui->ID_LineEdit->setText(QString::number(ID));
|
||||
this->show();
|
||||
}
|
||||
|
||||
void UserDialog::initWidget()
|
||||
{
|
||||
//设置lineEdit的输入限制
|
||||
//电话限制
|
||||
QRegExp reg("^[0-9]*$");
|
||||
ui->phone_LineEdit->setValidator(new QRegExpValidator(reg, this));
|
||||
ui->phone_LineEdit->setMaxLength(11);
|
||||
|
||||
//姓名限制
|
||||
QRegExp reg2("[\u4e00-\u9fa5A-Za-z0-9]+$");
|
||||
ui->name_LineEdit->setValidator(new QRegExpValidator(reg2,this));
|
||||
|
||||
//年龄限制
|
||||
QRegularExpression rege3("^(19[5-9][0-9]|20[0-4][0-9]|2050)-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$");
|
||||
//ui->dateEdit->setValidator;
|
||||
//ui->dateEdit->validate();
|
||||
// 创建正则表达式模式
|
||||
//QRegularExpression dateExp("[1-2][9|0][5-9][0-9]|20[0-4][0-9]|2050");
|
||||
|
||||
// 将正则表达式应用于QDateEdit
|
||||
// QRegularExpressionValidator* validator = new QRegularExpressionValidator(dateExp, &dateEdit);
|
||||
//ui->dateEdit->setValidator(validator);
|
||||
}
|
||||
|
||||
void UserDialog::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter painter(this);
|
||||
painter.fillRect(rect(),QColor(0,0,0,100));
|
||||
}
|
||||
|
||||
void UserDialog::changeEvent(QEvent* event)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
QWidget::changeEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
56
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.h
Normal file
56
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef USERDIALOG_H
|
||||
#define USERDIALOG_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "dataformate.h"
|
||||
#include "dbforrmate.h"
|
||||
|
||||
namespace Ui {
|
||||
class UserDialog;
|
||||
}
|
||||
|
||||
class UserDialog : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserDialog(QWidget *parent = nullptr);
|
||||
~UserDialog();
|
||||
|
||||
/*******
|
||||
* 说明:设置界面的类型
|
||||
* 参数:int type 0-新建 1-编辑
|
||||
* int ID = 0 //查看用户的ID
|
||||
* *****/
|
||||
void setDialogTitle(USER_ENUM type,int ID = 0);
|
||||
|
||||
ST_PatientMsg getPatientMsg();
|
||||
|
||||
bool isSelectUser();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
virtual void changeEvent(QEvent* event);
|
||||
|
||||
signals:
|
||||
void signalUpdateUserTable();
|
||||
|
||||
private:
|
||||
void setEditUserType(int ID);
|
||||
void setNewUserType();
|
||||
|
||||
void initWidget();
|
||||
private slots:
|
||||
void on_cancel_Btn_clicked();
|
||||
|
||||
void on_save_Btn_clicked();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Ui::UserDialog *ui;
|
||||
USER_ENUM m_type; //0-新建 1-编辑
|
||||
};
|
||||
|
||||
#endif // USERDIALOG_H
|
||||
557
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.ui
Normal file
557
ZBD_IIIDL_S_Project/Src/UserManager/userdialog.ui
Normal file
@@ -0,0 +1,557 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserDialog</class>
|
||||
<widget class="QWidget" name="UserDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1920</width>
|
||||
<height>1080</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>558</x>
|
||||
<y>241</y>
|
||||
<width>804</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>6</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#groupBox{background: #FFFFFF;
|
||||
border-radius: 32px;}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<widget class="QLabel" name="title_Label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>804</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-image: url(:/DependFile/Source/gamePage/dialog.png);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新建用户</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>姓名:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>性别:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>280</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>部位:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>361</y>
|
||||
<width>111</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>备注:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="name_LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>130</y>
|
||||
<width>150</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
font-size:25px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>我</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="sex_ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>210</y>
|
||||
<width>150</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#sex_ComboBox{
|
||||
border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
font-size: 25px;
|
||||
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
|
||||
font-family:黑体;
|
||||
|
||||
}</string>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>男</string>
|
||||
</property>
|
||||
<property name="maxCount">
|
||||
<number>2147483647</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>男</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>女</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="bodyIndex_ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>280</y>
|
||||
<width>150</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#bodyIndex_ComboBox{
|
||||
border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
font-size: 25px;
|
||||
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
|
||||
font-family:黑体;
|
||||
|
||||
}
|
||||
|
||||
</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>上肢</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>下肢</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>上下肢</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>130</y>
|
||||
<width>121</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>电话:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="phone_LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>130</y>
|
||||
<width>280</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
font-size:25px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>123</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>206</y>
|
||||
<width>121</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>生日:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDateEdit" name="dateEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>210</y>
|
||||
<width>280</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">width: 29px;
|
||||
height: 29px;
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
font-size:25px;</string>
|
||||
</property>
|
||||
<property name="maximumDateTime">
|
||||
<datetime>
|
||||
<hour>15</hour>
|
||||
<minute>59</minute>
|
||||
<second>59</second>
|
||||
<year>2050</year>
|
||||
<month>12</month>
|
||||
<day>31</day>
|
||||
</datetime>
|
||||
</property>
|
||||
<property name="minimumDateTime">
|
||||
<datetime>
|
||||
<hour>0</hour>
|
||||
<minute>0</minute>
|
||||
<second>0</second>
|
||||
<year>1920</year>
|
||||
<month>9</month>
|
||||
<day>14</day>
|
||||
</datetime>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="cancel_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>232</x>
|
||||
<y>513</y>
|
||||
<width>120</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="save_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>452</x>
|
||||
<y>513</y>
|
||||
<width>120</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>280</y>
|
||||
<width>121</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ID:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="ID_LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>280</y>
|
||||
<width>280</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
font-size:25px;</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>370</y>
|
||||
<width>631</width>
|
||||
<height>87</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>-1</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 2px;
|
||||
border: 1px solid #333333;
|
||||
font-weight: 400;
|
||||
color: #3E3E3E;
|
||||
line-height: 44px;
|
||||
font-size:25px;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
409
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.cpp
Normal file
409
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.cpp
Normal file
@@ -0,0 +1,409 @@
|
||||
#include "usermanager.h"
|
||||
#include "ui_usermanager.h"
|
||||
#include "cdatabaseinterface.h"
|
||||
#include "dbforrmate.h"
|
||||
#include <QDebug>
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
#include "currentuserdata.h"
|
||||
#include "selectuserdialog.h"
|
||||
#include "deleteuserdialog.h"
|
||||
#include <QTimer>
|
||||
#include "languagemanager.h"
|
||||
#include "dataformate.h"
|
||||
|
||||
UserManager::UserManager(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::UserManager),
|
||||
m_userDialog(nullptr),
|
||||
m_completer(nullptr),
|
||||
m_slectUserDialog(nullptr),
|
||||
m_deleteUserDialog(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_userDialog = new UserDialog();
|
||||
connect(m_userDialog,&UserDialog::signalUpdateUserTable,this,&UserManager::slotUpdateUserTable);
|
||||
initUserTableWidget();
|
||||
updateUserTableWidget();
|
||||
QTimer::singleShot(500,this,SLOT(setDefaultUser()));
|
||||
// setDefaultUser();
|
||||
connect(this,SIGNAL(signalCheckUserChanged(int)),ui->trainRecord_Widget,SLOT(slotCheckUserChanged(int)));
|
||||
|
||||
//设置搜索框自动补全
|
||||
m_completer = new QCompleter();
|
||||
m_completer->setFilterMode(Qt::MatchStartsWith);
|
||||
m_completer->setCompletionMode(QCompleter::PopupCompletion);
|
||||
m_completer->setMaxVisibleItems(7);
|
||||
m_completer->setModel(&stringListModel);
|
||||
ui->searchUser_LineEdit->setCompleter(m_completer);
|
||||
ui->searchUser_LineEdit->setPlaceholderText(tr("姓名或者ID"));
|
||||
connect(ui->searchUser_LineEdit,SIGNAL(editingFinished()),this,SLOT(editComplete()));
|
||||
|
||||
connect(ui->searchUser_LineEdit,&QLineEdit::textChanged,[this](const QString text){
|
||||
if(text == "")
|
||||
{
|
||||
updateUserTableWidget();
|
||||
}
|
||||
});
|
||||
// connect(ui->searchUser_LineEdit,&QLineEdit::textEdited,[this](const QString text){
|
||||
// qDebug()<<"textEdited"<<text;
|
||||
// });
|
||||
|
||||
m_slectUserDialog = new SelectUserDialog();
|
||||
m_deleteUserDialog = new DeleteUserDialog();
|
||||
|
||||
}
|
||||
|
||||
void UserManager::editComplete()
|
||||
{
|
||||
//此处可用来自动添加被检索时没有的内容,可以将lineEdit中的内容添加到model中,但是在咱们这种情况下不适用
|
||||
//目前的需求是将数据库中有的数据显示出来,没有的不需要补全
|
||||
}
|
||||
|
||||
|
||||
|
||||
UserManager::~UserManager()
|
||||
{
|
||||
if(m_userDialog)
|
||||
delete m_userDialog;
|
||||
if(m_completer)
|
||||
delete m_completer;
|
||||
if(m_slectUserDialog)
|
||||
delete m_slectUserDialog;
|
||||
if(m_deleteUserDialog)
|
||||
delete m_deleteUserDialog;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void UserManager::initUserTableWidget()
|
||||
{
|
||||
ui->user_TableWidget->horizontalHeader()->setVisible(false);
|
||||
ui->user_TableWidget->verticalHeader()->setVisible(false);
|
||||
ui->user_TableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->user_TableWidget->setAlternatingRowColors(true);
|
||||
ui->user_TableWidget->setPalette(QPalette(Qt::lightGray));
|
||||
ui->user_TableWidget->setColumnCount(3);
|
||||
ui->user_TableWidget->setRowCount(20);
|
||||
// ui->user_TableWidget->setGridStyle(Qt::NoPen);
|
||||
ui->user_TableWidget->setShowGrid(false);
|
||||
ui->user_TableWidget->setColumnWidth(0,140);
|
||||
ui->user_TableWidget->setColumnWidth(1,90);
|
||||
ui->user_TableWidget->setColumnWidth(2,240);
|
||||
|
||||
ui->user_TableWidget->setFont(QFont("黑体",15));
|
||||
|
||||
for(int i = 0;i < 20;i++)
|
||||
ui->user_TableWidget->setRowHeight(i,68);
|
||||
|
||||
//设置单行选中
|
||||
ui->user_TableWidget->setSelectionBehavior(QTableWidget::SelectRows);
|
||||
ui->user_TableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
//设置表格所有单元格不可编辑
|
||||
ui->user_TableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
connect(ui->user_TableWidget,&QTableWidget::cellClicked,[this](int row,int column){
|
||||
Q_UNUSED(column)
|
||||
//根据行列获取用户ID
|
||||
qDebug() <<"row colume m_currentRows"<<row<<column<<m_currentRows;
|
||||
if(row >= m_currentRows )
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
//qDebug()<<"选择了ID"<<ui->user_TableWidget->item(row,2)->data(Qt::DisplayRole).toUInt();
|
||||
|
||||
m_currentUserId = ui->user_TableWidget->item(row,2)->data(Qt::DisplayRole).toUInt();
|
||||
emit signalCheckUserChanged(m_currentUserId);
|
||||
});
|
||||
|
||||
//UI显示问题待解决
|
||||
// ui->user_TableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui->user_TableWidget->setStyleSheet("QTableWidget::item{outline:none;}"
|
||||
);
|
||||
}
|
||||
|
||||
void UserManager::updateUserTableWidget()
|
||||
{
|
||||
QString queryStr(QString("select * from PatientTable order by ID DESC"));
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
int tempNum = CDatabaseInterface::getInstance()->getValuesSize();
|
||||
int fillTableNum = tempNum < 20 ? tempNum : 20;
|
||||
m_currentRows = fillTableNum;
|
||||
if(fillTableNum > 0)
|
||||
{
|
||||
QList<QVariantMap> valueMapList;
|
||||
valueMapList = CDatabaseInterface::getInstance()->getValues(0,fillTableNum);
|
||||
fillUserTable(valueMapList);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->user_TableWidget->clearContents();
|
||||
qDebug()<<"updateUserTableWidget()未查询到符合条件的数据";
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug()<<CDatabaseInterface::getInstance()->getLastError();
|
||||
}
|
||||
|
||||
void UserManager::fillUserTable(const QList<QVariantMap> &ListMap)
|
||||
{
|
||||
ui->user_TableWidget->clearContents();
|
||||
wordList.clear();
|
||||
for(int row = 0;row < ListMap.size();++row)
|
||||
{
|
||||
ST_PatientMsg st_PatientMsg = variantMapToPatientMsg(ListMap.at(row));
|
||||
//更新自动补全表
|
||||
wordList.append(st_PatientMsg.name);
|
||||
wordList.append(QString::number(st_PatientMsg.ID));
|
||||
stringListModel.setStringList(wordList);
|
||||
//第0列
|
||||
/***
|
||||
QTableWidgetItem *checkItem = new QTableWidgetItem();
|
||||
ui->user_TableWidget->setItem(row,0,checkItem);
|
||||
QCheckBox *checkBox = new QCheckBox();
|
||||
checkBox->setFixedWidth(40);
|
||||
|
||||
checkBox->setLayoutDirection(Qt::RightToLeft);
|
||||
//使用该方法时必须先添加QTableWidgetItem
|
||||
ui->user_TableWidget->setCellWidget(row,0,checkBox);
|
||||
*****/
|
||||
//第0列 名字
|
||||
QTableWidgetItem *nameItem = new QTableWidgetItem(st_PatientMsg.name);
|
||||
// nameItem->setFlags(nameItem->flags() & (~Qt::ItemIsEditable)); //设置单个单元格不可编辑
|
||||
ui->user_TableWidget->setItem(row, 0, nameItem);
|
||||
//第1列 性别
|
||||
QString sexStr;
|
||||
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
||||
qDebug() << "language"<<language;
|
||||
if(0 == st_PatientMsg.sex)
|
||||
{
|
||||
if(language == English_E)
|
||||
sexStr = tr("Male");
|
||||
else if(language == Chinese_E)
|
||||
sexStr = tr("男");
|
||||
}
|
||||
else if(1 == st_PatientMsg.sex)
|
||||
{
|
||||
if(language == English_E)
|
||||
sexStr = tr("Female");
|
||||
else if(language == Chinese_E)
|
||||
sexStr = tr("女");
|
||||
}
|
||||
QTableWidgetItem *sexItem = new QTableWidgetItem(sexStr);
|
||||
// nameItem->setFlags(nameItem->flags() & (~Qt::ItemIsEditable)); //设置单个单元格不可编辑
|
||||
ui->user_TableWidget->setItem(row, 1, sexItem);
|
||||
|
||||
//第2列 ID
|
||||
QTableWidgetItem *IdItem = new QTableWidgetItem(QString::number(st_PatientMsg.ID));
|
||||
ui->user_TableWidget->setItem(row, 2, IdItem);
|
||||
|
||||
// ui->user_TableWidget->cellWidget(row,0)->setGeometry(10,20,10,20);
|
||||
ui->user_TableWidget->item(row,0)->setTextAlignment(Qt::AlignCenter);
|
||||
ui->user_TableWidget->item(row,1)->setTextAlignment(Qt::AlignCenter);
|
||||
ui->user_TableWidget->item(row,2)->setTextAlignment(Qt::AlignCenter);
|
||||
}
|
||||
}
|
||||
|
||||
void UserManager::setDefaultUser()
|
||||
{
|
||||
/***
|
||||
QString queryStr(QString("select * from PatientTable where ID = '%1'").arg(wordList.last().toInt()));
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
|
||||
{
|
||||
QVariantMap userMap = CDatabaseInterface::getInstance()->getValues(0,1).at(0);
|
||||
ST_PatientMsg st_patientMsg = variantMapToPatientMsg(userMap);
|
||||
|
||||
//设置当前用户
|
||||
CurrentUserData::getInstace()->setCurrentUserMsg(st_patientMsg);
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL,tr("提示"),tr("未查到默认用户信息"));
|
||||
}
|
||||
***/
|
||||
ST_PatientMsg st_patientMsg;
|
||||
st_patientMsg.ID = 100000;
|
||||
st_patientMsg.name = "xyyl";
|
||||
CurrentUserData::getInstace()->setCurrentUserMsg(st_patientMsg);
|
||||
}
|
||||
|
||||
void UserManager::on_searchUser_Btn_clicked()
|
||||
{
|
||||
//首先清理界面
|
||||
ui->user_TableWidget->clearContents();
|
||||
//检索的情况下不显示添加按钮,只显示符合检索条件的内容
|
||||
QString msg = ui->searchUser_LineEdit->text();
|
||||
QString query(QString("select * from PatientTable where name like '%1%' or id like '%2%'").arg(msg).arg(msg));
|
||||
|
||||
|
||||
QList<QVariantMap> valueMapList;
|
||||
valueMapList.clear();
|
||||
qDebug() <<"最开始用户数:"<<valueMapList.count();
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(query))
|
||||
{
|
||||
valueMapList = CDatabaseInterface::getInstance()->getValues(0,8);
|
||||
qDebug()<<"name:"<<variantMapToPatientMsg(valueMapList.at(0)).ID;
|
||||
|
||||
}
|
||||
if(variantMapToPatientMsg(valueMapList.at(0)).ID == 0) //如果有查到为0的ID,直接清空
|
||||
valueMapList.clear();
|
||||
m_currentRows = valueMapList.count(); //此时要更新能选择的行,防止崩溃
|
||||
qDebug() <<"查询后用户数:"<<valueMapList.count();
|
||||
if(0 == valueMapList.count())//id = 0,sex=男,name=""
|
||||
{
|
||||
qDebug()<<"未找到合适数据";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() <<"查询后的用户数:"<<valueMapList.count();
|
||||
fillUserTable(valueMapList);
|
||||
}
|
||||
|
||||
void UserManager::slotUpdateUserTable()
|
||||
{
|
||||
updateUserTableWidget();
|
||||
}
|
||||
|
||||
|
||||
void UserManager::on_newUser_Btn_clicked()
|
||||
{
|
||||
m_userDialog->setDialogTitle(E_NEW_USER);
|
||||
}
|
||||
|
||||
//选择用户
|
||||
void UserManager::on_selectUser_Btn_clicked()
|
||||
{
|
||||
QString queryStr(QString("select * from PatientTable where ID = '%1'").arg(m_currentUserId));
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
|
||||
{
|
||||
QVariantMap userMap = CDatabaseInterface::getInstance()->getValues(0,1).at(0);
|
||||
ST_PatientMsg st_patientMsg = variantMapToPatientMsg(userMap);
|
||||
|
||||
m_slectUserDialog->setUserMsg(st_patientMsg);
|
||||
m_slectUserDialog->show();
|
||||
m_slectUserDialog->exec();
|
||||
//设置当前用户
|
||||
if(m_slectUserDialog->isSelectUser())
|
||||
CurrentUserData::getInstace()->setCurrentUserMsg(st_patientMsg);
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL,tr("提示"),tr("未查到该用户信息"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UserManager::on_EditUser_Btn_clicked()
|
||||
{
|
||||
QString queryStr(QString("select * from PatientTable where ID = '%1'").arg(m_currentUserId));
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
|
||||
{
|
||||
QVariantMap userMap = CDatabaseInterface::getInstance()->getValues(0,1).at(0);
|
||||
//ST_PatientMsg st_patientMsg = variantMapToPatientMsg(userMap);
|
||||
|
||||
//m_slectUserDialog->setUserMsg(st_patientMsg);
|
||||
//m_slectUserDialog->show();
|
||||
//m_slectUserDialog->exec();
|
||||
//设置当前用户
|
||||
/*
|
||||
if(m_slectUserDialog->isSelectUser())
|
||||
CurrentUserData::getInstace()->setCurrentUserMsg(st_patientMsg);
|
||||
*/
|
||||
m_userDialog->setDialogTitle(E_EDIT_USER,m_currentUserId);
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL,tr("提示"),tr("未查到该用户信息"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void UserManager::on_deleteUser_Btn_clicked()
|
||||
{
|
||||
QString queryStr(QString("select * from PatientTable where ID = '%1'").arg(m_currentUserId));
|
||||
|
||||
if(CDatabaseInterface::getInstance()->exec(queryStr))
|
||||
{
|
||||
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
|
||||
{
|
||||
QVariantMap userMap = CDatabaseInterface::getInstance()->getValues(0,1).at(0);
|
||||
//ST_PatientMsg st_patientMsg = variantMapToPatientMsg(userMap);
|
||||
|
||||
//m_slectUserDialog->setUserMsg(st_patientMsg);
|
||||
//m_slectUserDialog->show();
|
||||
//m_slectUserDialog->exec();
|
||||
//设置当前用户
|
||||
/*
|
||||
if(m_slectUserDialog->isSelectUser())
|
||||
CurrentUserData::getInstace()->setCurrentUserMsg(st_patientMsg);
|
||||
*/
|
||||
//m_userDialog->setDialogTitle(E_EDIT_USER,m_currentUserId);
|
||||
m_deleteUserDialog->show();
|
||||
m_deleteUserDialog->exec();
|
||||
if(m_deleteUserDialog->isDeletedUser())
|
||||
{
|
||||
if(!CDatabaseInterface::getInstance()->deleteRowTable("PatientTable","ID",QString::number(m_currentUserId)))
|
||||
qDebug()<<"delete user failed"<<CDatabaseInterface::getInstance()->getLastError();
|
||||
updateUserTableWidget();
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(NULL,tr("提示"),tr("未查到该用户信息"));
|
||||
}
|
||||
|
||||
/**********之前的删除方式,可以同时删除多个用户**********
|
||||
QList<int> deleteIndexList;
|
||||
int deleteUserNum = 0;
|
||||
for(int i = 0;i <m_currentRows;++i)
|
||||
{
|
||||
QCheckBox *checkBox = static_cast<QCheckBox*>(ui->user_TableWidget->cellWidget(i,0));
|
||||
|
||||
if(checkBox->isChecked())
|
||||
{
|
||||
QString ID = ui->user_TableWidget->item(i,2)->data(Qt::DisplayRole).toString();
|
||||
if(!CDatabaseInterface::getInstance()->deleteRowTable("PatientTable","ID",ID))
|
||||
qDebug()<<"delete user failed"<<CDatabaseInterface::getInstance()->getLastError();
|
||||
else
|
||||
++deleteUserNum;
|
||||
}
|
||||
}
|
||||
if(deleteUserNum > 0)
|
||||
QMessageBox::information(NULL,tr("提示"),tr("删除成功"));
|
||||
***************/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UserManager::changeEvent(QEvent* event)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
updateUserTableWidget(); //刷新表
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
QWidget::changeEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserManager::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
ui->searchUser_LineEdit->clear();
|
||||
|
||||
//ui->trainRecordDestPage_LineEdit->clear(); //清空查询
|
||||
}
|
||||
67
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.h
Normal file
67
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef USERMANAGER_H
|
||||
#define USERMANAGER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "userdialog.h"
|
||||
#include <QCompleter>
|
||||
#include <QStringListModel>
|
||||
class SelectUserDialog;
|
||||
class DeleteUserDialog;
|
||||
namespace Ui {
|
||||
class UserManager;
|
||||
}
|
||||
|
||||
class UserManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UserManager(QWidget *parent = nullptr);
|
||||
~UserManager();
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
private slots:
|
||||
void on_newUser_Btn_clicked();
|
||||
|
||||
void on_selectUser_Btn_clicked();
|
||||
|
||||
void on_EditUser_Btn_clicked();
|
||||
|
||||
void on_deleteUser_Btn_clicked();
|
||||
|
||||
void on_searchUser_Btn_clicked();
|
||||
|
||||
void editComplete();
|
||||
|
||||
//设置默认用户
|
||||
void setDefaultUser();
|
||||
|
||||
public slots:
|
||||
void slotUpdateUserTable();
|
||||
|
||||
signals:
|
||||
void signalCheckUserChanged(int);
|
||||
|
||||
private:
|
||||
//初始化用户列表
|
||||
void initUserTableWidget();
|
||||
//更新用户列表
|
||||
void updateUserTableWidget();
|
||||
//填充Usertable
|
||||
void fillUserTable(const QList<QVariantMap> &);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Ui::UserManager *ui;
|
||||
UserDialog *m_userDialog;
|
||||
int m_currentRows; //当前有效行数
|
||||
int m_currentUserId; //当前用户ID
|
||||
QCompleter *m_completer; //自动补全
|
||||
QStringListModel stringListModel;
|
||||
QStringList wordList; //自动补全文字集
|
||||
SelectUserDialog *m_slectUserDialog;
|
||||
DeleteUserDialog *m_deleteUserDialog;
|
||||
};
|
||||
|
||||
#endif // USERMANAGER_H
|
||||
319
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.ui
Normal file
319
ZBD_IIIDL_S_Project/Src/UserManager/usermanager.ui
Normal file
@@ -0,0 +1,319 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserManager</class>
|
||||
<widget class="QWidget" name="UserManager">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1920</width>
|
||||
<height>980</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>604</width>
|
||||
<height>861</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QPushButton" name="searchUser_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>425</x>
|
||||
<y>28</y>
|
||||
<width>122</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: #05A6EC;
|
||||
border-radius: 4px;
|
||||
color:white;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>搜索</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="user_TableWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>170</y>
|
||||
<width>497</width>
|
||||
<height>681</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>104</y>
|
||||
<width>497</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#groupBox_2{background: #E5F2F9;
|
||||
border-radius: 2px;}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>38</x>
|
||||
<y>4</y>
|
||||
<width>71</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>姓名</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>5</y>
|
||||
<width>91</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>性别</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>314</x>
|
||||
<y>3</y>
|
||||
<width>69</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
<width>345</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#groupBox_3{background: #FFFFFF;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #454545;}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="searchUser_LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>21</x>
|
||||
<y>2</y>
|
||||
<width>301</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border:none;</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>请输入姓名或者ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<zorder>groupBox_3</zorder>
|
||||
<zorder>searchUser_Btn</zorder>
|
||||
<zorder>user_TableWidget</zorder>
|
||||
<zorder>groupBox_2</zorder>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="selectUser_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>880</y>
|
||||
<width>110</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>选择</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="EditUser_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>179</x>
|
||||
<y>880</y>
|
||||
<width>110</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>编辑</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="deleteUser_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>308</x>
|
||||
<y>880</y>
|
||||
<width>110</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="newUser_Btn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>437</x>
|
||||
<y>880</y>
|
||||
<width>110</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>黑体</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius: 4px;
|
||||
border: 1px solid #0D9DDB;
|
||||
color:#0D9DDB ;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新建</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TrainRecord" name="trainRecord_Widget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>604</x>
|
||||
<y>0</y>
|
||||
<width>1316</width>
|
||||
<height>961</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TrainRecord</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>trainrecord.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user