📄 addman.cpp
字号:
// ADDMAN.cpp : implementation file
//
#include "stdafx.h"
#include "MYpro.h"
#include "ADDMAN.h"
#include "Access1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ADDMAN dialog
ADDMAN::ADDMAN(CWnd* pParent /*=NULL*/)
: CDialog(ADDMAN::IDD, pParent)
{
//{{AFX_DATA_INIT(ADDMAN)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void ADDMAN::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ADDMAN)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ADDMAN, CDialog)
//{{AFX_MSG_MAP(ADDMAN)
ON_BN_CLICKED(IDC_OK, OnOk)
ON_BN_CLICKED(IDC_CANNEL, OnCannel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ADDMAN message handlers
void ADDMAN::OnOk()
{
CString no;
CString name;
CString sex;
CString job;
CString birth;
CString cmd;
GetDlgItem(IDC_ADD_NO)->GetWindowText(no);
GetDlgItem(IDC_ADD_NAME)->GetWindowText(name);
GetDlgItem(IDC_ADD_SEX)->GetWindowText(sex);
GetDlgItem(IDC_ADD_JOB)->GetWindowText(job);
GetDlgItem(IDC_ADD_BIRTH)->GetWindowText(birth);
if(no==""||name==""||sex==""||job==""||birth=="") //用户密码任一为空返回
{
AfxMessageBox("请输入完整");
return;
}
cmd="insert into man values('"+no+"','"+name+"','"+sex+"','"+job+"','"+birth+"')";
// TODO: Add your control notification handler code here
Access* ac=new Access();
CoInitialize(NULL);
_RecordsetPtr _pRecordset;
try{
_pRecordset=ac->connect(cmd);
}
catch(_com_error e){
AfxMessageBox(e.ErrorMessage());
AfxMessageBox(e.Source());
AfxMessageBox(e.Description());
}
CoUninitialize();
AfxMessageBox("入库成功");
CDialog::OnOK();
}
void ADDMAN::OnCannel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -