-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatienteditview.cpp
47 lines (40 loc) · 1.56 KB
/
patienteditview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "patienteditview.h"
#include "ui_patienteditview.h"
PatientEditView::PatientEditView(QWidget *parent, int index) :
QWidget(parent),
ui(new Ui::PatientEditView)
{
ui->setupUi(this);
dataMapper = new QDataWidgetMapper();
QSqlTableModel *tableModel = DataBase::getInstance().patientTabModel.get();
dataMapper->setModel(tableModel);
dataMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
dataMapper->addMapping(ui->id_edit,tableModel->fieldIndex("ID"));
dataMapper->addMapping(ui->name_edit,tableModel->fieldIndex("NAME"));
dataMapper->addMapping(ui->number_edit,tableModel->fieldIndex("ID_CARD"));
dataMapper->addMapping(ui->height_spin,tableModel->fieldIndex("HEIGHT"));
dataMapper->addMapping(ui->weight_spin,tableModel->fieldIndex("WEIGHT"));
dataMapper->addMapping(ui->phone_edit,tableModel->fieldIndex("MOBILEPHONE"));
dataMapper->addMapping(ui->date,tableModel->fieldIndex("DOB"));
dataMapper->addMapping(ui->sex_box,tableModel->fieldIndex("SEX"));
dataMapper->addMapping(ui->create_date,tableModel->fieldIndex("CREATEDTIMESTAMP"));
dataMapper->setCurrentIndex(index);
// 只有获得焦点才会保存到数据库
ui->create_date->setFocus();
ui->sex_box->setFocus();
ui->id_edit->setFocus();
}
PatientEditView::~PatientEditView()
{
delete ui;
}
void PatientEditView::on_pushButton_clicked()
{
DataBase::getInstance().submitPatientEdit();
emit cancel();
}
void PatientEditView::on_pushButton_2_clicked()
{
DataBase::getInstance().revertPatientEdit();
emit cancel();
}