门诊预约系统中查询功能需要表格类设计封装
36.CTools.h .cpp
#ifndef CTOOLS_H
#define CTOOLS_H
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
#define KEY_ESC 27
#define KEY_ENTER 13
#define KEY_BACKSPACE 8
class CTools //CTools::gotoxy(); 静态成员函数调用的方法
{
public:
static void paintWindow(int startX,int startY,int width,int height);//打印窗口
static void gotoxy(int x,int y);//形参 光标定位
static void glb_string(int maxLen,int inputType,int ips,char str[]);
static int getkey();
//显示时间
static char * showTime();
//static void checkerBorad(int x,int y,int lie,int hang);
static void paintRowCol(int row,int col,int startX,int startY,int width,int height);
static void paintRowCol();
};
#endif
#include "CTools.h"
#include //引用库头文件
#include
#include
#include
void CTools::gotoxy(int x,int y)//形参
{
HANDLE hOut;
COORD pos= {x,y};
// 光标的起始位(第1列,第3行) 0是第1列 2是第3行
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
//printf("定位光标位置搜索(%d,%d)n",pos.X,pos.Y);
}
void CTools::paintWindow(int startX,int startY,int width,int height) //打印窗口 可以设置窗口大小 用户登录系统窗口
{
int i=0;
//打印顶部
//光标定位 找规律 ┗ ┛ ┏ ┓ ┃ ━
//顶部 y不变 x 在变 (x-x+w)
gotoxy(startX,startY);
printf("┏");
for(i=0;i0)//换行结束输入
{
break;
}
switch(inputType)
{
case 0:
if(ch>='0'&&ch<='9'&&i='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
{
if(ips==0)
{
putch('*');
}
else{
putch(ch);
}
str[i++]=ch;
}
break;
case 2:
if(i='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9'))
{
if(ips==0)
{
putch('*');
}
else{
putch(ch);
}
str[i++]=ch;
}
break;
default:
break;
}
}
}
int CTools::getkey()
{
char key=0;
key=getch();
if(key==-32)//方向按键 第一个值都是32
{
key=getch();
switch(key){
case 72:
return KEY_UP;
case 80:
return KEY_DOWN;
case 75:
return KEY_LEFT;
case 77:
return KEY_RIGHT;
}
}
else if(key==13)
{
return KEY_ENTER;
}
else if(key==27)
{
return KEY_ESC;
}
else if(key==8)
{
return KEY_BACKSPACE;
}
return key;
}
char * CTools::showTime()
{
time_t temp;
struct tm *p;
char buf[20]={0};
time(&temp);
p=localtime(&temp);
sprintf(buf,"%4d年%02d月%02d日",p->tm_year+1900,p->tm_mon+1,p->tm_mday);
return buf;
}
void CTools::paintRowCol(int startX,int startY,int width,int height,int row,int col)
{
int i;
int j;
CTools::paintWindow(startX,startY,width,height);
for(i= 1;i
37.CTable.h .cpp
#ifndef CTABLE_H
#define CTABLE_H
#include"CtrBase.h"
#include
#include
#include"CtrBase.h"
using namespace std;
#include"CTable.h"
class Table:public CtrBase
{
public:
Table();
Table(int x,int y,int width,int height,int row,int col,vector header);
~Table();
void show();//第一个画表格,第二部分显示表头
void showData();//专门显示数据
void showdoctorData();
void showdepartmentData();
void showoutpatientData();
void showoutpatientuserData();
void showoutpatientdoctorData();
void clearTable();//专门清空显示数据的那几行()
// void keyListen(int key);//左右翻页,上下数据选择
int getsumPage();
int getcurPage(); //私有的不可直接访问
void setCurpage(int cunPage){this->curPage =cunPage;}
private:
void *data;
int row;
int col;
int x;
int y;
vector header;//表头
int sumPage;
int curPage;//当前页码
};
#endif
#include"CTable.h"
#include"iostream"
#include"CTools.h"
#include"conio.h"
#include"CData.h"
#include