📄 dlgaddbus.cpp
字号:
// DlgAddBus.cpp : implementation file
//
#include "stdafx.h"
#include "Ticket.h"
#include "DlgAddBus.h"
#include "MainFrm.h"
#include "TicketDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgAddBus dialog
CDlgAddBus::CDlgAddBus(CWnd* pParent /*=NULL*/)
: CDialog(CDlgAddBus::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgAddBus)
m_BusNumber = 0;
m_City = _T("");
m_Hour = 0;
m_Minute = 0;
m_SeatTotal = 0;
m_Date = -1;
//}}AFX_DATA_INIT
}
void CDlgAddBus::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgAddBus)
DDX_Text(pDX, IDC_EDIT_BUSNUMBER, m_BusNumber);
DDV_MinMaxInt(pDX, m_BusNumber, 1, 2147483647);
DDX_Text(pDX, IDC_EDIT_CITY, m_City);
DDV_MaxChars(pDX, m_City, 10);
DDX_Text(pDX, IDC_EDIT_HOUR, m_Hour);
DDV_MinMaxInt(pDX, m_Hour, 0, 23);
DDX_Text(pDX, IDC_EDIT_MINUTE, m_Minute);
DDV_MinMaxInt(pDX, m_Minute, 0, 59);
DDX_Text(pDX, IDC_EDIT_SEATTOTAL, m_SeatTotal);
DDV_MinMaxInt(pDX, m_SeatTotal, 1, 999);
DDX_CBIndex(pDX, IDC_COMBO_DATE, m_Date);
//}}AFX_DATA_MAP
if(pDX->m_bSaveAndValidate&&m_City.IsEmpty()){
AfxMessageBox("请输入终点城市!");
pDX->Fail();
}
}
BEGIN_MESSAGE_MAP(CDlgAddBus, CDialog)
//{{AFX_MSG_MAP(CDlgAddBus)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgAddBus message handlers
void CDlgAddBus::CheckTime()
{
CComboBox* pCmb=(CComboBox*)GetDlgItem(IDC_COMBO_DATE);
pCmb->ResetContent();
CTime timenow=CTime::GetCurrentTime();
CString str;
CBusManager& BM=((CTicketDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument())->m_BusManager;
bool flag=true;
if(timenow.GetYear()>BM.m_FoundTime.GetYear())
flag=false;
else if(timenow.GetMonth()>BM.m_FoundTime.GetMonth())
flag=false;
else if(timenow.GetDay()>BM.m_FoundTime.GetDay())
flag=false;
if(flag){
str.Format("%d / %d / %d",timenow.GetYear(),timenow.GetMonth(),timenow.GetDay());
pCmb->AddString(str);
m_Time[0]=timenow;
timenow+=86400;
str.Format("%d / %d / %d",timenow.GetYear(),timenow.GetMonth(),timenow.GetDay());
pCmb->AddString(str);
m_Time[1]=timenow;
timenow+=86400;
str.Format("%d / %d / %d",timenow.GetYear(),timenow.GetMonth(),timenow.GetDay());
pCmb->AddString(str);
m_Time[2]=timenow;
}else{
timenow+=172800;
str.Format("%d / %d / %d",timenow.GetYear(),timenow.GetMonth(),timenow.GetDay());
pCmb->AddString(str);
m_Time[0]=timenow;
}
m_Date=0;
UpdateData(false);
}
void CDlgAddBus::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
CheckTime();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -