📄 modifydlg.cpp
字号:
// ModifyDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Address.h"
#include "ModifyDlg.h"
#include "PersonSet.h"
#include "MainDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModifyDlg dialog
CModifyDlg::CModifyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CModifyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CModifyDlg)
m_modname = _T("");
m_modsex = _T("");
m_modtelephone = _T("");
m_modhandphone = _T("");
m_modaddress = _T("");
m_modworkplace = _T("");
m_modemail = _T("");
m_modoicq = _T("");
m_modid = 0;
m_modrelation = _T("");
//}}AFX_DATA_INIT
}
void CModifyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModifyDlg)
DDX_Text(pDX, IDC_EDIT8, m_modid);
DDX_Text(pDX, IDC_EDIT1, m_modname);
DDX_CBString(pDX, IDC_COMBO1, m_modsex);
DDX_Text(pDX, IDC_EDIT9, m_modrelation);
DDX_Text(pDX, IDC_EDIT2, m_modtelephone);
DDX_Text(pDX, IDC_EDIT3, m_modhandphone);
DDX_Text(pDX, IDC_EDIT4, m_modaddress);
DDX_Text(pDX, IDC_EDIT5, m_modworkplace);
DDX_Text(pDX, IDC_EDIT6, m_modemail);
DDX_Text(pDX, IDC_EDIT7, m_modoicq);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModifyDlg, CDialog)
//{{AFX_MSG_MAP(CModifyDlg)
ON_BN_CLICKED(IDC_CLEAR_BUTTON, OnClearButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModifyDlg message handlers
void CModifyDlg::OnOK()
{
//TODO: Add extra validation here
UpdateData(TRUE);
CPersonSet m_recordset;
CString strSQL;
CMainDlg dlg;
if(!m_modname.IsEmpty())
{
strSQL.Format("update person set NAME='%s',SEX='%s',RELATION='%s',TELEPHONE='%s',HANDPHONE='%s',ADDRESS='%s',WORKPLACE='%s',EMAIL='%s',OICQ='%s' where ID=%d"
,m_modname,m_modsex,m_modrelation,m_modtelephone,m_modhandphone,m_modaddress,m_modworkplace,m_modemail,m_modoicq,m_modid);
m_database.ExecuteSQL(strSQL);
m_database.Close();
CDialog::OnOK();
}
else
{
MessageBox("“姓名”项不可以为空!","提示",MB_OK|MB_ICONINFORMATION);
}
}
void CModifyDlg::OnClearButton()
{
// TODO: Add your control notification handler code here
if(MessageBox("是否真的要清空?","提示",MB_YESNO|MB_ICONQUESTION)==IDYES)
{
CEdit* m_pmodid=(CEdit*)GetDlgItem(IDC_EDIT8);
//m_pmodid->SetWindowText("");
//m_modname.Empty();
//m_modsex.Empty();
m_modrelation.Empty();
m_modtelephone.Empty();
m_modhandphone.Empty();
m_modemail.Empty();
m_modaddress.Empty();
m_modworkplace.Empty();
m_modoicq.Empty();
UpdateData(FALSE);
}
}
void CModifyDlg::OnCancel()
{
// TODO: Add extra cleanup here
//m_database.Close();
CDialog::OnCancel();
}
BOOL CModifyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -