Skip to content

Commit

Permalink
Update(19092020)
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Đức Trương committed Sep 19, 2020
1 parent 3057b1f commit 63ae408
Show file tree
Hide file tree
Showing 40 changed files with 2,342 additions and 85 deletions.
Binary file modified QuanLyChiTieu/Images/BackGr/bkgr_Login.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/BackGr/nkgr_p4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/Arrows-Down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/DiChuyen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/GiaDinh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/GiaiTri.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/HoaDon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/HocPhi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/ID-Card-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/Khac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/KinhDoanh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/MuaSam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/No-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/QuaTang.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/SucKhoe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/bachHoa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/reload-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/savings-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuanLyChiTieu/Images/Pictures/user-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions QuanLyChiTieu/QuanLyChiTieu.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui sql
QT += core gui sql charts

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

Expand All @@ -18,19 +18,26 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
adduser.cpp \
changepin.cpp \
chitieu.cpp \
expensetracker.cpp \
main.cpp \
loginapp.cpp
loginapp.cpp \
quanlychitieu.cpp \
quanlytaikhoan.cpp

HEADERS += \
adduser.h \
changepin.h \
chitieu.h \
expensetracker.h \
loginapp.h
loginapp.h \
quanlychitieu.h \
quanlytaikhoan.h

FORMS += \
adduser.ui \
changepin.ui \
chitieu.ui \
expensetracker.ui \
loginapp.ui

Expand Down
20 changes: 19 additions & 1 deletion QuanLyChiTieu/TaiNguyen.qrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
<RCC>
<qresource prefix="/">
<file>Images/BackGr/bkgr_Login.jpg</file>
<file>Images/BackGr/bkgr_SignUp.jpg</file>
<file>Images/BackGr/budget.jpg</file>
<file>Images/Pictures/User_Avatar_.png</file>
<file>Images/BackGr/bkgr_Login.jpg</file>
<file>Images/Pictures/Arrows-Down.png</file>
<file>Images/Pictures/bachHoa.png</file>
<file>Images/Pictures/DiChuyen.png</file>
<file>Images/Pictures/GiaiTri.png</file>
<file>Images/Pictures/HoaDon.png</file>
<file>Images/Pictures/HocPhi.png</file>
<file>Images/Pictures/Khac.png</file>
<file>Images/Pictures/KinhDoanh.png</file>
<file>Images/Pictures/MuaSam.png</file>
<file>Images/Pictures/QuaTang.png</file>
<file>Images/Pictures/SucKhoe.png</file>
<file>Images/Pictures/GiaDinh.png</file>
<file>Images/Pictures/ID-Card-icon.png</file>
<file>Images/Pictures/savings-icon.png</file>
<file>Images/Pictures/No-icon.png</file>
<file>Images/BackGr/nkgr_p4.jpg</file>
<file>Images/Pictures/user-icon.png</file>
<file>Images/Pictures/reload-icon.png</file>
</qresource>
</RCC>
18 changes: 17 additions & 1 deletion QuanLyChiTieu/adduser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ AddUser::~AddUser()
delete ui;
}

QString AddUser::Encrypt(QString str){
QString res="";

srand(time(NULL));

for(int i = 0; i<str.size(); ++i){
res+= QString::number((str[i].unicode() - 48 ) * 23 + 1998) ;
int asc = 130 + ( rand() % ( 223 - 130 + 1 ) );
res+=char(asc);
}
return res;
}

void AddUser::on_pushButton_DangKy_AddUser_clicked()
{
QString TenDangNhap, MaPin, NhapLaiMaPin, HoVaTen, Email, CongViec;
Expand Down Expand Up @@ -60,7 +73,10 @@ void AddUser::on_pushButton_DangKy_AddUser_clicked()

QSqlQuery qry;

if( qry.exec("INSERT dbo.NguoiDung( TenDangNhap,MaPin,HoVaTen,Email,CongViec ) VALUES('"+TenDangNhap+"', '" +MaPin+"', N'" + HoVaTen +"', '" + Email +"', N'"+ CongViec +"' )")){
QString EncryptMaPin = Encrypt(MaPin);

if( qry.exec("INSERT dbo.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!!"));
hide();

Expand Down
4 changes: 4 additions & 0 deletions QuanLyChiTieu/adduser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QDialog>
#include <loginapp.h>
#include <quanlychitieu.h>
#include <QString>

namespace Ui {
class AddUser;
Expand All @@ -15,13 +17,15 @@ class AddUser : public QDialog
public:
explicit AddUser(QWidget *parent = nullptr);
~AddUser();
QString Encrypt(QString str);

private slots:
void on_pushButton_DangKy_AddUser_clicked();

private:
Ui::AddUser *ui;
LoginAPP *login;
QuanLyChiTieu ChiTieu;
};

#endif // ADDUSER_H
18 changes: 12 additions & 6 deletions QuanLyChiTieu/adduser.ui
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ background-color: rgb(255, 119, 137,0);</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_MaPin_AddUser">
Expand All @@ -117,7 +118,8 @@ border-radius: 10px;</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
Expand All @@ -135,7 +137,8 @@ border-radius: 10px;</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
Expand All @@ -153,7 +156,8 @@ border-radius: 10px;</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Email_AddUser">
Expand All @@ -168,7 +172,8 @@ border-radius: 10px;</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_CongViec_AddUser">
Expand All @@ -183,7 +188,8 @@ border-radius: 10px;</string>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: 2px solid gray;
border-radius: 10px;</string>
border-radius: 10px;
font: 12pt &quot;Segoe UI&quot;;</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_DangKy_AddUser">
Expand Down
102 changes: 102 additions & 0 deletions QuanLyChiTieu/changepin.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,116 @@
#include "changepin.h"
#include "ui_changepin.h"

#include <expensetracker.h>

#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QMessageBox>
#include <QDebug>

ChangePin::ChangePin(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChangePin)
{
ui->setupUi(this);

this->setWindowTitle(QString::fromUtf8("Thay mã pin"));

//DataBase
QSqlDatabase myDB = QSqlDatabase::addDatabase("QODBC");

myDB.setDatabaseName("DRIVER={SQL Server Native Client 11.0};SERVER=DEREKPC;DATABASE=DO_AN_CHI_TIEU;UID=sa;PWD=derek123;WSID=.;Trusted_connection=yes");

bool connected = myDB.open();

if(!connected) QMessageBox::warning(this,"Chú ý",QString::fromUtf8("Lỗi! Không kết nối được CSDL!!"));
}

ChangePin::~ChangePin()
{
delete ui;
}

QString ChangePin::Encrypt(QString str){
QString res="";

srand(time(NULL));

for(int i = 0; i<str.size(); ++i){
res+= QString::number((str[i].unicode() - 48 ) * 23 + 1998) ;
int asc = 130 + ( rand() % ( 223 - 130 + 1 ) );
res+=char(asc);
}
return res;
}

QString ChangePin::Decrypt(QString str){
int s=0;
QString res="";
for(int i = 0; i<str.size(); ++i){
if( str[i].unicode() < 48 || str[i].unicode() > 57 ){
s = (s - 1998)/23;
res += QString::number(s);
s=0;
continue;
}

s = s*10 + (str[i].unicode() - 48);
}
return res;
}

void ChangePin::on_pushButton_XacNhan_clicked()
{
QString MaPinCu, MaPinMoi, NhapLaiMaPinMoi;

MaPinCu = ui->lineEdit_MaPinCu->text();
MaPinMoi = ui->lineEdit_MaPinMoi->text();
NhapLaiMaPinMoi = ui->lineEdit_NhapLaiMaPinMoi->text();



for ( int i = 0; i < MaPinMoi.size(); ++i) {
if( MaPinMoi[i] < 48 || MaPinMoi[i] > 57 ){
QMessageBox::warning(this,"Chú ý",QString::fromUtf8("Mã pin chỉ gồm các chữ số"));
return;
}
}

if( MaPinMoi != NhapLaiMaPinMoi ) {
QMessageBox::warning(this,"Chú ý",QString::fromUtf8("Nhập lại mã pin sai!!"));
return;
}

myDB.open();
QSqlQuery qry;

QString DecryptMaPin;

if( qry.exec("select * from NguoiDung Where TenDangNhap = '"+TenDangNhap+"'") ){
while( qry.next() ){
DecryptMaPin = Decrypt(qry.value("MaPin").toString());
if( MaPinCu != DecryptMaPin ){
QMessageBox::warning(this,"Chú ý",QString::fromUtf8("Mã pin cũ không chính xác!!"));
return;
}
}

}

QString EncryptMaPin = Encrypt(MaPinMoi);

if( qry.exec("update NguoiDung set MaPin = '"+EncryptMaPin+"' where TenDangNhap = '"+TenDangNhap+"'") ){
QMessageBox::information(this,"Thông báo",QString::fromUtf8("Đã thay đổi mã pin thành công!!"));
this->hide();
}
else QMessageBox::warning(this,"Lỗi",QString::fromUtf8("Lỗi không thể thay đổi mã pin!!"));
this->hide();

}

void ChangePin::on_pushButton_Huy_clicked()
{
QMessageBox::warning(this,"Chú ý",QString::fromUtf8("Bạn có chắc muốn huỷ!!"));
this->close();
}
23 changes: 23 additions & 0 deletions QuanLyChiTieu/changepin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#include <QDialog>

#include <expensetracker.h>

#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QMessageBox>
#include <QDebug>
#include <QString>

namespace Ui {
class ChangePin;
}
Expand All @@ -15,8 +23,23 @@ class ChangePin : public QDialog
explicit ChangePin(QWidget *parent = nullptr);
~ChangePin();

QString Encrypt(QString str);
QString Decrypt(QString str);

friend class ExpenseTracker;

protected:
QString TenDangNhap;

private slots:
void on_pushButton_XacNhan_clicked();

void on_pushButton_Huy_clicked();

private:
Ui::ChangePin *ui;
QSqlDatabase myDB;

};

#endif // CHANGEPIN_H
Loading

0 comments on commit 63ae408

Please sign in to comment.