三:准备
程序主界面绘制
主界面功能选择,实现界面跳转
管理员主界面绘制
管理员主界面功能选择,实现界面跳转
医生主界面绘制以及功能选择,实现界面跳转
11.CMainWin.h .cpp
#ifndef CMAINWIN_H
#define CMAINWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CMainWin:public CWinBase
{
public:
CMainWin();
~CMainWin();
CMainWin(int x,int y,int w,int h);
int doAction();
protected:
private:
CLabel *titlezhu,*titlehao;
CButton *btnzhuce ,*btndenglu,*btntuichu;
};
#endif
#include"CMainWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;
CMainWin::CMainWin():CWinBase()
{
}
CMainWin::~CMainWin()
{
}
CMainWin::CMainWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlezhu = new CLabel(17,7,10,2,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehao = new CLabel(37,19,10,2,"OMO211224",LABEL);//1
this->btnzhuce = new CButton(19,9,8,3,"注册",BUTTON);//2
this->btndenglu = new CButton(19,12,8,3,"登录",BUTTON); //3
this->btntuichu = new CButton(19,15,8,3,"退出",BUTTON);//4
this->addControl(this->titlezhu);
this->addControl(this->titlehao);
this->addControl(this->btnzhuce);
this->addControl(this->btndenglu);
this->addControl(this->btntuichu);
}
int CMainWin::doAction()
{
switch(this->focusIndex)
{
case 2:
return 1; //到注册界面
case 3:
return 2; //到登录界面
default:
break;
}
return 0;
}
12.CAdminmainWin.h .cpp
#ifndef CADMINMAINWIN_H
#define CADMINMAINWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CAdminmainWin:public CWinBase
{
public:
CAdminmainWin();
~CAdminmainWin();
CAdminmainWin(int x,int y,int w,int h);
int doAction();
protected:
private:
CLabel *titleguan,*titlehy,*titlerq;
CButton *btnyh ,*btnys,*btnks,*btnsj,*btntc;
};
#endif
#include"CAdminmainWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;
CAdminmainWin::CAdminmainWin():CWinBase()
{
}
CAdminmainWin::~CAdminmainWin()
{
}
CAdminmainWin::CAdminmainWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titleguan = new CLabel(21,7,10,2,"管理员主界面",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//1
this->titlerq = new CLabel(29,10,10,2,"日期",LABEL);//2
this->btnyh = new CButton(10,11,8,3,"用户管理",BUTTON);//3
this->btnys = new CButton(28,11,8,3,"医生管理",BUTTON); //4
this->btnks = new CButton(10,14,8,3,"科室管理",BUTTON); //5
this->btnsj = new CButton(28,14,8,3,"数据统计",BUTTON); //6
this->btntc = new CButton(10,17,8,3,"退出",BUTTON); //7
this->addControl(this->titleguan);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->btnyh);
this->addControl(this->btnys);
this->addControl(this->btnks);
this->addControl(this->btnsj);
this->addControl(this->btntc);
}
int CAdminmainWin::doAction()
{
switch(this->focusIndex)
{
case 7:
return 2;
case 4:
return 15;
case 3:
return 17;
case 5:
return 18;
default:
break;
}
return 4;
}
13.CAdminuserqueryWin.h .cpp
#ifndef CADMINUSERQUERYWIN_H
#define CADMINUSERQUERYWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
#include"CTable.h"
class CAdminuserqueryWin:public CWinBase
{
public:
CAdminuserqueryWin();
~CAdminuserqueryWin();
CAdminuserqueryWin(int x,int y,int w,int h);
int doAction();
void showWindow();
int WinRun();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titlesryhid,*titlefy;
CButton *btnchaxun ,*btnfanhui;
CEdit *editsryhid;
Table *table;
};
#endif
#pragma warning(disable :4786)
#include"CAdminuserqueryWin.h"
#include"CTools.h"
#include"CData.h"
#include"CTable.h"
#include<iostream>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
#include<windows.h>
CAdminuserqueryWin::CAdminuserqueryWin():CWinBase()
{
}
CAdminuserqueryWin::~CAdminuserqueryWin()
{
}
CAdminuserqueryWin::CAdminuserqueryWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(25,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//1
this->titlerq = new CLabel(39,10,10,2,"日期",LABEL);//2
this->titlesryhid = new CLabel(9,13,10,2,"请输入用户账号:",LABEL);//3
this->titlefy = new CLabel(42,33,10,2,"按<- ->翻页",LABEL);//4
this->editsryhid = new CEdit(26,12,10,3,"",11,2,1,EDIT);//5
this->btnchaxun = new CButton(44,12,10,3,"查询",BUTTON); //6
this->btnfanhui = new CButton(9,32,10,3,"返回",BUTTON); //7
vector<string> header;
header.push_back("账号");
header.push_back("身份信息");
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titlesryhid);
this->addControl(this->titlefy);
this->addControl(this->editsryhid);
this->addControl(this->btnchaxun);
this->addControl(this->btnfanhui);
this->table=new Table(7,18,31,10,4,2,header);
}
int CAdminuserqueryWin::doAction()
{
map<string ,User>::iterator it;
switch(this->focusIndex)
{
case 7: //返回
return 3; //管理员主界面
case 6: //查询
for(it=CData::userMap.begin();it!=CData::userMap.end();it++)
{
if(strstr(it->second.getphoneNum().c_str(),this->editsryhid->getContent())!=NULL)//查询
{
this->table->clearTable();//清空表格
this->table->show();//显示表格
CTools::gotoxy(9,22);
cout<<it->second.getphoneNum().c_str()<<endl;
CTools::gotoxy(40,22);
cout<<it->second.getSfzID().c_str()<<endl;
}
}
this->editsryhid->clear();
this->WinRun();
return this->doAction();
/* for(it=CData::userMap.begin();it!=CData::userMap.end();it++)
{
if(strcmp(it->second.getphoneNum().c_str(),this->editsryhid->getContent())!=0)//查询
{
CTools::gotoxy(10,15);
cout<<"没有找到该用户信息"<<endl;
}
}
this->editsryhid->clear();
this->WinRun();
return this->doAction();*/
default:
break;
}
return 17;
}
void CAdminuserqueryWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
this->table->show();
this->table->showData();
}
int CAdminuserqueryWin::WinRun()
{
int i=0,key=0;
int a,b;
for(i=0;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT||this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2,this->ctrlArr[i]->getY()+1);
break;
}
}
while(1)
{
key=CTools::getkey();
switch(key){
case KEY_DOWN://向下按键 查找下一个编辑框 按钮
i++;//按键数组下标越界
if(i==this->ctrlCount)
{
i=0;//为了避免下标越界 从头开始对控件结构体数组找编辑框 按钮
}
for(;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
}
break;
case KEY_UP:
i--;
if(i==-1) //从后往前找 数组起始0 i--为-1 数组下标由大到小 (控件数组下标0位置)
{
i=this->ctrlCount-1; //控件个数(控件结构体数组下标最大)-1 (控件数组下标ctrlCount位置)
}
for(;i>0;i--)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
if(i==0) //第一个 若第一个不是编辑框 按钮
{
i=this->ctrlCount; //就从最后一个往前查找 for循环中有i--,不用再-1
}
}
break;
case KEY_LEFT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<=b&&a>1)
{
a--;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showData();
}
break;
case KEY_RIGHT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<b)
{
a++;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showData();
}
break;
case KEY_ENTER:
if(this->ctrlArr[i]->getType()==BUTTON)
{
this->focusIndex=i;
return doAction();//返回切换到的界面的下标
//获取winRun中输入的编辑框的值
}
break;
default: //其他字符(不是按键)并且当前控件是编辑框
if(this->ctrlArr[i]->getType()==EDIT)
{
if(key==KEY_BACKSPACE)//执行回删
{
this->ctrlArr[i]->backSpace();
}
else{
this->ctrlArr[i]->keyListen(key);
}
}
break;
}
}
}
14.CAdmindoctorWin.h .cpp
#ifndef CADMINDOCTORWIN_H
#define CADMINDOCTORWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CAdmindoctorWin:public CWinBase
{
public:
CAdmindoctorWin();
~CAdmindoctorWin();
CAdmindoctorWin(int x,int y,int w,int h);
int doAction();
protected:
private:
CLabel *titleysgl,*titlehy;
CButton *btnyscx ,*btnxzys,*btnysxxxg,*btnfanhui;
};
#endif
#include"CAdmindoctorWin.h"
#include"CTools.h"
#include"CData.h"
#include<iostream>
using namespace std;
CAdmindoctorWin::CAdmindoctorWin():CWinBase()
{
}
CAdmindoctorWin::~CAdmindoctorWin()
{
}
CAdmindoctorWin::CAdmindoctorWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->btnyscx = new CButton(8,15,10,3,"医生查询",BUTTON); //0
this->btnxzys = new CButton(28,15,10,3,"新增医生",BUTTON); //1
this->btnysxxxg = new CButton(8,18,10,3,"医生信息修改",BUTTON);//2
this->btnfanhui = new CButton(18,23,10,3,"返回",BUTTON); //3
this->titleysgl = new CLabel(21,7,34,4,"医生管理界面",LABEL);//4
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//5
this->addControl(this->btnyscx);
this->addControl(this->btnxzys);
this->addControl(this->btnysxxxg);
this->addControl(this->btnfanhui);
this->addControl(this->titleysgl);
this->addControl(this->titlehy);
}
int CAdmindoctorWin::doAction()
{
switch(this->focusIndex)
{
case 3:
return 3; //管理员主界面
case 1:
return 14; //新增医生主界面
case 0:
return 16; //医生查询主界面
case 2:
return 22; //医生信息修改主界面
default:
break;
}
return 15;//管理员管医生界面
}
15.CAdmindoctorqueryWin.h .cpp
#ifndef CADMINDOCTORQUERYWIN_H
#define CADMINDOCTORQUERYWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
#include"CTable.h"
class CAdmindoctorqueryWin:public CWinBase
{
public:
CAdmindoctorqueryWin();
~CAdmindoctorqueryWin();
CAdmindoctorqueryWin(int x,int y,int w,int h);
int doAction();
void showWindow();
int WinRun();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titlesrysid,*titlefy,*titlexzsj;
CButton *btnchaxun ,*btnfanhui;
CEdit *editsrysid;
Table *table;
};
#endif
#pragma warning(disable :4786)
#include"CAdmindoctorqueryWin.h"
#include"CTools.h"
#include"CData.h"
#include"CTable.h"
#include<vector>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
CAdmindoctorqueryWin::CAdmindoctorqueryWin():CWinBase()
{
}
CAdmindoctorqueryWin::~CAdmindoctorqueryWin()
{
}
CAdmindoctorqueryWin::CAdmindoctorqueryWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(25,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//1
this->titlerq = new CLabel(39,10,10,2,"日期",LABEL);//2
this->titlesrysid = new CLabel(9,13,10,2,"请输入医生ID:",LABEL);//3
this->titlefy = new CLabel(42,33,10,2,"按<- ->翻页",LABEL);//4
this->titlexzsj = new CLabel(42,35,10,2,"按上 下选择数据",LABEL);//5
this->editsrysid = new CEdit(24,12,10,3,"",11,2,1,EDIT);//6
this->btnchaxun = new CButton(42,12,10,3,"查询",BUTTON); //7
this->btnfanhui = new CButton(9,34,10,3,"返回",BUTTON); //8
vector<string>header;
header.push_back("医生ID");
header.push_back("医生姓名");
header.push_back("职位");
header.push_back("所属科室");
header.push_back("所属医院");
header.push_back("简介");
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titlesrysid);
this->addControl(this->titlefy);
this->addControl(this->titlexzsj);
this->addControl(this->editsrysid);
this->addControl(this->btnchaxun);
this->addControl(this->btnfanhui);
this->table = new Table(5,18,41,10,4,6,header);
}
int CAdmindoctorqueryWin::doAction()
{
char str[10]={0};
map<int , Doctor> ::iterator it;
switch(this->focusIndex)
{
case 8: //返回
return 15; //管理医生主界面
case 7:
for(it=CData::doctorMap.begin();it!=CData::doctorMap.end();it++)
{
itoa(it->second.getID(),str,10);
if(strstr(str,this->editsrysid->getContent())!=NULL)
{
this->table->clearTable();
this->table->show();
CTools::gotoxy(9,22);
cout<<it->second.getID()<<endl;
CTools::gotoxy(20,22);
cout<<it->second.getName().c_str()<<endl;
CTools::gotoxy(35,22);
cout<<it->second.getPosition().c_str()<<endl;
CTools::gotoxy(48,22);
cout<<it->second.getDepartment().c_str()<<endl;
CTools::gotoxy(60,22);
cout<<it->second.getHospital().c_str()<<endl;
CTools::gotoxy(75,22);
cout<<it->second.getJianjie().c_str()<<endl;
}
}
this->editsrysid->clear();
this->WinRun();
return this->doAction();
default:
break;
}
return 16;
}
void CAdmindoctorqueryWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
this->table->show();
this->table->showdoctorData();
}
int CAdmindoctorqueryWin::WinRun()
{
int i=0,key=0;
int a,b;
for(i=0;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT||this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2,this->ctrlArr[i]->getY()+1);
break;
}
}
while(1)
{
key=CTools::getkey();
switch(key){
case KEY_DOWN://向下按键 查找下一个编辑框 按钮
i++;//按键数组下标越界
if(i==this->ctrlCount)
{
i=0;//为了避免下标越界 从头开始对控件结构体数组找编辑框 按钮
}
for(;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
}
break;
case KEY_UP:
i--;
if(i==-1) //从后往前找 数组起始0 i--为-1 数组下标由大到小 (控件数组下标0位置)
{
i=this->ctrlCount-1; //控件个数(控件结构体数组下标最大)-1 (控件数组下标ctrlCount位置)
}
for(;i>0;i--)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
if(i==0) //第一个 若第一个不是编辑框 按钮
{
i=this->ctrlCount; //就从最后一个往前查找 for循环中有i--,不用再-1
}
}
break;
case KEY_LEFT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<=b&&a>1)
{
a--;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showdoctorData();
}
break;
case KEY_RIGHT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<b)
{
a++;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showdoctorData();
}
break;
case KEY_ENTER:
if(this->ctrlArr[i]->getType()==BUTTON)
{
this->focusIndex=i;
return doAction();//返回切换到的界面的下标
//获取winRun中输入的编辑框的值
}
break;
default: //其他字符(不是按键)并且当前控件是编辑框
if(this->ctrlArr[i]->getType()==EDIT)
{
if(key==KEY_BACKSPACE)//执行回删
{
this->ctrlArr[i]->backSpace();
}
else{
this->ctrlArr[i]->keyListen(key);
}
}
break;
}
}
}
16.CAdmindoctoraddWin.h .cpp
#ifndef CADMINDOCTORADDWIN_H
#define CADMINDOCTORADDWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CAdmindoctoraddWin:public CWinBase
{
public:
CAdmindoctoraddWin();
~CAdmindoctoraddWin();
CAdmindoctoraddWin(int x,int y,int w,int h);
int doAction();
void showWindow();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titleysid,*titleysxm,*titlessyy,*titlessks,*titleyszw
,*titlejianjie,*titleslyy,*titlets1,*titlets2,*titlets3;
CButton *btnqueding ,*btnfanhui;
CEdit *editysxm,*editssyy,*editssks,*edityszw,*editjianjie;
};
#endif
#pragma warning(disable :4786)
#include"CAdmindoctoraddWin.h"
#include"CTools.h"
#include"CData.h"
#include"CDoctor.h"
#include<iostream>
using namespace std;
CAdmindoctoraddWin::CAdmindoctoraddWin():CWinBase()
{
}
CAdmindoctoraddWin::~CAdmindoctoraddWin()
{
}
CAdmindoctoraddWin::CAdmindoctoraddWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(15,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//1
this->titlerq = new CLabel(39,10,10,2,"日期",LABEL);//2
this->titleysid = new CLabel(9,15,10,2,"医生ID:",LABEL);//3
this->titleysxm = new CLabel(9,18,10,2,"医生姓名",LABEL);//4
this->titlessyy = new CLabel(9,21,10,2,"所属医院",LABEL);//5
this->titlessks = new CLabel(9,24,10,2,"所属科室",LABEL);//6
this->titleyszw = new CLabel(9,27,10,2,"医生职位",LABEL);//7
this->titlejianjie = new CLabel(9,30,10,2,"简介",LABEL);//8
this->editysxm = new CEdit(21,17,10,3,"",11,3,1,EDIT);//9
this->editssyy = new CEdit(21,20,10,3,"",11,2,1,EDIT);//10
this->editssks = new CEdit(21,23,10,3,"",11,2,1,EDIT);//11
this->edityszw = new CEdit(21,26,10,3,"",11,2,1,EDIT);//12
this->editjianjie = new CEdit(21,29,20,4,"",11,3,1,EDIT);//13
this->btnqueding = new CButton(8,33,10,3,"确定",BUTTON); //14
this->btnfanhui = new CButton(28,33,10,3,"返回",BUTTON); //15
this->titleslyy = new CLabel(25,21,10,2,"省立医院",LABEL);//16
this->titlets1 = new CLabel(42,26,10,2,"4:专家;5:主任医师",LABEL);//17
this->titlets2 = new CLabel(42,28,10,2,"6:副主任;7:主治医师",LABEL);//18
this->titlets3 = new CLabel(42,24,10,2,"8:内科;9:外科",LABEL);
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titleysid);
this->addControl(this->titleysxm);
this->addControl(this->titlessyy);
this->addControl(this->titlessks);
this->addControl(this->titleyszw);
this->addControl(this->titlejianjie);
this->addControl(this->editysxm);
this->addControl(this->editssyy);
this->addControl(this->editssks);
this->addControl(this->edityszw);
this->addControl(this->editjianjie);
this->addControl(this->btnqueding);
this->addControl(this->btnfanhui);
this->addControl(this->titleslyy);
this->addControl(this->titlets1);
this->addControl(this->titlets2);
this->addControl(this->titlets3);
}
int CAdmindoctoraddWin::doAction()
{
map<int ,Doctor>::iterator it;
switch(this->focusIndex)
{
case 15:
return 15; //管理医生主界面
case 14:
//首先输入医生姓名 所属科室 医生职位 简介内容不能为空
if(strlen(this->editysxm->getContent())==0
||strlen(this->editssks->getContent())==0||strlen(this->edityszw->getContent())==0
||strlen(this->editjianjie->getContent())==0)
{
CTools::gotoxy(10,12);
cout<<"医生姓名或所属科室或医生职位或简介内容不能为空,请输入"<<endl;
//清空编辑框内容
this->editysxm->clear();
this->editssks->clear();
this->edityszw->clear();
this->editjianjie->clear();
system("pause");
return 14;
}
//要求医生姓名中文 长度2-10位
if(strlen(this->editysxm->getContent())<4||strlen(this->editysxm->getContent())>20)
{
cout<<"医生姓名长度要求为2-10位,请重新输入"<<endl;
//清空编辑框内容
this->editysxm->clear();
this->editssks->clear();
this->edityszw->clear();
this->editjianjie->clear();
system("pause");
return 14;
}
//int ID,string name,string pwd,string jianjie,string hospital,
//string position,string department,int role
CData::doctorMap.insert(make_pair<int,Doctor>(CData::Nowdoctor,
Doctor(CData::Nowdoctor,this->editysxm->getContent(),"123456",
this->editjianjie->getContent(),"省立医院",
this->edityszw->getContent(),this->editssks->getContent(),DOCTOR)));
CData::addDoctor(Doctor(CData::Nowdoctor,this->editysxm->getContent(),"123456",
this->editjianjie->getContent(),"省立医院",
this->edityszw->getContent(),this->editssks->getContent(),DOCTOR));
CData::Nowdoctor++;
CTools::gotoxy(10,25);
cout<<"新增医生成功,请稍等"<<endl;
//清空编辑框内容
this->editysxm->clear();
this->editssks->clear();
this->edityszw->clear();
this->editjianjie->clear();
system("pause");
return 14;//用户添加医生界面
default:
break;
}
return 14;
}
void CAdmindoctoraddWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
//基类指针操作派生类成员函数
//虚函数 让每一个子类的函数都能够去调用
//通过基类指针 或 引用调用虚函数 触发动态绑定
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
//显示当前医生的ID
CTools::gotoxy(22,15);
cout<<CData::Nowdoctor<<endl;
}
17.CAdmindoctormodifyWin.h .cpp
#ifndef CADMINDOCTORMODIFYWIN_H
#define CADMINDOCTORMODIFYWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CAdmindoctormodifyWin:public CWinBase
{
public:
CAdmindoctormodifyWin();
~CAdmindoctormodifyWin();
CAdmindoctormodifyWin(int x,int y,int w,int h);
int doAction();
void showWindow();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titleysid,*titleyzw,*titlexzw,*titleqrzw
,*titlets1,*titlets2;
CButton *btnqueding ,*btnfanhui;
CEdit *edityzw,*editxzw,*editqrzw,*editysid;
};
#endif
#include"CAdmindoctormodifyWin.h"
#include"CTools.h"
#include"CData.h"
#include"CDoctor.h"
#include<iostream>
using namespace std;
#include<map>
#include<fstream>
#include<windows.h>
#include<string>
CAdmindoctormodifyWin::CAdmindoctormodifyWin():CWinBase()
{
}
CAdmindoctormodifyWin::~CAdmindoctormodifyWin()
{
}
CAdmindoctormodifyWin::CAdmindoctormodifyWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(15,7,34,4,"修改医生信息窗口",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000 管理员",LABEL);//1
this->titlerq = new CLabel(39,10,10,2,"日期",LABEL);//2
this->titleysid = new CLabel(9,12,10,2,"医生ID",LABEL);//3
this->titleyzw = new CLabel(9,15,10,2,"原职位",LABEL);//4
this->titlexzw = new CLabel(9,18,10,2,"新职位",LABEL);//5
this->titleqrzw = new CLabel(9,21,10,2,"确认职位",LABEL);//6
this->editysid = new CEdit(21,11,10,3,"",4,2,1,EDIT);//7
this->edityzw = new CEdit(21,14,10,3,"",1,2,1,EDIT);//8
this->editxzw = new CEdit(21,17,10,3,"",1,2,1,EDIT);//9
this->editqrzw = new CEdit(21,20,10,3,"",1,2,1,EDIT);//10
this->btnqueding = new CButton(8,23,10,3,"确定",BUTTON); //11
this->btnfanhui = new CButton(28,23,10,3,"返回",BUTTON); //12
this->titlets1 = new CLabel(42,15,10,2,"4:专家;5:主任医师",LABEL);//13
this->titlets2 = new CLabel(42,17,10,2,"6:副主任;7:主治医师",LABEL);//14
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titleysid);
this->addControl(this->titleyzw);
this->addControl(this->titlexzw);
this->addControl(this->titleqrzw);
this->addControl(this->editysid);
this->addControl(this->edityzw);
this->addControl(this->editxzw);
this->addControl(this->editqrzw);
this->addControl(this->btnqueding);
this->addControl(this->btnfanhui);
this->addControl(this->titlets1);
this->addControl(this->titlets2);
}
int CAdmindoctormodifyWin::doAction()
{
map<int,Doctor>::iterator it;
switch(this->focusIndex)
{
case 12:
return 15; //管理员管理医生界面
case 11://确认职位
//判断输入编辑框内容是否为空
if(strlen(this->editysid->getContent())==0||
strlen(this->edityzw->getContent())==0||
strlen(this->editxzw->getContent())==0||
strlen(this->editqrzw->getContent())==0)
{
cout<<"医生ID或原职位或新职位或确认职位不能为空,请输入"<<endl;
this->editysid->clear();
this->edityzw->clear();
this->editxzw->clear();
this->editqrzw->clear();
system("pause");
return 22;
}
//输入两次职位是否一致
if(atoi(this->editxzw->getContent())!=atoi(this->editqrzw->getContent()))
{
cout<<"输入的两次职位不一致,请重新输入"<<endl;
this->editysid->clear();
this->edityzw->clear();
this->editxzw->clear();
this->editqrzw->clear();
system("pause");
return 22;
}
//找到输入医生id与数据医生id一致可以修改该医生的信息
//if(strcmp(this->editysid->getContent(),it->first)==0)
for(it=CData::doctorMap.begin();it!=CData::doctorMap.end();it++)
{
if(atoi(this->editysid->getContent())==it->first)
{
//更新医生map
//set方法获取编辑框内容
it->second.setPosition(this->editxzw->getContent());
//重新文件
CData::writeDoctor();
CTools::gotoxy(10,25);
cout<<"修改医生职位成功"<<endl;
this->editysid->clear();
this->edityzw->clear();
this->editxzw->clear();
this->editqrzw->clear();
system("pause");
return 22;
}
}
default:
break;
}
return 22;//修改医生职位界面
}
void CAdmindoctormodifyWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
}
18.CAdmindepartmentWin.h .cpp
#ifndef CADMINDEPARTMENTWIN_H
#define CADMINDEPARTMENTWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
#include"CTable.h"
class CAdmindepartmentWin:public CWinBase
{
public:
CAdmindepartmentWin();
~CAdmindepartmentWin();
CAdmindepartmentWin(int x,int y,int w,int h);
int doAction();
void showWindow();
int WinRun();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titlesrksid,*titlefy;
CButton *btnchaxun ,*btnfanhui,*btnxzks;
CEdit *editsrksid;
Table *table;
};
#endif
#pragma warning(disable :4786)
#include"CAdmindepartmentWin.h"
#include"CTools.h"
#include"CData.h"
#include"CTable.h"
#include<vector>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
CAdmindepartmentWin::CAdmindepartmentWin():CWinBase()
{
}
CAdmindepartmentWin::~CAdmindepartmentWin()
{
}
CAdmindepartmentWin::CAdmindepartmentWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(25,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,1000管理员",LABEL);//1
this->titlerq = new CLabel(49,10,10,2,"日期",LABEL);//2
this->titlesrksid = new CLabel(9,13,10,2,"请输入科室ID:",LABEL);//3
this->titlefy = new CLabel(42,33,10,2,"按<- ->翻页",LABEL);//4
this->editsrksid = new CEdit(24,12,10,3,"",11,2,1,EDIT);//5
this->btnchaxun = new CButton(42,12,10,3,"查询",BUTTON); //6
this->btnxzks = new CButton(61,12,10,3,"新增科室",BUTTON); //7
this->btnfanhui = new CButton(9,32,10,3,"返回",BUTTON); //8
vector<string>header;
header.push_back("科室ID");
header.push_back("科室名称");
header.push_back("科室说明");
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titlesrksid);
this->addControl(this->titlefy);
this->addControl(this->editsrksid);
this->addControl(this->btnchaxun);
this->addControl(this->btnxzks);
this->addControl(this->btnfanhui);
this->table = new Table(7,18,26,10,4,3,header);
}
int CAdmindepartmentWin::doAction()
{
map<string,Department>::iterator it;
switch(this->focusIndex)
{
case 8: //返回
return 3; //管理员主界面
case 6: //查询
for(it=CData::departmentMap.begin();it!=CData::departmentMap.end();it++)
{
if(strstr(it->second.getKsId().c_str(),this->editsrksid->getContent())!=NULL)
{
this->table->clearTable();
this->table->show();
CTools::gotoxy(9,22);
cout<<it->second.getKsId().c_str()<<endl;
CTools::gotoxy(26,22);
cout<<it->second.getKsName().c_str()<<endl;
CTools::gotoxy(43,22);
cout<<it->second.getKsState().c_str()<<endl;
}
}
this->editsrksid->clear();
this->WinRun();
return this->doAction();
default:
break;
}
return 18;
}
void CAdmindepartmentWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
this->table->show();
this->table->showdepartmentData();
}
int CAdmindepartmentWin::WinRun()
{
int i=0,key=0;
int a,b;
for(i=0;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT||this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2,this->ctrlArr[i]->getY()+1);
break;
}
}
while(1)
{
key=CTools::getkey();
switch(key){
case KEY_DOWN://向下按键 查找下一个编辑框 按钮
i++;//按键数组下标越界
if(i==this->ctrlCount)
{
i=0;//为了避免下标越界 从头开始对控件结构体数组找编辑框 按钮
}
for(;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
}
break;
case KEY_UP:
i--;
if(i==-1) //从后往前找 数组起始0 i--为-1 数组下标由大到小 (控件数组下标0位置)
{
i=this->ctrlCount-1; //控件个数(控件结构体数组下标最大)-1 (控件数组下标ctrlCount位置)
}
for(;i>0;i--)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
if(i==0) //第一个 若第一个不是编辑框 按钮
{
i=this->ctrlCount; //就从最后一个往前查找 for循环中有i--,不用再-1
}
}
break;
case KEY_LEFT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<=b&&a>1)
{
a--;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showdepartmentData();
}
break;
case KEY_RIGHT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<b)
{
a++;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showdepartmentData();
}
break;
case KEY_ENTER:
if(this->ctrlArr[i]->getType()==BUTTON)
{
this->focusIndex=i;
return doAction();//返回切换到的界面的下标
//获取winRun中输入的编辑框的值
}
break;
default: //其他字符(不是按键)并且当前控件是编辑框
if(this->ctrlArr[i]->getType()==EDIT)
{
if(key==KEY_BACKSPACE)//执行回删
{
this->ctrlArr[i]->backSpace();
}
else{
this->ctrlArr[i]->keyListen(key);
}
}
break;
}
}
}
19.CDoctormainWin.h .cpp
#ifndef CDOCTORMAINWIN_H
#define CDOCTORMAINWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
class CDoctormainWin:public CWinBase
{
public:
CDoctormainWin();
~CDoctormainWin();
CDoctormainWin(int x,int y,int w,int h);
int doAction();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq;
CButton *btngr ,*btnjz,*btntc;
};
#endif
#include"CDoctormainWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;
CDoctormainWin::CDoctormainWin():CWinBase()
{
}
CDoctormainWin::~CDoctormainWin()
{
}
CDoctormainWin::CDoctormainWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(15,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,用户名,角色",LABEL);//1
this->titlerq = new CLabel(29,10,10,2,"日期",LABEL);//2
this->btngr = new CButton(10,11,8,3,"个人中心",BUTTON);//3
this->btnjz = new CButton(28,11,10,3,"就诊信息查询",BUTTON); //4
this->btntc = new CButton(10,14,8,3,"退出",BUTTON); //5
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->btngr);
this->addControl(this->btnjz);
this->addControl(this->btntc);
}
int CDoctormainWin::doAction()
{
switch(this->focusIndex)
{
case 5:
return 2; //登录界面
case 4:
return 20; //医生的就诊信息界面
default:
break;
}
return 5;
}
20.CDoctormedicalinfoWin.h .cpp
#ifndef CDOCTORMEDICALINFOWIN_H
#define CDOCTORMEDICALINFOWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
#include"CTable.h"
class CDoctormedicalinfoWin:public CWinBase
{
public:
CDoctormedicalinfoWin();
~CDoctormedicalinfoWin();
CDoctormedicalinfoWin(int x,int y,int w,int h);
int doAction();
void showWindow();
int WinRun();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titlefy,*titlexzsj;
CButton *btnfanhui,*btnjzjl;
Table *table;
};
#endif
#pragma warning(disable :4786)
#include"CDoctormedicalinfoWin.h"
#include"CTools.h"
#include"CData.h"
#include"CTable.h"
#include<vector>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
CDoctormedicalinfoWin::CDoctormedicalinfoWin():CWinBase()
{
}
CDoctormedicalinfoWin::~CDoctormedicalinfoWin()
{
}
CDoctormedicalinfoWin::CDoctormedicalinfoWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(25,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,用户名,角色",LABEL);//1
this->titlerq = new CLabel(49,10,10,2,"日期",LABEL);//2
this->titlefy = new CLabel(50,30,10,2,"按<-- -->翻页",LABEL);//3
this->titlexzsj = new CLabel(50,33,10,2,"按下 上选择数据",LABEL);//4
this->btnfanhui = new CButton(10,29,8,3,"返回",BUTTON); //5
this->btnjzjl = new CButton(25,29,8,3,"医生就诊记录",BUTTON); //6
vector<string>header;
header.push_back("编号");
header.push_back("就诊用户ID");
header.push_back("状态");
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titlefy);
this->addControl(this->titlexzsj);
this->addControl(this->btnfanhui);
this->addControl(this->btnjzjl);
this->table = new Table(7,14,30,10,4,3,header);
}
int CDoctormedicalinfoWin::doAction()
{
switch(this->focusIndex)
{
case 5:
return 4; //医生主界面
case 6:
return 21; //医生主界面
default:
break;
}
return 20;//医生的就诊信息界面
}
void CDoctormedicalinfoWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
this->table->show();
this->table->showoutpatientdoctorData();
}
int CDoctormedicalinfoWin::WinRun()
{
int i=0,key=0;
int a,b;
for(i=0;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT||this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2,this->ctrlArr[i]->getY()+1);
break;
}
}
while(1)
{
key=CTools::getkey();
switch(key){
case KEY_DOWN://向下按键 查找下一个编辑框 按钮
i++;//按键数组下标越界
if(i==this->ctrlCount)
{
i=0;//为了避免下标越界 从头开始对控件结构体数组找编辑框 按钮
}
for(;i<this->ctrlCount;i++)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
}
break;
case KEY_UP:
i--;
if(i==-1) //从后往前找 数组起始0 i--为-1 数组下标由大到小 (控件数组下标0位置)
{
i=this->ctrlCount-1; //控件个数(控件结构体数组下标最大)-1 (控件数组下标ctrlCount位置)
}
for(;i>0;i--)
{
if(this->ctrlArr[i]->getType()==EDIT)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
,this->ctrlArr[i]->getY()+1);
break;
}
else if(this->ctrlArr[i]->getType()==BUTTON)
{
CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
,this->ctrlArr[i]->getY()+1);
break;
}
if(i==0) //第一个 若第一个不是编辑框 按钮
{
i=this->ctrlCount; //就从最后一个往前查找 for循环中有i--,不用再-1
}
}
break;
case KEY_LEFT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<=b&&a>1)
{
a--;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showoutpatientdoctorData();
}
break;
case KEY_RIGHT:
a=this->table->getcurPage();
b=this->table->getsumPage();
if(a<b)
{
a++;
this->table->setCurpage(a);
this->table->clearTable();
this->table->show();
this->table->showoutpatientdoctorData();
}
break;
case KEY_ENTER:
if(this->ctrlArr[i]->getType()==BUTTON)
{
this->focusIndex=i;
return doAction();//返回切换到的界面的下标
//获取winRun中输入的编辑框的值
}
break;
default: //其他字符(不是按键)并且当前控件是编辑框
if(this->ctrlArr[i]->getType()==EDIT)
{
if(key==KEY_BACKSPACE)//执行回删
{
this->ctrlArr[i]->backSpace();
}
else{
this->ctrlArr[i]->keyListen(key);
}
}
break;
}
}
}
21.CDoctormedicalrecWin.h .cpp
#ifndef CDOCTORMEDICALRECWIN_H
#define CDOCTORMEDICALRECWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"
#include<map>
class CDoctormedicalrecWin:public CWinBase
{
public:
CDoctormedicalrecWin();
~CDoctormedicalrecWin();
CDoctormedicalrecWin(int x,int y,int w,int h);
int doAction();
void showWindow();
protected:
private:
CLabel *titlehyld,*titlehy,*titlerq,*titleyhid,*titleyyms,*titlejzms,*titlets;
CButton *btnqueding ,*btnfanhui;
CEdit *edityyms,*editjzms,*edityhid;
};
#endif
#pragma warning(disable :4786)
#include"CDoctormedicalrecWin.h"
#include"CTools.h"
#include"CData.h"
#include"COutpatient.h"
#include<iostream>
using namespace std;
#include<map>
#include<fstream>
#include<windows.h>
#include <string>
CDoctormedicalrecWin::CDoctormedicalrecWin():CWinBase()
{
}
CDoctormedicalrecWin::~CDoctormedicalrecWin()
{
}
CDoctormedicalrecWin::CDoctormedicalrecWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
this->titlehyld = new CLabel(15,7,34,4,"欢迎来到门诊预约管理系统",LABEL);//0
this->titlehy = new CLabel(8,10,10,2,"欢迎,用户名,角色",LABEL);//1
this->titlerq = new CLabel(39,10,10,2,"日期",LABEL);//2
this->titleyhid = new CLabel(9,14,10,2,"用户ID:",LABEL);//3
this->titleyyms = new CLabel(9,17,10,2,"预约描述:",LABEL);//4
this->titlejzms = new CLabel(9,20,10,2,"就诊描述:",LABEL);//5
this->edityhid = new CEdit(22,13,10,3,"",11,2,1,EDIT);//6
this->edityyms = new CEdit(22,16,10,3,"",11,3,1,EDIT);//7
this->editjzms = new CEdit(22,19,14,3,"",18,3,1,EDIT);//8
this->btnqueding = new CButton(10,23,8,3,"确定",BUTTON);//9
this->btnfanhui = new CButton(28,23,10,3,"返回",BUTTON); //10
this->titlets = new CLabel(42,17,10,2,"请用中文填写预约描述以及就诊描述",LABEL);//11
this->addControl(this->titlehyld);
this->addControl(this->titlehy);
this->addControl(this->titlerq);
this->addControl(this->titleyhid);
this->addControl(this->titleyyms);
this->addControl(this->titlejzms);
this->addControl(this->edityhid);
this->addControl(this->edityyms);
this->addControl(this->editjzms);
this->addControl(this->btnqueding);
this->addControl(this->btnfanhui);
this->addControl(this->titlets);
}
int CDoctormedicalrecWin::doAction()
{
map<string ,Outpatient>::iterator it;
switch(this->focusIndex)
{
case 10:
return 20; //医生就诊信息界面
case 9: //确定
//判断编辑框内容是否为空
if(strlen(this->edityhid->getContent())==0||
strlen(this->edityyms->getContent())==0||
strlen(this->editjzms->getContent())==0)
{
CTools::gotoxy(10,25);
cout<<"用户ID或预约描述或就诊描述不能为空"<<endl;
this->edityhid->clear();
this->edityyms->clear();
this->editjzms->clear();
system("pause");
return 21;
}
for(it=CData::outpatientMap.begin();it!=CData::outpatientMap.end();it++)
{
if(strcmp(this->edityhid->getContent(),it->second.getPhoneNum().c_str())==0)
{
it->second.setDescribeU(this->edityyms->getContent());
it->second.setDescribeD(this->editjzms->getContent());
CData::writeOutpatient();
CTools::gotoxy(10,25);
cout<<"预约描述,就诊描述已填入"<<endl;
this->edityhid->clear();
this->edityyms->clear();
this->editjzms->clear();
system("pause");
return 21;
}
/* else
{
CTools::gotoxy(10,25);
cout<<"电话不匹配请重新输入"<<endl;
this->edityhid->clear();
this->edityyms->clear();
this->editjzms->clear();
system("pause");
return 21;
}*/
}
default:
break;
}
return 21;
}
void CDoctormedicalrecWin::showWindow()
{
//显示大框 显示每个控件
CTools::paintWindow(this->startX,this->startY,this->width,this->height);
for(int i=0;i<this->ctrlCount;i++)
{
this->ctrlArr[i]->show(); //执行基类的show函数
}
char buf[15]={0};
strcpy(buf,CTools::showTime());
CTools::gotoxy(this->startX+this->width+6,10);
cout<<buf<<endl;
}