📄 info_show.cpp
字号:
// info_show.cpp : implementation file
//
#include "stdafx.h"
#include "file_handle.h"
#include "info_show.h"
#include "database_show.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// info_show dialog
info_show::info_show(CWnd* pParent /*=NULL*/)
: CDialog(info_show::IDD, pParent)
{
//{{AFX_DATA_INIT(info_show)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void info_show::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(info_show)
DDX_Control(pDX, IDC_LIST1, m_info_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(info_show, CDialog)
//{{AFX_MSG_MAP(info_show)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// info_show message handlers
BOOL info_show::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
DWORD dwStyle = m_info_list.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
dwStyle |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
//dwStyle |= LVS_EX_CHECKBOXES;//item前生成checkbox控件
m_info_list.SetExtendedStyle(dwStyle); //设置扩展风格
m_info_list.InsertColumn(0, "序号", LVCFMT_LEFT, 45 );//插入列
m_info_list.InsertColumn(1, "主机1", LVCFMT_LEFT, 120 );
m_info_list.InsertColumn(2, "区域号", LVCFMT_LEFT, 70);
m_info_list.InsertColumn(3, "代理1", LVCFMT_LEFT, 120 );
m_info_list.InsertColumn(4, "主机2", LVCFMT_LEFT, 120);
m_info_list.InsertColumn(5, "区域号", LVCFMT_LEFT, 70);
m_info_list.InsertColumn(6, "代理2", LVCFMT_LEFT, 120 );
m_info_list.InsertColumn(7, "代理集", LVCFMT_LEFT, 70);
m_info_list.InsertColumn(8, "会话开始时间", LVCFMT_LEFT, 140);
m_info_list.InsertColumn(9, "会话持续时间", LVCFMT_LEFT, 120);
database_show info;
info.DBConnect();
CDBVariant varValue;
CString str[5];
int js[4];
int nRow=0,no=1;
char nostr[3],js_ch[4][2];
CRecordset rs(&info.m_db);
rs.Open(CRecordset::dynaset,sql);
if(rs.GetRecordCount() != 0)
rs.MoveFirst();
while(!rs.IsEOF())
{
int temp = 0;
rs.GetFieldValue(temp,varValue);
str[0] = varValue.m_pstring->GetBuffer(1);
rs.GetFieldValue(1,varValue);
js[0] = varValue.m_chVal;
rs.GetFieldValue(2,varValue);
str[1] = varValue.m_pstring->GetBuffer(1);
rs.GetFieldValue(3,varValue);
str[2] = varValue.m_pstring->GetBuffer(1);
rs.GetFieldValue(4,varValue);
js[1] = varValue.m_chVal;
rs.GetFieldValue(5,varValue);
str[3] = varValue.m_pstring->GetBuffer(1);
rs.GetFieldValue(6,varValue);
js[2] = varValue.m_chVal;
rs.GetFieldValue(7,varValue);
str[4].Format("%d-%d-%d %d:%d:%d",varValue.m_pdate->year,varValue.m_pdate->month,varValue.m_pdate->day,varValue.m_pdate->hour,varValue.m_pdate->minute,varValue.m_pdate->second);
rs.GetFieldValue(8,varValue);
js[3] = varValue.m_iVal;
sprintf(nostr,"%d",no++);
m_info_list.InsertItem(nRow,nostr);
m_info_list.SetItemText(nRow,1,(LPSTR)(LPCTSTR)str[0]);
m_info_list.SetItemText(nRow,2,itoa(js[0],js_ch[0],10));
m_info_list.SetItemText(nRow,3,(LPSTR)(LPCTSTR)str[1]);
m_info_list.SetItemText(nRow,4,(LPSTR)(LPCTSTR)str[2]);
m_info_list.SetItemText(nRow,5,itoa(js[1],js_ch[1],10));
m_info_list.SetItemText(nRow,6,(LPSTR)(LPCTSTR)str[3]);
m_info_list.SetItemText(nRow,7,itoa(js[2],js_ch[2],10));
m_info_list.SetItemText(nRow,8,(LPSTR)(LPCTSTR)str[4]);
m_info_list.SetItemText(nRow,9,itoa(js[3],js_ch[3],10));
nRow++;
rs.MoveNext();
}
rs.Close();
info.m_db.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void info_show::transe(CString &s)
{
sql = s;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -