void
AllUser()
{
system(
"
cls
"
);
SQLRETURN retcode;
retcode
=
ConnectDBLOIN(
"
ADDloin
"
,
""
,
""
);
if
(retcode
!=
TRUE)
{
printf(
"
连接数据库失败
"
);
return
;
}
retcode
=
ExeSqlDirectLOIN(
"
select * from Loinlist
"
);
if
(retcode
!=
TRUE)
{
printf(
"
数据库操作失败
"
);
return
;
}
char
Password[
20
];
char
Name[
20
];
SQLINTEGER PasswordLen, iNameLen;
printf(
"
\n\n\n\n\n\t\t\t★全部用户★\n
"
);
printf(
"
\t\t◇账 户◇\t\t◇密 码◇ \n
"
);
while
((retcode
=
SQLFetch(m_hstmt_loin))
!=
SQL_NO_DATA)
{
SQLGetData(m_hstmt_loin,
3
, SQL_C_CHAR, Password,
20
,
&
PasswordLen);
SQLGetData(m_hstmt_loin,
2
, SQL_C_CHAR, Name,
20
,
&
iNameLen);
printf(
"
\t\t%s\t\t\t%s\n
"
,Name,Password);
}
DisConnectLOIN();
}
void
AddCount()
{
char
Password[
20
];
char
Name[
20
];
char
mysql[
100
];
system(
"
cls
"
);
SQLRETURN retcode;
printf(
"
\n\n\n\n
"
);
printf(
"
\t\t\t★账户:
"
);scanf(
"
%s
"
,Name);
printf(
"
\t\t\t★密码:
"
);scanf(
"
%s
"
,Password);
retcode
=
ConnectDBLOIN(
"
ADDloin
"
,
""
,
""
);
if
(retcode
!=
TRUE)
{
printf(
"
连接数据库失败
"
);
return
;
}
sprintf(mysql,
"
insert into Loinlist(Name,Password) values('%s','%s')
"
,Name,Password);
retcode
=
ExeSqlDirectLOIN(mysql);
if
(retcode
!=
TRUE)
{
printf(
"
数据库操作失败
"
);
return
;
}
else
{
printf(
"
\t\t添加账户成功!
"
);
}
DisConnectLOIN();
}
void
DeleteCount()
{
char
Name[
20
];
char
mysql[
100
];
system(
"
cls
"
);
SQLRETURN retcode;
printf(
"
\n\n\n\n
"
);
printf(
"
\t\t\t★要删除的账户:
"
);scanf(
"
%s
"
,Name);
retcode
=
ConnectDBLOIN(
"
ADDloin
"
,
""
,
""
);
if
(retcode
!=
TRUE)
{
printf(
"
连接数据库失败
"
);
return
;
}
sprintf(mysql,
"
delete from Loinlist where Name='%s'
"
,Name);
retcode
=
ExeSqlDirectLOIN(mysql);
if
(retcode
!=
TRUE)
{
printf(
"
数据库操作失败
"
);
return
;
}
else
{
printf(
"
\t\t删除用户成功!
"
);
}
DisConnectLOIN();
}
void
PasswordModifY()
{
char
Password[
20
];
char
PasswordM[
20
];
char
Name[
20
];
char
mysql[
100
];
system(
"
cls
"
);
SQLRETURN retcode;
printf(
"
\n\n\n\n
"
);
printf(
"
\t\t\t★需要修改密码的账户:
"
);scanf(
"
%s
"
,Name);
printf(
"
\t\t\t★原始密码:
"
);scanf(
"
%s
"
,Password);
printf(
"
\t\t\t★修改后的密码:
"
);scanf(
"
%s
"
,PasswordM);
retcode
=
ConnectDBLOIN(
"
ADDloin
"
,
""
,
""
);
if
(retcode
!=
TRUE)
{
printf(
"
连接数据库失败
"
);
return
;
}
sprintf(mysql,
"
select *from Loinlist where Name='%s'
"
,Name);
retcode
=
ExeSqlDirectLOIN(mysql);
if
(retcode
!=
TRUE)
{
printf(
"
数据库操作失败
"
);
return
;
}
SQLINTEGER PasswordLen,iNameLen;
char
nn[
20
],pp[
20
];
while
((retcode
=
SQLFetch(m_hstmt_loin))
!=
SQL_NO_DATA)
{
SQLGetData(m_hstmt_loin,
3
, SQL_C_CHAR, nn,
20
,
&
PasswordLen);
SQLGetData(m_hstmt_loin,
2
, SQL_C_CHAR, pp,
20
,
&
iNameLen);
}
if
(strcmp(pp,Name)
==
0
&&
strcmp(nn,Password)
==
0
)
{
sprintf(mysql,
"
update Loinlist SET Password='%s'where Name='%s'
"
,PasswordM,Name);
retcode
=
ExeSqlDirectLOIN(mysql);
if
(retcode
!=
TRUE)
{
printf(
"
数据库操作失败
"
);
return
;
}
else
{
printf(
"
\t\t用户%s密码修改成功!
"
,Name);
}
}
else
{
if
(strcmp(pp,Name)
!=
0
)
{
printf(
"
用户账户错误\n
"
);
}
else
if
(strcmp(nn,Password)
!=
0
)
printf(
"
用户密码错误\n
"
);
else
printf(
"
此账户不存在!\n
"
);
}
DisConnectLOIN();
}
void
UserManagement()
{
int
choice;
system(
"
cls
"
);
system(
"
color f
"
);
printf(
"
\n\n\n\n\n\t\t\t ★用户账户管理★\n
"
);
printf(
"
\t\t\t ◇1.全部账户◇ \n
"
);
printf(
"
\t\t\t ◇2.增加用户 ◇ \n
"
);
printf(
"
\t\t\t ◇3.删除用户 ◇ \n
"
);
printf(
"
\t\t\t ◇4.修改密码◇ \n
"
);
printf(
"
\t\t\t ◇Enter Choice:
"
);scanf(
"
%d
"
,
&
choice);
switch
(choice)
{
case
1
:AllUser();
break
;
case
2
:AddCount();
break
;
case
3
:DeleteCount();
break
;
case
4
:PasswordModifY();
break
;
default
:printf(
"
输入错误!
"
);
break
;
}
}