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

📄 sec_dialog2.cpp

📁 对医院的药品进行管理
💻 CPP
字号:
// sec_dialog2.cpp : implementation file
//

#include "stdafx.h"
#include "医药管理系统.h"
#include "sec_dialog2.h"

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

/////////////////////////////////////////////////////////////////////////////
// sec_dialog dialog


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


void sec_dialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(sec_dialog)
	DDX_Control(pDX, IDC_LIST1, m_Grid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(sec_dialog, CDialog)
	//{{AFX_MSG_MAP(sec_dialog)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_WM_CANCELMODE()
	ON_WM_CAPTURECHANGED()
	ON_WM_CHAR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// sec_dialog message handlers

void sec_dialog::OnAppAbout() 
{
	// TODO: Add your command handler code here
	
}



void sec_dialog::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

void sec_dialog::OnCaptureChanged(CWnd *pWnd) 
{
	// TODO: Add your message handler code here
	
	CDialog::OnCaptureChanged(pWnd);
}

BOOL sec_dialog::OnInitDialog() 
{
	
	CDialog::OnInitDialog();
    	// TODO: Add extra initialization here
/*	m_Grid.SetExtendedStyle(LVS_EX_FLATSB
		|LVS_EX_FULLROWSELECT
		|LVS_EX_HEADERDRAGDROP
		|LVS_EX_ONECLICKACTIVATE
		|LVS_EX_GRIDLINES);*/
	 ::CoInitialize(NULL); 
	 UpdateData(true);
	m_Grid.ModifyStyle(0L,LVS_REPORT);
	m_Grid.ModifyStyle(0L,LVS_SINGLESEL);
	m_Grid.ModifyStyle(0L,LVS_SHOWSELALWAYS);
	m_Grid.ModifyStyle(0L,LVS_NOSORTHEADER);
    m_Grid.SetExtendedStyle(LVS_EX_GRIDLINES);

	m_Grid.InsertColumn(0,"编号",LVCFMT_LEFT,95,0);
	m_Grid.InsertColumn(1,"姓名",LVCFMT_LEFT,95,1);
	m_Grid.InsertColumn(2,"性别",LVCFMT_LEFT,95,2);
	m_Grid.InsertColumn(3,"职业",LVCFMT_LEFT,95,3);
	m_Grid.InsertColumn(4,"年龄",LVCFMT_LEFT,95,4);
	CString strname;
	try
	{
		strname.Format("Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Shujuku;Initial Catalog=shujuku");
		m_pConnection.CreateInstance("ADODB.Connection");
		_bstr_t strConnect=strname;
		m_pConnection->Open(strConnect,"","",adModeUnknown);
	}
	catch(_com_error e)
	{
		AfxMessageBox(e.Description());
	}
	_bstr_t bstrSQL = "select * from kjbdsjk order by 编号 desc";
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pRecordset->Open(bstrSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	while(!m_pRecordset->adoEOF)
	{
		m_Grid.InsertItem(0,"");
		m_Grid.SetItemText(0,0,(char*)(_bstr_t)m_pRecordset->GetCollect("编号"));
		m_Grid.SetItemText(0,1,(char*)(_bstr_t)m_pRecordset->GetCollect("姓名"));
		m_Grid.SetItemText(0,2,(char*)(_bstr_t)m_pRecordset->GetCollect("性别"));
		m_Grid.SetItemText(0,3,(char*)(_bstr_t)m_pRecordset->GetCollect("职业"));
		m_Grid.SetItemText(0,4,(char*)(_bstr_t)m_pRecordset->GetCollect("年龄"));
		m_pRecordset->MoveNext();
	}
	if(m_pRecordset!=NULL)
		m_pRecordset->Close();
	m_pConnection->Close();

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

void sec_dialog::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnChar(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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