当前位置:首页 > 通信管理系统曾冠龙
VC++课程设计
第六章. 结果分析及心得体会
通过本次Visual C++课程设计,我从中学到了不少的知识。首先是对VC++设计数据库管理系统应该把握的一些步骤更加清晰明了了,其次就是对一些代码的理解更加深刻,特别是有关于程序代码与数据库相关联的设计。ODBC确实具有强大的功能,特别是在数据库管理系统设计方面。另外,此次课程设计也加深了我对MFC编程的了解,并且可以使用一些书本上的知识解决问题。当然,在本次设计中也遇到很多问题,比如某个类的添加及其头文件的添加等,有时候不小心就会出错,还有就是对一些变量的添加出错。但是通过和同组成员的讨论,我们完成了课程设计,这是我最大的收获。
第七章.参考文献
<
第八章.附录.
void CCommunicationDlg::InitTreeList() {
m_tree_list.DeleteAllItems(); CString strPeoPleQuery;
strPeoPleQuery=\ CDatabase db1;
CGroupInfo gi(&db1);
gi.Open(AFX_DB_USE_DEFAULT_TYPE,strPeoPleQuery); while(!gi.IsEOF())
{ HTREEITEM hGroup=m_tree_list.InsertItem(gi.m_groupName); m_tree_list.SetItemData(hGroup,gi.m_id); CString strPeoPleQuery;
strPeoPleQuery.Format(\* FROM people WHERE
groupId=%d\
西北民族大学
29
VC++课程设计
CDatabase db2;
CPeople people(&db2);
people.Open(AFX_DB_USE_DEFAULT_TYPE,strPeoPleQuery); HTREEITEM hPeople; while(!people.IsEOF())
{ hPeople=m_tree_list.InsertItem(people.m_fullname,hGroup); m_tree_list.SetItemData(hPeople,people.m_id); people.MoveNext(); }
db2.Close();
gi.MoveNext(); }
void CCommunicationDlg::OnSelchangedTreeList(NMHDR* pNMHDR, pResult) {
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here HTREEITEM hItem=m_tree_list.GetSelectedItem(); if(hItem!=NULL)
{ if(m_tree_list.GetParentItem(hItem)==NULL) {
CollapseTree();
m_tree_list.Expand(hItem,TVE_EXPAND); m_tree_list.EnsureVisible(hItem); INTERFACECTRLDATA temp; SwitchData(temp,true);
GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_APPEND)->EnableWindow(TRUE); } else {
CDatabase db;
CPeople people(&db); CString strSql;
strSql.Format(\* FROM people id=%d\
people.Open(AFX_DB_USE_DEFAULT_TYPE,strSql); INTERFACECTRLDATA interfaceData; if(!people.IsEOF()) {
if(people.m_sex) {
interfaceData.bSex=true; }
西北民族大学
LRESULT* WHERE
30
VC++课程设计
else {
interfaceData.bSex=false; }
interfaceData.strCompany=people.m_company;
interfaceData.strHomeAddress=people.m_homeAddress; interfaceData.strMail=people.m_mail; interfaceData.strMemory=people.m_memory; interfaceData.strMobile=people.m_mobile; interfaceData.strMajor=people.m_major; interfaceData.strName=people.m_fullname; interfaceData.strGraduate=people.m_graduate; interfaceData.strCity=people.m_city; interfaceData.strQq=people.m_qq; }
SwitchData(interfaceData,true);
GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_APPEND)->EnableWindow(FALSE); } }
*pResult=0; }
void CCommunicationDlg::CollapseTree() {
HTREEITEM htiItem=m_tree_list.GetRootItem(); while(NULL!=htiItem) {
m_tree_list.Expand(htiItem,TVE_COLLAPSE);
htiItem=m_tree_list.GetNextSiblingItem(htiItem); } }
void CCommunicationDlg::SwitchData(INTERFACECTRLDATA &info, bool flag) {
if(flag) {
m_address=info.strHomeAddress; m_company=info.strCompany; m_mail=info.strMail; m_memory=info.strMemory; m_mobile=info.strMobile; m_city=info.strCity;
西北民族大学
31
VC++课程设计
m_name=info.strName;
m_graduate=info.strGraduate; m_major=info.strMajor; m_qq=info.strQq; if(info.bSex) {
m_sex=0; }
else {
m_sex=1; }
UpdateData(FALSE); } else {
UpdateData(TRUE);
info.strHomeAddress=m_address; info.strHomeAddress.TrimLeft(); info.strHomeAddress.TrimRight();
info.strCompany=m_company; info.strCompany.TrimLeft(); info.strCompany.TrimRight();
info.strMail=m_mail; info.strMail.TrimLeft(); info.strMail.TrimRight();
info.strMemory=m_memory; info.strMemory.TrimLeft(); info.strMemory.TrimRight();
info.strMobile=m_mobile; info.strMobile.TrimLeft(); info.strMobile.TrimRight();
info.strMajor=m_major; info.strMajor.TrimLeft(); info.strMajor.TrimRight();
info.strName=m_name; info.strName.TrimLeft();
西北民族大学
32
共分享92篇相关文档