// dagView.cpp : implementation of the CDagView class
//
#include "stdafx.h"
#include "dag.h"
#include <afxtempl.h>
#include "dagDoc.h"
#include "dagView.h"
#include "mainfrm.h"
#include "dagDetialView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-------------------------
extern CDagApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDagView
IMPLEMENT_DYNCREATE(CDagView, CListView)
BEGIN_MESSAGE_MAP(CDagView, CListView)
//{{AFX_MSG_MAP(CDagView)
ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemchanged)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDagView construction/destruction
CDagView::CDagView()
{
m_strTableName="sambios0101";
}
CDagView::~CDagView()
{
}
BOOL CDagView::PreCreateWindow(CREATESTRUCT& cs)
{
return CListView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDagView drawing
void CDagView::OnDraw(CDC* pDC)
{
CDagDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
void CDagView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& refListCtrl=GetListCtrl();
long dwStyleOld;
dwStyleOld = GetWindowLong(refListCtrl.m_hWnd, GWL_STYLE);
dwStyleOld |= LVS_REPORT|LVS_SHOWSELALWAYS;
SetWindowLong(refListCtrl.GetSafeHwnd(), GWL_STYLE,dwStyleOld);
dwStyleOld=refListCtrl.GetExtendedStyle();
dwStyleOld |= LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT;
refListCtrl.SetExtendedStyle(dwStyleOld);
FillData(refListCtrl);
}
/////////////////////////////////////////////////////////////////////////////
// CDagView printing
BOOL CDagView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDagView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
void CDagView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
/////////////////////////////////////////////////////////////////////////////
// CDagView diagnostics
#ifdef _DEBUG
void CDagView::AssertValid() const
{
CListView::AssertValid();
}
void CDagView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
CDagDoc* CDagView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDagDoc)));
return (CDagDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDagView message handlers
void CDagView::FillData(CListCtrl& refListCtrl)
{
refListCtrl.DeleteAllItems();
int nColumnCount = refListCtrl.GetHeaderCtrl()->GetItemCount();
// Delete all of the columns.
for (int i=0;i < nColumnCount;i++)
{
refListCtrl.DeleteColumn(0);
}
CString strSql="select * from "+m_strTableName;
_RecordsetPtr pRS;
FieldsPtr fldLoop = NULL;
_variant_t Index;
Index.vt=VT_I2;
pRS.CreateInstance(__uuidof(Recordset));
try
{
pRS->Open((LPCTSTR)strSql, // 查询表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
fldLoop = pRS->GetFields();
CArray<_bstr_t,_bstr_t> ColumnList;
for (i = 0; i < (int)fldLoop->GetCount(); i++)
{
Index.iVal=i;
_bstr_t ColName=fldLoop->GetItem(Index)->GetName();
ColumnList.Add(ColName);
refListCtrl.InsertColumn(i,(LPSTR)ColName,LVCFMT_LEFT,50);
// (int)fldLoop->GetItem(Index)->GetAttributes());
}
if(!pRS->BOF)
pRS->MoveFirst();
_variant_t var;
CString strValue;
i=0;
while(!pRS->adoEOF)
{
refListCtrl.InsertItem(i,"");
for(int j=0;j<ColumnList.GetSize();j++)
{
_bstr_t Col=ColumnList.GetAt(j);
var=pRS->GetCollect((const _variant_t)(Col));
if(var.vt != VT_NULL)
strValue = (LPCSTR)_bstr_t(var);
refListCtrl.SetItemText(i,j,strValue);
}
i++;
pRS->MoveNext();
}
}
int CDagView::GetColumnIndex(CListCtrl &ref,LPCTSTR strCol)
{
CHeaderCtrl * pHeader=ref.GetHeaderCtrl();
int nCount=pHeader->GetItemCount();
TCHAR lpBuffer[256];
bool fFound = false;
HDITEM hdi;
hdi.mask = HDI_TEXT;
hdi.pszText = lpBuffer;
hdi.cchTextMax = 256;
int index=-1;
for (int i=0;!fFound && (i < nCount);i++)
{
pHeader->GetItem(i, &hdi);
if (strcmp(hdi.pszText, strCol) == 0)
{
index=i;
fFound = true;
}
}
return index;
}
void CDagView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CListCtrl& refListCtrl=GetListCtrl();
if(pNMListView->uNewState&LVIS_SELECTED)
{
m_pkeys.RemoveAll();
m_pkeysMap.RemoveAll();
int iCurrent = pNMListView->iItem;
_RecordsetPtr pRSKeys;
pRSKeys.CreateInstance(__uuidof(Recordset));
CString strSql="sp_pkeys "+m_strTableName;
try
{
pRSKeys->Open((LPCTSTR)strSql, // 查询表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
if(!pRSKeys->BOF)
pRSKeys->MoveFirst();
_variant_t var;
while(!pRSKeys->adoEOF)
{
var=pRSKeys->GetCollect("COLUMN_NAME");
if(var.vt != VT_NULL)
{
m_pkeys.Add(_bstr_t(var));
int iSubItem=GetColumnIndex(refListCtrl,(LPSTR)_bstr_t(var));
CString strValue=refListCtrl.GetItemText(iCurrent,iSubItem);
m_pkeysMap.SetAt(_bstr_t(var),strValue);
}
pRSKeys->MoveNext();
}
}
UpdateDetialView();
*pResult = 0;
}
void CDagView::UpdateDetialView()
{
CMainFrame* pFrame=static_cast<CMainFrame*>(AfxGetMainWnd());
CDagDetialView* pDagDetialView=static_cast<CDagDetialView*>(pFrame->m_wndSplitter2.GetPane(1,0));
pDagDetialView->OnInitialUpdate();
}
没有合适的资源?快使用搜索试试~ 我知道了~
VC 操作 SQL Server 主从表.zip
共39个文件
h:9个
cpp:7个
ico:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 60 浏览量
2022-06-19
02:50:48
上传
评论
收藏 467KB ZIP 举报
温馨提示
vBulletin v3.6.3 GB2312简体中文语言包(含图片).zip
资源详情
资源评论
资源推荐
收起资源包目录
VC 操作 SQL Server 主从表.zip (39个子文件)
VC 操作 SQL Server 主从表
dag
DagDetialView.h 2KB
StdAfx.cpp 205B
dag.suo 9KB
dagDoc.h 1KB
dag.rc 12KB
dag.dsp 7KB
dag.cpp 5KB
SkinMagicLib.h 12KB
MainFrm.h 2KB
dag.h 1KB
dagDoc.cpp 1KB
DETOURS.lib 72KB
dag.clw 3KB
StdAfx.h 1KB
ClassTreeView.cpp 5KB
MainFrm.cpp 3KB
Resource.h 958B
ClassTreeView.h 2KB
SkinMagicLib.lib 1.17MB
dag.dsw 575B
res
dag.rc2 395B
OPENFOLDxp.ICO 3KB
dag.ico 1KB
CLSDFOLD.ICO 1KB
dagDoc.ico 1KB
CLSDFOLDxp.ICO 3KB
toolbar1.bmp 630B
Toolbar.bmp 1KB
OPENFOLD.ICO 1KB
Folder.bmp 2KB
dag.plg 1KB
DagDetialView.cpp 4KB
dag.sln 895B
dagView.cpp 6KB
dag.vcproj 8KB
dagView.h 2KB
Kromo.smf 33KB
dag.opt 52KB
sambios_数据库备份 915KB
共 39 条
- 1
programxh
- 粉丝: 17
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于OpenCV实现双目视觉测距系统完整源码+全部数据.zip
- Python爬虫是一种自动从互联网上提取信息的程序 要开始使用Python进行爬虫,你需要了解以下基础知识
- JavaScript 使用技巧.md
- 一个简单的Python爬虫实例,使用requests和BeautifulSoup库爬取网页标题和链接 我们将以爬取豆瓣电影为例
- 背多分组-塔斯汀商业画布.pdf
- INTRODUCTION TO OPERATIONS RESEARCH 11th Edition
- Note-TJF.txt
- EasyRoads3D Pro v3
- 数据挖掘AG的新闻文章语料库-100 万篇新闻文章的集合
- Linux操作系统实习实训周作业
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0