#include "employee.h"
#include "ui_employee.h"
employee::employee(QWidget *parent) :
QDialog(parent),
ui(new Ui::employee)
{
ui->setupUi(this);
}
employee::~employee()
{
delete ui;
}
void employee::on_receive_clicked()
{
int id=ui->eid->text().toInt();
QString name=ui->ename->text().trimmed();
QString cccd=ui->ecccd->text().trimmed();
QString phone=ui->ephone->text().trimmed();
QString address=ui->eaddress->text().trimmed();
QDateTime datetime=QDateTime::currentDateTime();
QString datetimetext=datetime.toString();
conn.connOpen();
QSqlQuery query;
query.prepare("insert into employee (id,name,cccd,phone,diachi,time_in) values ('"+QString::number(id)+"','"+name+"','"+cccd+"','"+phone+"','"+address+"','"+datetimetext+"')");
if(!query.exec())
qDebug() << query.lastError().text() << query.lastQuery();
else
{
QMessageBox::information( this,tr("Success!"), tr("Nhận ca thành công!") );
}
conn.connclose();
}
void employee::on_exit_clicked()
{
this->hide();
}
void employee::on_tableView_activated(const QModelIndex &index)
{
QString val=ui->tableView->model()->data(index).toString();
if(!conn.connOpen()){
qDebug() << "Database loaded not successfull!";
} else{
qDebug() << "Database loaded successfull!";
}
QSqlQuery query;
query.prepare("select * from employee where id='"+val+"' or name='"+val+"' or cccd='"+val+"' or phone='"+val+"' or diachi='"+val+"' ");
if(query.exec()){
while(query.next()){
ui->eid->setText(query.value(0).toString());
ui->ename->setText(query.value(1).toString());
ui->ecccd->setText(query.value(2).toString());
ui->ephone->setText(query.value(3).toString());
ui->eaddress->setText(query.value(4).toString());
}
conn.connclose();
}
else{
QMessageBox::critical(this,tr("Error::"),query.lastError().text());
}
}
void employee::on_load_clicked()
{
QSqlQueryModel * modal=new QSqlQueryModel();
if(!conn.connOpen()){
qDebug() << "Database loaded not successfull!";
} else{
qDebug() << "Database loaded successfull!";
}
QSqlQuery* query=new QSqlQuery();
query->prepare("select * from employee");
query->exec();
modal->setQuery(*query);
ui->tableView->setModel(modal);
conn.connclose();
qDebug()<<(modal->rowCount());
}
void employee::on_leave_clicked()
{
int id=ui->eid->text().toInt();
QDateTime datetime=QDateTime::currentDateTime();
QString datetimetext=datetime.toString();
conn.connOpen();
QSqlQuery query;
query.prepare("update employee set time_out='"+datetimetext+"' where id='"+QString::number(id)+"'");
if(!query.exec())
qDebug() << query.lastError().text() << query.lastQuery();
else
qDebug() << "Update was successful "<< query.lastQuery();
conn.connclose();
}
void employee::on_add_clicked()
{
QString phone,cccd,id;
phone=ui->ephone->text();
cccd=ui->ecccd->text();
id=ui->eid->text();
bool cccd_check=false,phone_check=false,id_check=false;
QRegularExpression idrx("^[0-9]{4}$",
QRegularExpression::CaseInsensitiveOption);
QRegularExpression phonerx("^[0-9]{10}$",
QRegularExpression::CaseInsensitiveOption);
QRegularExpression cccdrx("^[0-9]{12}$",
QRegularExpression::CaseInsensitiveOption);
if(!idrx.match(id).hasMatch()){
QMessageBox::warning(this,"tip1","!");
id_check = true;
return ;
}else if(ui->ename->text()==""){
QMessageBox::information(this,"Notification","!");
return;
}else if(!cccdrx.match(cccd).hasMatch()){
QMessageBox::warning(this,"tip1","!");
cccd_check = true;
return ;
} else if(!phonerx.match(phone).hasMatch()){
QMessageBox::warning(this,"tip1","");
phone_check = true;
return ;
}else if(ui->eaddress->text()==""){
QMessageBox::information(this,"Notification","!");
return;
}else{
int ok=QMessageBox::warning(this,"Xác Nhận Thông Tin","Bạn có chắc chắn thông tin nhập vào là chính xác ??",QMessageBox::Yes,QMessageBox::No);
if(ok==QMessageBox::No){
return ;
}else{
int id=ui->eid->text().toInt();
QString name=ui->ename->text().trimmed();
QString cccd=ui->ecccd->text().trimmed();
QString phone=ui->ephone->text().trimmed();
QString address=ui->eaddress->text().trimmed();
conn.connOpen();
QSqlQuery query;
query.prepare("insert into employee (id,name,cccd,phone,diachi) values ('"+QString::number(id)+"','"+name+"','"+cccd+"','"+phone+"','"+address+"')");
if(!query.exec())
qDebug() << query.lastError().text() << query.lastQuery();
else
{
QMessageBox::information(this,"Information","THÊM THÀNH CÔNG !!");
qDebug() << "Update was successful "<< query.lastQuery();
}
conn.connclose();
}
}
}
void employee::on_search_clicked()
{
int in_dex=ui->index->text().toInt();
if(!conn.connOpen()){
qDebug() << "Database loaded not successfull!";
} else{
qDebug() << "Database loaded successfull!";
}
QSqlQuery query;
query.prepare("select * from employee where id='"+QString::number(in_dex)+"'");
if(!query.exec()){
qDebug() << query.lastError().text() << query.lastQuery();
}else{
qDebug() << "Fetch was successful";
if(query.next()){
ui->eid->setText(query.value(0).toString());
ui->ename->setText(query.value(1).toString());
ui->ecccd->setText(query.value(2).toString());
ui->ephone->setText(query.value(3).toString());
ui->eaddress->setText(query.value(4).toString());
}else{
QMessageBox::information(this,"NOTIFICATION","SOS !! Không Tìm Thấy Nhân Viên Cần Tìm");
}
}
conn.connclose();
}
没有合适的资源?快使用搜索试试~ 我知道了~
QT-大作业-酒店管理系统
共55个文件
h:20个
cpp:12个
ui:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 146 浏览量
2023-12-21
11:59:13
上传
评论
收藏 197KB RAR 举报
温馨提示
1、本地数据库,不用安装数据库。
资源推荐
资源详情
资源评论
收起资源包目录
room.rar (55个子文件)
room
listguest.cpp 4KB
QLKS.sln 1KB
QLKS.vcxproj.filters 8KB
QLKS.pro.user 23KB
secmain.ui 19KB
payamount.ui 7KB
guest.h 2KB
checkin.h 801B
hotel.sqbpro 2KB
QLKS.APS 1KB
room.cpp 4KB
ui_listguest.h 13KB
mainwindow.h 624B
QLKS.pro 1KB
hotel.h 1KB
ui_payamount.h 8KB
listguest.h 700B
hotel.db 36KB
ui_checkin.h 9KB
background.qrc 75B
small.webp 46KB
resource.h 383B
mainwindow.cpp 2KB
ui_secmain.h 18KB
checkout.h 707B
QLKS.rc 2KB
listguest.ui 13KB
checkin.ui 9KB
database.cpp 1KB
main.cpp 183B
debug
hotel.db 36KB
Sqlite_DB.exe 478KB
room.ui 19KB
mainwindow.ui 8KB
hotel.cpp 6KB
checkout.ui 9KB
room.h 1KB
checkin.cpp 5KB
employee.h 915B
ui_room.h 16KB
ui_checkout.h 9KB
secmain.h 951B
ui_mainwindow.h 9KB
QLKS.pro.user.0c1eb3e.22 19KB
checkout.cpp 5KB
QLKS.vcxproj.user 165B
ui_employee.h 13KB
employee.cpp 6KB
database.h 729B
secmain.cpp 2KB
QLKS.vcxproj 55KB
payamount.h 378B
employee.ui 13KB
guest.cpp 2KB
payamount.cpp 837B
共 55 条
- 1
资源评论
- 2301_803418022024-06-19超级好的资源,很值得参考学习,对我启发很大,支持!
进击的大海贼
- 粉丝: 1w+
- 资源: 196
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功