📄 newcashdealdlg.cpp
字号:
// NewCashDealDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MoneyAnyWhere.h"
#include "NewCashDealDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewCashDealDlg dialog
CNewCashDealDlg::CNewCashDealDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNewCashDealDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewCashDealDlg)
m_strDealAccount = _T("");
m_iDealMoney = 0;
m_strCategory = _T("");
//}}AFX_DATA_INIT
}
void CNewCashDealDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewCashDealDlg)
DDX_Control(pDX, IDC_COMBO_CATEGORY, m_ctrComboBox);
DDX_Text(pDX, IDC_EDIT_DEALACCOUNT, m_strDealAccount);
DDX_Text(pDX, IDC_EDIT_DEALMONEY, m_iDealMoney);
DDX_CBString(pDX, IDC_COMBO_CATEGORY, m_strCategory);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewCashDealDlg, CDialog)
//{{AFX_MSG_MAP(CNewCashDealDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BTNHELP, OnBtnhelp)
ON_BN_CLICKED(IDC_BTNOK, OnBtnok)
ON_BN_CLICKED(IDC_BTNCANEL, OnBtncanel)
ON_EN_SETFOCUS(IDC_EDIT_DEALMONEY, OnSetfocusEditDealmoney)
ON_EN_KILLFOCUS(IDC_EDIT_DEALMONEY, OnKillfocusEditDealmoney)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewCashDealDlg message handlers
void CNewCashDealDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
this->GetClientRect(&rect);
CBrush *pBrush = new CBrush(COLORREF(RGB(222,215,181)));
dc.FillRect(rect,pBrush);
}
void CNewCashDealDlg::OnBtnhelp()
{
AfxMessageBox(L"帮助!");
}
void CNewCashDealDlg::OnBtnok()
{
UpdateData(true);
GetDlgItemText(IDC_DATETIMEPICKER_DEALDATE,m_strDealTime);
m_strInOrOut = Query(m_strCategory);
this->ShowWindow(SW_HIDE);
//CDialog::OnOK();
}
void CNewCashDealDlg::OnBtncanel()
{
CDialog::OnCancel();
}
BOOL CNewCashDealDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(!Init())
return false;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/*************************************************
函数功能:初始化INI文件
-------------------------------------------------
修改时间:2005-3-12
修改人: 宋雷
修改内容:m_pAccountTypeIni和m_pAccountTypeIni的初始化,同时将信息增加到ComboBox中
*************************************************/
BOOL CNewCashDealDlg::Init()
{
//m_ctrComboBox.DeleteAllItems();
// m_pAccountTypeIni = new CIniReader(L"\\Program Files\\理财能手\\Data\\DealType.ini");
// m_pAccountTypeIni2 = new CIniReader(L"\\Program Files\\理财能手\\Data\\DealType.ini");
m_pAccountTypeIni = new CIniReader(L"DealType.ini");
m_pAccountTypeIni2 = new CIniReader(L"DealType.ini");
CString strType;
//装载和解析INI文件
if(! m_pAccountTypeIni->Load())
{
::AfxMessageBox(L"Can not load ini");
delete m_pAccountTypeIni;
m_pAccountTypeIni = NULL;
return FALSE;
}
if(! m_pAccountTypeIni->Parse())
{
::AfxMessageBox(L"Invalid format ");
delete m_pAccountTypeIni;
m_pAccountTypeIni = NULL;
return FALSE;
}
CSection TypeInfo= (*m_pAccountTypeIni)[L"Info"];
POSITION _pos = TypeInfo.m_item.GetStartPosition();
while( _pos != NULL)
{
String _key;
String _value;
TypeInfo.m_item.GetNextAssoc(_pos, _key, _value);
if((CString)_key==(CString)"DealType_count") //获得该现金帐户一共有多少笔交易
{
m_iTypeCount = _wtoi(_value);
}
}
if(! m_pAccountTypeIni2->Load())
{
::AfxMessageBox(L"Can not load ini");
delete m_pAccountTypeIni2;
m_pAccountTypeIni2 = NULL;
return FALSE;
}
if(! m_pAccountTypeIni2->Parse())
{
::AfxMessageBox(L"Invalid format ini");
delete m_pAccountTypeIni2;
m_pAccountTypeIni2 = NULL;
return FALSE;
}
//AfxMessageBox(m_pAccountIni->GetFilePath());
for(int i=0;i<m_iTypeCount;i++)
{
CString str;
str.Format(L"%d",i);
CSection Info= (*m_pAccountTypeIni2)[str];
POSITION pos = Info.m_item.GetStartPosition();
while( pos != NULL )
{
String key;
String value;
// Get key ( string ) and value ( string )
Info.m_item.GetNextAssoc(pos, key, value);
if(key == "name")
strType = value ;
}
m_ctrComboBox.InsertString(i,strType);
}
}
/*************************************************
函数功能:根据收支类型返回是支出,还是收入
-------------------------------------------------
修改时间:2005-3-12
修改人: 宋雷
修改内容:根据收支类型返回是支出,还是收入
*************************************************/
CString CNewCashDealDlg::Query(CString strDealType)
{
int iPos =0;
CString str,str2;
for(int i=0;i<m_iTypeCount;i++)
{
str.Format(L"%d",i);
CSection Info= (*m_pAccountTypeIni2)[str];
POSITION pos = Info.m_item.GetStartPosition();
while( pos != NULL )
{
String key;
String value;
// Get key ( string ) and value ( string )
Info.m_item.GetNextAssoc(pos, key, value);
if((key == "name") && ((CString)value == strDealType))
{
iPos = i;
}
}
}
str.Format(L"%d",iPos);
(*m_pAccountTypeIni2)[str].m_item.Lookup(L"type",str2);
return str2;
}
void CNewCashDealDlg::OnSetfocusEditDealmoney()
{
SHSipPreference(m_hWnd, SIP_UP);
// TODO: Add your control notification handler code here
}
void CNewCashDealDlg::OnKillfocusEditDealmoney()
{
SHSipPreference(m_hWnd, SIP_DOWN);
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -