📄 airtime_ceview.cpp
字号:
// Airtime_CEView.cpp : implementation of the CAirtime_CEView class
//
#include "stdafx.h"
#include "Airtime_CE.h"
#include "Airtime_CEDoc.h"
#include "Airtime_CEView.h"
#include "initData.h"
#include "dbfengine.h"
#include "BeiZhuInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWordArray g_wStationsArray;
int m_nIsListAll;
int m_nStepNum;
int g_nTotalRecordNum=0;
int g_nTotalFieldNum;
PBYTE g_pFieldBuf=new BYTE[255+1];
CDbFile g_dbf;
/////////////////////////////////////////////////////////////////////////////
// CAirtime_CEView
IMPLEMENT_DYNCREATE(CAirtime_CEView, CFormView)
BEGIN_MESSAGE_MAP(CAirtime_CEView, CFormView)
//{{AFX_MSG_MAP(CAirtime_CEView)
ON_BN_CLICKED(IDC_BUTTON_Start, OnBUTTONStart)
ON_BN_CLICKED(IDC_BUTTON_Days, OnBUTTONDays)
ON_BN_CLICKED(IDC_BUTTON_Endstop, OnBUTTONEndstop)
ON_BN_CLICKED(IDC_BUTTON_Flightno, OnBUTTONFlightno)
ON_BN_CLICKED(IDC_BUTTON_ListAll, OnBUTTONListAll)
ON_BN_CLICKED(IDC_BUTTON_Next, OnBUTTONNext)
ON_BN_CLICKED(IDC_BUTTON_Prev, OnBUTTONPrev)
ON_BN_CLICKED(IDC_BUTTON_SearchAll, OnBUTTONSearchAll)
ON_CBN_SELENDOK(IDC_COMBO_Days, OnSelendokCOMBODays)
ON_WM_DESTROY()
ON_COMMAND(ID_BEIZHU, OnMenuitem32772)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAirtime_CEView construction/destruction
CAirtime_CEView::CAirtime_CEView()
: CFormView(CAirtime_CEView::IDD)
{
//{{AFX_DATA_INIT(CAirtime_CEView)
//}}AFX_DATA_INIT
// TODO: add construction code here
m_nStepNum=0;
m_nIsListAll=1;
}
CAirtime_CEView::~CAirtime_CEView()
{
}
void CAirtime_CEView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAirtime_CEView)
DDX_Control(pDX, IDC_LIST1, m_listctrl);
DDX_Text(pDX, IDC_EDIT1, m_s1);
DDX_Text(pDX, IDC_EDIT2, m_s2);
//}}AFX_DATA_MAP
}
BOOL CAirtime_CEView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CAirtime_CEView diagnostics
#ifdef _DEBUG
void CAirtime_CEView::AssertValid() const
{
CFormView::AssertValid();
}
void CAirtime_CEView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CAirtime_CEDoc* CAirtime_CEView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAirtime_CEDoc)));
return (CAirtime_CEDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CAirtime_CEView message handlers
void CAirtime_CEView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetDlgItem(IDC_BUTTON_Prev)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Start)->SetWindowText(arrButtonName[0]);
GetDlgItem(IDC_BUTTON_Endstop)->SetWindowText(arrButtonName[1]);
GetDlgItem(IDC_BUTTON_Days)->SetWindowText(arrButtonName[2]);
GetDlgItem(IDC_BUTTON_Flightno)->SetWindowText(arrButtonName[3]);
GetDlgItem(IDC_BUTTON_SearchAll)->SetWindowText(arrButtonName[4]);
GetDlgItem(IDC_BUTTON_ListAll)->SetWindowText(arrButtonName[5]);
GetDlgItem(IDC_BUTTON_Prev)->SetWindowText(arrButtonName[6]);
GetDlgItem(IDC_BUTTON_Next)->SetWindowText(arrButtonName[7]);
m_listctrl.AddColumn(arrColName[0],0);
m_listctrl.SetColumnWidth(0,60);
m_listctrl.AddColumn(arrColName[1],1);
m_listctrl.SetColumnWidth(1,80);
m_listctrl.AddColumn(arrColName[2],2);
m_listctrl.SetColumnWidth(2,60);
m_listctrl.AddColumn(arrColName[3],3);
m_listctrl.SetColumnWidth(3,65);
m_listctrl.AddColumn(arrColName[4],4);
m_listctrl.SetColumnWidth(4,60);
m_listctrl.AddColumn(arrColName[5],5);
m_listctrl.SetColumnWidth(5,60);
m_listctrl.AddColumn(arrColName[6],6);
m_listctrl.SetColumnWidth(6,60);
m_listctrl.AddColumn(arrColName[7],7);
m_listctrl.SetColumnWidth(7,60);
m_listctrl.AddColumn(arrColName[8],8);
m_listctrl.SetColumnWidth(8,60);
m_listctrl.AddColumn(arrColName[9],9);
m_listctrl.AddColumn(arrColName[10],10);
CString sInstallDir=g_dbf.GetExeDir();
TCHAR cc[200];
wsprintf(cc,_T("%s"),sInstallDir+_T("\\Airtime.tdf\0"));
if(!g_dbf.OpenDbf(cc))
{
AfxMessageBox(_T("Cannot open Airtime.tdf file!"));
SendMessage(WM_CLOSE);
return;
};
if(!g_dbf.InitHeadStructure())
{
AfxMessageBox(_T("Cannot read Airtime.tdf fileheader!"));
SendMessage(WM_CLOSE);
return;
};
g_nTotalFieldNum=g_dbf.GetFieldCount();
ShowAll();
int i;
CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Start);
pCombo->ResetContent();
for(i=0;i<MaxStartCount;i++)
pCombo->AddString(arrStart[i]);
pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Endstop);
pCombo->ResetContent();
for(i=0;i<MaxStartCount;i++)
pCombo->AddString(arrStart[i]);
pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Days);
pCombo->ResetContent();
for(i=0;i<MaxDaysCount;i++)
pCombo->AddString(arrDays[i]);
pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Flightno);
pCombo->ResetContent();
for(i=0;i<MaxFlightnoCount;i++)
pCombo->AddString(arrFlightno[i]);
}
void CAirtime_CEView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
// MoveWindow(0,0,260,320);
}
int CAirtime_CEView::StationIn(PBYTE cc,CString s)
{
int nRtn=0;
CString ss=cc;
int pos=ss.Find(s);
if(pos>-1)nRtn=1;
if(s=="")nRtn=1;
return nRtn;
}
int CAirtime_CEView::StationIn2(const char* cc,const char* c)
{
char* ptr=strstr(cc,c);
if(ptr==NULL)return 0;
return 1;
}
int CAirtime_CEView::DaysIn(PBYTE ccField,int nCurSel)
{
int nRtn=0;
CString ss=ccField;
TCHAR c[10];
wsprintf(c,_T("%d"),nCurSel);
CString s=c;
int pos=ss.Find(s);//c);
if(pos>-1)nRtn=1;
return nRtn;
}
void CAirtime_CEView::RefreshCtrl()
{
TCHAR cc[20];
int i,j,len;
CString s;
g_nTotalRecordNum=g_wStationsArray.GetSize();
wsprintf(cc,_T("%d"),g_nTotalRecordNum);
m_s2=cc;
int total=min(10,g_nTotalRecordNum);
if(total<1)
{
::MessageBox(GetSafeHwnd(),_T("没有找到要查找的记录!"),
_T(" 提示 !"),MB_OK);
m_s1=_T("0");
GetDlgItem(IDC_BUTTON_Start)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Endstop)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Days)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Flightno)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_SearchAll)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_ListAll)->EnableWindow(TRUE);
UpdateData(FALSE);
return ;
}
for(i=0;i<total;i++)
{
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,5,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,0,s);
for(j=1;j<3;j++)
{
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,j-1,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,j,s);
}
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,3,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,3,s);
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,4,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,4,s);
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,2,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,5,s);
for(j=6;j<g_nTotalFieldNum;j++)
{
len=g_dbf.ReadFieldStr(g_wStationsArray[i]+1,j,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,j,s);
}
}
if(total>=10)
{
m_s1=_T("1~");
GetDlgItem(IDC_BUTTON_Next)->EnableWindow(TRUE);
}
else
{
m_s1=_T("1~");//+m_s2;
}
GetDlgItem(IDC_BUTTON_Start)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Endstop)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Days)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Flightno)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_SearchAll)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_ListAll)->EnableWindow(TRUE);
UpdateData(FALSE);
}
void CAirtime_CEView::InitCtrl()
{
GetDlgItem(IDC_BUTTON_Prev)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Next)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Start)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Endstop)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Days)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Flightno)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_SearchAll)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_ListAll)->EnableWindow(FALSE);
m_nStepNum=0;
g_nTotalRecordNum=0;
m_s2=_T("0");
m_s1=_T("0");
m_listctrl.DeleteAllItems();
UpdateData(FALSE);
}
void CAirtime_CEView::ShowAll()
{
GetDlgItem(IDC_BUTTON_Prev)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_Next)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_Start)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_Endstop)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_Days)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_Flightno)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_SearchAll)->EnableWindow(0);
GetDlgItem(IDC_BUTTON_ListAll)->EnableWindow(0);
m_listctrl.DeleteAllItems();//99.7.7. Add
g_wStationsArray.RemoveAll();//99.7.7. Add
int i ,j ,len;
CString s;
TCHAR cc3[30];
g_nTotalRecordNum=g_dbf.GetRecordCount();
m_s1=_T("1~");
m_nStepNum=0;
wsprintf(cc3,_T("%d"),g_nTotalRecordNum);
m_s2=cc3;
int count=0;
for(i=0;i<g_dbf.GetRecordCount();i++)
{
g_wStationsArray.Add(count);
count++;
}
for(i=0;i<10;i++)
{
len=g_dbf.ReadFieldStr(i+1,5,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,0,s);
for(j=1;j<3;j++)
{
len=g_dbf.ReadFieldStr(i+1,j-1,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,j,s);
}
len=g_dbf.ReadFieldStr(i+1,3,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,3,s);
len=g_dbf.ReadFieldStr(i+1,4,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,4,s);
len=g_dbf.ReadFieldStr(i+1,2,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,5,s);
for(j=6;j<g_nTotalFieldNum;j++)
{
len=g_dbf.ReadFieldStr(i+1,j,g_pFieldBuf);
s=g_dbf.CharToWideChar(g_pFieldBuf,len);
s=MyMakeUpperAndRemoveSpaces(s);
m_listctrl.AddItem(i,j,s);
}
}
GetDlgItem(IDC_BUTTON_Prev)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_Next)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_Start)->EnableWindow(1);
GetDlgItem(IDC_BUTTON_Endstop)->EnableWindow(1);
GetDlgItem(IDC_BUTTON_Days)->EnableWindow(1);
GetDlgItem(IDC_BUTTON_Flightno)->EnableWindow(1);
GetDlgItem(IDC_BUTTON_SearchAll)->EnableWindow(1);
GetDlgItem(IDC_BUTTON_ListAll)->EnableWindow(1);
UpdateData(FALSE);
}
void CAirtime_CEView::OnBUTTONDays()
{
CString s;
CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Days);
int nCurSel=pCombo->GetCurSel();
if(nCurSel==CB_ERR)
{
return;
}
InitCtrl();
if(nCurSel==0)
{
m_nIsListAll=1;
}
else
m_nIsListAll=0;
int i=0;
int j;
TCHAR cc[20];
int len;
if(m_nIsListAll)
{
ShowAll();
return;
}
int count=0;
g_wStationsArray.RemoveAll();
DWORD l;
for(i=0;i<g_dbf.GetRecordCount();i++)
{
l=g_dbf.ReadFieldStr(i+1,2,g_pFieldBuf);
if(DaysIn(g_pFieldBuf,nCurSel))
{
g_wStationsArray.Add(count);
}
count++;
}
RefreshCtrl();
}
void CAirtime_CEView::OnBUTTONEndstop()
{
CString s;
CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Endstop);
int nCurSel=pCombo->GetCurSel();
if(nCurSel==CB_ERR)
{
pCombo->GetWindowText(s);
}
else
{
pCombo->GetLBText(nCurSel,s);
}
s=MyMakeUpperAndRemoveSpaces(s);
if(s=="")return;
UpdateList(2,s);
}
void CAirtime_CEView::OnBUTTONFlightno()
{
CString s;
CComboBox* pCombo=(CComboBox*)GetDlgItem(IDC_COMBO_Flightno);
int nCurSel=pCombo->GetCurSel();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -