?? inputdialog.cpp
字號:
// InputDialog.cpp : implementation file
//
#include "stdafx.h"
#include "Tally.h"
#include "InputDialog.h"
#include "Item.h"
#include "TallyDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInputDialog dialog
CInputDialog::CInputDialog(CWnd* pParent /*=NULL*/)
: CDialog(CInputDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CInputDialog)
m_dCost = 0.0;
m_Date = 0;
m_sName = _T("");
m_sRemark = _T("");
isChange = FALSE;
m_uiType = -1;
//}}AFX_DATA_INIT
}
void CInputDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInputDialog)
DDX_Text(pDX, IDC_COST, m_dCost);
DDX_DateTimeCtrl(pDX, IDC_DATE, m_Date);
DDX_Text(pDX, IDC_NAME, m_sName);
DDX_Text(pDX, IDC_REMARK, m_sRemark);
DDX_CBIndex(pDX, IDC_TYPE, m_uiType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInputDialog, CDialog)
//{{AFX_MSG_MAP(CInputDialog)
ON_BN_CLICKED(IDC_ADD_BOTTOM, OnAddItem)
ON_EN_CHANGE(IDC_COST, OnChangeCost)
ON_NOTIFY(DTN_DROPDOWN, IDC_DATE, OnDropdownDate)
ON_EN_CHANGE(IDC_NAME, OnChangeName)
ON_EN_CHANGE(IDC_REMARK, OnChangeRemark)
ON_CBN_DROPDOWN(IDC_TYPE, OnDropdownType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInputDialog message handlers
void CInputDialog::OnAddItem()
{
// TODO: Add your control notification handler code here
this->UpdateData();
if (m_sName.IsEmpty()){
AfxMessageBox("名稱不能為空!");
return;
}
if (m_dCost == 0) {
AfxMessageBox("金額不能為0");
return;
}
if (m_uiType ==-1) {
AfxMessageBox("請指定類型!");
return;
}
CWnd * pMain = AfxGetApp( )->m_pMainWnd;
CDocument * pActiveDoc = ((CMDIFrameWnd*)pMain)->MDIGetActive()->GetActiveDocument();
CItem item(this->m_sName,this->m_Date.GetDay(),this->m_dCost, m_sRemark,this->m_uiType);
((CTallyDoc*)pActiveDoc)->AddItem(this->m_Date.GetMonth(),item);
((CTallyDoc*)pActiveDoc)->UpdateAllViews(NULL);
AfxMessageBox("添加成功");
isChange = FALSE;
}
void CInputDialog::OnOK()
{
// TODO: Add extra validation here
int res;
if (isChange){
res = AfxMessageBox("當前數據尚未添加,是否添加?",MB_OKCANCEL);
if (res == IDOK) {
OnAddItem();
CDialog::OnOK();
}
else {
CDialog::OnCancel();
}
}
else
CDialog::OnOK();
}
void CInputDialog::OnChangeCost()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
isChange = TRUE;
}
void CInputDialog::OnDropdownDate(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
isChange = TRUE;
*pResult = 0;
}
void CInputDialog::OnChangeName()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
isChange = TRUE;
}
void CInputDialog::OnChangeRemark()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
isChange = TRUE;
}
void CInputDialog::OnDropdownType()
{
// TODO: Add your control notification handler code here
isChange = TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -