project/xyylMCWEACSystem/hospitalinfo.cpp

450 lines
12 KiB
C++

#include "hospitalinfo.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>
#include "datamanager.h"
HospitalInfo::HospitalInfo(QWidget * parent ):QWidget (parent)
{
init();
initLay();
initConnect();
}
HospitalInfo::~HospitalInfo()
{
}
void HospitalInfo::init()
{
this->setStyleSheet("QWidget \
{\
background-color:white;\
border-radius:10px;\
}"\
);
m_labHospitalInfo.setText("医院信息:");;
m_labHospitalInfo.setStyleSheet("width: 128px; height: 46px;font-family: 思源黑体;font-size: 32px;font-weight: 500; color: #0D9DDB;");
m_labStart1.setText("*");
m_labStart2.setText("*");
m_labStart1.setObjectName("labStar");
m_labStart2.setObjectName("labStar");
m_labStart1.setFixedWidth(10);
m_labStart2.setFixedWidth(10);
//m_labStart1.setStyleSheet("color:red");
//m_labStart2.setStyleSheet("color:red");
//医院名称
m_labHospitalName.setText("医院名称:");
m_labHospitalName.setObjectName("labhospitalName");
//科室
m_labSection.setText("科 室:");;
m_labSection.setObjectName("labSection");
//用户人数
m_labUserNum.setText(" 用户人数:");;
m_labUserNum.setObjectName("labUserNum");
//数据名称
m_labDataBaseName.setText("数据名称:");;
m_labDataBaseName.setObjectName("labDataBaseName");
//用户名称
m_labUser.setText("用户名称:");
m_labUser.setObjectName("labUser");
//用户名称
m_labpasswd.setText("用户密码:");;
m_labpasswd.setObjectName("labpasswd");
//确认密码
m_labRepasswd.setText("确认密码:");;
m_labRepasswd.setObjectName("labRepasswd");
//确认
m_btnOK.setText("确认");;
m_btnCancel.setText("取消");;
int ihight = 40;
m_labStart1.setFixedHeight(ihight);
m_labStart2.setFixedHeight(ihight);
//医院名称
m_labHospitalName.setFixedHeight(ihight);
m_editHospitalName.setFixedHeight(ihight);
//科室
m_labSection.setFixedHeight(ihight);
m_editSection.setFixedHeight(ihight);
//用户人数
m_labUserNum.setFixedHeight(ihight);
m_editUserNum.setFixedHeight(ihight);
//数据名称
m_labDataBaseName.setFixedHeight(ihight);
m_editDataBaseName.setFixedHeight(ihight);
//用户名称
m_labUser.setFixedHeight(ihight);
m_editUser.setFixedHeight(ihight);
//用户密码
m_labpasswd.setFixedHeight(ihight);
m_editPasswd.setFixedHeight(ihight);
//确认密码
m_labRepasswd.setFixedHeight(ihight);
m_editRePasswd.setFixedHeight(ihight);
#if 0
int iwidth = 40;
//医院名称
m_labHospitalName.setFixedHeight(iwidth);
//科室
m_labSection.setFixedHeight(iwidth);
//用户人数
m_labUserNum.setFixedHeight(iwidth);
//数据名称
m_labDataBaseName.setFixedHeight(iwidth);
//用户名称
m_labUser.setFixedHeight(iwidth);
//用户名称
m_labpasswd.setFixedHeight(iwidth);
//确认密码
m_labRepasswd.setFixedHeight(iwidth);
int iwidth = QFontMetrics(this->font()).width("医院名称")+8;
//医院名称
m_labHospitalName.setFixedWidth(iwidth);
//科室
m_labSection.setFixedWidth(iwidth);
//用户人数
m_labUserNum.setFixedWidth(iwidth+10);
//数据名称
m_labDataBaseName.setFixedWidth(iwidth+10);
//用户名称
m_labUser.setFixedWidth(iwidth+10);
//用户名称
m_labpasswd.setFixedWidth(iwidth+10);
//确认密码
m_labRepasswd.setFixedWidth(iwidth+10);
#endif
//确认
m_btnOK.setText("确认");;
m_btnCancel.setText("取消");;
m_btnOK.setStyleSheet("QPushButton{\
background: white;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:hover{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:pressed{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:checked{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}");
m_btnCancel.setStyleSheet("QPushButton{\
background: white;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:hover{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:pressed{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}\
QPushButton:checked{\
background: #0d9ddb;\
border-radius:10px;padding:7px 10px;\
}");
m_btnCancel.setMinimumWidth(100);
m_btnOK.setMinimumWidth(100);
#if 0
int ediWidth = 150;
//医院信息
//医院名称
m_labHospitalName.setFixedWidth(ediWidth);
m_editHospitalName.setFixedWidth(ediWidth);
//科室
m_editSection.setFixedWidth(ediWidth);
m_editSection.setFixedWidth(ediWidth);;
//用户人数
m_editUserNum.setFixedWidth(ediWidth);
m_editUserNum.setFixedWidth(ediWidth);;
//数据名称
m_labHospitalName.setFixedWidth(ediWidth);
m_editDataBaseName.setFixedWidth(ediWidth);;
//用户名称
m_labHospitalName.setFixedWidth(ediWidth);
m_editUser.setFixedWidth(ediWidth);;
//用户密码
m_labHospitalName.setFixedWidth(ediWidth);
m_editPasswd.setFixedWidth(ediWidth);;
//确认密码
m_labHospitalName.setFixedWidth(ediWidth);
m_editRePasswd.setFixedWidth(ediWidth);;
#endif
}
void HospitalInfo::initLay()
{
#if 0
int width_space = 60;
QHBoxLayout * hlay0 = new QHBoxLayout;
hlay0->addWidget(&m_labHospitalInfo);
QHBoxLayout * hlay = new QHBoxLayout;
hlay->addSpacing(width_space);
hlay->addWidget(&m_labStart2);
hlay->addWidget(&m_labHospitalName);
hlay->addWidget(&m_editHospitalName);
hlay->addWidget(&m_labUser);
hlay->addWidget(&m_editUser);
//科室
QHBoxLayout * hlay1 = new QHBoxLayout;
hlay1->addSpacing(width_space);
hlay1->addWidget(&m_labStart1);
hlay1->addWidget(&m_labSection);//
hlay1->addWidget(&m_editSection);
hlay1->addWidget(&m_labpasswd);
hlay1->addWidget(&m_editPasswd);
//用户人数
QHBoxLayout * hlay2 = new QHBoxLayout;
hlay2->addSpacing(width_space);
hlay2->addWidget(&m_labUserNum);
hlay2->addWidget(&m_editUserNum);
hlay2->addWidget(&m_labRepasswd);
hlay2->addWidget(&m_editRePasswd);
//数据名称
QHBoxLayout * hlay3 = new QHBoxLayout;
hlay3->addSpacing(width_space);
hlay3->addWidget(&m_labDataBaseName);
hlay3->addWidget(&m_editDataBaseName);
QHBoxLayout * hlay4 = new QHBoxLayout;
hlay4->addStretch();
hlay4->addWidget(&m_btnOK);
hlay4->addWidget(&m_btnCancel);
hlay4->addStretch();
QVBoxLayout * vlay = new QVBoxLayout;
vlay->addLayout(hlay0);
vlay->addSpacing(30);
vlay->addLayout(hlay);
vlay->addLayout(hlay1);
vlay->addLayout(hlay2);
vlay->addLayout(hlay3);
vlay->addStretch();
hlay0->setSpacing(0);
hlay->setSpacing(0);
hlay1->setSpacing(0);
hlay2->setSpacing(0);
hlay3->setSpacing(0);
hlay4->setSpacing(0);
QWidget * w = new QWidget;
w->setLayout(vlay);
QVBoxLayout * hlayall = new QVBoxLayout;
hlayall->addWidget(w);
hlayall->addLayout(hlay4);
w->setStyleSheet("QWidget \
{\
background-color:white;\
border-radius:10px;\
}"\
);
setLayout(hlayall);
#else
QVBoxLayout * vlay1 = new QVBoxLayout;
QHBoxLayout * hlay = new QHBoxLayout;
hlay->addWidget(&m_labStart2);
hlay->addWidget(&m_labHospitalName);
vlay1->addLayout(hlay);
QHBoxLayout * hlay2 = new QHBoxLayout;
hlay2->addWidget(&m_labStart1);
hlay2->addWidget(&m_labSection);
vlay1->addLayout(hlay2);
vlay1->addWidget(&m_labUserNum);
vlay1->addWidget(&m_labDataBaseName);
vlay1->addStretch();
QVBoxLayout * vlay2 = new QVBoxLayout;
vlay2->addWidget(&m_editHospitalName);
vlay2->addWidget(&m_editSection);
vlay2->addWidget(&m_editUserNum);
vlay2->addWidget(&m_editDataBaseName);
vlay2->addStretch();
QVBoxLayout * vlay3= new QVBoxLayout;
vlay3->addWidget(&m_labUser);
vlay3->addWidget(&m_labpasswd);
vlay3->addWidget(&m_labRepasswd);
vlay3->addStretch();
QVBoxLayout * vlay4= new QVBoxLayout;
vlay4->addWidget(&m_editUser);
vlay4->addWidget(&m_editPasswd);
vlay4->addWidget(&m_editRePasswd);
vlay4->addStretch();
QHBoxLayout * hlay4 = new QHBoxLayout;
hlay4->addStretch();
hlay4->addWidget(&m_btnOK);
hlay4->addWidget(&m_btnCancel);
hlay4->addStretch();
QHBoxLayout * hlayAll = new QHBoxLayout;
hlayAll->addLayout(vlay1);
hlayAll->addLayout(vlay2);
hlayAll->addLayout(vlay3);
hlayAll->addLayout(vlay4);
int ispace = 3;
vlay1->setSpacing(ispace);
vlay2->setSpacing(ispace);
vlay3->setSpacing(ispace);
vlay4->setSpacing(ispace);
QVBoxLayout * vall = new QVBoxLayout;
//vall->addLayout(hlayAll);
QWidget * w = new QWidget;
QHBoxLayout * hlayw = new QHBoxLayout;
hlayw->addWidget(&m_labHospitalInfo );
QVBoxLayout * vlayw = new QVBoxLayout;
vlayw->addLayout(hlayw);
vlayw->addLayout(hlayAll);
w->setLayout(vlayw);
vall->addWidget(w);
vall->addLayout(hlay4);
vall->addStretch();
setLayout(vall);
#endif
}
bool HospitalInfo::initConnect()
{
bool reok;
reok = connect(&m_btnOK,SIGNAL(clicked()),this,SLOT(slotSave()));
if(!reok)
{
qDebug()<<"save connect failed"<<endl;
}
}
void HospitalInfo::slotSave()
{
//医院名称
QString sHostpitalName = m_editHospitalName.text();
//科室
QString sSection = m_editSection.text();
//用户人数
QString UserNum = m_editUserNum.text();
//数据名称
QString DataName = m_editDataBaseName.text();
//用户名称
QString UserName = m_editUser.text();
//用户密码
QString UserPasswd = m_editPasswd.text();
//确认密码
QString RePasswd = m_editRePasswd.text();
DataManager::instance().updateHospitalInfo( sHostpitalName,
UserName,
sSection,
UserPasswd,
UserNum,
RePasswd,
DataName);
slotUpdateShow();
}
void HospitalInfo::slotUpdateShow()
{
QString sHostpitalName;
QString UserName;
QString sSection;
QString UserPasswd;
QString UserNum;
QString RePasswd;
QString DataName;
DataManager::instance().HospitalInfo( sHostpitalName,
UserName,
sSection,
UserPasswd,
UserNum,
RePasswd,
DataName);
//医院名称
m_editHospitalName.setText(sHostpitalName);
//科室
m_editSection.setText(sSection);
//用户人数
m_editUserNum.setText(UserNum);
//数据名称
m_editDataBaseName.setText(DataName);
//用户名称
m_editUser.setText(UserName);
//用户密码
m_editPasswd.setText(UserPasswd);
//确认密码
m_editRePasswd.setText(RePasswd);
}
void HospitalInfo::slotCancel()
{
//
}