📄 superwordsdlg.cpp
字号:
}
catch (CDBException *e)
{
AfxMessageBox(e->m_strError);
// not rethrowing, so delete exception
e->Delete();
delete *ppDatabase;
*ppDatabase = NULL;
}
catch (CMemoryException *e)
{
// output status
AfxMessageBox(_T("Failed to open database--Memory exception thrown."));
// not rethrowing, so delete exception
e->Delete();
delete *ppDatabase;
*ppDatabase = NULL;
// indicate fatal error
nReturnCode = -1;
}
return nReturnCode;
}
void CSuperWordsDlg::closeDatabase(CDatabase **ppDatabase)
{
// only process if the database object exists
if (*ppDatabase != NULL)
{
if ((*ppDatabase)->IsOpen())
(*ppDatabase)->Close();
// closing doesn't delete the object
delete *ppDatabase;
*ppDatabase = NULL;
}
}
void CSuperWordsDlg::RefreshData()
{
CString szTemp;
szTemp.Empty();
int nListIndex=0;
if(m_dataRecset != NULL)
{
//list group
m_dataRecset->MoveFirst();
while(!m_dataRecset->IsEOF())
{
m_list.InsertItem(nListIndex,LPSTR_TEXTCALLBACK);
m_list.SetItemText(nListIndex,0,m_dataRecset->m_name);
m_list.SetItemText(nListIndex,1,m_dataRecset->m_email);
m_list.SetItemText(nListIndex,2,m_dataRecset->m_oicq);
m_list.SetItemText(nListIndex,3,m_dataRecset->m_mobile);
m_list.SetItemText(nListIndex,4,m_dataRecset->m_phone);
m_list.SetItemText(nListIndex,5,m_dataRecset->m_birthday);
m_list.SetItemText(nListIndex,6,m_dataRecset->m_workunit);
m_list.SetItemText(nListIndex,7,m_dataRecset->m_homepage);
m_list.SetItemText(nListIndex,8,m_dataRecset->m_demo);
nListIndex++;
m_dataRecset->MoveNext();
}
}
}
void CSuperWordsDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
CloseDatabase() ;
}
void CSuperWordsDlg::OnButtonMember()
{
// TODO: Add your control notification handler code here
CCreateCardDialog dlg;
//dlg.DoModal();
if(dlg.DoModal()==IDOK)
{
m_dataRecset->AddNew ();
m_dataRecset->m_name=dlg.m_name;
m_dataRecset->m_email=dlg.m_email;
m_dataRecset->m_oicq=dlg.m_oicq;
m_dataRecset->m_mobile=dlg.m_mobile;
m_dataRecset->m_phone=dlg.m_phone;
m_dataRecset->m_birthday=dlg.m_birthday;
m_dataRecset->m_workunit=dlg.m_unit;
m_dataRecset->m_homepage=dlg.m_homepage;
m_dataRecset->m_demo=dlg.m_demo;
m_dataRecset->Update ();
int nListIndex = m_list.GetItemCount();
m_list.InsertItem(nListIndex,LPSTR_TEXTCALLBACK);
m_list.SetItemText(nListIndex,0,dlg.m_name);
m_list.SetItemText(nListIndex,1,dlg.m_email);
m_list.SetItemText(nListIndex,2,dlg.m_oicq);
m_list.SetItemText(nListIndex,3,dlg.m_mobile);
m_list.SetItemText(nListIndex,4,dlg.m_phone);
m_list.SetItemText(nListIndex,5,dlg.m_birthday);
m_list.SetItemText(nListIndex,6,dlg.m_unit);
m_list.SetItemText(nListIndex,7,dlg.m_homepage);
m_list.SetItemText(nListIndex,8,dlg.m_demo);
}
}
void CSuperWordsDlg::OnButtonFind()
{
// TODO: Add your control notification handler code here
CFindDlg dlg;
CString szItem,szValue,szFind;
int nIndex=0;
if(dlg.DoModal()==IDOK)
{
CSuperWordsApp *pApp = (CSuperWordsApp *)AfxGetApp();
szItem.Empty();
szItem = pApp->m_szSelectItem;
szValue.Empty();
szValue = pApp->m_szValue;
if(szItem=="姓名")
nIndex=1;
else if(szItem=="EMAIL")
nIndex=2;
else if(szItem=="OICQ")
nIndex=3;
else if(szItem=="手机号码")
nIndex=4;
else if(szItem=="电话号码")
nIndex=5;
else if(szItem=="生日")
nIndex=6;
else if(szItem=="工作单位")
nIndex=7;
else if(szItem=="个人主页")
nIndex=8;
else if(szItem=="备注")
nIndex=9;
BOOL bFind=FALSE;
int nItemFind=0;
m_dataRecset->MoveFirst();
while(!m_dataRecset->IsEOF())
{
switch(nIndex)
{
case 1:
if(m_dataRecset->m_name.Find(szValue)!=-1)
bFind=TRUE;
break;
case 2:
if(m_dataRecset->m_email.Find(szValue)!=-1)
bFind=TRUE;
break;
case 3:
if(m_dataRecset->m_oicq.Find(szValue)!=-1)
bFind=TRUE;
break;
case 4:
if(m_dataRecset->m_mobile.Find(szValue)!=-1)
bFind=TRUE;
break;
case 5:
if(m_dataRecset->m_phone.Find(szValue)!=-1)
bFind=TRUE;
break;
case 6:
if(m_dataRecset->m_birthday.Find(szValue)!=-1)
bFind=TRUE;
break;
case 7:
if(m_dataRecset->m_workunit.Find(szValue)!=-1)
bFind=TRUE;
break;
case 8:
if(m_dataRecset->m_homepage.Find(szValue)!=-1)
bFind=TRUE;
break;
case 9:
if(m_dataRecset->m_demo.Find(szValue)!=-1)
bFind=TRUE;
break;
}
if(bFind)
break;
m_dataRecset->MoveNext();
nItemFind++;
}
if(!bFind)
{
MessageBox("通讯录中没有此记录!","提示",MB_OK);
return;
}
m_dataRecset->MoveFirst();
m_dataRecset->Move( nItemFind, SQL_FETCH_RELATIVE );
// CSuperWorldApp *pApp = (CSuperWorldApp *)AfxGetApp();
pApp->m_bookData.szName = m_dataRecset->m_name ;
pApp->m_bookData.szEmail = m_dataRecset->m_email ;
pApp->m_bookData.szOicq = m_dataRecset->m_oicq ;
pApp->m_bookData.szMobile = m_dataRecset->m_mobile ;
pApp->m_bookData.szPhone = m_dataRecset->m_phone ;
pApp->m_bookData.szBirthday= m_dataRecset->m_birthday;
pApp->m_bookData.szWorkUnit= m_dataRecset->m_workunit;
pApp->m_bookData.szHomepage= m_dataRecset->m_homepage;
pApp->m_bookData.szDemo = m_dataRecset->m_demo ;
CPropertyDlg dlg;
if(dlg.DoModal()==IDOK)
{
m_dataRecset->Edit ();
m_dataRecset->m_name =dlg.m_name;
m_dataRecset->m_email =dlg.m_email;
m_dataRecset->m_oicq =dlg.m_oicq;
m_dataRecset->m_mobile =dlg.m_mobile;
m_dataRecset->m_phone =dlg.m_phone;
m_dataRecset->m_birthday =dlg.m_birthday;
m_dataRecset->m_workunit =dlg.m_unit;
m_dataRecset->m_homepage =dlg.m_homepage;
m_dataRecset->m_demo =dlg.m_demo;
m_dataRecset->Update ();
m_list.SetItemText(nItemFind,0,dlg.m_name);
m_list.SetItemText(nItemFind,1,dlg.m_email);
m_list.SetItemText(nItemFind,2,dlg.m_oicq);
m_list.SetItemText(nItemFind,3,dlg.m_mobile);
m_list.SetItemText(nItemFind,4,dlg.m_phone);
m_list.SetItemText(nItemFind,5,dlg.m_birthday);
m_list.SetItemText(nItemFind,6,dlg.m_unit);
m_list.SetItemText(nItemFind,7,dlg.m_homepage);
m_list.SetItemText(nItemFind,8,dlg.m_demo);
}
}
}
void CSuperWordsDlg::OnButtonEmail()
{
// TODO: Add your control notification handler code here
CSendMail dlg;
dlg.DoModal();
}
void CSuperWordsDlg::OnButtonDelete()
{
// TODO: Add your control notification handler code here
int nItem;
POSITION pos = m_list.GetFirstSelectedItemPosition();
if (pos == NULL)
{
MessageBox("请先选择所要删除的记录!","提示",MB_OK);
return;
}
else
{
nItem = m_list.GetNextSelectedItem(pos);
if(MessageBox("真的要删除此记录吗?","提示",MB_YESNO)==IDYES)
{
m_list.DeleteItem(nItem);
//delete database
m_dataRecset->MoveFirst();
m_dataRecset->Move( nItem, SQL_FETCH_RELATIVE );
if(m_dataRecset->CanUpdate())
{
m_dataRecset->Delete();
m_dataRecset->MoveNext();
}
}
}
}
void CSuperWordsDlg::OnButtonProperty()
{
// TODO: Add your control notification handler code here
int nItem;
POSITION pos = m_list.GetFirstSelectedItemPosition();
if (pos == NULL)
{
MessageBox("请先选择记录!","提示",MB_OK);
return;
}
else
{
nItem = m_list.GetNextSelectedItem(pos);
m_dataRecset->MoveFirst();
m_dataRecset->Move( nItem, SQL_FETCH_RELATIVE );
CSuperWordsApp *pApp = (CSuperWordsApp *)AfxGetApp();
pApp->m_bookData.szName = m_dataRecset->m_name ;
pApp->m_bookData.szEmail = m_dataRecset->m_email ;
pApp->m_bookData.szOicq = m_dataRecset->m_oicq ;
pApp->m_bookData.szMobile = m_dataRecset->m_mobile ;
pApp->m_bookData.szPhone = m_dataRecset->m_phone ;
pApp->m_bookData.szBirthday= m_dataRecset->m_birthday;
pApp->m_bookData.szWorkUnit= m_dataRecset->m_workunit;
pApp->m_bookData.szHomepage= m_dataRecset->m_homepage;
pApp->m_bookData.szDemo = m_dataRecset->m_demo ;
CPropertyDlg dlg;
if(dlg.DoModal()==IDOK)
{
m_dataRecset->Edit ();
m_dataRecset->m_name =dlg.m_name;
m_dataRecset->m_email =dlg.m_email;
m_dataRecset->m_oicq =dlg.m_oicq;
m_dataRecset->m_mobile =dlg.m_mobile;
m_dataRecset->m_phone =dlg.m_phone;
m_dataRecset->m_birthday =dlg.m_birthday;
m_dataRecset->m_workunit =dlg.m_unit;
m_dataRecset->m_homepage =dlg.m_homepage;
m_dataRecset->m_demo =dlg.m_demo;
m_dataRecset->Update ();
m_list.SetItemText(nItem,0,dlg.m_name);
m_list.SetItemText(nItem,1,dlg.m_email);
m_list.SetItemText(nItem,2,dlg.m_oicq);
m_list.SetItemText(nItem,3,dlg.m_mobile);
m_list.SetItemText(nItem,4,dlg.m_phone);
m_list.SetItemText(nItem,5,dlg.m_birthday);
m_list.SetItemText(nItem,6,dlg.m_unit);
m_list.SetItemText(nItem,7,dlg.m_homepage);
m_list.SetItemText(nItem,8,dlg.m_demo);
}
}
}
void CSuperWordsDlg::OnEmail()
{
// TODO: Add your command handler code here
CSendMail dlg;
dlg.DoModal();
}
void CSuperWordsDlg::OnButtonSystem()
{
// TODO: Add your control notification handler code here
CUserDlg Dlg;
Dlg.DoModal();
}
void CSuperWordsDlg::OnNotes()
{
// TODO: Add your command handler code here
CWorldDialog dlg;
dlg.DoModal();
}
void CSuperWordsDlg::OnAbout()
{
// TODO: Add your command handler code here
CAboutDlg dlg;
dlg.DoModal();
}
void CSuperWordsDlg::OnFontColor()
{
// TODO: Add your command handler code here
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();
m_list.SetTextColor(color);
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
}
}
void CSuperWordsDlg::OnBackColor()
{
// TODO: Add your command handler code here
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();
m_list.SetBkColor(color);
m_list.SetTextBkColor(color);
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
}
}
void CSuperWordsDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if(AfxMessageBox("确定要退出吗?",MB_YESNO)==IDYES)
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -