⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addbumen.cpp

📁 管理类软件,入门咯.公司管理系统MFC开发设计,轻松学会
💻 CPP
字号:
// ADDBUMEN.cpp : implementation file
//

#include "stdafx.h"
#include "B05050727.h"
#include "ADDBUMEN.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CADDBUMEN dialog


CADDBUMEN::CADDBUMEN(CWnd* pParent /*=NULL*/)
	: CDialog(CADDBUMEN::IDD, pParent)
{
	//{{AFX_DATA_INIT(CADDBUMEN)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CADDBUMEN::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CADDBUMEN)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CADDBUMEN, CDialog)
	//{{AFX_MSG_MAP(CADDBUMEN)
	ON_BN_CLICKED(IDOK, OnADDBUMEN)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CADDBUMEN message handlers

void CADDBUMEN::OnADDBUMEN() 
{
	// TODO: Add your control notification handler code here
	CString str1,str2,str3,str4,str5,str6;
	GetDlgItemText(IDC_EDIT1,str1);
	GetDlgItemText(IDC_EDIT2,str2);
	GetDlgItemText(IDC_EDIT3,str3);
	
	CoInitialize(NULL);
	_ConnectionPtr pconnect(__uuidof(Connection));
	_CommandPtr comd(__uuidof(Command));
	pconnect->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=人事";
	pconnect->Open("","","",NULL);
	comd->put_ActiveConnection(_variant_t((IDispatch *)pconnect));
	CString cmd="INSERT INTO 部门 values('";
	cmd+=str1;   cmd+="','";    cmd+=str2;    cmd+="','";   cmd+=str3;	cmd+="')";

	comd->CommandText=_bstr_t(cmd);
	comd->Execute(NULL,NULL,adCmdText);
	
	pconnect->Close();
	comd.Release();
	pconnect.Release();
	CoUninitialize();
	AfxMessageBox("添加成功");
	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -