?? sortwell.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 + -