基于MYSQL的医院综合信息管理系统设计报告样本_第1页
基于MYSQL的医院综合信息管理系统设计报告样本_第2页
基于MYSQL的医院综合信息管理系统设计报告样本_第3页
基于MYSQL的医院综合信息管理系统设计报告样本_第4页
基于MYSQL的医院综合信息管理系统设计报告样本_第5页
已阅读5页,还剩89页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

数据库实验报告医院综合信息管理系统专业班级组长组员指引教师目录TOC\o"1-2"\h\z\u一、 需求分析: 21.1人员信息管理系统 21.2门诊信息管理系统 31.3收费信息管理系统 3二、系统分析: 32.1系统功能简介 32.2功能模块 3三、数据库设计: 43.1E-R图: 43.2数据字典: 6四、前台设计: 84.1.医生信息管理: 84.2.病人信息管理: 84.3.药物信息管理: 94.4.诊断界面: 104.5.处方界面: 104.6.病人处方查询: 104.7.收费信息管理: 11五、程序调试成果: 12六、总结: 22内容提纲:本系统是一种基于MYSQL而建立医院综合信息管理系统。用MicrosoftVisualStudio结合MYSQL开发了3个模块。涉及有人员信息管理,门诊信息管理,收费信息管理。其中人员信息管理其中有医生信息管理,病人信息管理和药物信息管理。门诊信息管理其中则具有就诊信息管理,病人处方管理。这3模块基本实现了医院综合信息管理系统需求。【核心词】:MicrosoftVisualStudio,MYSQL,人员信息管理,门诊信息管理,收费信息管理需求分析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。1.1人员信息管理系统人员信息管理即对于人和物品管理,人则包括医生及医护人员,就诊病人,尚有药物等。咱们需要对她们基本信息进行记录,并且还要具备增长,删除,修改,查询等基本功能,因此我建立了一种基本信息管理模块来专门解决。我也在数据库中相应了三张表:doctor,patient,durg以便对人员信息管理信息进行存储。1.2门诊信息管理系统对于就诊信息管理,病人看病后会产生新数据,例如医生对病人诊断信息,以及药物处方信息。而与其相应则是我做门诊信息管理,其中我做了两个窗口,一种是诊断信息窗口,重要实现对诊断信息储存;另一种是处方信息窗口,有增长、删除、修改药物等功能。然后我另做了一种查询窗口,以便病人查询自己处方记录。相应数据库,我做了两张表:diagnosis,prescription。1.3收费信息管理系统对于收费信息管理,病人拿处处方后,就会取药,付款。则我需要对其总价进行计算,再者就是对于药物库存进行修改。于是相应规定我做了一种收费前台。虽然在数据库中没有相应相应表。可是它操作重要是对prescription读取,以及对durg库存修改。二、系统分析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。2.1系统功能简介2.1.1人员信息管理系统功能对医生、病人、药物基本信息进行增长,删除,修改,查询等基本功能2.1.2门诊信息管理系统功能对就诊信息存储功能和对处方信息进行增长、删除、修改药物等基本功能3.2.3收费信息管理系统对医疗费用进行总和计算功能和对药物库存进行修改功能2.2功能模块系统重要功能模块图如下:医院综合信息管理系统医院综合信息管理系统人员信息管理系统门诊信息管理系统收费信息管理系统医生信息管理病人信息管理药物信息管理就诊信息管理病人处方管理收费信息管理药物库存管理三、数据库设计:3.1E-R图:3.1.1医生信息doctorE-R图namenamesexageemploynophonedoctor3.1.2病人信息patientE-R图namenamesexagepatientnonophonepatient3.1.3药物信息drugE-R图drugdrugdrugnononamenopricenoinventoryno3.1.4诊断信息diagnosisE-R图diagnosisdiagnosisdiagnosisnononoemploynonopatientnonoconditionno3.1.5处方信息prescriptionE-Rprescriptionprescriptionprescriptionnononopatientnononamenotimenoaccount3.1.6实体间重要关系E-R图DDoctorPaitientDurgDiagnosisPrescriptionN11111113.2数据字典:表1:doctor:表2:patient表3:durg表4:diagnosis表5:prescription四、前台设计:4.1.医生信息管理:4.2.病人信息管理:4.3.药物信息管理:4.4.诊断界面:4.5.处方界面:4.6.病人处方查询:4.7.收费信息管理:五、程序调试成果:1.主界面:2.添加功能:实当代码:voidCEmployeeDlg::OnBnClickedOk(){ //TODO:在此添加控件告知解决程序代码 //CDialogEx::OnOK(); UpdateData(true); if(m_number.IsEmpty()) { MessageBox(CString("编号不能为空”)); return; } if(m_name.IsEmpty()) { MessageBox(CString("名称不能为空!")); return; } if(m_idcard.IsEmpty()) { MessageBox(CString("省份证号码不能为空!")); return; } CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_tsql; sql="select*fromdoctor"; _RecordsetPtrm_pRecordset;m_pRecordset=m_AdoConn.GetRecordSet(sql); try { m_pRecordset->AddNew();//添加新行 m_pRecordset->PutCollect("employeeno",(_bstr_t)m_number); m_pRecordset->PutCollect("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",(_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中本来数据 CStringstr; str="select*fromdoctor"; AddToGrid(str);//重新遍历}2.修改功能:实当代码:voidCEmployeeDlg::OnBnClickedChange(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringtempSql; tempSql.Format(CString("UPDATE`mydb`.`doctor`SET`name`='%s',`sex`='%s',`age`='%s',`native`='%s',`nation`='%s',`office`='%s',`position`='%s',`idcard`='%s',`phone`='%s'WHERE`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中本来数据 CStringstr; str="select*fromdoctor"; AddToGrid(str);//重新遍历}3.删除功能:代码实现:voidCEmployeeDlg::OnBnClickedDelete(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringtempSql; tempSql.Format(CString("deletefromdoctorwhereemployeeno='%s'"),m_number); CStringtenpstr; tenpstr.Format(CString("与否要删除%s记录"),m_name); if(MessageBox(tenpstr,CString("提示"),MB_OKCANCEL)==IDOK) { m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString("删除成功.")); m_grid.DeleteAllItems();//删除grid中本来数据 CStringstr; str="select*fromdoctor"; AddToGrid(str);//重新遍历 }}4.查询功能:实当代码:voidCEmployeeDlg::OnBnClickedSelect(){ //TODO:在此添加控件告知解决程序代码 m_grid.DeleteAllItems(); UpdateData(true); CStringstr1,str2; intnum1,num2; num1=m_combo.GetCurSel(); if(0==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*fromdoctorwhereemployeenolike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(1==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*fromdoctorwherenamelike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(2==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*fromdoctorwhereofficelike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(3==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*fromdoctorwherepositionlike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(4==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*fromdoctorwhereidcardlike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(5==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2="select*fromdoctororderbyemployeenoDESC"; AddToGrid(str2);//遍历功能信息记录 }}5.诊断界面:6.处方界面:7.处方查询:8.付款界面:9.修改库存:对比图:付款前:付款后:六、总结:通过这次数据库大作业,咱们熟悉了vs数据库ADO编程。对于它添加,修改,删除环节均有了较大理解。在本次作业当中遇到两大问题。一是:数据库连接问题,本来开始准备用access做后台,可是不懂得为什么我电脑始终连接不上,于是改用了MYAQL连接。二是:在是使用记录集指针问题_RecordsetPtrm_pRecordset,在实现添加,删除,修改,查询等操作时,只能执行一次就浮现指针无效成果。最后发现是在连接数据库时没有初始化COM,因此导致有指针无效成果。然后,最让我开心是,是实现总价计算。我是用两个数组,amount[20],和price[20]记住数量和单价,运用for循环计算总价。然后,就是在vs中字符之间转换也是咱们应当注意问题。总之,这次实验,让咱们学到了许多课本上学不到知识,也锻炼了咱们思考问题,解决问题能力。附录:医院综合信息管理系统源代码//ADOConn.cpp:实现文献//#include"stdafx.h"#include"hospital.h"#include"ADOConn.h"//CADOConnCADOConn::CADOConn(){}CADOConn::~CADOConn(){}//CADOConn成员函数boolCADOConn::OnInitADOConn(void){ HRESULThr; ::CoInitialize(NULL); try { hr=m_pDBConnection.CreateInstance("ADODB.Connection"); if(SUCCEEDED(hr)) { m_pDBConnection->ConnectionTimeout=3; //设立连接字符串 _bstr_tstrConnection="Driver={MySQLODBC5.2UnicodeDriver};SERVER=127.0.0.1;DATABASE=mydb;UID=root;PASSWORD=123456;PORT=3306"; hr=m_pDBConnection->Open(strConnection,"","",adModeUnknown); } } catch(_com_errore)//捕获异常 { CStringtemp; temp.Format(CString("连接数据库错误信息:%s"),e.ErrorMessage()); ::MessageBox(NULL,temp,CString("提示信息"),NULL); returnfalse; } returnfalse;}//断开数据库连接voidCADOConn::ExitConnect(void){ if(m_pRecordset!=NULL) m_pRecordset->Close(); m_pDBConnection->Close(); //释放环境 ::CoUninitialize();}//获取记录集_RecordsetPtr&CADOConn::GetRecordSet(_bstr_tbstrSQL){ try { if(m_pDBConnection==NULL)OnInitADOConn(); m_pRecordset.CreateInstance(__uuidof(Recordset));m_pRecordset->Open(bstrSQL,m_pDBConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); }catch(_com_errore) { CStringtemp; temp.Format(CString("读取数据库错误信息:%s"),e.ErrorMessage()); ::MessageBox(NULL,temp,CString("提示信息"),NULL); } returnm_pRecordset;}//执行SQL语句boolCADOConn::ExecuteSQL(_bstr_tbstrSQL){ _variant_tRecordsAffected; try {if(m_pDBConnection==NULL) OnInitADOConn(); m_pDBConnection->Execute(bstrSQL,NULL,adCmdText); returntrue; } catch(_com_errore) { CStringtemp; temp.Format(CString("执行SQL语句错误信息:%s"),e.Description()); ::MessageBox(NULL,temp,CString("提示信息"),NULL); returnfalse; }}//返回记录集对象指针SQL执行函数_RecordsetPtrCADOConn::ExcuteSQLObj(_bstr_tbstrSQL){ try {if(m_pDBConnection==NULL) OnInitADOConn();m_pRecordset=m_pDBConnection->Execute(bstrSQL,NULL,adCmdText); } catch(_com_errore) { CStringtemp; m_pRecordset=NULL; temp.Format(CString("执行SQL语句错误信息:%s"),e.ErrorMessage()); ::MessageBox(NULL,temp,CString("提示信息"),NULL); } returnm_pRecordset;}//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,pParent){ m_patientno=_T(""); m_amount=_T(""); m_name=_T(""); m_no=0;}CPrescriptionDlg::~CPrescriptionDlg(){}voidCPrescriptionDlg::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_Text(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_CLICKED(IDC_DELETE,&CPrescriptionDlg::OnBnClickedDelete) ON_BN_CLICKED(IDC_CLEAR,&CPrescriptionDlg::OnBnClickedClear)END_MESSAGE_MAP()//CPrescriptionDlg消息解决程序BOOLCPrescriptionDlg::OnInitDialog(){ CDialogEx::OnInitDialog(); //TODO:在此添加额外初始化 flag=0; returnTRUE;//returnTRUEunlessyousetthefocustoacontrol //异常:OCX属性页应返回FALSE}voidCPrescriptionDlg::AddToGrid(CStringstr){ CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringsql; sql.Format(str); _RecordsetPtrm_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql); while(m_AdoConn.m_pRecordset->adoEOF==0) { m_grid.InsertItem(0,CString("")); m_grid.SetItemText(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->GetCollect("amount")); m_grid.SetItemText(0,4,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("time")); m_pRecordset->MoveNext(); } m_AdoConn.ExitConnect(); UpdateData(true);}voidCPrescriptionDlg::OnBnClickedOk(){ //TODO:在此添加控件告知解决程序代码 //CDialogEx::OnOK(); m_no=1; if(flag==0) { m_grid.SetExtendedStyle(LVS_EX_FLATSB |LVS_EX_FULLROWSELECT |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.InsertColumn(4,CString("用药时间"),LVCFMT_LEFT,100,4); flag=!flag; //自动编号 CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_tsql; sql="selectprescriptionnofromprescription"; _RecordsetPtrm_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql); while(m_AdoConn.m_pRecordset->adoEOF==0) { if(m_no<(int)_ttoi((CString)(char*)(_bstr_t)m_pRecordset->GetCollect("prescriptionno"))) m_no=(int)_ttoi((CString)(char*)(_bstr_t)m_pRecordset->GetCollect("prescriptionno")); m_pRecordset->MoveNext(); } m_AdoConn.ExitConnect(); m_no++; CStringstr,str1; GetDlgItem(IDC_PATIENTNO)->GetWindowText(str1); str=CString("select*fromprescriptionwherepatientnolike")+CString("'")+str1+CString("'"); AddToGrid(str);//遍历员工信息记录 } UpdateData(true); if(m_patientno.IsEmpty()) { MessageBox(CString("病人编号不能为空!")); return; } if(m_name.IsEmpty()) { MessageBox(CString("名称不能为空!")); return; } CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_tsql; sql="select*fromprescription"; _RecordsetPtrm_pRecordset;m_pRecordset=m_AdoConn.GetRecordSet(sql); //获取工作时间 CTimetime; m_time.GetTime(time); COleDateTimeconvert_time; convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay()); try { m_pRecordset->AddNew();//添加新行 m_pRecordset->PutCollect("patientno",(_bstr_t)m_patientno); m_pRecordset->PutCollect("name",(_bstr_t)m_name); m_pRecordset->PutCollect("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中本来数据 CStringstr,str1; GetDlgItem(IDC_PATIENTNO)->GetWindowText(str1); str=CString("select*fromprescriptionwherepatientnolike")+CString("'")+str1+CString("'"); AddToGrid(str);//遍历员工信息记录}voidCPrescriptionDlg::OnBnClickedChange(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn();//创立连接 CStringtempSql;//删除字符类型为CString CStringsextemp; //获取用药时间 CTimetime;m_time.GetTime(time); COleDateTimeconvert_time; convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay());CStringtimetemp=convert_time.Format(); tempSql.Format(CString("updatemydb.prescriptionsetname='%s',amount='%s',time='%s'wherename='%s'"),m_patientno,m_amount,timetemp,m_name); m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString("修改成功.")); m_grid.DeleteAllItems();//删除grid中本来数据 CStringstr; str="select*fromprescription"; AddToGrid(str);//重新遍历}voidCPrescriptionDlg::OnNMClickList1(NMHDR*pNMHDR,LRESULT*pResult){ LPNMITEMACTIVATEpNMItemActivate=reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); //TODO:在此添加控件告知解决程序代码 intnItem=0; POSITIONpos=m_grid.GetFirstSelectedItemPosition(); if(pos==NULL) TRACE0("Noitemswereselected!\n"); else { while(pos) { nItem=m_grid.GetNextSelectedItem(pos);//找到被选中行号 TRACE1("Item%dwasselected!\n",nItem); } //读取被选中行数据 m_patientno=m_grid.GetItemText(nItem,1); m_name=m_grid.GetItemText(nItem,2); m_amount=m_grid.GetItemText(nItem,3); //解决用药时间 COleVarianttempTimeStr; CStringtempStr=m_grid.GetItemText(nItem,4); tempTimeStr=tempStr; tempTimeStr.ChangeType(VT_DATE); COleDateTimetempTime; tempTime=tempTimeStr; m_time.SetTime(tempTime); UpdateData(FALSE);//更新对话框 } *pResult=0;}voidCPrescriptionDlg::OnBnClickedDelete(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringtempSql; tempSql.Format(CString("deletefromprescriptionwherename='%s'"),m_name); CStringtempstr; tempstr.Format(CString("与否拟定要删除%s记录"),m_name); if(MessageBox(tempstr,CString("提示"),MB_OKCANCEL)==IDOK) { m_AdoConn.ExecuteSQL((_bstr_t)tempSql);//执行AQL语句,注意改成ADO字符串 m_AdoConn.ExitConnect(); MessageBox(CString("删除成功.")); m_grid.DeleteAllItems();//删除grid中本来数据 CStringstr; str="select*fromprescription"; AddToGrid(str);//重新遍历 }}voidCPrescriptionDlg::OnBnClickedClear(){ //TODO:在此添加控件告知解决程序代码 m_amount=_T(""); m_name=_T(""); UpdateData(false);}//PatientDlg.cpp:实现文献//病人管理:吴婷#include"stdafx.h"#include"hospital.h"#include"PatientDlg.h"#include"afxdialogex.h"#include"ADOConn.h"//CPatientDlg对话框IMPLEMENT_DYNAMIC(CPatientDlg,CDialogEx)CPatientDlg::CPatientDlg(CWnd*pParent/*=NULL*/) :CDialogEx(CPatientDlg::IDD,pParent){ m_age=_T(""); m_allergy=_T(""); m_content=_T(""); m_idcard=_T(""); m_name=_T(""); m_nation=_T(""); m_native=_T(""); m_phone=_T(""); m_no=_T(""); m_sex=_T("");}CPatientDlg::~CPatientDlg(){}voidCPatientDlg::DoDataExchange(CDataExchange*pDX){ CDialogEx::DoDataExchange(pDX); DDX_Text(pDX,IDC_EDIT_AGE,m_age); DDX_Text(pDX,IDC_EDIT_ALLERGY,m_allergy); DDX_Text(pDX,IDC_EDIT_CONTENT,m_content); DDX_Text(pDX,IDC_EDIT_IDCARD,m_idcard); DDX_Text(pDX,IDC_EDIT_NAME,m_name); DDX_Text(pDX,IDC_EDIT_NATION,m_nation); DDX_Text(pDX,IDC_EDIT_NATIVE,m_native); DDX_Text(pDX,IDC_EDIT_PHONE,m_phone); DDX_Text(pDX,IDC_EDIT_NO,m_no); DDX_Text(pDX,IDC_EDIT_SEX,m_sex); DDX_Control(pDX,IDC_LIST_PATIENT,m_grid); DDX_Control(pDX,IDC_COMBO1,m_combo);}BEGIN_MESSAGE_MAP(CPatientDlg,CDialogEx) ON_BN_CLICKED(IDOK,&CPatientDlg::OnBnClickedOk) ON_BN_CLICKED(IDC_CHANGE,&CPatientDlg::OnBnClickedChange) ON_BN_CLICKED(IDC_DELETE,&CPatientDlg::OnBnClickedDelete) ON_BN_CLICKED(IDC_CLEAR,&CPatientDlg::OnBnClickedClear) ON_BN_CLICKED(IDC_SELECT,&CPatientDlg::OnBnClickedSelect) ON_NOTIFY(NM_CLICK,IDC_LIST_PATIENT,&CPatientDlg::OnNMClickListPatient)END_MESSAGE_MAP()//CPatientDlg消息解决程序BOOLCPatientDlg::OnInitDialog(){ CDialogEx::OnInitDialog(); //TODO:在此添加额外初始化 m_grid.SetExtendedStyle(LVS_EX_FLATSB |LVS_EX_FULLROWSELECT |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.InsertColumn(4,CString("民族"),LVCFMT_LEFT,100,4); m_grid.InsertColumn(5,CString("籍贯"),LVCFMT_LEFT,100,5); m_grid.InsertColumn(6,CString("身份证号码"),LVCFMT_LEFT,100,6); m_grid.InsertColumn(7,CString("联系电话"),LVCFMT_LEFT,100,7); m_grid.InsertColumn(8,CString("过敏史"),LVCFMT_LEFT,100,8); m_combo.InsertString(0,CString("病人编号")); m_combo.InsertString(1,CString("姓名")); m_combo.InsertString(2,CString("身份证号码")); m_combo.InsertString(3,CString("所有信息")); m_combo.SetCurSel(3); CStringstr; str="select*frompatient"; AddToGrid(str);//遍历员工信息记录 returnTRUE;//returnTRUEunlessyousetthefocustoacontrol //异常:OCX属性页应返回FALSE}voidCPatientDlg::AddToGrid(CStringstr){ CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringsql; sql.Format(str); _RecordsetPtrm_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql); while(m_AdoConn.m_pRecordset->adoEOF==0) { m_grid.InsertItem(0,CString("")); m_grid.SetItemText(0,0,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("patientno")); m_grid.SetItemText(0,1,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("name")); m_grid.SetItemText(0,2,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("sex")); m_grid.SetItemText(0,3,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("age")); m_grid.SetItemText(0,4,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("native")); m_grid.SetItemText(0,5,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("nation")); m_grid.SetItemText(0,6,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("allergy")); m_grid.SetItemText(0,7,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("idcard")); m_grid.SetItemText(0,8,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("phone")); m_pRecordset->MoveNext(); } m_AdoConn.ExitConnect(); UpdateData(true);}voidCPatientDlg::OnBnClickedOk(){ //TODO:在此添加控件告知解决程序代码 //CDialogEx::OnOK(); UpdateData(true); if(m_no.IsEmpty()) { MessageBox(CString("编号不能为空!")); return; } if(m_name.IsEmpty()) { MessageBox(CString("名称不能为空!")); return; } if(m_idcard.IsEmpty()) { MessageBox(CString("省份证号码不能为空!")); return; } CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_tsql; sql="select*frompatient"; _RecordsetPtrm_pRecordset;m_pRecordset=m_AdoConn.GetRecordSet(sql); try { m_pRecordset->AddNew();//添加新行 m_pRecordset->PutCollect("patientno",(_bstr_t)m_no); m_pRecordset->PutCollect("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("allergy",(_bstr_t)m_allergy); 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中本来数据 CStringstr; str="select*frompatient"; AddToGrid(str);//重新遍历}voidCPatientDlg::OnBnClickedChange(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringtempSql; tempSql.Format(CString("UPDATE`mydb`.`patient`SET`name`='%s',`sex`='%s',`age`='%s',`native`='%s',`nation`='%s',`allergy`='%s',`idcard`='%s',`phone`='%s'WHERE`patientno`='%s'"),m_name,m_sex,m_age,m_native,m_nation,m_allergy,m_idcard,m_phone,m_no); m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString("修改成功.")); m_grid.DeleteAllItems();//删除grid中本来数据 CStringstr; str="select*frompatient"; AddToGrid(str);//重新遍历}voidCPatientDlg::OnBnClickedDelete(){ //TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringtempSql; tempSql.Format(CString("deletefrompatientwherepatientno='%s'"),m_no); CStringtenpstr; tenpstr.Format(CString("与否要删除%s记录"),m_name); if(MessageBox(tenpstr,CString("提示"),MB_OKCANCEL)==IDOK) { m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString("删除成功.")); m_grid.DeleteAllItems();//删除grid中本来数据 CStringstr; str="select*frompatient"; AddToGrid(str);//重新遍历 }}voidCPatientDlg::OnBnClickedClear(){ //TODO:在此添加控件告知解决程序代码 m_age=_T(""); m_no=_T(""); m_idcard=_T(""); m_name=_T(""); m_nation=_T(""); m_native=_T(""); m_allergy=_T(""); m_phone=_T(""); m_sex=_T(""); UpdateData(false);}voidCPatientDlg::OnBnClickedSelect(){ //TODO:在此添加控件告知解决程序代码 m_grid.DeleteAllItems(); UpdateData(true); CStringstr1,str2; intnum1; num1=m_combo.GetCurSel(); if(0==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*frompatientwherepatientnolike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(1==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*frompatientwherenamelike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(2==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2=CString("select*frompatientwhereidcardlike")+CString("'")+str1+CString("'"); AddToGrid(str2);//遍历功能信息记录 } if(3==num1) { GetDlgItem(IDC_EDIT_CONTENT)->GetWindowText(str1); str2="select*frompatientorderbypatientnoDESC"; AddToGrid(str2);//遍历功能信息记录 }}voidCPatientDlg::OnNMClickListPatient(NMHDR*pNMHDR,LRESULT*pResult){ LPNMITEMACTIVATEpNMItemActivate=reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); //TODO:在此添加控件告知解决程序代码 intnItem=0; POSITIONpos=m_grid.GetFirstSelectedItemPosition(); if(pos==NULL) TRACE0("Noitemswereselected!\n"); else { while(pos) { nItem=m_grid.GetNextSelectedItem(pos);//找到被选中行号 TRACE1("Item%dwasselected!\n",nItem); } //读取被选中行数据 m_no=m_grid.GetItemText(nItem,0); m_name=m_grid.GetItemText(nItem,1); m_sex=m_grid.GetItemText(nItem,2); m_age=m_grid.GetItemText(nItem,3); m_native=m_grid.GetItemText(nItem,4); m_nation=m_grid.GetItemText(nItem,5); m_allergy=m_grid.GetItemText(nItem,6); m_idcard=m_grid.GetItemText(nItem,7); m_phone=m_grid.GetItemText(nItem,8); UpdateData(FALSE);//更新对话框 } *pResult=0;}//EmployeeDlg.cpp:实现文献//人员管理:吴婷#include"stdafx.h"#include"hospital.h"#include"EmployeeDlg.h"#include"afxdialogex.h"#include"ADOConn.h"//CEmployeeDlg对话框IMPLEMENT_DYNAMIC(CEmployeeDlg,CDialogEx)CEmployeeDlg::CEmployeeDlg(CWnd*pParent/*=NULL*/) :CDialogEx(CEmployeeDlg::IDD,pParent){ m_age=_T(""); m_content=_T(""); m_idcard=_T(""); m_name=_T(""); m_nation=_T(""); m_native=_T(""); m_number=_T(""); m_office=_T(""); m_phone=_T(""); m_position=_T(""); m_sex=_T("");}CEmployeeDlg::~CEmployeeDlg(){}voidCEmployeeDlg::DoDataExchange(CDataExchange*pDX){ CDialogEx::DoDataExchange(pDX); DDX_Text(pDX,IDC_EDIT_AGE,m_age); DDX_Text(pDX,IDC_EDIT_CONTENT,m_content); DDX_Text(pDX,IDC_EDIT_IDCARD,m_idcard); DDX_Text(pDX,IDC_EDIT_NAME,m_name); DDX_Text(pDX,IDC_EDIT_NATION,m_nation); DDX_Text(pDX,IDC_EDIT_NATIVE,m_native); DDX_Text(pDX,IDC_EDIT_NUMBER,m_number); DDX_Text(pDX,IDC_EDIT_OFFICE,m_office); DDX_Text(pDX,IDC_EDIT_PHONE,m_phone); DDX_Text(pDX,IDC_EDIT_POSITION,m_position); DDX_Text(pDX,IDC_EDIT_SEX,m_sex); DDX_Control(pDX,IDC_LIST_EMPLOYEE,m_grid); DDX_Control(pDX,IDC_COMBO1,m_combo);}BEGIN_MESSAGE_MAP(CEmployeeDlg,CDialogEx) ON_BN_CLICKED(IDOK,&CEmployeeDlg::OnBnClickedOk) ON_BN_CLICKED(IDC_CHANGE,&CEmployeeDlg::OnBnClickedChange) ON_BN_CLICKED(IDC_DELETE,&CEmployeeDlg::OnBnClickedDelete) ON_BN_CLICKED(IDC_CLEAR,&CEmployeeDlg::OnBnClickedClear) ON_BN_CLICKED(IDC_SELECT,&CEmployeeDlg::OnBnClickedSelect) ON_NOTIFY(NM_CLICK,IDC_LIST_EMPLOYEE,&CEmployeeDlg::OnNMClickListEmployee)END_MESSAGE_MAP()//CEmployeeDlg消息解决程序BOOLCEmployeeDlg::OnInitDialog(){ CDialogEx::OnInitDialog(); //TODO:在此添加额外初始化 m_grid.SetExtendedStyle(LVS_EX_FLATSB |LVS_EX_FULLROWSELECT |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.InsertColumn(4,CString("籍贯"),LVCFMT_LEFT,100,4); m_grid.InsertColumn(5,CString("民族"),LVCFMT_LEFT,100,5); m_grid.InsertColumn(6,CString("从属科室"),LVCFMT_LEFT,100,6); m_grid.InsertColumn(7,CString("职称"),LVCFMT_LEFT,100,7); m_grid.InsertColumn(8,CString("身份证号码"),LVCFMT_LEFT,100,8); m_grid.InsertColumn(9,CString("联系电话"),LVCFMT_LEFT,100,9); m_combo.InsertString(0,CString("人员编号")); m_combo.InsertString(1,CString("姓名")); m_combo.InsertString(2,CString("从属科室")); m_combo.InsertString(3,CString("职称")); m_combo.InsertString(4,CString("身份证号码")); m_combo.InsertString(5,CString("所有信息")); m_combo.SetCurSel(5); CStringstr; str="select*fromdoctor"; AddToGrid(str);//遍历员工信息记录 returnTRUE;//returnTRUEunlessyousetthefocustoacontrol //异常:OCX属性页应返回FALSE}voidCEmployeeDlg::AddToGrid(CStringstr){ CADOConnm_AdoConn; m_AdoConn.OnInitADOConn(); CStringsql; sql.Format(str); _RecordsetPtrm_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql); while(m_AdoConn.m_pRecordset->adoEOF==0) { m_grid.InsertItem(0,CString("")); m_grid.SetItemText(0,0,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("employeeno")); m_grid.SetItemText(0,1,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("name")); m_grid.SetItemText(0,2,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("sex")); m_grid.SetItemText(0,3,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("age")); m_grid.SetItemText(0,4,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("native")); m_grid.SetItemText(0,5,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("nation")); m_grid.SetItemText(0,6,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("office")); m_grid.SetItemText(0,7,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("position")); m_grid.SetItemText(0,8,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("idcard")); m_grid.SetItemText(0,9,(CString)(char*)(_bstr_t)m_pReco

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论