Skip to content

Commit

Permalink
Fixed 03102020
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Đức Trương committed Oct 2, 2020
1 parent b357e66 commit bcc760d
Show file tree
Hide file tree
Showing 11 changed files with 669 additions and 628 deletions.
5 changes: 3 additions & 2 deletions QuanLyChiTieu/QuanLyChiTieu.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ QT += core gui sql charts

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TEMPLATE += lib
TEMPLATE += lib app

CONFIG += c++11 plugin release
CONFIG += c++11 release import_plugins

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS


# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
Expand Down
7 changes: 6 additions & 1 deletion QuanLyChiTieu/adduser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AddUser::AddUser(QWidget *parent) :
{
ui->setupUi(this);

this->setFixedSize(1147,749);
this->setFixedSize(1151,671);

this->setWindowIcon(QIcon(":/Images\\Icon\\cash-icon.png"));

Expand Down Expand Up @@ -68,6 +68,11 @@ void AddUser::on_pushButton_DangKy_AddUser_clicked()
if( qry.exec("INSERT NguoiDung( TenDangNhap,MaPin,HoVaTen,Email,CongViec ) VALUES('"+TenDangNhap+"', '" +EncryptMaPin+"', N'" + HoVaTen +"', '" + Email +"', N'"+ CongViec +"' )")){
ChiTieu.ThemDanhMucMacDinh(TenDangNhap);
QMessageBox::information(this, QString::fromUtf8("Chúc mừng"), QString::fromUtf8("Bạn đã đăng ký thành công!!"));

QString Index = TenDangNhap+"_index";
qry.exec("CREATE UNIQUE INDEX "+Index+" ON LoaiThuNhap(LoaiThuNhap) WHERE TenChu = '"+TenDangNhap+"' ");
qry.exec("CREATE UNIQUE INDEX "+Index+" ON TaiKhoan(Ten) WHERE TenChu = '"+TenDangNhap+"' ");

hide();

}
Expand Down
15 changes: 12 additions & 3 deletions QuanLyChiTieu/chitieu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,37 @@ void ChiTieu::on_btn_OK_clicked()


// Truy vấn DB

//// Trừ tiền trong tài khoản

QSqlQuery qry;

lli SoDuTK = TaiKhoanQL.LaySoDu(Username,TenTaiKhoan);

SoDuTK -= SoTien;
//Lấy mã tài khoản
int MTK = TaiKhoanQL.LayMaTaiKhoan(this->Username, TenTaiKhoan);


//Kiểm tra có đủ số dư trong tài khoản hay không
if( SoDuTK < 0 ){
QMessageBox::warning(this,"Nguy hiểm",QString::fromUtf8("Số tiền chi tiêu vượt quá số dư của tài khoản này!!"));
return;
}

else{
//Trừ trong bảng TietKiem nếu có
if( TaiKhoanQL.LayLoaiTaiKhoan(this->Username, TenTaiKhoan) == "Tiết kiệm" ){
TietKiemQL.CapNhatSoDu(this->Username, MTK, SoDuTK);
}
//done

// Trừ tiền trong tài khoản
qry.prepare("UPDATE TaiKhoan SET SoDu = :SoDuTK WHERE Ten = :TenTaiKhoan AND TenChu = :Username; ");

qry.bindValue(":SoDuTK", SoDuTK);
qry.bindValue(":TenTaiKhoan", TenTaiKhoan);
qry.bindValue(":Username", Username);

qry.exec();
//done


}
Expand Down
2 changes: 2 additions & 0 deletions QuanLyChiTieu/chitieu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <quanlytaikhoan.h>
#include <expensetracker.h>
#include <quanlychitieu.h>
#include <tietkiem.h>
#include <thongke.h>

#include <QString>
Expand Down Expand Up @@ -46,6 +47,7 @@ private slots:
Ui::ChiTieu *ui;
QuanLyTaiKhoan TaiKhoanQL;
QuanLyChiTieu DanhMucQL;
TietKiem TietKiemQL;
ThongKe ThongKeQL;
};

Expand Down
Loading

0 comments on commit bcc760d

Please sign in to comment.