1、数据库实验报告医院综合信息管理系统专 业 班 级 组 长 组 员 指引教师 目录一、需求分析:21.1人员信息管理系统21.2门诊信息管理系统31.3收费信息管理系统3二、系统分析:32.1系统功能简介32.2功能模块3三、数据库设计:43.1 E-R图:43.2数据字典:6四、前台设计:84.1.医生信息管理:84.2.病人信息管理:84.3.药物信息管理:94.4.诊断界面:104.5.处方界面:104.6.病人处方查询:104.7.收费信息管理:11五、程序调试成果:12六、总结:22内容提纲 :本系统是一种基于MYSQL而建立医院综合信息管理系统。用Microsoft Visual S
2、tudio 结合MYSQL开发了3个模块。涉及有人员信息管理,门诊信息管理,收费信息管理。其中人员信息管理其中有医生信息管理,病人信息管理和药物信息管理。门诊信息管理其中则具有就诊信息管理,病人处方管理。这3模块基本实现了医院综合信息管理系统需求。【核心词】:Microsoft Visual Studio ,MYSQL,人员信息管理,门诊信息管理,收费信息管理一、 需求分析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。1.1人员信息管理系统人员信息管理即对于人和物品管理,人则包括医生及医护人员,就诊病人,尚有药物等。咱们需要对她们基本信息进行
3、记录,并且还要具备增长,删除,修改,查询等基本功能,因此我建立了一种基本信息管理模块来专门解决。我也在数据库中相应了三张表:doctor,patient,durg以便对人员信息管理信息进行存储。1.2门诊信息管理系统对于就诊信息管理,病人看病后会产生新数据,例如医生对病人诊断信息,以及药物处方信息。而与其相应则是我做门诊信息管理,其中我做了两个窗口,一种是诊断信息窗口,重要实现对诊断信息储存;另一种是处方信息窗口,有增长、删除、修改药物等功能。然后我另做了一种查询窗口,以便病人查询自己处方记录。相应数据库,我做了两张表:diagnosis,prescription。1.3收费信息管理系统对于收
4、费信息管理,病人拿处处方后,就会取药,付款。则我需要对其总价进行计算,再者就是对于药物库存进行修改。于是相应规定我做了一种收费前台。虽然在数据库中没有相应相应表。可是它操作重要是对prescription读取,以及对durg库存修改。二、系统分析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。2.1系统功能简介2. 1. 1 人员信息管理系统功能对医生、病人、药物基本信息进行增长,删除,修改,查询等基本功能2. 1. 2 门诊信息管理系统功能对就诊信息存储功能和对处方信息进行增长、删除、修改药物等基本功能3. 2. 3 收费信息管理系统对医疗费
5、用进行总和计算功能和对药物库存进行修改功能2.2功能模块系统重要功能模块图如下:医院综合信息管理系统人员信息管理系统门诊信息管理系统收费信息管理系统医生信息管理病人信息管理药物信息管理就诊信息管理病人处方管理收费信息管理药物库存管理三、数据库设计:3.1 E-R图:3.1.1医生信息doctor E-R图namesexageemploynophonedoctor3.1.2病人信息patient E-R图namesexagepatientnonophonepatient3.1.3药物信息drug E-R图drugdrugnononamenopricenoinventoryno3.1.4诊断信息d
6、iagnosis E-R图diagnosisdiagnosisnononoemploynonopatientnonoconditionno3.1.5处方信息prescription E-R图prescriptionprescriptionnononopatientnononamenotimenoaccount3.1.6实体间重要关系E-R图DoctorPaitientDurgDiagnosisPrescriptionN11111113.2数据字典:表1:doctor:表2:patient表3:durg表4:diagnosis表5:prescription四、前台设计:4.1.医生信息管理:4.
7、2.病人信息管理:4.3.药物信息管理:4.4.诊断界面:4.5.处方界面:4.6.病人处方查询:4.7.收费信息管理:五、程序调试成果:1.主界面:2.添加功能:实当代码:void CEmployeeDlg:OnBnClickedOk()/ TODO:在此添加控件告知解决程序代码/CDialogEx:OnOK();UpdateData(true);if(m_number.IsEmpty()MessageBox(CString(编号不能为空”);return;if(m_name.IsEmpty()MessageBox(CString(名称不能为空!);return;if(m_idcard.Is
8、Empty()MessageBox(CString(省份证号码不能为空!);return;CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();_bstr_t sql;sql = select* from doctor;_RecordsetPtr m_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet(sql);trym_pRecordset-AddNew();/添加新行m_pRecordset-PutCollect(employeeno,(_bstr_t)m_number);m_pRecordset-PutCol
9、lect(name,(_bstr_t)m_name);m_pRecordset-PutCollect(sex,(_bstr_t)m_sex);m_pRecordset-PutCollect(age,(_bstr_t)m_age);m_pRecordset-PutCollect(native,(_bstr_t)m_native);m_pRecordset-PutCollect(nation,(_bstr_t)m_nation);m_pRecordset-PutCollect(office,(_bstr_t)m_office);m_pRecordset-PutCollect(position,(_
10、bstr_t)m_position);m_pRecordset-PutCollect(idcard,(_bstr_t)m_idcard);m_pRecordset-PutCollect(phone,(_bstr_t)m_phone);m_pRecordset-Update();/更新数据库m_AdoConn.ExitConnect();/断开数据库连接catch(.)MessageBox(CString(操作失败);return;MessageBox(CString(保存成功);m_grid.DeleteAllItems();/删除grid中本来数据CString str;str=select
11、* from doctor;AddToGrid(str);/重新遍历2.修改功能:实当代码:void CEmployeeDlg:OnBnClickedChange()/ TODO:在此添加控件告知解决程序代码UpdateData(true);CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();CString tempSql;tempSql.Format(CString(UPDATEmydb.doctorSET name=%s,sex=%s,age=%s,native=%s,nation=%s,office=%s,position=%s,idcard=%s,
12、phone=%sWHERE employeeno=%s),m_name,m_sex,m_age,m_native,m_nation,m_office,m_position,m_idcard,m_phone,m_number);m_AdoConn.ExecuteSQL(_bstr_t)tempSql);m_AdoConn.ExitConnect();MessageBox(CString(修改成功.);m_grid.DeleteAllItems();/删除grid中本来数据CString str;str=select* from doctor;AddToGrid(str);/重新遍历3删除功能:代
13、码实现:void CEmployeeDlg:OnBnClickedDelete()/ TODO:在此添加控件告知解决程序代码UpdateData(true);CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();CString tempSql;tempSql.Format(CString(delete from doctor where employeeno = %s),m_number);CString tenpstr;tenpstr.Format(CString(与否要删除%s记录),m_name);if(MessageBox(tenpstr,CStri
14、ng(提示),MB_OKCANCEL)=IDOK)m_AdoConn.ExecuteSQL(_bstr_t)tempSql);m_AdoConn.ExitConnect();MessageBox(CString(删除成功.);m_grid.DeleteAllItems();/删除grid中本来数据CString str; str=select* from doctor; AddToGrid(str);/重新遍历4.查询功能:实当代码:void CEmployeeDlg:OnBnClickedSelect()/ TODO:在此添加控件告知解决程序代码m_grid.DeleteAllItems()
15、;UpdateData(true);CString str1,str2;int num1,num2;num1=m_combo.GetCurSel();if(0=num1)GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1);str2=CString(select* from doctor where employeeno like )+CString()+str1+CString();AddToGrid(str2);/ 遍历功能信息记录if(1=num1)GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1)
16、;str2=CString(select* from doctor where name like )+CString()+str1+CString();AddToGrid(str2);/ 遍历功能信息记录if(2=num1)GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1);str2=CString(select* from doctor where office like )+CString()+str1+CString();AddToGrid(str2);/ 遍历功能信息记录if(3=num1)GetDlgItem(IDC_EDIT_CONT
17、ENT)-GetWindowText(str1);str2=CString(select* from doctor where position like )+CString()+str1+CString();AddToGrid(str2);/ 遍历功能信息记录if(4=num1)GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1);str2=CString(select* from doctor where idcard like )+CString()+str1+CString();AddToGrid(str2);/ 遍历功能信息记录if(5=n
18、um1)GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1);str2=select* from doctor order by employeeno DESC;AddToGrid(str2);/ 遍历功能信息记录5.诊断界面:6.处方界面:7.处方查询:8.付款界面:9.修改库存:对比图:付款前:付款后:六、总结:通过这次数据库大作业,咱们熟悉了vs数据库ADO编程。对于它添加,修改,删除环节均有了较大理解。在本次作业当中遇到两大问题。一是:数据库连接问题,本来开始准备用access做后台,可是不懂得为什么我电脑始终连接不上,于是改用了MYAQL连
19、接。二是:在是使用记录集指针问题_RecordsetPtr m_pRecordset,在实现添加,删除,修改,查询等操作时,只能执行一次就浮现指针无效成果。最后发现是在连接数据库时没有初始化COM,因此导致有指针无效成果。然后,最让我开心是,是实现总价计算。我是用两个数组,amount20,和price20记住数量和单价,运用for循环计算总价。然后,就是在 vs中字符之间转换也是咱们应当注意问题。总之,这次实验,让咱们学到了许多课本上学不到知识,也锻炼了咱们思考问题,解决问题能力。附录:医院综合信息管理系统源代码/ ADOConn.cpp :实现文献/#include stdafx.h#in
20、clude hospital.h#include ADOConn.h/ CADOConnCADOConn:CADOConn()CADOConn:CADOConn()/ CADOConn 成员函数bool CADOConn:OnInitADOConn(void)HRESULT hr;:CoInitialize(NULL);tryhr=m_pDBConnection.CreateInstance(ADODB.Connection);if(SUCCEEDED(hr)m_pDBConnection-ConnectionTimeout=3;/设立连接字符串_bstr_t strConnection=Dr
21、iver=MySQL ODBC 5.2 Unicode Driver;SERVER=127.0.0.1;DATABASE=mydb;UID=root;PASSWORD=123456;PORT=3306;hr=m_pDBConnection-Open(strConnection,adModeUnknown);catch(_com_error e)/捕获异常CString temp;temp.Format(CString(连接数据库错误信息:%s),e.ErrorMessage();:MessageBox(NULL,temp,CString(提示信息),NULL);return false;ret
22、urn false;/ 断开数据库连接void CADOConn:ExitConnect(void)if (m_pRecordset!=NULL) m_pRecordset-Close();m_pDBConnection-Close();/释放环境:CoUninitialize();/ 获取记录集_RecordsetPtr& CADOConn:GetRecordSet(_bstr_t bstrSQL)tryif(m_pDBConnection=NULL) OnInitADOConn();m_pRecordset.CreateInstance(_uuidof(Recordset); m_pRec
23、ordset-Open(bstrSQL,m_pDBConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); catch(_com_error e)CString temp;temp.Format(CString(读取数据库错误信息:%s),e.ErrorMessage();:MessageBox(NULL,temp,CString(提示信息),NULL);return m_pRecordset;/ 执行SQL语句bool CADOConn:ExecuteSQL(_bstr_t bstrSQL)_variant
24、_t RecordsAffected;try if(m_pDBConnection=NULL) OnInitADOConn();m_pDBConnection-Execute(bstrSQL,NULL,adCmdText);return true;catch(_com_error e)CString temp;temp.Format(CString(执行SQL语句错误信息:%s),e.Description();:MessageBox(NULL,temp,CString(提示信息),NULL);return false;/ 返回记录集对象指针SQL执行函数_RecordsetPtr CADOC
25、onn:ExcuteSQLObj(_bstr_t bstrSQL)try if(m_pDBConnection=NULL) OnInitADOConn(); m_pRecordset=m_pDBConnection-Execute(bstrSQL,NULL,adCmdText);catch(_com_error e)CString temp;m_pRecordset=NULL;temp.Format(CString(执行SQL语句错误信息:%s),e.ErrorMessage();:MessageBox(NULL,temp,CString(提示信息),NULL);return m_pRecor
26、dset;/ PrescriptionDlg.cpp :实现文献/处方:万淑妍#include stdafx.h#include hospital.h#include PrescriptionDlg.h#include afxdialogex.h#include ADOConn.h/ CPrescriptionDlg 对话框IMPLEMENT_DYNAMIC(CPrescriptionDlg,CDialogEx)CPrescriptionDlg:CPrescriptionDlg(CWnd* pParent /*=NULL*/):CDialogEx(CPrescriptionDlg:IDD,pP
27、arent)m_patientno = _T();m_amount = _T();m_name = _T();m_no = 0;CPrescriptionDlg:CPrescriptionDlg()void CPrescriptionDlg:DoDataExchange(CDataExchange* pDX)CDialogEx:DoDataExchange(pDX);DDX_Control(pDX,IDC_LIST1,m_grid);DDX_Text(pDX,IDC_PATIENTNO,m_patientno);DDX_Text(pDX,IDC_AMOUNT,m_amount);DDX_Tex
28、t(pDX,IDC_DURGNAME,m_name);DDX_Control(pDX,IDC_DATETIMEPICKER1,m_time);BEGIN_MESSAGE_MAP(CPrescriptionDlg,CDialogEx)ON_BN_CLICKED(IDOK,&CPrescriptionDlg:OnBnClickedOk)ON_BN_CLICKED(IDC_CHANGE,&CPrescriptionDlg:OnBnClickedChange)ON_NOTIFY(NM_CLICK,IDC_LIST1,&CPrescriptionDlg:OnNMClickList1)ON_BN_CLIC
29、KED(IDC_DELETE,&CPrescriptionDlg:OnBnClickedDelete)ON_BN_CLICKED(IDC_CLEAR,&CPrescriptionDlg:OnBnClickedClear)END_MESSAGE_MAP()/ CPrescriptionDlg 消息解决程序BOOL CPrescriptionDlg:OnInitDialog()CDialogEx:OnInitDialog();/ TODO: 在此添加额外初始化flag=0;return TRUE; / return TRUE unless you set the focus to a contro
30、l/ 异常:OCX 属性页应返回 FALSEvoid CPrescriptionDlg:AddToGrid(CString str)CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();CString sql;sql.Format(str);_RecordsetPtr m_pRecordset;m_pRecordset = m_AdoConn.GetRecordSet(_bstr_t)sql);while(m_AdoConn.m_pRecordset-adoEOF=0)m_grid.InsertItem(0,CString();m_grid.SetItemT
31、ext(0,0,(CString)(char*)(_bstr_t)m_pRecordset-GetCollect(prescriptionno);m_grid.SetItemText(0,1,(CString)(char*)(_bstr_t)m_pRecordset-GetCollect(patientno);m_grid.SetItemText(0,2,(CString)(char*)(_bstr_t)m_pRecordset-GetCollect(name);m_grid.SetItemText(0,3,(CString)(char*)(_bstr_t)m_pRecordset-GetCo
32、llect(amount);m_grid.SetItemText(0,4,(CString)(char*)(_bstr_t)m_pRecordset-GetCollect(time);m_pRecordset-MoveNext();m_AdoConn.ExitConnect();UpdateData(true);void CPrescriptionDlg:OnBnClickedOk()/ TODO:在此添加控件告知解决程序代码/CDialogEx:OnOK();m_no=1;if(flag=0)m_grid.SetExtendedStyle(LVS_EX_FLATSB|LVS_EX_FULLR
33、OWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_ONECLICKACTIVATE|LVS_EX_GRIDLINES);m_grid.InsertColumn(0,CString(处方编号),LVCFMT_LEFT,100,0);m_grid.InsertColumn(1,CString(病人编号),LVCFMT_LEFT,100,1);m_grid.InsertColumn(2,CString(药物名称),LVCFMT_LEFT,100,2);m_grid.InsertColumn(3,CString(使用数量),LVCFMT_LEFT,100,3);m_grid.
34、InsertColumn(4,CString(用药时间),LVCFMT_LEFT,100,4);flag= !flag;/自动编号CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();_bstr_t sql;sql = select prescriptionno from prescription;_RecordsetPtr m_pRecordset;m_pRecordset = m_AdoConn.GetRecordSet(_bstr_t)sql);while(m_AdoConn.m_pRecordset-adoEOF=0)if(m_noGetCollec
35、t(prescriptionno)m_no=(int)_ttoi(CString)(char*)(_bstr_t)m_pRecordset-GetCollect(prescriptionno);m_pRecordset-MoveNext();m_AdoConn.ExitConnect();m_no+;CString str,str1;GetDlgItem(IDC_PATIENTNO)-GetWindowText(str1);str=CString(select* from prescription where patientno like )+CString()+str1+CString();
36、AddToGrid(str);/ 遍历员工信息记录UpdateData(true);if(m_patientno.IsEmpty()MessageBox(CString(病人编号不能为空!);return;if(m_name.IsEmpty()MessageBox(CString(名称不能为空!);return;CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();_bstr_t sql;sql = select * from prescription;_RecordsetPtr m_pRecordset; m_pRecordset=m_AdoConn.Ge
37、tRecordSet(sql);/获取工作时间CTime time;m_time.GetTime(time);COleDateTime convert_time;convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay();trym_pRecordset-AddNew();/添加新行m_pRecordset-PutCollect(patientno,(_bstr_t)m_patientno);m_pRecordset-PutCollect(name,(_bstr_t)m_name);m_pRecordset-PutColle
38、ct(amount,(_bstr_t)m_amount);m_pRecordset-PutCollect(time,(_variant_t)convert_time);m_pRecordset-PutCollect(prescriptionno,(_bstr_t)m_no);m_pRecordset-Update();/更新数据库m_AdoConn.ExitConnect();/断开数据库连接catch(.)MessageBox(CString(操作失败);return;MessageBox(CString(保存成功.);m_grid.DeleteAllItems();/删除grid中本来数据
39、CString str,str1;GetDlgItem(IDC_PATIENTNO)-GetWindowText(str1);str=CString(select* from prescription where patientno like )+CString()+str1+CString();AddToGrid(str);/ 遍历员工信息记录void CPrescriptionDlg:OnBnClickedChange()/ TODO:在此添加控件告知解决程序代码UpdateData(true);CADOConn m_AdoConn;m_AdoConn.OnInitADOConn();/创
40、立连接CString tempSql; /删除字符类型为CStringCString sextemp;/获取用药时间CTime time; m_time.GetTime(time);COleDateTime convert_time;convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay(); CString timetemp = convert_time.Format();tempSql.Format(CString(update mydb.prescription set name=%s,amount=%s,time=%s where name = %s),m_patientno,m_amount,timetemp,m_name); m_AdoConn.ExecuteSQL(_bstr_t)tempSql);m_AdoConn.ExitConnect();MessageBox(CString(修改成功.);m_grid.DeleteAllItems();/