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

📄 flightqueryview.cpp

📁 EVC环境
💻 CPP
字号:
// FlightQueryView.cpp : implementation of the CFlightQueryView class
//
#include "MainFrm.h"
#include "BthSet.h"
#include "QueryView.h"
#include "stdafx.h"

#include "FlightQuery.h"

#include "FlightQueryDoc.h"
#include "FlightQueryView.h"

#include "IRecset.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern  CreateList(RECT rect,CString m_szSQL);
/////////////////////////////////////////////////////////////////////////////
// CFlightQueryView

IMPLEMENT_DYNCREATE(CFlightQueryView, CFormView)

BEGIN_MESSAGE_MAP(CFlightQueryView, CFormView)
	//{{AFX_MSG_MAP(CFlightQueryView)
//	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryView construction/destruction

CFlightQueryView::CFlightQueryView()
	: CFormView(CFlightQueryView::IDD)
{
	//{{AFX_DATA_INIT(CFlightQueryView)
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CFlightQueryView::~CFlightQueryView()
{
}

void CFlightQueryView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFlightQueryView)
//	DDX_Control(pDX, IDC_STATICOUT, m_StaticOut);
//	DDX_Control(pDX, IDC_STATICIN, m_StaticIn);
	//}}AFX_DATA_MAP
}

BOOL CFlightQueryView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryView diagnostics

#ifdef _DEBUG
void CFlightQueryView::AssertValid() const
{
	CFormView::AssertValid();
}

void CFlightQueryView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

//CFlightQueryDoc* CFlightQueryView::GetDocument() // non-debug version is inline
//{
//	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFlightQueryDoc)));
//	return (CFlightQueryDoc*)m_pDocument;
//}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryView message handlers

BOOL CFlightQueryView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}

void CFlightQueryView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
 	CString m_szSQL;
	CRect rect;
//	CButton m_Button;
//	BOOL b_temp;
	int n=0;			
		
	UpdateData(TRUE);
	CenterWindow(GetDesktopWindow());

//	CVORecordset rs(theApp.m_Conn);

	m_szSQL=_T("SELECT * FROM FLIGHT WHERE [A_or_D]=A");
//	m_StaticIn.GetClientRect(rect);
	rect.left=5;
	rect.top=23;
	rect.bottom=130;
	rect.right=235;

	CGridCtrl* m_pGridCtrl=NULL;		
	
	CVORecordset rs(theApp.m_Conn);
	
	rs.Open(m_szSQL, adOpenForwardOnly, adLockReadOnly);

	if(!rs.IsOpen() )
		AfxMessageBox(TEXT("Unable to execute command"));
	else
	{
		rs.MoveFirst();

		if(!rs.IsEOF() )	// If NOT at end of file
		{		
			CString strFieldName;
			CString strFieldValue;

			if (m_pGridCtrl == NULL)
			{
				// Create the Gridctrl object
	 			m_pGridCtrl = new CGridCtrl; 
				if (!m_pGridCtrl) return ;

				// Create the Gridctrl window	
	
				m_pGridCtrl->Create(rect, 
					this, 
					101);

				// fill it up with stuff
				m_pGridCtrl->SetEditable(TRUE);
				m_pGridCtrl->SetListMode(TRUE);
				m_pGridCtrl->SetHeaderSort(TRUE);
			//	m_pGridCtrl->EnableDragAndDrop(TRUE);
				m_pGridCtrl->SetRowResize(TRUE);
			//	m_pGridCtrl->GetColumnCount();
				

				m_pGridCtrl->SetRowCount(rs.GetRecordCount()+1);
				m_pGridCtrl->SetColumnCount(rs.GetFieldCount());
				m_pGridCtrl->SetFixedRowCount(1);
				m_pGridCtrl->SetFixedColumnCount(1);
				
				GV_ITEM Item;
				Item.mask = GVIF_TEXT|GVIF_FORMAT;
				Item.row = 0;
				Item.col = 0;
				int mm=rs.GetRecordCount();

				for(int i = 0; i < rs.GetFieldCount(); i++)
				{	
					Item.col = i;
					strFieldName = rs.GetFieldName(i);
					if(strFieldName=="operation_date")
						strFieldName="航班日期";
					
					if(strFieldName=="Flight_no")
						strFieldName="航班号";

					if(strFieldName=="aircraft_type_IATA")
						strFieldName="机型";

					if(strFieldName=="AC_REG_no")
						strFieldName="机号";

					if(strFieldName=="A_or_D")
						strFieldName="进/离港";

					if(strFieldName=="STD")
						strFieldName="计划起飞时间";

					if(strFieldName=="ETD")
						strFieldName="预计起飞时间";
	
					if(strFieldName=="ATD")
						strFieldName="实际起飞时间";

					if(strFieldName=="STA")
						strFieldName="计划落地时间";

					if(strFieldName=="ETA")
						strFieldName="预计落地时间";

					if(strFieldName=="ATA")
						strFieldName="实际落地时间";

					if(strFieldName=="gate")
						strFieldName="登机门";

					if(strFieldName=="airline_IATA")
						strFieldName="航空公司代码";

					if(strFieldName=="bay")
						strFieldName="机位";

					if(strFieldName=="actual_end_time")
						strFieldName="走廊实际结束时间";

					if(strFieldName=="abnormal_status")
						strFieldName="不正常状态";

					if(strFieldName=="delay_code")
						strFieldName="延误代码";

					if(strFieldName=="cause_of_delay")
						strFieldName="延误原因";

					if(strFieldName=="estimated_delay_time")
						strFieldName="延误时间";
	
					if(strFieldName=="actual_start_time")
						strFieldName="走廊实际开始时间";

					if(strFieldName=="terminal_no")
						strFieldName="航站楼";

					Item.nFormat = DT_LEFT|DT_WORDBREAK;	
					Item.strText.Format(strFieldName);
					m_pGridCtrl->SetItem(&Item);
					m_pGridCtrl->SetColumnWidth(i,50);
				}				

				while(!rs.IsEOF())
				{
					if(rs.GetFieldCount() < 1)
						break;
					m_pGridCtrl->SetRowHeight(n,17);
					n++;
					for(int i = 0; i < rs.GetFieldCount(); i++)
					{
						strFieldValue = rs.GetFieldValueString(i);
						Item.row = n;
						Item.col = i;
						if(i == 0)
							Item.nFormat = DT_RIGHT|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX;
						else						
							Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX;													
						Item.strText.Format(strFieldValue);							
						m_pGridCtrl->SetItem(&Item);
					}
					rs.MoveNext();
					
				}

				TRACE(TEXT("Field Count: %ld\n"), rs.GetFieldCount() );	

				m_pGridCtrl->SetFixedBkColor(RGB(150,150,250));

			}
		}
	}
//	m_StaticIn.DestroyWindow();
//	m_StaticIn.Create(_T("进港航班"),WS_BORDER|WS_TABSTOP|WS_VISIBLE,rect,this,101);
//	m_Button.Create(
//	b_temp = CreateList(rect,m_szSQL);			

	m_szSQL=_T("SELECT * FROM FLIGHT WHERE [A_or_D]=D");
//	m_StaticOut.GetClientRect(rect);
		
	rect.left=5;
	rect.right=235;
	rect.top=146;
	rect.bottom=260;	

	m_pGridCtrl=NULL;
	n=0;	
	rs.Open(m_szSQL, adOpenForwardOnly, adLockReadOnly);

	if(!rs.IsOpen() )
		AfxMessageBox(TEXT("Unable to execute command"));
	else
	{
		rs.MoveFirst();

		if(!rs.IsEOF() )	// If NOT at end of file
		{		
			CString strFieldName;
			CString strFieldValue;

			if (m_pGridCtrl == NULL)
			{
				// Create the Gridctrl object
	 			m_pGridCtrl = new CGridCtrl; 
				if (!m_pGridCtrl) return ;

				// Create the Gridctrl window	
	
				m_pGridCtrl->Create(rect, 
					this, 
					101);

				// fill it up with stuff
				m_pGridCtrl->SetEditable(TRUE);
				m_pGridCtrl->SetListMode(TRUE);
				m_pGridCtrl->SetHeaderSort(TRUE);
			//	m_pGridCtrl->EnableDragAndDrop(TRUE);
				m_pGridCtrl->SetRowResize(TRUE);
			//	m_pGridCtrl->GetColumnCount();
				

				m_pGridCtrl->SetRowCount(rs.GetRecordCount()+1);
				m_pGridCtrl->SetColumnCount(rs.GetFieldCount());
				m_pGridCtrl->SetFixedRowCount(1);
				m_pGridCtrl->SetFixedColumnCount(1);
				
				GV_ITEM Item;
				Item.mask = GVIF_TEXT|GVIF_FORMAT;
				Item.row = 0;
				Item.col = 0;
				int mm=rs.GetRecordCount();

				for(int i = 0; i < rs.GetFieldCount(); i++)
				{	
					Item.col = i;
					strFieldName = rs.GetFieldName(i);
					if(strFieldName=="operation_date")
						strFieldName="航班日期";
					
					if(strFieldName=="Flight_no")
						strFieldName="航班号";

					if(strFieldName=="aircraft_type_IATA")
						strFieldName="机型";

					if(strFieldName=="AC_REG_no")
						strFieldName="机号";

					if(strFieldName=="A_or_D")
						strFieldName="进/离港";

					if(strFieldName=="STD")
						strFieldName="计划起飞时间";

					if(strFieldName=="ETD")
						strFieldName="预计起飞时间";
	
					if(strFieldName=="ATD")
						strFieldName="实际起飞时间";

					if(strFieldName=="STA")
						strFieldName="计划落地时间";

					if(strFieldName=="ETA")
						strFieldName="预计落地时间";

					if(strFieldName=="ATA")
						strFieldName="实际落地时间";

					if(strFieldName=="gate")
						strFieldName="登机门";

					if(strFieldName=="airline_IATA")
						strFieldName="航空公司代码";

					if(strFieldName=="bay")
						strFieldName="机位";

					if(strFieldName=="actual_end_time")
						strFieldName="走廊实际结束时间";

					if(strFieldName=="abnormal_status")
						strFieldName="不正常状态";

					if(strFieldName=="delay_code")
						strFieldName="延误代码";

					if(strFieldName=="cause_of_delay")
						strFieldName="延误原因";

					if(strFieldName=="estimated_delay_time")
						strFieldName="延误时间";
	
					if(strFieldName=="actual_start_time")
						strFieldName="走廊实际开始时间";

					if(strFieldName=="terminal_no")
						strFieldName="航站楼";

					Item.nFormat = DT_LEFT|DT_WORDBREAK;	
					Item.strText.Format(strFieldName);
					m_pGridCtrl->SetItem(&Item);
					m_pGridCtrl->SetColumnWidth(i,50);
				}

				

				while(!rs.IsEOF())
				{
					if(rs.GetFieldCount() < 1)
						break;				
					m_pGridCtrl->SetRowHeight(n,17);
					n++;
					for(int i = 0; i < rs.GetFieldCount(); i++)
					{
						strFieldValue = rs.GetFieldValueString(i);
						Item.row = n;
						Item.col = i;
						if(i == 0)
							Item.nFormat = DT_RIGHT|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX;
						else						
							Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX;													
						Item.strText.Format(strFieldValue);							
						m_pGridCtrl->SetItem(&Item);
					}
					rs.MoveNext();
					
				}

				TRACE(TEXT("Field Count: %ld\n"), rs.GetFieldCount() );	

				m_pGridCtrl->SetFixedBkColor(RGB(150,150,250));

			}
		}
	}
//	b_temp = CreateList(rect,m_szSQL);

	// TODO: Add your specialized code here and/or call the base class

}

//void CFlightQueryView::OnButton1() 
//{
	// TODO: Add your control notification handler code here

//}

⌨️ 快捷键说明

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