📄 browseinf.cpp
字号:
// BrowseInf.cpp : implementation file
//
#include "stdafx.h"
#include "PIM.h"
#include "BrowseInf.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowseInf dialog
CBrowseInf::CBrowseInf(CWnd* pParent /*=NULL*/)
: CDialog(CBrowseInf::IDD, pParent)
{
//{{AFX_DATA_INIT(CBrowseInf)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CBrowseInf::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBrowseInf)
DDX_Control(pDX, IDC_INFLIST, m_cInfList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBrowseInf, CDialog)
//{{AFX_MSG_MAP(CBrowseInf)
ON_BN_CLICKED(IDC_DELETEINF, OnDeleteinf)
ON_BN_CLICKED(IDC_REFURBISHINF, OnRefurbishinf)
ON_NOTIFY(NM_CLICK, IDC_INFLIST, OnClickInflist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBrowseInf message handlers
void CBrowseInf::OnDeleteinf()
{
// TODO: Add your control notification handler code here
if (theApp.m_pADOSet->State != adStateClosed)
{
theApp.m_pADOSet->Close();
}
CString delId;
CString delName;
_variant_t strQuery;
_variant_t holder;
delId=m_cInfList.GetItemText(m_IndexInFieldList,0);
delName=m_cInfList.GetItemText(m_IndexInFieldList,1);
strQuery="select * from 资料 where ID="+delId;
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
int iCount=theApp.m_pADOSet->GetRecordCount();
if(iCount==0)
{
AfxMessageBox("数据库里不存在该数据");
m_cInfList.DeleteItem( m_IndexInFieldList );
}
else
{
if(AfxMessageBox("你真要删除纪录:"+delName+"吗 ?",\
MB_YESNO|MB_ICONQUESTION)!=IDYES)
{
theApp.m_pADOSet->Close();
return;
}
if(theApp.m_pADOSet->Delete(adAffectCurrent) == S_OK)
{
m_cInfList.DeleteItem( m_IndexInFieldList );
AfxMessageBox(delName+"已经删除");
}
}
theApp.m_pADOSet->Close();
}
void CBrowseInf::OnRefurbishinf()
{
// TODO: Add your control notification handler code here
m_cInfList.DeleteAllItems();
_variant_t Holder, strQuery;
int ilistrow;
if (theApp.m_pADOSet->State != adStateClosed)
{
theApp.m_pADOSet->Close();
}
strQuery = "select * from 资料";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
int iCount=theApp.m_pADOSet->GetRecordCount();
if(iCount>0)
{
theApp.m_pADOSet->MoveFirst();
}
for(int i=0;i<iCount;i++)
{
Holder = theApp.m_pADOSet->GetCollect("ID");
ilistrow = m_cInfList.InsertItem(0,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("文件名");
m_cInfList.SetItemText(ilistrow,1,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("内容提要");
m_cInfList.SetItemText(ilistrow,2,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("路径");
m_cInfList.SetItemText(ilistrow,3,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->Close();
}
BOOL CBrowseInf::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_cInfList.SetBkColor(RGB(177, 151, 240));
m_cInfList.SetTextColor(RGB(0,0,0));
m_cInfList.SetTextBkColor(RGB(177, 151, 240));
m_cInfList.SetExtendedStyle(LVS_EX_FULLROWSELECT|\
LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);
m_cInfList.InsertColumn(0,"ID",LVCFMT_LEFT,40,-1);
m_cInfList.InsertColumn(1,"文件名",LVCFMT_LEFT,100,-1);
m_cInfList.InsertColumn(2,"内容提要",LVCFMT_LEFT,380,-1);
m_cInfList.InsertColumn(3,"路径",LVCFMT_LEFT,150,-1);
_variant_t Holder, strQuery;
int ilistrow;
if (theApp.m_pADOSet->State != adStateClosed)
{
theApp.m_pADOSet->Close();
}
strQuery = "select * from 资料";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
int iCount=theApp.m_pADOSet->GetRecordCount();
if(iCount>0)
{
theApp.m_pADOSet->MoveFirst();
}
for(int i=0;i<iCount;i++)
{
Holder = theApp.m_pADOSet->GetCollect("ID");
ilistrow = m_cInfList.InsertItem(0,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("文件名");
m_cInfList.SetItemText(ilistrow,1,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("内容提要");
m_cInfList.SetItemText(ilistrow,2,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
Holder = theApp.m_pADOSet->GetCollect("路径");
m_cInfList.SetItemText(ilistrow,3,\
Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBrowseInf::OnClickInflist(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos;
pos = m_cInfList.GetFirstSelectedItemPosition();
m_IndexInFieldList = m_cInfList.GetNextSelectedItem(pos);
int iItemCount;
iItemCount=m_cInfList.GetItemCount();
if(iItemCount==0)
{
return;
}
if(m_IndexInFieldList==-1)
{
return;
}
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -