📄 deldvdinfodialog.cpp
字号:
// DelDVDInfoDialog.cpp : implementation file
//
#include "stdafx.h"
#include "Rent.h"
#include "DelDVDInfoDialog.h"
#include "connectionDB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDelDVDInfoDialog dialog
CDelDVDInfoDialog::CDelDVDInfoDialog(CWnd* pParent /*=NULL*/)
: CDialog(CDelDVDInfoDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CDelDVDInfoDialog)
m_date = _T("");
m_id = _T("");
m_name = _T("");
m_note = _T("");
m_num = _T("");
m_place = _T("");
//}}AFX_DATA_INIT
}
BOOL CDelDVDInfoDialog::OnInitDialog(){
CDialog::OnInitDialog();
m_DelBtn.EnableWindow(FALSE);
return TRUE;
}
void CDelDVDInfoDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDelDVDInfoDialog)
DDX_Control(pDX, IDC_DEL, m_DelBtn);
DDX_Text(pDX, IDC_DATE, m_date);
DDX_Text(pDX, IDC_DVDID, m_id);
DDX_Text(pDX, IDC_NAME, m_name);
DDX_Text(pDX, IDC_NOTE, m_note);
DDX_Text(pDX, IDC_NUM, m_num);
DDX_Text(pDX, IDC_PALCE, m_place);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDelDVDInfoDialog, CDialog)
//{{AFX_MSG_MAP(CDelDVDInfoDialog)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDelDVDInfoDialog message handlers
void CDelDVDInfoDialog::OnDel()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(IDYES == MessageBox("是否删除?","提示",MB_YESNO)){
CConnectionDB connect;
if(connect.GetConnectionPtr()==NULL){
connect.Connectiondb();
}
m_pConnection=connect.GetConnectionPtr();
_RecordsetPtr pRecordset;
pRecordset.CreateInstance(__uuidof(Recordset));
CString sql;
sql.Format("select * from DVDInfo where DVDID = '%s'",m_id);
HRESULT hr;
try{
pRecordset->Open(_variant_t(sql),m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
if(!pRecordset->adoEOF){
pRecordset->MoveFirst(); //移到首条记录
hr=pRecordset->Delete(adAffectCurrent); //删除当前记录
if(SUCCEEDED(hr)){
MessageBox("删除成功!","提示");
m_DelBtn.EnableWindow(FALSE);
}
if(FAILED(hr)){
MessageBox("删除失败!","提示");
}
}
}
catch(_com_error e){
MessageBox("删除失败!","提示");
}
pRecordset->Close();
pRecordset=NULL;
}
}
void CDelDVDInfoDialog::OnSearch()
{ // TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_id.IsEmpty()){
MessageBox("请输入DVD的编号","提示");
return;
}
CConnectionDB connect;
if(connect.GetConnectionPtr()==NULL){
connect.Connectiondb();
}
m_pConnection=connect.GetConnectionPtr();
_RecordsetPtr pRecordset;
pRecordset.CreateInstance(__uuidof(Recordset));
CString sql;
sql.Format("select * from DVDInfo where DVDID = '%s'",m_id);
_variant_t var;
HRESULT hr;
try{
hr=pRecordset->Open(_variant_t(sql),m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
if(SUCCEEDED(hr)){
var=pRecordset->GetCollect("DVDName");
if(var.vt!=VT_NULL)
m_name=(LPCSTR)_bstr_t(var);
var=pRecordset->GetCollect("OutDate");
if(var.vt!=VT_NULL)
m_date=(LPCSTR)_bstr_t(var);
var=pRecordset->GetCollect("Place");
if(var.vt!=VT_NULL)
m_place=(LPCSTR)_bstr_t(var);
var=pRecordset->GetCollect("DVDNum");
if(var.vt!=VT_NULL)
m_num=(LPCSTR)_bstr_t(var);
var=pRecordset->GetCollect("Note");
if(var.vt!=VT_NULL)
m_note=(LPCSTR)_bstr_t(var);
else
m_note=_T("");
m_DelBtn.EnableWindow(TRUE);
UpdateData(FALSE);
}
}catch(_com_error e){
MessageBox("没有找到相关信息","提示");
}
pRecordset->Close();
pRecordset=NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -