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

📄 flightquery.cpp

📁 EVC环境
💻 CPP
字号:
// FlightQuery.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "FlightQuery.h"

#include "MainFrm.h"
#include "GridCtrl.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

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryApp

BEGIN_MESSAGE_MAP(CFlightQueryApp, CWinApp)
	//{{AFX_MSG_MAP(CFlightQueryApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryApp construction

CFlightQueryApp::CFlightQueryApp()
	: CWinApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CFlightQueryApp object

CFlightQueryApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryApp initialization

BOOL CFlightQueryApp::InitInstance()
{
	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));


	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CFlightQueryDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CFlightQueryView));
	AddDocTemplate(pDocTemplate);
	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();		// Added for WCE apps
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CFlightQueryApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CFlightQueryApp commands
// Added for WCE apps

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CenterWindow();

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

BOOL CreateList(RECT rect, CString m_szSQL)
{
	int n=0;
	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 FALSE;

				// Create the Gridctrl window	
				CWnd *pParent;			
	//			* pParent = GetWindow();
				m_pGridCtrl->Create(rect, 
					pParent, 
					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);
				}

				

				while(!rs.IsEOF())
				{
					if(rs.GetFieldCount() < 1)
						break;
					
					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->SetColumnWidth(0,30);
				m_pGridCtrl->SetColumnWidth(1,35);
				m_pGridCtrl->SetColumnWidth(2,40);

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

			}
		}
	}
	return TRUE;
}

⌨️ 快捷键说明

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