1 增加病例翻页数据库支持逻辑 2 增加医院信息更新数据库支持
This commit is contained in:
parent
8a68ef046d
commit
e57bbaf79f
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
DataManager::DataManager(QObject * parent )
|
||||
DataManager::DataManager(QObject * parent ):QObject(parent)
|
||||
{
|
||||
init();
|
||||
};
|
||||
@ -110,7 +110,7 @@ bool DataManager::updateHospitalInfo(QString sHostpitalName,
|
||||
SqlGenerate sqlGener;
|
||||
QString sql = sqlGener.insertData("t_Hostpital",map);
|
||||
qDebug()<<sql<<endl;
|
||||
m_sqlcore.execute(sql);
|
||||
return m_sqlcore.execute(sql);
|
||||
|
||||
}
|
||||
bool DataManager::updateMedicRecord(
|
||||
@ -133,8 +133,73 @@ bool DataManager::updateMedicRecord(
|
||||
map.insert("f_Laterality", Laterality);
|
||||
map.insert("f_Other", Other);
|
||||
SqlGenerate sqlGener;
|
||||
QString sql = sqlGener.insertData("t_Hostpital",map);
|
||||
QString sql = sqlGener.insertData("t_MedicRecords",map);
|
||||
qDebug()<<sql<<endl;
|
||||
m_sqlcore.execute(sql);
|
||||
return m_sqlcore.execute(sql);
|
||||
}
|
||||
int DataManager::getMedicRecordCount( QString sName)
|
||||
{
|
||||
int ret = -1;
|
||||
QString querySql = QString("select count(*) from t_MedicRecords where f_Name LIKE '%") + sName + "%';";
|
||||
//qDebug() << "querySql = " << querySql << endl;
|
||||
auto query(m_sqlcore.select(querySql));
|
||||
if (!query.isNull())
|
||||
{
|
||||
if (query->first())
|
||||
{
|
||||
ret = query->value(0).toUInt();
|
||||
}
|
||||
query->finish();
|
||||
query->clear();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
uint DataManager::getMedicRecordList(const QString& fileName,
|
||||
QList<MedicRecord>& filesInfo,
|
||||
int& curPage,
|
||||
int perPageCnt)
|
||||
{
|
||||
uint ret = 0;
|
||||
filesInfo.clear();
|
||||
QString tmpFileName = fileName;
|
||||
QString querySql = QString("SELECT f_CheckNum,f_Type,f_Name, f_Sex,f_Birthday,f_Year,f_Laterality,f_Other from t_MedicRecords where f_Name LIKE '%") + tmpFileName + "%'";
|
||||
querySql += QString(" LIMIT %1 offset %2;").arg(perPageCnt)
|
||||
.arg(curPage * perPageCnt);
|
||||
|
||||
auto query(m_sqlcore.select(querySql));
|
||||
if (query.isNull())
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
while (query->next())
|
||||
{
|
||||
|
||||
|
||||
|
||||
MedicRecord info;
|
||||
info.m_CheckNum= query->value(0).toString();
|
||||
info.m_Type = query->value(1).toString();
|
||||
info.m_Name = query->value(2).toString();
|
||||
info.m_Sex = query->value(3).toString();
|
||||
info.m_Birthday = query->value(4).toString();
|
||||
info.m_Year = query->value(5).toString();
|
||||
info.m_Laterality = query->value(6).toString();
|
||||
info.m_Other = query->value(7).toString();
|
||||
|
||||
filesInfo.append(info);
|
||||
++ret;
|
||||
}
|
||||
if (ret > 0)
|
||||
{
|
||||
++curPage;
|
||||
}
|
||||
|
||||
query->finish();
|
||||
query->clear();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -4,6 +4,17 @@
|
||||
#include <QObject>
|
||||
#include "SqlCore.h"
|
||||
#include "SqlGenerate.h"
|
||||
struct MedicRecord
|
||||
{
|
||||
QString m_CheckNum ;
|
||||
QString m_Type ;
|
||||
QString m_Name ;
|
||||
QString m_Sex;
|
||||
QString m_Birthday;
|
||||
QString m_Year;
|
||||
QString m_Laterality;
|
||||
QString m_Other;
|
||||
};
|
||||
class DataManager:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -23,13 +34,17 @@ public:
|
||||
bool updateMedicRecord(
|
||||
QString CheckNum ,
|
||||
QString Type ,
|
||||
QString _Name ,
|
||||
QString Name ,
|
||||
QString Sex,
|
||||
QString _Birthday,
|
||||
QString Year,
|
||||
QString Laterality,
|
||||
QString Other);
|
||||
|
||||
int getMedicRecordCount(QString sName);
|
||||
uint getMedicRecordList(const QString& fileName,
|
||||
QList<MedicRecord>& filesInfo,
|
||||
int& curPage,
|
||||
int perPageCnt);
|
||||
private:
|
||||
void init();
|
||||
void initTable();
|
||||
|
@ -380,28 +380,34 @@ void HospitalInfo::slotSave()
|
||||
|
||||
//医院名称
|
||||
|
||||
QString sName = m_editHospitalName.text();
|
||||
QString sHostpitalName = m_editHospitalName.text();
|
||||
//科室
|
||||
|
||||
QString sSection = m_editSection.text();
|
||||
//用户人数
|
||||
|
||||
QString sNum = m_editUserNum.text();
|
||||
QString UserNum = m_editUserNum.text();
|
||||
|
||||
//数据名称
|
||||
|
||||
QString sDataNAme = m_editDataBaseName.text();
|
||||
QString DataName = m_editDataBaseName.text();
|
||||
|
||||
//用户名称
|
||||
QString sUserName = m_editUser.text();
|
||||
QString UserName = m_editUser.text();
|
||||
//用户密码
|
||||
QString sUserPasswd = m_editPasswd.text();
|
||||
QString UserPasswd = m_editPasswd.text();
|
||||
//确认密码
|
||||
QString sRePasswwd = m_editRePasswd.text();
|
||||
QString RePasswd = m_editRePasswd.text();
|
||||
|
||||
DataManager::instance().updateHospitalInfo( sHostpitalName,
|
||||
UserName,
|
||||
sSection,
|
||||
UserPasswd,
|
||||
UserNum,
|
||||
RePasswd,
|
||||
DataName);
|
||||
|
||||
DataManager::instance().updateHospitalInfo(
|
||||
|
||||
);
|
||||
}
|
||||
void HospitalInfo::slotCancel()
|
||||
{
|
||||
|
@ -174,6 +174,9 @@ MedicalRecordManager::~MedicalRecordManager()
|
||||
}
|
||||
void MedicalRecordManager::init()
|
||||
{
|
||||
//当前页
|
||||
m_currentPage = 0 ;
|
||||
|
||||
m_labMedRecManager.setText("病例管理");
|
||||
//QAction
|
||||
m_actSearch = new QAction;
|
||||
@ -348,3 +351,109 @@ void MedicalRecordManager::initTable()
|
||||
m_tableWidget.setHorizontalHeaderLabels(lstHHead);//setWordWrap(true)
|
||||
//m_tableWidget.show();
|
||||
}
|
||||
void MedicalRecordManager::slotPreviousPage()
|
||||
{
|
||||
|
||||
}
|
||||
void MedicalRecordManager::slotNextPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MedicalRecordManager::updateContext()
|
||||
{
|
||||
QString fileName = m_editSearch.text();
|
||||
fileName = fileName.simplified();
|
||||
QList<MedicRecord> lstInfo;
|
||||
int rowCounts = DataManager::instance().getMedicRecordCount(fileName);
|
||||
//logInfo() << fileName << rowCounts << endl;
|
||||
double page = (double)rowCounts / (double)100;
|
||||
if (page > (int)page)
|
||||
{
|
||||
page = page + 1;
|
||||
}
|
||||
else if (page == 0)
|
||||
{
|
||||
page = 1;
|
||||
}
|
||||
if (m_currentPage == (int)page)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataManager::instance().getMedicRecordList(fileName, lstInfo, m_currentPage, m_tableWidget.rowCount());
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||
m_tableWidget.verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||
QString::number((int)page);//设置一共有多少页
|
||||
int row = 0;
|
||||
for (; row < lstInfo.size(); row++)
|
||||
{
|
||||
int col=0;
|
||||
QTableWidgetItem *item_id = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_m_CheckNum = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_type = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Name = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Sex = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Age = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Laterality = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_other = m_tableWidget.item(row, col++);
|
||||
item_id->setCheckState(Qt::Unchecked);
|
||||
item_id->setFlags(Qt::ItemIsEditable| Qt::ItemIsSelectable| Qt::ItemIsUserCheckable| Qt::ItemIsEnabled| Qt::ItemIsDragEnabled| Qt::ItemIsDropEnabled);
|
||||
int id_page = 0;
|
||||
if (m_currentPage == 0)
|
||||
{
|
||||
id_page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
id_page = m_currentPage;
|
||||
}
|
||||
item_id->setData(Qt::DisplayRole, row + 1 + (id_page - 1) * 100);
|
||||
//设置数据
|
||||
|
||||
}
|
||||
|
||||
if (row < m_tableWidget.rowCount())
|
||||
{
|
||||
for (int i = row; i < m_tableWidget.rowCount(); i++)
|
||||
{
|
||||
int col=0;
|
||||
QTableWidgetItem *item_id = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_m_CheckNum = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_type = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Name = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Sex = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Age = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_Laterality = m_tableWidget.item(row, col++);
|
||||
QTableWidgetItem *item_other = m_tableWidget.item(row, col++);
|
||||
item_id->setData(Qt::CheckStateRole, QVariant());
|
||||
item_id->setData(Qt::DisplayRole, "");
|
||||
//item_id->setFlags(Qt::NoItemFlags);
|
||||
item_m_CheckNum->setData(Qt::DisplayRole, "");
|
||||
item_type->setData(Qt::UserRole, "");
|
||||
item_Name->setData(Qt::DisplayRole, "");
|
||||
item_Sex->setData(Qt::DisplayRole, "");
|
||||
item_Age->setData(Qt::DisplayRole, "");
|
||||
item_Age->setData(Qt::DisplayRole, "");
|
||||
item_Laterality->setData(Qt::DisplayRole, "");
|
||||
item_other->setData(Qt::DisplayRole, "");
|
||||
|
||||
}
|
||||
}
|
||||
if (m_currentPage == 0)
|
||||
{
|
||||
//m_labCurentPage.setText(QString::number(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_labCurentPage.setText(QString::number(m_currentPage));
|
||||
}
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);//单独使用--每一列宽度平均//Qt::4 //horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
||||
m_tableWidget.horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
||||
m_tableWidget.verticalHeader()->scrollToTop();
|
||||
m_tableWidget.scrollToTop();
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,10 @@
|
||||
#include <QDateEdit>
|
||||
#include <QTableWidget>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QAction>
|
||||
#include "datamanager.h"
|
||||
|
||||
class MedicalRecordManager:public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -33,6 +34,15 @@ private slots:
|
||||
des: 搜索
|
||||
*/
|
||||
void slotSearch();
|
||||
|
||||
|
||||
//页面跳转
|
||||
|
||||
void slotPreviousPage();//上一页update
|
||||
void slotNextPage(); //下一页
|
||||
void updateContext();
|
||||
private:
|
||||
int m_currentPage;
|
||||
private:
|
||||
QLabel m_labMedRecManager;
|
||||
QAction * m_actSearch;
|
||||
|
Loading…
x
Reference in New Issue
Block a user