Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
M
ModifyProject-Qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qiu Chuntao
ModifyProject-Qt
Commits
44eff581
Commit
44eff581
authored
Oct 14, 2020
by
Qiu Chuntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize the code
parent
47efbeaf
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
236 additions
and
6 deletions
+236
-6
Qtsqlite.pro.user
Qtsqlite.pro.user
+210
-0
regist.cpp
regist.cpp
+2
-0
userwindow.cpp
userwindow.cpp
+24
-6
No files found.
Qtsqlite.pro.user
0 → 100644
View file @
44eff581
This diff is collapsed.
Click to expand it.
regist.cpp
View file @
44eff581
...
...
@@ -34,6 +34,8 @@ void Regist::on_pushButton_clicked()
return
;
}
QMessageBox
::
about
(
this
,
"提示"
,
"注册成功"
);
this
->
parentWidget
()
->
show
();
this
->
hide
();
}
void
Regist
::
on_goback_clicked
()
...
...
userwindow.cpp
View file @
44eff581
...
...
@@ -46,8 +46,12 @@ void UserWindow::on_find_usr_clicked()
bool
ok
;
QString
text
=
QInputDialog
::
getText
(
this
,
tr
(
"查询"
),
tr
(
"查找用户"
),
QLineEdit
::
Normal
,
tr
(
"
请输入用户名
"
),
&
ok
);
tr
(
""
),
&
ok
);
if
(
ok
)
{
if
(
text
.
isEmpty
())
{
QMessageBox
::
warning
(
this
,
"提示"
,
"请输入需要查找的用户!"
,
QMessageBox
::
Ok
);
return
;
}
QString
str
=
QString
(
"SELECT * FROM user WHERE username = '%1'"
).
arg
(
text
);
QSqlQuery
query
(
QSqlDatabase
::
database
(
"HB"
));
if
(
!
query
.
exec
(
str
))
{
...
...
@@ -81,8 +85,12 @@ void UserWindow::on_delet_usr_clicked()
bool
ok
;
QString
text
=
QInputDialog
::
getText
(
this
,
tr
(
"删除用户"
),
tr
(
"查找用户"
),
QLineEdit
::
Normal
,
tr
(
"
请输入用户名
"
),
&
ok
);
tr
(
""
),
&
ok
);
if
(
ok
)
{
if
(
text
.
isEmpty
())
{
QMessageBox
::
warning
(
this
,
"提示"
,
"输入为空"
,
QMessageBox
::
Ok
);
return
;
}
QString
str
=
QString
(
"DELETE FROM user WHERE username = '%1'"
).
arg
(
text
);
QSqlQuery
sql_query
(
db
);
if
(
!
sql_query
.
exec
(
str
))
{
...
...
@@ -107,16 +115,23 @@ void UserWindow::on_updata_usr_clicked()
bool
ok
;
QString
text
=
QInputDialog
::
getText
(
this
,
tr
(
"修改用户信息"
),
tr
(
"查找用户"
),
QLineEdit
::
Normal
,
tr
(
"
请输入需要修改的用户
"
),
&
ok
);
tr
(
""
),
&
ok
);
if
(
ok
)
{
if
(
text
.
isEmpty
())
{
QMessageBox
::
warning
(
this
,
"提示"
,
"输入为空"
,
QMessageBox
::
Ok
);
return
;
}
int
ret
=
QMessageBox
::
question
(
this
,
tr
(
"修改选项"
),
"修改用户名/密码?(Yes-用户名|No-密码)"
,
QMessageBox
::
Yes
|
QMessageBox
::
No
|
QMessageBox
::
Cancel
);
if
(
ret
==
QMessageBox
::
Yes
)
{
QString
newname
=
QInputDialog
::
getText
(
this
,
tr
(
"提示"
),
tr
(
"修改用户名!"
),
QLineEdit
::
Normal
,
tr
(
"请输入要修改的用户名"
),
&
ok
);
tr
(
""
),
&
ok
);
if
(
newname
.
isEmpty
())
{
QMessageBox
::
warning
(
this
,
"提示"
,
"输入为空"
,
QMessageBox
::
Ok
);
return
;
}
QString
str
=
QString
(
"UPDATE user SET username = '%1' WHERE username = '%2'"
).
arg
(
newname
).
arg
(
text
);
QSqlQuery
sql_query
(
db
);
if
(
!
sql_query
.
exec
(
str
))
{
...
...
@@ -130,7 +145,10 @@ void UserWindow::on_updata_usr_clicked()
QString
newpassword
=
QInputDialog
::
getText
(
this
,
tr
(
"提示"
),
tr
(
"修改密码"
),
QLineEdit
::
Normal
,
tr
(
"请输入需要修改的密码"
),
&
ok
);
if
(
newpassword
.
isEmpty
())
{
QMessageBox
::
warning
(
this
,
"提示"
,
"输入为空"
,
QMessageBox
::
Ok
);
return
;
}
QString
str
=
QString
(
"UPDATE user SET password = '%1' WHERE username = '%2'"
).
arg
(
newpassword
).
arg
(
text
);
QSqlQuery
sql_query
(
db
);
if
(
!
sql_query
.
exec
(
str
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment