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

📄 sortwell.cpp

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

#include "stdafx.h"
#include "drawcli.h"
#include "SortWell.h"
#include "ADOConn.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSortWell dialog


CSortWell::CSortWell(CWnd* pParent /*=NULL*/)
	: CDialog(CSortWell::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSortWell)
	m_WellCount = _T("");
	//}}AFX_DATA_INIT
}


void CSortWell::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSortWell)
	DDX_Control(pDX, IDC_SORT_LISTWELLS, m_SortListWells);
	DDX_Control(pDX, IDC_SORT_LISTWELLS2, m_ListAll);
	DDX_Text(pDX, IDC_STATICCOUNT, m_WellCount);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSortWell, CDialog)
	//{{AFX_MSG_MAP(CSortWell)
	ON_LBN_DBLCLK(IDC_SORT_LISTWELLS, OnDblclkSortListwells)
	ON_LBN_DBLCLK(IDC_SORT_LISTWELLS2, OnDblclkSortListwells2)
	ON_BN_CLICKED(IDC_BUTTONADD, OnButtonadd)
	ON_BN_CLICKED(IDC_BUTTONREMOVE, OnButtonremove)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSortWell message handlers

void CSortWell::OnDblclkSortListwells() 
{
	// TODO: Add your control notification handler code here
		OnButtonremove() ;
}

void CSortWell::OnDblclkSortListwells2() 
{
	// TODO: Add your control notification handler code here
	OnButtonadd() ;
}

void CSortWell::OnButtonadd() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CString strSelAdd = "";
	int idx=m_ListAll.GetCurSel();
	if (idx == -1)
	{
		MessageBox("请在可用井中选择一个要添加的井!");
		return;
	}
	m_ListAll.GetText(idx,strSelAdd);
	int icnt = m_SortListWells.GetCount();
	//int k=-1;
	for(int i=0; i<icnt; i++)
	{
		CString strWell = "";
		m_SortListWells.GetText(i,strWell);
		if (strWell.Compare(strSelAdd)==0)
		{
			MessageBox("此井已经在剖面图中!");
			return;
		}
	}
	m_SortListWells.AddString(strSelAdd);
	m_ListAll.DeleteString(idx);
	
	m_WellCount.Format("井数:%d",m_SortListWells.GetCount());
	UpdateData(FALSE);
}

void CSortWell::OnButtonremove() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CString strSelDel = "";
	int idx=m_SortListWells.GetCurSel();
	if (idx == -1)
	{
		MessageBox("请在可用井中选择一个要删除的井!");
		return;
	}
	m_SortListWells.GetText(idx,strSelDel);
	int icnt = m_ListAll.GetCount();
	int k=-1;
	for(int i=0; i<icnt; i++)
	{
		CString strWell = "";
		m_ListAll.GetText(i,strWell);
		if (strWell.Compare(strSelDel)==0)
		{
			//MessageBox("此井已经在剖面图中!");
			k = i;
			break;
		}
	}
	if (k == -1) m_ListAll.AddString(strSelDel);
	m_SortListWells.DeleteString(idx);
	m_WellCount.Format("井数:%d",m_SortListWells.GetCount());
	UpdateData(FALSE);
}

BOOL CSortWell::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
//	SetWindowText(m_strTitle);
	// TODO: Add extra initialization here
	int icnt = m_ArrWellNO.GetSize();
	for(int i=0; i<icnt; i++)
	{
		m_SortListWells.AddString(m_ArrWellNO[i]);
	}
	m_WellCount.Format("井数:%d",icnt);
	GetListWell();
	//m_WellCount = "共有井:"+(char)icnt;
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CSortWell::GetListWell()
{
	//	UpdateData(TRUE);
	
	if (!m_sQKDY.IsEmpty() && m_sQKDY.Compare("")!=0)
	{
		_bstr_t vSQL;
		vSQL = "select distinct trim(jh) as jh from daa01 where qkdy='"+ m_sQKDY +"' order by jh";//查询出区块内的所有井
		_RecordsetPtr m_pRecordset = NULL;
		
		ADOConn m_AdoConn;
		m_AdoConn.OnInitADOConn();
		m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
		
		//返回各列的值
		if (m_pRecordset->ADOEOF)
		{
			if(m_pRecordset)
			{
				if(m_pRecordset->State == adStateOpen)
					m_pRecordset->Close();
			}
			m_AdoConn.ExitConnect();
			return ;
		}
		
		char charTempvar[16];
		while (!m_pRecordset->ADOEOF)
		{
			
			strcpy(charTempvar,"");
			strcpy(charTempvar, m_pRecordset->GetCollect("JH").operator _bstr_t().operator const char *());
			if (m_SortListWells.FindString(0,LPTSTR(charTempvar)) == -1)
				m_ListAll.AddString(LPTSTR(charTempvar));
			
			//m_ListWells.SetItemText(iIndex,0,(char*)_bstr_t(m_pRecordset->GetCollect("JH")));
			//m_ListWells.AddString((char*)_bstr_t(m_pRecordset->GetCollect("JH")));
			
			//iIndex++;
			m_pRecordset->MoveNext() ;
		}
		if(m_pRecordset)
			if(m_pRecordset->State == adStateOpen)
				m_pRecordset->Close();
			//str.Format("%d",i)
			//m_wellnum.Format("[%d]口井",iIndex);
			//断开与数据库的连接
			m_AdoConn.ExitConnect();
	}
	
	//	UpdateData(FALSE);
}
void CSortWell::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	m_ArrWellNO.RemoveAll();
	CString str;
	for(int i=0; i<m_SortListWells.GetCount(); i++)
	{
		m_SortListWells.GetText(i,str);
		m_ArrWellNO.Add(str);
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

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