From e16dbaea48aa5b8b6ea834313b463f5fa9255318 Mon Sep 17 00:00:00 2001 From: lsy2246 Date: Tue, 2 Jan 2024 00:43:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=A5=BD=E4=BA=86=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global_variables.h | 21 ++ .../effect_keystroke.h | 18 +- .../effect_windows_api.c | 2 +- .../founction_statement_page.h | 4 + .../function_statement_effect.h | 1 + .../idea/Student _Manage _System/main.c | 32 ++- .../page_newly_built.c | 13 ++ .../Student _Manage _System/page_print_view.c | 107 +++++++++ .../page_system_start.c | 205 ++++++++++++++++++ 9 files changed, 388 insertions(+), 15 deletions(-) create mode 100644 practice_code/idea/Student _Manage _System/Global_variables.h create mode 100644 practice_code/idea/Student _Manage _System/page_newly_built.c create mode 100644 practice_code/idea/Student _Manage _System/page_print_view.c create mode 100644 practice_code/idea/Student _Manage _System/page_system_start.c diff --git a/practice_code/idea/Student _Manage _System/Global_variables.h b/practice_code/idea/Student _Manage _System/Global_variables.h new file mode 100644 index 0000000..3793b47 --- /dev/null +++ b/practice_code/idea/Student _Manage _System/Global_variables.h @@ -0,0 +1,21 @@ +#ifndef GLOBAL_VARIABLES_H //检查函数有没有被声明 +#define GLOBAL_VARIABLES_H //定义宏 + +struct Personal_Information//定义个人信息结构体变量 +{ + unsigned int id;//编号 + char name[20];//姓名 + bool sex;//性别 + unsigned int student_id;//学号 + unsigned int class;//班级 + unsigned int year;//入学年份 + char phone[11];//手机号 + unsigned int course_number[20];//课程编号 +}; + +extern struct Personal_Information that_person;//当前的联系人 +extern bool pick_revision;//判断文件有没有修改完成 +extern bool pick_view_mode;//判断查看视图的模式 +extern unsigned Total;//学生总数 + +#endif //GLOBAL_VARIABLES_H \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/effect_keystroke.h b/practice_code/idea/Student _Manage _System/effect_keystroke.h index 47b9c5b..d9966e2 100644 --- a/practice_code/idea/Student _Manage _System/effect_keystroke.h +++ b/practice_code/idea/Student _Manage _System/effect_keystroke.h @@ -1,15 +1,19 @@ #ifndef EFFECT_KEYSTROKE_H //检查宏有没有被定义过 #define EFFECT_KEYSTROKE_H //定义宏 + //按键ascll码定义 #define UP 72 // 方向键:上 #define DOWN 80 // 方向键:下 #define LEFT 75 // 方向键:左 #define RIGHT 77 // 方向键:右 -#define CTRL_A 1 // 功能键: Ctrl+A -#define CTRL_D 4 // 功能键: Ctrl+D -#define CTRL_S 19 // 功能键: Ctrl+S -#define CTRL_F 6 // 功能键: Ctrl+F -#define ESC 27 // 功能键: ESC -#define TAB 9 // 功能键: TAB -#define ENTER 13 //功能键: Enter +#define CTRL_A 1 // 功能键: 上一夜 +#define CTRL_D 4 // 功能键: 下一页 +#define CTRL_S 19 // 功能键:保存 +#define CTRL_F 6 // 功能键:查找 +#define CTRL_Z 26 // 功能键:重新读档 +#define ESC 27 // 功能键:退出 +#define TAB 9 // 功能键:切换 +#define ENTER 13 // 功能键:回车 +#define DELETE 127// 功能键:删除 + #endif //EFFECT_KEYSTROKE_H \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/effect_windows_api.c b/practice_code/idea/Student _Manage _System/effect_windows_api.c index e1bfc8a..dbb0c12 100644 --- a/practice_code/idea/Student _Manage _System/effect_windows_api.c +++ b/practice_code/idea/Student _Manage _System/effect_windows_api.c @@ -1,6 +1,6 @@ #include -void HideCursor ()//隐藏光标 +void HideCursor ( void )//隐藏光标 { CONSOLE_CURSOR_INFO curInfo; //定义光标信息的结构体变量 curInfo . dwSize = 1; //如果没赋值的话,光标隐藏无效 diff --git a/practice_code/idea/Student _Manage _System/founction_statement_page.h b/practice_code/idea/Student _Manage _System/founction_statement_page.h index 54d2cfd..8312468 100644 --- a/practice_code/idea/Student _Manage _System/founction_statement_page.h +++ b/practice_code/idea/Student _Manage _System/founction_statement_page.h @@ -1,5 +1,9 @@ #ifndef FUNCTION_STATEMENT_PAGE_H //检查宏有没有被定义过 #define FUNCTION_STATEMENT_PAGE_H //定义宏 +void system_start(void);//管理系统主页 +void newly_built(void);//新增联系人页面 +void print_view_mode1(void);//打印视图模式 +void print_view_mode2(void);//打印列表模式 #endif //FUNCTION_STATEMENT_PAGE_H \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/function_statement_effect.h b/practice_code/idea/Student _Manage _System/function_statement_effect.h index 2701c56..f18d50a 100644 --- a/practice_code/idea/Student _Manage _System/function_statement_effect.h +++ b/practice_code/idea/Student _Manage _System/function_statement_effect.h @@ -2,6 +2,7 @@ #define FUNCTION_STATEMENT_EFFECT_H //定义宏 #include "effect_keystroke.h"//包含按键头文件 +#include "Global_variables.h"//包含全局变量头文件 void HideCursor ();//隐藏光标 diff --git a/practice_code/idea/Student _Manage _System/main.c b/practice_code/idea/Student _Manage _System/main.c index afa5626..95e117f 100644 --- a/practice_code/idea/Student _Manage _System/main.c +++ b/practice_code/idea/Student _Manage _System/main.c @@ -2,17 +2,23 @@ #include #include #include +#include //自定义头文件 #include "founction_statement_page.h"//界面 #include "function_statement_effect.h"//功能 +//初始化全局变量 +bool pick_revision = true;//初始化文件是否修改 +bool pick_view_mode = false;//视图模式 +unsigned int Total =0;//初始化学生总数 + //主函数 int main ( void ) { //定义变量 - char start_pick='0';//开始的选择 - + static char start_pick='0';//开始的选择 + srand((unsigned)time(NULL)); while(1) { //打印菜单 @@ -20,7 +26,15 @@ int main ( void ) system ( "cls" );//清屏 printf ( "\n\n\n\n\n\n\n\n" ); color(2);//设置颜色 - printf ("\t\t\t\t\t\t————欢迎使用学生管理系统————\n"); + printf ("\t\t\t\t\t\t 欢迎使用学生管理系统\n"); + + printf ("\t\t\t\t\t\t"); + for ( int i = 0 ; i < 28 ; ++ i ) + { + color(rand()%9+1);//设置颜色 + printf ("■"); + } + printf("\n"); color(1);//设置颜色 printf ("\t\t\t\t\t\t[Enter]"); color(7);//设置颜色 @@ -32,13 +46,17 @@ int main ( void ) color(4);//设置颜色 printf ("\t\t\t\t\t\t按下相应按键进入对应模式\n"); //获取用户的输入 - start_pick=(char)_getch(); + if(_kbhit()) + { + start_pick=(char)_getch(); + } //判断用户输入 switch(start_pick) { case ENTER: { - + start_pick='0'; + system_start();//管理系统主页 break; } case ESC: @@ -46,7 +64,7 @@ int main ( void ) return 0; } } + Sleep(2); } return 0; -} - +} \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/page_newly_built.c b/practice_code/idea/Student _Manage _System/page_newly_built.c new file mode 100644 index 0000000..fb9a4bf --- /dev/null +++ b/practice_code/idea/Student _Manage _System/page_newly_built.c @@ -0,0 +1,13 @@ +//头文件 +#include +#include +#include +#include + +//自定义头文件 +#include "function_statement_effect.h"//功能 + +void newly_built(void) +{ + +} \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/page_print_view.c b/practice_code/idea/Student _Manage _System/page_print_view.c new file mode 100644 index 0000000..778a905 --- /dev/null +++ b/practice_code/idea/Student _Manage _System/page_print_view.c @@ -0,0 +1,107 @@ +//头文件 +#include +#include +#include +#include + +//自定义头文件 +#include "founction_statement_page.h"//界面 +#include "function_statement_effect.h"//功能 + +struct Personal_Information that_person={1,"梁师谊",true,2023150,1,2020,"18888888888",{1,2,3}};//当前的联系人 + +void print_view_mode1(void)//打印视图模式 +{ + //将原来的清空 + for ( int i = 3 ; i < 28 ; ++ i ) + { + for ( int j = 0 ; j < 100 ; ++ j ) + { + CursorJump ( i , j );//位置跳转 + printf (" "); + } + } + //打印 + CursorJump ( 3 , 0 );//位置跳转 + color(7); + printf ("编号 "); + printf ("姓名\t"); + printf ("性别 "); + printf ("学号\t"); + printf ("班级\t"); + printf ("入学年份 "); + printf ("手机号码\t"); + printf ("选课编号"); + for ( int i = 5 ; i < 27 ; i+=2 ) + { + //编号 + CursorJump ( i , 0 );//位置跳转 + color (10); + printf ("%d ",that_person.id); + //姓名 + CursorJump ( i , 6 );//位置跳转 + color (13); + printf ("%s",that_person.name); + //性别 + CursorJump ( i , 16 );//位置跳转 + if(that_person.sex) + { + color (11); + printf ("男"); + } + else + { + color (12); + printf ("女"); + } + //学号 + CursorJump ( i , 22 );//位置跳转 + color (9); + printf ("%d",that_person.student_id); + //班级 + CursorJump ( i , 32 );//位置跳转 + color (14); + printf ("%d班",that_person.class); + //入学年份 + CursorJump ( i , 40 );//位置跳转 + color (9); + printf ("%d年",that_person.year); + //电话号码 + CursorJump ( i , 50 );//位置跳转 + color (15); + printf ("%s",that_person.phone); + CursorJump ( i , 64 );//位置跳转 + for ( int j = 0 ; that_person.course_number[j] != '\0' ; ++ j ) + { + if(j>0) + { + color (12); + printf (","); + } + color (11); + printf ("%d",that_person.course_number[j]); + } + } +} + +void print_view_mode2(void)//打印列表模式 +{ + //将原来的清空 + for ( int i = 3 ; i < 28 ; ++ i ) + { + for ( int j = 0 ; j < 100 ; ++ j ) + { + CursorJump ( i , j );//位置跳转 + printf (" "); + } + } + for ( int i = 4 ; i < 28 ; i+=2 ) + { + for ( int j = 6 ; j < 92 ; j+=10 ) + { + CursorJump ( i , j );//位置跳转 + color (11); + printf ("%s",that_person.name); + } + } +} \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/page_system_start.c b/practice_code/idea/Student _Manage _System/page_system_start.c new file mode 100644 index 0000000..29bd466 --- /dev/null +++ b/practice_code/idea/Student _Manage _System/page_system_start.c @@ -0,0 +1,205 @@ +//头文件 +#include +#include +#include +#include + +//自定义头文件 +#include "founction_statement_page.h"//界面 +#include "function_statement_effect.h"//功能 + + +static void printf_start_image ( void )//打印图像信息 +{ + //上边按键信息 + system ( "cls" );//清屏 + color ( 10 ); + printf ( "\t\t\t学生管理\n" ); + color ( 14 ); + printf ( "[ESC] " ); + color ( 12 ); + printf ( "退出 " ); + color ( 14 ); + printf ( "[CTRL+Z] " ); + color ( 12 ); + printf ( "重新读档 " ); + color ( 14 ); + printf ( "[CTRL+S] " ); + color ( 12 ); + printf ( "保存修改 " ); + color ( 14 ); + printf ( "[TAB] " ); + color ( 12 ); + printf ( "切换视图 " ); + color ( 14 ); + printf ( "[WSAD/箭头键] " ); + color ( 12 ); + printf ( "移动选择 " ); + color ( 14 ); + printf ( "[CTRL+A/D] " ); + color ( 12 ); + printf ( "翻页\n" ); + //打印边界 + color ( 15 ); + for ( int i = 0 ; i < 100 ; ++ i )//上面的 + { + printf ( "—" ); + } + for ( int i = 0 ; i < 100 ; ++ i )//底部 + { + CursorJump ( 28 , i );//位置跳转 + printf ( "—" ); + } + for ( int i = 0 ; i < 30 ; ++ i ) + { + CursorJump ( i , 100 );//位置跳转 + printf ( "|" ); + } + for ( int i = 101 ; i < 120 ; ++ i )//个人信息那里 + { + CursorJump ( 5 , i );//位置跳转 + printf ( "—" ); + } + CursorJump ( 6 , 104 );//位置跳转 + color ( 13 ); + printf ( "学生个人信息" ); + CursorJump ( 28 , 45 );//位置跳转 + color ( 13 ); + printf ( "状态栏" ); + //打印右边按键信息 + CursorJump ( 0 , 101 );//位置跳转 + color ( 14 ); + printf ( "[N]" ); + color ( 12 ); + printf ( " 新建学生" ); + CursorJump ( 1 , 101 );//位置跳转 + color ( 14 ); + printf ( "[F]" ); + color ( 12 ); + printf ( " 查找学生" ); + CursorJump ( 2 , 101 );//位置跳转 + color ( 14 ); + printf ( "[E]" ); + color ( 12 ); + printf ( " 编辑信息" ); + CursorJump ( 3 , 101 );//位置跳转 + color ( 14 ); + printf ( "[Q]" ); + color ( 12 ); + printf ( " 查看成绩" ); + CursorJump ( 4 , 101 );//位置跳转 + color ( 14 ); + printf ( "[Delete] " ); + color ( 12 ); + printf ( "删除学生" ); + + //底部信息 + CursorJump ( 29 , 0 );//位置跳转 + color(9); + printf (" 当前状态:"); + if(pick_revision) + { + color(11); + printf("未修改\t"); + } + else + { + color(11); + printf("未保存\t"); + } + + color(9); + printf ("学生总数:"); + color(11); + printf("%d\t",Total); + if(pick_view_mode) + { + color(9); + printf ("视图模式:"); + color(11); + printf("详细模式\t"); + } + else + { + color(9); + printf ("视图模式:"); + color(11); + printf("列表模式\t"); + } + color(9); + printf ("选择编号:"); + color(11); + printf("%d\t",that_person.id); + color(9); + printf ("第"); + color(11); + printf("%d/%d",that_person.id%10,Total%10); + color(9); + printf ("页"); + //打印时间 + color ( 11 ); + CursorJump ( 0 , 50 );//位置跳转 + time_t now_time; + time ( & now_time ); + printf ( "当前时间为:%s\n" , asctime ( gmtime ( & now_time ) ) ); +} + +void system_start ( void ) +{ + printf_start_image ( );//打印图像信息 + if(pick_view_mode)//打印视图模式 + { + print_view_mode1();//打印视图模式 + } + else + { + print_view_mode2();//打印列表模式 + } + while ( 1 ) + { + //更新时间 + color ( 11 ); + CursorJump ( 0 , 50 );//位置跳转 + time_t now_time; + time ( & now_time ); + printf ( "当前时间为:%s\n" , asctime ( gmtime ( & now_time ) ) ); + + //接收用户输入 + if ( _kbhit ( ) ) + { + static char tmp_input;//临时接收输入 + tmp_input=(char)_getch();//接收用户的输入 + + if(tmp_input==ESC) + { + if(pick_revision) + { + return; + } + else + { + MessageBox(0,"修改未保存","警告",0); + } + } + else if(tmp_input ==TAB) + { + if(pick_view_mode)//打印视图模式 + { + pick_view_mode=false; + print_view_mode1();//打印视图模式 + } + else + { + pick_view_mode=true; + print_view_mode2();//打印列表模式 + } + } + else if(tmp_input=='N'||tmp_input=='n') + { + newly_built();//新增联系人页面 + } + } + + } + +} \ No newline at end of file