-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagregarcitaspaciente.cpp
55 lines (43 loc) · 1.91 KB
/
agregarcitaspaciente.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
48
49
50
51
52
53
54
#include "agregarcitaspaciente.h"
#include <QDebug>
#include <QSqlQuery>
agregarCitasPaciente::agregarCitasPaciente()
{
database=QSqlDatabase::database();
}
agregarCitasPaciente::agregarCitasPaciente(QString hostName, int port, QString dbName, QString userName, QString pass){
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName(hostName);
db.setPort(port);
db.setDatabaseName(dbName);
db.setUserName(userName);
db.setPassword(pass);
db.open();
}
bool agregarCitasPaciente::citasPaciente(QString matricula,QString fecha, QString hora, QString doctor, QString sintomas){
bool res=false;
//query de insertado
QSqlQuery insertar;
if(insertar.exec("insert into cita(matricula,fecha,hora,doctor,sintomas,idcitaExterna,estado) values("+ matricula +",'"+ fecha +"','"+ hora +"',"+ doctor +",'"+ sintomas +"',NULL,false)") ){
res= true;
}
else {
qDebug()<<insertar.lastError().text();
}
return res;
}
bool agregarCitasPaciente::citasExternas(QString matricula, QString nombreCompleto, QString lugarOrigen, QString edad, QString sexo, QString fecha, QString hora , QString doctor, QString sintomas)
{
bool res=false;
QSqlQuery insertar;
if(insertar.exec("insert into citaExterna(matricula,nombreCompleto,lugarOrigen,edad,sexo) values("+ matricula +",'"+ nombreCompleto +"','"+ lugarOrigen +"',"+ edad +",'"+ sexo+"')") )
{
QString idcitaExterna;
idcitaExterna = insertar.lastInsertId().toString();
if(insertar.exec("insert into cita(matricula,fecha,hora,doctor,sintomas,idcitaExterna,estado) values("+ matricula +",'"+ fecha +"','"+ hora +"',"+ doctor +",'"+ sintomas +"',"+ idcitaExterna +",false)") ){
res=true;
}
else qDebug()<<"Error en cita"<<insertar.lastError().text();
} else qDebug()<<"Error en cita externa"<<insertar.lastError().text();
return res;
}