门诊预约系统(五)

目录

用户主页面

CuesrScreen.h

 CuesrScreen.c

 效果图

用户填写预约表页面

Cbook.h

Cbook.c

 效果图

用户查询预约表页面

SearchBook.h

 SearchBook.c

效果图 


门诊预约系统(一)

门诊预约系统(二)

门诊预约系统(三)

门诊预约系统(四)

本文将介绍用户模块,用户主要填写预约信息

用户主页面

CuesrScreen.h

#pragma once
#include "screenBase.h"
#include "Cbuttun.h"
#include "Label.h"
class CuserScreen:public screenBase
{
public:
	CuserScreen(int x = 0, int y = 0, int w = 0, int h = 0);	//带参构造函数
	~CuserScreen();	//析构函数
	int doaction();	//处理用户操作
protected:
	Label* lab_welcome;
	Cbuttun* but_personal, * but_appoinement, *but_number,* but_exit;
};

 CuesrScreen.c

#include "CuserScreen.h"
CuserScreen::CuserScreen(int x, int y, int w, int h):screenBase(x, y, w, h)
{
	this->lab_welcome = new Label(30, 8, 6, 3, "欢迎使用门诊预约系统");
	this->but_personal = new Cbuttun(20, 12, 6, 3, "个人中心");
	this->but_appoinement = new Cbuttun(20, 16, 6, 3, "预约挂号");
	this->but_number = new Cbuttun(40, 12, 8, 3, "查询预约记录");
	this->but_exit = new Cbuttun(40, 16, 6, 3, "退出");
	this->Screen.push_back(this->lab_welcome);
	this->Screen.push_back(this->but_personal);		//1
	this->Screen.push_back(this->but_appoinement);	//2
	this->Screen.push_back(this->but_number);		//3
	this->Screen.push_back(this->but_exit);			//4
}

CuserScreen::~CuserScreen()
{
	for (int i = 0; i < this->Screen.size(); i++)
	{
		delete this->Screen[i];
	}
}
int CuserScreen::doaction()
{
	if (this->index == 1)
	{
		//进入个人中心页面
		return 1;
	}
	else if (this->index == 2)
	{
		//进入预约挂号页面
		return 9;
	}
	else if (this->index == 3)
	{
		//进入查询页面
		return 13;
	}
	else if (this->index == 4)
	{
		//退出
		return 0;
	}
}

 效果图

用户填写预约表页面

Cbook.h

#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
#include "Cedit.h"
class Cbooking:public screenBase
{
public:
	Cbooking(int x = 0, int y = 0, int w = 0, int h = 0);
	~Cbooking();
	int doaction();
protected:
	Label* lab_title, * lab_department, * lab_doctor, * lab_description, * lab_name;
	Cbuttun *but_confirm, *but_back;
	Cedit* ed_name, * ed_doctor, * ed_department, * ed_description;
};

Cbook.c

#define _CRT_SECURE_NO_WARNINGS
#include "Cbooking.h"
#include "Cmydata.h"
Cbooking::Cbooking(int x, int y, int w, int h):screenBase(x, y, w, h)
{
	this->lab_title = new Label(32, 5, 6, 3, "欢迎使用门诊预约系统");
	this->lab_name = new Label(19, 8, 6, 3, "姓名");
	this->lab_doctor = new Label(19, 12, 6, 3, "医生");
	this->lab_department = new Label(19, 16, 6, 3, "科室");
	this->lab_description = new Label(19, 20, 6, 3, "病情描述");
	this->ed_name = new Cedit(30, 8, 12, 3, "", 3, 15, 0);
	this->ed_doctor = new Cedit(30, 12, 12, 3, "", 3, 15, 0);
	this->ed_department = new Cedit(30, 16, 12, 3, "", 3, 15, 0);
	this->ed_description = new Cedit(30, 20, 12, 3, "", 3, 15, 0);
	this->but_confirm = new Cbuttun(25, 23, 6, 3, "确定");
	this->but_back = new Cbuttun(40, 23, 6, 3, "返回");
	this->Screen.push_back(this->lab_title);
	this->Screen.push_back(this->lab_name);
	this->Screen.push_back(this->lab_doctor);
	this->Screen.push_back(this->lab_department);
	this->Screen.push_back(this->lab_description);
	this->Screen.push_back(this->ed_name);
	this->Screen.push_back(this->ed_doctor);
	this->Screen.push_back(this->ed_department);
	this->Screen.push_back(this->ed_description);
	this->Screen.push_back(this->but_confirm);
	this->Screen.push_back(this->but_back);
}
Cbooking::~Cbooking()
{
	for (int i = 0; i < this->Screen.size(); i++)
	{
		delete this->Screen[i];
	}
}
int Cbooking::doaction()
{
	if (this->index == 9)
	{
		Ctool::gotoxy(0, 29);
		//获取输入内容
		this->ed_name->getContent();
		this->ed_doctor->getContent();
		this->ed_department->getContent();
		this->ed_description->getContent();
		//添加前检查
		if (strlen(this->ed_name->getContent()) == 0 || strlen(this->ed_doctor->getContent()) == 0 || strlen(this->ed_department->getContent()) == 0 || strlen(this->ed_description->getContent()) == 0)
		{
			Ctool::gotoxy(0, 29);
			cout << "输入不能为空" << endl;
			return 6;
		}
		else
		{
			//插入数据库
			//在doctorInfo表中查找是否有该医生
			Cmydata* data = Cmydata::Getmydata();
			char sql[256] = { 0 };
			char** qres = nullptr;
			int row = 0, col = 0;
			//在doctorInfo表中查找是否有该医生
			sprintf(sql, "select * from doctorInfo where doctorname = '%s'", this->ed_doctor->getContent());
			int res = data->getres_exec(sql, qres, row, col);
			if (res == 1)
			{
				Ctool::gotoxy(0, 29);
				cout << "该医生不存在" << endl;
				this->ed_name->clear();
				this->ed_doctor->clear();
				this->ed_department->clear();
				this->ed_description->clear();
				return 9;
			}
			sprintf(sql, "insert into bookInfo(name, doctorname, department, description, status) values('%s', '%s' , '%s' , '%s', '未就诊')", this->ed_name->getContent(), this->ed_doctor->getContent(), this->ed_department->getContent(), this->ed_description->getContent());
			data->getres_exec(sql, qres, row, col);
			cout << "添加成功" << endl;
			this->ed_name->clear();
			this->ed_doctor->clear();
			this->ed_department->clear();
			this->ed_description->clear();
		}
		return 3;
	}
	else if (this->index == 10)
	{
		this->ed_name->clear();
		this->ed_doctor->clear();
		this->ed_department->clear();
		this->ed_description->clear();
		return 3;
	}
}

 效果图

用户查询预约表页面

SearchBook.h

#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
#include "Cedit.h"
class searchBook:public screenBase
{
public:
    searchBook(int x = 0, int y = 0, int w = 0, int h = 0);
    ~searchBook();
    int doaction();
protected:
    Label* title, * name;
    Cbuttun* back, * search;
    Cedit* ed_name;
};

 SearchBook.c

#define _CRT_SECURE_NO_WARNINGS
#include "searchBook.h"
#include <iomanip>
#include "Cmydata.h"
searchBook::searchBook(int x, int y, int w, int h) :screenBase(x, y, w, h)
{
	this->title = new Label(35, 6, 6, 3, "查询预约信息");
	this->name = new Label(28, 8, 6, 3, "请输入姓名:");
	this->ed_name = new Cedit(40, 8, 10, 3, "", 3, 10, 0);
	this->back = new Cbuttun(42, 22, 6, 3, "返回");
	this->search = new Cbuttun(22, 22, 6, 3, "查询");
	this->Screen.push_back(this->title);
	this->Screen.push_back(this->name);
	this->Screen.push_back(this->ed_name);
	this->Screen.push_back(this->search);
	this->Screen.push_back(this->back);
}
searchBook::~searchBook()
{
	for (int i = 0; i < this->Screen.size(); i++)
	{
		delete this->Screen[i];
	}
}
int searchBook::doaction()
{
	if (this->index == 4)
	{
		this->ed_name->clear();
		return 3;
	}
	else if (this->index == 3)
	{
		//显示预约表
		Ctool::gotoxy(0, 29);
		Cmydata* data = Cmydata::Getmydata();
		char sql[256] = { 0 };
		char** qres = nullptr;
		int row = 0, col = 0;
		sprintf(sql, "select * from bookInfo where name = '%s'", this->ed_name->getContent());
		int res = data->getres_exec(sql, qres, row, col);
		if (res == 0)
		{
			if (row == 0)
			{
				Ctool::gotoxy(0, 29);
				this->ed_name->clear();
				cout << "没有找到" << endl;
				return 13;
			}
			else
			{
				Ctool::gotoxy(18, 10);
				for (int i = 0; i < row + 1; i++)
				{
					for (int j = 0; j < col; j++)
					{
						Ctool::gotoxy(18 + j * 10, 10 + i * 2);
						cout << "|" << setw(12) << left << qres[i * col + j] << " ";
					}
					cout << "|" << endl;
				}
				this->ed_name->clear();
				return 13;
			}
		}
	}
}

效果图 

 至此项目代码全部结束,有些功能尚未实现,有的地方还有待优化,后面会继续更新。

代码----->

https://ad.pdb2.com/l/CPCeKnK8DHfjEiN

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值