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

📄 update.cpp

📁 VC进行数据库编程
💻 CPP
字号:
// Update.cpp : implementation file
//

#include "stdafx.h"
#include "Tele.h"
#include "Update.h"
#include "brow.h"

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

/////////////////////////////////////////////////////////////////////////////
// CUpdate dialog


CUpdate::CUpdate(CWnd* pParent /*=NULL*/)
	: CDialog(CUpdate::IDD, pParent)

{
	//{{AFX_DATA_INIT(CUpdate)
	m_strName = _T("");
	m_strTele = _T("");
	m_strRemarks = _T("");
	m_strSignal = _T("");
	//}}AFX_DATA_INIT
}


void CUpdate::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUpdate)
	DDX_Text(pDX, IDC_EDIT1, m_strName);
	DDX_Text(pDX, IDC_EDIT2, m_strTele);
	DDX_Text(pDX, IDC_EDIT3, m_strRemarks);
	DDX_Text(pDX, IDC_EDIT4, m_strSignal);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUpdate, CDialog)
	//{{AFX_MSG_MAP(CUpdate)
	ON_BN_CLICKED(IDC_BUTTON_UPDATE, OnButtonUpdate)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUpdate message handlers

void CUpdate::OnButtonUpdate() 
{
	UpdateData(TRUE);
	
		if ( (strcmp(m_strName,"") == 0) || (strcmp(m_strTele,"") == 0) || (strcmp(m_strSignal,"") == 0)  )
	{
		AfxMessageBox("信息不全");
		return;
	}


	CString strSql

	= "UPDATE telelist SET name = '"
	+ m_strName +
	"',tele ='"
	+ m_strTele +
	"',remarks='"
	+ m_strRemarks +
	"' WHERE ID ="
	+ m_strSignal;  

	((static_cast<CTeleApp *>(AfxGetApp()))->g_pDb)->Execute(strSql);

	AfxMessageBox("更新完毕");

}



BOOL CUpdate::OnInitDialog()
{
	CDialog::OnInitDialog();

	CADORecordset* pRs = new CADORecordset(CTeleApp::g_pDb);
	CString TempSql;
	
	if(pRs->Open( (LPCTSTR) ("SELECT *  FROM telelist where ID =" + CBrow::g_strItem) ) )
		
		
	pRs->GetFieldValue("name",m_strName);
		
	pRs->GetFieldValue("tele",m_strTele);
	
	pRs->GetFieldValue("remarks",m_strRemarks);
		
	pRs->GetFieldValue("ID",m_strSignal);
		
	pRs->Close();
		
	delete pRs;	

	UpdateData(FALSE);

	return TRUE;
}

⌨️ 快捷键说明

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