Skip to content

Commit 811697a

Browse files
committed
基本完善了对linux的支持,增加了查找功能,优化体验逻辑
1 parent 9f7ed0c commit 811697a

File tree

7 files changed

+414
-111
lines changed

7 files changed

+414
-111
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# lc_xueguanxitong
22
支持多用户的学管系统
3+
支持win32,基本支持linux
34

5+
源代码编码模式为GBK
46

57
支持多用户登录,修改账号密码
68

class_student.hpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class TmpDat
44
{
55
public:
6-
long long Num;
6+
std::string Num;
77
std::string S_name;
88
double Score;
99
};
@@ -16,24 +16,13 @@ class Student
1616
void welcome2();
1717
void start();
1818
std::string KEY = "key.ini";
19-
;
2019

2120
private:
22-
std::string a, b;
23-
std::string ID, password, p_password;
24-
25-
char weltxt1[1000] = "欢迎您使用本【学生信息管理系统】,请您在下方输入您的用户名和密码进行登录\n\n请输入您的用户名: \n";
26-
char weltxt2[1000] = "请输入密码: \n";
27-
char weltxt3[1000] = "欢迎您首次使用本【学生信息管理系统】,请您创建一个用户名和密码来使用本系统。\n\n请按任意键继续... \n";
2821
bool check_isfile_empty(std::string);
29-
std::string tmp;
3022
void re_gister(bool);
3123
void lo_ad();
3224
bool key_load();
3325
bool key_save();
34-
35-
std::string dat_name;
36-
3726
bool init();
3827
void cle_ar();
3928
bool save();
@@ -42,9 +31,14 @@ class Student
4231
int add_s();
4332
int del_s();
4433
int modify_s();
34+
int find_s();
35+
void find_bynum();
36+
void find_byname();
37+
void find_during();
4538
int count_s();
4639
void show(bool, int);
47-
bool check(int);
40+
bool check(std::string);
41+
bool check_is_num(std::string &str);
4842

4943
static bool by_num(TmpDat a, TmpDat b)
5044
{
@@ -60,4 +54,14 @@ class Student
6054
{
6155
return (a.Score != b.Score ? a.Score > b.Score : a.Score < b.Score);
6256
}
57+
58+
std::string a, b;
59+
std::string ID, password, p_password;
60+
61+
char weltxt1[1000] = "欢迎您使用本【学生信息管理系统】,请您在下方输入您的用户名和密码进行登录\n\n请输入您的用户名: \n";
62+
char weltxt2[1000] = "请输入密码: \n";
63+
char weltxt3[1000] = "欢迎您首次使用本【学生信息管理系统】,请您创建一个用户名和密码来使用本系统。\n\n请按任意键继续... \n";
64+
65+
std::string tmp;
66+
std::string dat_name;
6367
};

fun_load.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <iostream>
22
#include <fstream>
3-
#include <conio.h>
43
#include <map>
54
#include "sleep_cls.hpp"
65
#include "class_student.hpp"
@@ -20,7 +19,7 @@ int Student::welcome()
2019
if (check_isfile_empty(KEY))
2120
{
2221
cout << "用户密码存储文件信息缺失,即将被迫回档,重新注册!\n***您可能会失去已有数据***\n按任意键继续... ";
23-
_getch();
22+
Koishi.my_getch();
2423
Koishi.my_cls();
2524
re_gister(true);
2625
return 0;
@@ -46,17 +45,19 @@ int Student::welcome()
4645
return 1;
4746
}
4847
}
48+
4949
void Student::welcome2()
5050
{
5151
for (char *i = weltxt3; *i != '\000'; *i++)
5252
{
5353
putchar(*i);
5454
Koishi.my_sleep(8);
5555
}
56-
_getch();
56+
Koishi.my_getch();
5757
re_gister(true);
5858
return;
5959
}
60+
6061
void Student::re_gister(bool n_ew)
6162
{
6263
if (n_ew)
@@ -66,19 +67,20 @@ void Student::re_gister(bool n_ew)
6667
if (!check_file(KEY))
6768
{
6869
cout << "\n创建用户配置文件失败!\n按任意键返回...";
69-
_getch();
70+
Koishi.my_getch();
7071
return;
7172
}
7273
}
7374
else if (!key_load())
7475
{
75-
_getch();
76+
Koishi.my_getch();
7677
return;
7778
}
7879
while (1)
7980
{
8081
cout << "请创建您的的用户名(技术所限,请不要带空格):\n";
8182
cin >> ID;
83+
cin.ignore();
8284
if (login.find(ID) != login.end())
8385
{
8486
cout << "该用户名已存在,请重新选择另一个用户名(1)或者修改登录密码(2)";
@@ -115,11 +117,11 @@ void Student::re_gister(bool n_ew)
115117
key_it->second = password;
116118
if (!key_save())
117119
{
118-
_getch();
120+
Koishi.my_getch();
119121
return;
120122
}
121123
cout << "\n修改密码成功!即将返回初始界面!\n 按任意键继续...";
122-
_getch();
124+
Koishi.my_getch();
123125
Koishi.my_cls();
124126
return;
125127
}
@@ -134,7 +136,7 @@ void Student::re_gister(bool n_ew)
134136
login.insert({ID, password});
135137
if (!key_save())
136138
{
137-
_getch();
139+
Koishi.my_getch();
138140
return;
139141
}
140142
Koishi.my_cls();
@@ -154,7 +156,7 @@ void Student::lo_ad()
154156
{
155157
if (!key_load())
156158
{
157-
_getch();
159+
Koishi.my_getch();
158160
return;
159161
}
160162
for (char *i = weltxt1; *i != '\000'; *i++)
@@ -167,6 +169,7 @@ void Student::lo_ad()
167169
do
168170
{
169171
cin >> ID;
172+
cin.ignore();
170173
} while (ID == "\000");
171174
key_it = login.find(ID);
172175
if (key_it == login.end())
@@ -199,13 +202,10 @@ void Student::lo_ad()
199202
}
200203
}
201204
Koishi.my_cls();
202-
for (int i = 3; i > 0; i--)
203-
{
204-
cout << "\t\t\t登陆成功!\n";
205-
cout << "\t\t\t" << i << "秒后将进入系统……" << endl;
206-
Koishi.my_sleep(1000);
207-
Koishi.my_cls();
208-
}
205+
cout << "\t\t\t登陆成功!\n";
206+
cout << "\t\t\t按任意键进入系统\n";
207+
Koishi.my_getch();
208+
Koishi.my_cls();
209209
dat_name = ID + ".dat";
210210
return;
211211
}
@@ -249,6 +249,7 @@ bool Student::key_save()
249249
key.close();
250250
return r_key_save;
251251
}
252+
252253
bool Student::check_file(string file_name)
253254
{
254255
fstream fs;
@@ -261,6 +262,7 @@ bool Student::check_file(string file_name)
261262
fs.close();
262263
return r;
263264
}
265+
264266
bool Student::check_isfile_empty(string file_name)
265267
{
266268
int n = 0;

0 commit comments

Comments
 (0)