⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infodetaildlg.cpp

📁 这是本人的课程设计
💻 CPP
字号:
// InfoDetailDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Electric.h"
#include "InfoDetailDlg.h"

#include "afxdb.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CInfoDetailDlg dialog


CInfoDetailDlg::CInfoDetailDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInfoDetailDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInfoDetailDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CInfoDetailDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInfoDetailDlg)
	DDX_Control(pDX, IDC_USER_DETAIL, m_infoDetailList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInfoDetailDlg, CDialog)
	//{{AFX_MSG_MAP(CInfoDetailDlg)
	ON_UPDATE_COMMAND_UI(ID_ADMIN_LOGON, OnUpdateAdminLogon)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInfoDetailDlg message handlers

BOOL CInfoDetailDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	//add the column for the list
	m_infoDetailList.InsertColumn(0,"用户名",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(1,"手机号",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(2,"密码",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(3,"身份证",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(4,"余额",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(5,"资费套餐",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(6,"彩铃业务",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(7,"我的e家",LVCFMT_CENTER,100);
	m_infoDetailList.InsertColumn(8,"宽带上网",LVCFMT_CENTER,100);

	//put the record into s
	CDBVariant s0,s1,s2,s3,s4,s5,s6,s7,s8;
	//strTemp is for the record to string.
	CString strPhoneNo,strPhonePW,strIdentify,strName,strBalance,strFundLunge,strRing,strEHome,strNet;	 
	/*get field from database*/
	CDatabase db;
	//count the line
	//int nIndex = 0;
	db.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=ephone.mdb;");
	CRecordset *rs = new CRecordset(&db);
	rs->Open(CRecordset::snapshot,"select * from user",CRecordset::readOnly);
	while(!rs->IsEOF())
	{
		//get the name
		rs->GetFieldValue(short(0),s0);
		if(s0.m_dwType == DBVT_STRING)
		strName = *s0.m_pstring;
		//get the phoneNo.
		rs->GetFieldValue(short(1),s1);
		if(s1.m_dwType == DBVT_STRING)
		strPhoneNo = *s1.m_pstring;
		//get the phonePW
		rs->GetFieldValue(short(2),s2);
		if(s2.m_dwType == DBVT_STRING)
		strPhonePW = *s2.m_pstring;
		//get the identify no
		rs->GetFieldValue(short(3),s3);
		if(s3.m_dwType == DBVT_STRING)
		strIdentify = *s3.m_pstring;

		//get the balance
		rs->GetFieldValue(short(4),s4);
		if(s4.m_dwType == DBVT_STRING)
		strBalance = *s4.m_pstring;
		//get the fund lunge
		rs->GetFieldValue(short(5),s5);
		if(s5.m_dwType == DBVT_STRING)
		strFundLunge = *s5.m_pstring;
		//get the ring bussie
		rs->GetFieldValue(short(6),s6);
		if(s6.m_dwType == DBVT_STRING)
		strRing = *s6.m_pstring;
		//get the eHome content
		rs->GetFieldValue(short(7),s7);
		if(s7.m_dwType == DBVT_STRING)
		strEHome = *s7.m_pstring;

		//get net content
		rs->GetFieldValue(short(8),s8);
		if(s8.m_dwType == DBVT_STRING)
		strNet = *s8.m_pstring;

		//add content for the list
		int nIndex = m_infoDetailList.GetItemCount();
		LV_ITEM   lvitemAdd = {0};
		lvitemAdd.mask = LVIF_TEXT;
		lvitemAdd.iItem = nIndex ;
		lvitemAdd.iSubItem = 0;
		lvitemAdd.pszText =strName.GetBuffer(20);

		if (m_infoDetailList.InsertItem(&lvitemAdd) != -1)
		{ 
		   //add the 2nd item
		   LV_ITEM lvitem = {0};
		   lvitem.mask = LVIF_TEXT;
		   lvitem.iItem = nIndex ;
		   lvitem.iSubItem = 1;
		   lvitem.pszText =strPhoneNo.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem);   
	
		   //add the 3nd item
		   LV_ITEM lvitem1 = {0};
		   lvitem1.mask = LVIF_TEXT;
		   lvitem1.iItem = nIndex ;
		   lvitem1.iSubItem = 2;
		   lvitem1.pszText =strPhonePW.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem1);   
		   //add the 4nd item
		   LV_ITEM lvitem2 = {0};
		   lvitem2.mask = LVIF_TEXT;
		   lvitem2.iItem = nIndex ;
		   lvitem2.iSubItem = 3;
		   lvitem2.pszText =strIdentify.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem2);   

		   //add the 5nd item
		   LV_ITEM lvitem4 = {0};
		   lvitem4.mask = LVIF_TEXT;
		   lvitem4.iItem = nIndex ;
		   lvitem4.iSubItem = 4;
		   lvitem4.pszText =strBalance.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem4);   
	
		   //add the 6nd item
		   LV_ITEM lvitem5 = {0};
		   lvitem5.mask = LVIF_TEXT;
		   lvitem5.iItem = nIndex ;
		   lvitem5.iSubItem = 5;
		   lvitem5.pszText =strFundLunge.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem5);   
		   //add the 7nd item
		   LV_ITEM lvitem6 = {0};
		   lvitem6.mask = LVIF_TEXT;
		   lvitem6.iItem = nIndex ;
		   lvitem6.iSubItem = 6;
		   lvitem6.pszText =strRing.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem6); 
		   
		   //add the 8nd item
		   LV_ITEM lvitem7 = {0};
		   lvitem7.mask = LVIF_TEXT;
		   lvitem7.iItem = nIndex ;
		   lvitem7.iSubItem = 7;
		   lvitem7.pszText =strEHome.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem7);   
		   //add the 9nd item
		   LV_ITEM lvitem8 = {0};
		   lvitem8.mask = LVIF_TEXT;
		   lvitem8.iItem = nIndex ;
		   lvitem8.iSubItem = 8;
		   lvitem8.pszText =strNet.GetBuffer(20);
		   m_infoDetailList.SetItem(&lvitem8);   
		}
		nIndex++;
		rs->MoveNext();
	}
    rs->Close();
	db.Close();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CInfoDetailDlg::OnUpdateAdminLogon(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -