📄 businfo.cpp
字号:
// BusInfo.cpp : implementation file
//
#include "stdafx.h"
#include "Toolmangne.h"
#include "BusInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBusInfo dialog
extern CString UserId;
extern CToolmangneApp theApp;
CBusInfo::CBusInfo(CWnd* pParent /*=NULL*/)
: CDialog(CBusInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CBusInfo)
m_pass = _T("");
m_addr = _T("");
m_tell = _T("");
//}}AFX_DATA_INIT
//init();
}
void CBusInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBusInfo)
DDX_Text(pDX, IDC_EDIT1, m_pass);
DDX_Text(pDX, IDC_EDIT2, m_addr);
DDX_Text(pDX, IDC_EDIT3, m_tell);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBusInfo, CDialog)
//{{AFX_MSG_MAP(CBusInfo)
ON_BN_CLICKED(IDOK, OnMoidey)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBusInfo message handlers
void CBusInfo::OnMoidey()
{
// TODO: Add your control notification handler code here
/*
UpdateData();
CString sql = "UPDATE Customer Set ID='"+UserId+"',Name='"+m_name+"',PassWord='"+m_pass+"',Address='"+m_addr+"',TeL='"+m_tell+"' WHERE ID="+UserId;
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
_variant_t RecordsAffected;
try
{
m_pRecordset->Open(_variant_t(sql), // 查询DemoTable表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(...)
{
AfxMessageBox("修改数据失败");
return ;
}
//m_pRecordset->Close();
//m_pRecordset = NULL;
//sql = "insert into Provider values ("+"+)";
*/
CString sql = "delete from Customer WHERE ID="+UserId;
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
_variant_t RecordsAffected;
try
{
m_pRecordset->Open(_variant_t(sql), // 查询DemoTable表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(...)
{
AfxMessageBox("修改数据失败");
return ;
}
insert();
}
void CBusInfo::init()
{
CString sql = "select * from Customer where ID ="+UserId;
// TODO: Add extra validation here
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open(_variant_t(sql), // 查询DemoTable表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
_variant_t var;
if(!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
else
{
//AfxMessageBox("没有你查找的数据");
return ;
}
// 读入库中各字段并加入列表框中
while(!m_pRecordset->adoEOF)
{
var = m_pRecordset->GetCollect("Name");
if(var.vt != VT_NULL)
m_name = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("PassWord");
if(var.vt != VT_NULL)
m_pass = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("Address");
if(var.vt != VT_NULL)
m_addr = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("TeL");
if(var.vt != VT_NULL)
m_tell = (LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
}
catch(...)
{
AfxMessageBox("装载失败");
return ;
}
UpdateData(false);
}
void CBusInfo::OnButton1()
{
init();
}
void CBusInfo::insert()
{
UpdateData();
_RecordsetPtr m_pRecordset;
CString sql = "insert into Customer values('"+UserId+"','"+m_name+"','"+m_pass+"','"+m_addr+"','"+m_tell+"')";
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open(_variant_t(sql), // 查询DemoTable表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(...)
{
AfxMessageBox("修改数据失败");
return ;
}
AfxMessageBox("修改数据成功");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -