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

📄 listwell.cpp

📁 连接oracle
💻 CPP
字号:
// ListWell.cpp : implementation file
//

#include "stdafx.h"
#include "drawcli.h"
#include "ListWell.h"


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

/////////////////////////////////////////////////////////////////////////////
// CListWell dialog

IMPLEMENT_DYNCREATE(CListWell, CDialog)

CListWell::CListWell(CWnd* pParent /*=NULL*/)
	: CDialog(CListWell::IDD, pParent)
{
	//{{AFX_DATA_INIT(CListWell)
	m_wellnum = _T("");
	//}}AFX_DATA_INIT
	m_pParent = pParent;
	m_nID = CListWell::IDD;
}


void CListWell::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListWell)
	DDX_Control(pDX, IDC_LW_LISTWELLS, m_listwells);
	DDX_Control(pDX, IDC_LW_LISTQKDY, m_listqkdy);
	DDX_Text(pDX, IDC_LW_WELLNUM, m_wellnum);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CListWell, CDialog)
	//{{AFX_MSG_MAP(CListWell)
	ON_LBN_SELCHANGE(IDC_LW_LISTQKDY, OnSelchangeLwListqkdy)
	ON_LBN_DBLCLK(IDC_LW_LISTWELLS, OnDblclkLwListwells)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
	ON_COMMAND(IDCANCEL, OnCancel)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListWell message handlers

BOOL CListWell::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//连接数据库
	//UpdateData(TRUE);
	
	m_AdoConn.OnInitADOConn();
	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = "select distinct qkdy from daa01";//查询出所有区块
	//执行SELETE语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

	//返回各列的值
	if (m_pRecordset->ADOEOF)
		return FALSE;
	//CWnd * m_LsCWnd;
	//m_LsCWnd = GetDlgItem(IDC_LW_LISTQKDY);
	//m_listqkdy.SetCurSel( 0 )
	while (!m_pRecordset->ADOEOF)
	{
		m_listqkdy.AddString((char*)_bstr_t(m_pRecordset->GetCollect("qkdy")));
		m_pRecordset->MoveNext() ;
	}
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
	m_listqkdy.SetCurSel(0);
	
	UpdateData(FALSE);
	GetListWell();
	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//选择了区块,得到此区块的井列表
void CListWell::OnSelchangeLwListqkdy() 
{
	// TODO: Add your control notification handler code here
	GetListWell();
}

void CListWell::OnCancel()
{
    DestroyWindow();
}

CListWell::~CListWell()
{
	m_AdoConn.ExitConnect();
	DestroyWindow();
}
//双击井的列表
void CListWell::OnDblclkLwListwells() 
{
	// TODO: Add your control notification handler code here
	//GetWellLink();
}
//根据选择了区块,得到此区块的井列表 CString pQkdy
void CListWell::GetListWell()
{
	
	UpdateData(TRUE);
	m_listwells.ResetContent();
	int i = m_listqkdy.GetCurSel();
	CString str = "";
	m_listqkdy.GetText(i,str );
	if (!str.IsEmpty() && "" != str)
	{
		_bstr_t vSQL;
		vSQL = "select * from daa01 where qkdy='"+ str +"' order by jh";//查询出区块内的所有井
		_RecordsetPtr m_pRecordset;
		
		m_AdoConn.OnInitADOConn();
		m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

		//返回各列的值
		if (m_pRecordset->ADOEOF)
		{
			m_AdoConn.ExitConnect();
			return ;
		}
	
		int iCnt = 0;
		while (!m_pRecordset->ADOEOF)
		{
			iCnt++;
			m_listwells.AddString((char*)_bstr_t(m_pRecordset->GetCollect("JH")));
			m_pRecordset->MoveNext() ;
		}
		//str.Format("%d",i)
		m_wellnum.Format("[%d]口井",iCnt);
		//断开与数据库的连接
		m_AdoConn.ExitConnect();
	}
	
	UpdateData(FALSE);
}
/*****************************************************************
//得到与列表指定井的相连通的井
//根据每一口井,得到其层数(及相关显示参数)将井的信息存放在数组中
******************************************************************/
void CListWell::GetWellLink()
{
	//CString str = m_listwells.GetCurSel();
	
}

void CListWell::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	//m_listwells.SetW
	/*CWnd   *   pWnd   =   GetDlgItem(IDC_LW_LISTWELLS);   
	if(NULL   !=   pWnd->GetSafeHwnd())   
	{   
		CRect   r;   
		GetClientRect(&r);   
		//r.right   /=   2;   
		//r.bottom   /=   5   ;   
		r.top /= 5;
		pWnd->MoveWindow(r);   
	}*/
	if(NULL   !=   m_listwells.GetSafeHwnd())   
	{   
		int   bx,by;   
		int   nWidht,nHeight;   
		CRect   r;   
		//得到起点横坐标和宽度   
		GetWindowRect(&r);   
		bx   =   0   ;   
		nWidht   =   r.Width() -10  ;///2   ;   
		
		CRect   rect;   
		GetClientRect(&rect);

		//得到取点纵坐标和高度   
		m_listwells.GetWindowRect(&r);   
		ScreenToClient(&r);   
		by   =   r.top   ;   
		nHeight   =   rect.bottom-r.top;//r.Height();   

		//CRect   rList(bx,by,bx   +   nWidht,by   +   nHeight);   
		CRect   rList(bx,by,bx   +   nWidht,by   +   nHeight);   
		m_listwells.MoveWindow(rList);
		
		CRect	rQkdy(0,0, bx + nWidht,161);
		m_listqkdy.MoveWindow(rQkdy);
	}   	
}

⌨️ 快捷键说明

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