基于MYSQL的医院综合信息管理系统设计报告 下载本文

实现代码:

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.IsEmpty()) { MessageBox(CString(\省份证号码不能为空!\)); return; } CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_t sql; sql = \; _RecordsetPtr m_pRecordset;

m_pRecordset=m_AdoConn.GetRecordSet(sql); try { m_pRecordset->AddNew();//添加新行 m_pRecordset->PutCollect(\,(_bstr_t)m_number); m_pRecordset->PutCollect(\,(_bstr_t)m_name); m_pRecordset->PutCollect(\,(_bstr_t)m_sex); m_pRecordset->PutCollect(\,(_bstr_t)m_age); m_pRecordset->PutCollect(\,(_bstr_t)m_native); m_pRecordset->PutCollect(\,(_bstr_t)m_nation); m_pRecordset->PutCollect(\,(_bstr_t)m_office); m_pRecordset->PutCollect(\,(_bstr_t)m_position); m_pRecordset->PutCollect(\,(_bstr_t)m_idcard); m_pRecordset->PutCollect(\,(_bstr_t)m_phone); m_pRecordset->Update();//更新数据库 m_AdoConn.ExitConnect();//断开数据库连接

13

} catch(...) { MessageBox(CString(\操作失败\)); return; } MessageBox(CString(\保存成功\)); m_grid.DeleteAllItems();//删|除grid中原来的数据 CString str; str=\; AddToGrid(str);//重新遍历 }

2.修改功能:

实现代码:

void CEmployeeDlg::OnBnClickedChange() { // TODO: 在此添加控件通知处理程序代码 UpdateData(true); CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); CString tempSql; tempSql.Format(CString(\

`name`='%s',`sex`='%s',`age`='%s',`native`='%s',`nation`='%s',`office`='%s',`position`='%s',`idcard`='%s',`phone`='%s'WHERE

14

`employeeno`='%s'\m_phone,m_number); m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString(\修改成功.\ m_grid.DeleteAllItems();//删除grid中原来的数据 CString str; str=\ AddToGrid(str);//重新遍历 }

3.删除功能:

15

代码实现:

void CEmployeeDlg::OnBnClickedDelete() { // TODO: 在此添加控件通知处理程序代码 UpdateData(true); CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); CString tempSql; tempSql.Format(CString(\ CString tenpstr; tenpstr.Format(CString(\是否要删除%s的记录\ if(MessageBox(tenpstr,CString(\提示\ { m_AdoConn.ExecuteSQL((_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString(\删除成功.\ m_grid.DeleteAllItems();//删除grid中原来的数据 CString str; str=\ AddToGrid(str);//重新遍历 } }

16