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

📄 module1dlg.cpp

📁 该项目是为PPC(PocketPc)使用者提供方便的理财事务.如,现金的借贷,债务处理,证券买卖,以及物品管 理等等。该项目的主要用户群是:PPC使用者.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Module1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "MoneyAnyWhere.h"
#include "Module1Dlg.h"
#include "MoneyAnyWhereView.h"
#include "Account.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//
int	g_iSum=0;
int MAX_ACCOUNT=0;
CAccount *pAccount;
/////////////////////////////////////////////////////////////////////////////
// CModule1Dlg dialog


CModule1Dlg::CModule1Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModule1Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModule1Dlg)
	//}}AFX_DATA_INIT
	m_pParent=pParent;

}


void CModule1Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModule1Dlg)
	DDX_Control(pDX, IDC_LIST_CASH, m_ctrAccountList);
	DDX_Control(pDX, IDC_BTNOPERATION, m_btnOper);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModule1Dlg, CDialog)
	//{{AFX_MSG_MAP(CModule1Dlg)
	ON_COMMAND(ID_MENUBTN_MODIFYACCOUNT, OnModify)
	ON_COMMAND(ID_MENUBTN_ADDACCOUNT, OnAdd)
	ON_COMMAND(ID_MENUBTN_DELACCOUNT, OnDelete)
	ON_WM_PAINT()
	ON_WM_DESTROY()
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_CASH, OnDblclkListCash)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModule1Dlg message handlers
/*************************************************
函数功能:初始化对话框,完成颜色填充,控件初始化等操作

-------------------------------------------------
修改时间:2005-3-8
修改人:  宋雷
修改内容:按钮,列表控件的初始化

修改时间:2005-3-10
修改人:  宋雷
修改内容:增加了对INI和文件的初始化
*************************************************/
BOOL CModule1Dlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_btnClose.SetIcon(IDI_CLOSE, CSize(16, 16));
	m_btnClose.SetFlat(FALSE);

	m_btnOper.SetMenu(IDR_MENUBTN_ACCOUNT, m_hWnd);
	m_btnOper.SetFlat(FALSE);

	//改变列表的背景色
	m_ctrAccountList.SetBkColor(COLORREF(RGB(251,251,249)));
	m_ctrAccountList.SetExtendedStyle(LVS_EX_FULLROWSELECT);//|LVS_EX_GRIDLINES);
	//设置表头格式为Account/Name/Date
	m_ctrAccountList.SetHeadings(_T("帐户名,60;帐户类型,60;币种,60;金额,60"));
	//宽度设置
	m_ctrAccountList.SetColumnWidth(0,80);
	m_ctrAccountList.SetColumnWidth(1,40);
	m_ctrAccountList.SetColumnWidth(2,50);
	m_ctrAccountList.SetColumnWidth(3,70);
	//数据添加
	//m_ctrAccountList.AddItem(_T("宋雷的现金"),_T("现金"),_T("人民币"),_T("98225"));
	//m_ctrAccountList.AddItem(_T("姚明的现金"),_T("现金"),_T("美元"),_T("923325"));
	//设置背景色,列向索引/横向索引/字体颜色/字体背景色
	m_ctrAccountList.SetItemColor(0,1,RGB(255,0,0),RGB(90,125,90));
	
	if(!Init())
		return false;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
/*************************************************
函数功能:改变对话框背景色,并显示部分信息



-------------------------------------------------
修改时间:2005-3-9
修改人:  宋雷
修改内容:将对话框以RGB(227,234,206)色填充,并增加
*************************************************/
void CModule1Dlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect	rect;
	this->GetClientRect(&rect);
	CBrush	*pBrush = new CBrush(COLORREF(RGB(227,234,206)));
	dc.FillRect(rect,pBrush);	
	dc.SetBkColor(COLORREF(RGB(227,234,206)));
	dc.DrawText(L"个人帐户中心",CRect(0,0,100,20),NULL);
	CString	str;
	str.Format(L"按人民币合计:%d",g_iSum);
	//m_ctrAccountList.GetClientRect(&rect);
	dc.DrawText(str,CRect(100,190,240,210),NULL);
	
	// Do not call CDialog::OnPaint() for painting messages
}
/*************************************************
函数功能:增加帐户



-------------------------------------------------
修改时间:2005-3-9
修改人:  宋雷
修改内容:显示增加对话框,显示选择现金的对话框,只是模拟操作,并没有实际增加

修改时间:2005-3-10
修改人:  宋雷
修改内容:完成了对INI和文件的增加

ModifyDate 2005-3-15
Modifier   Tony
Content    Add Asset to menu
*************************************************/
void CModule1Dlg::OnAdd()
{
	int	iType;
	CString	str,str2;
	CString	tmpStr;
	CSection tmpSec,tmpSec2;


	if(m_ChooseDlg.DoModal()==IDOK)
	{
		iType = m_ChooseDlg.m_iRadioType ;
		if(iType == 0)
		{
			if(m_MakeDlg.DoModal()==IDOK)
			{
				//str.Format(L"现金帐户名为%s,币种为%s,金额为%d",m_MakeDlg.m_strCashName,m_MakeDlg.m_strMoneyType,m_MakeDlg.m_iCashAmount);
		
				//以下代码生成以帐户名称为文件名的INI文件
				str2 = m_MakeDlg.m_strCashName +".ini";

				//For Test add by Tony
				//str2 = "\\Program Files\\理财能手\\Data\\"+str2;
				m_pAccountIni = new CIniReader(str2);

				tmpSec.m_SectionName = "Info";
				CString  strtmp;
				strtmp.Format(L"%d",m_MakeDlg.m_iCashAmount);
				m_pAccountIni->AddPair(L"name",m_MakeDlg.m_strCashName,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"amount",strtmp,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"date",m_MakeDlg.m_strCashBeginTime,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"money_type",m_MakeDlg.m_strMoneyType,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"type",L"现金",tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"deal_count",L"0",tmpSec.m_SectionName);
				m_pAccountIni->Store();
				//以下代码将新生成的帐户信息加到已有的 帐户.ini 中
				tmpSec2.m_SectionName.Format(L"%d",MAX_ACCOUNT);
				MAX_ACCOUNT++;
				tmpStr.Format(L"%d",MAX_ACCOUNT);
				m_pAccountIni2->AddPair(L"account_count",tmpStr,L"Info"); //将帐户数自增1
				m_pAccountIni2->AddPair(L"name",m_MakeDlg.m_strCashName,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"amount",strtmp,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"date",m_MakeDlg.m_strCashBeginTime,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"money_type",m_MakeDlg.m_strMoneyType,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"type",L"现金",tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"deal_count",L"0",tmpSec2.m_SectionName);
				m_pAccountIni2->Store();

				
			}
		}

		else if(iType == 1)  //选择存款
			{
				if(m_SavingDlg.DoModal()==IDOK)
				{
					//str.Format(L"现金帐户名为%s,币种为%s,金额为%d",m_MakeDlg.m_strCashName,m_MakeDlg.m_strMoneyType,m_MakeDlg.m_iCashAmount);
			
					//以下代码生成以帐户名称为文件名的INI文件
					str2 = m_SavingDlg.m_strSavingName +".ini";


						//For Test add by Tony
					//str2 = "\\Program Files\\理财能手\\Data\\"+str2;
					m_pAccountIni = new CIniReader(str2);
					tmpSec.m_SectionName = "Info";
					CString  strtmp;
					strtmp.Format(L"%d",m_SavingDlg.m_iSavingAmount);
					m_pAccountIni->AddPair(L"name",m_SavingDlg.m_strSavingName,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"amount",strtmp,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"date",m_SavingDlg.m_strSavingBeginTime,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"money_type",m_SavingDlg.m_strMoneyType,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"type",L"存款",tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"deal_count",L"0",tmpSec.m_SectionName);
					m_pAccountIni->Store();
					//以下代码将新生成的帐户信息加到已有的 帐户.ini 中
					tmpSec2.m_SectionName.Format(L"%d",MAX_ACCOUNT);
					MAX_ACCOUNT++;
					tmpStr.Format(L"%d",MAX_ACCOUNT);
					m_pAccountIni2->AddPair(L"account_count",tmpStr,L"Info"); //将帐户数自增1
					m_pAccountIni2->AddPair(L"name",m_SavingDlg.m_strSavingName,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"amount",strtmp,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"date",m_SavingDlg.m_strSavingBeginTime,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"money_type",m_SavingDlg.m_strMoneyType,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"type",L"存款",tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"deal_count",L"0",tmpSec2.m_SectionName);
					m_pAccountIni2->Store();
			
				}
			}


		
		else if(iType == 3)  //选择证券
			{
				if(m_SavingDlg.DoModal()==IDOK)
				{
					//str.Format(L"现金帐户名为%s,币种为%s,金额为%d",m_MakeDlg.m_strCashName,m_MakeDlg.m_strMoneyType,m_MakeDlg.m_iCashAmount);
			
					//以下代码生成以帐户名称为文件名的INI文件


					str2 = m_SavingDlg.m_strSavingName +".ini";

						//For Test add by Tony
					//str2 = "\\Program Files\\理财能手\\Data\\"+str2;
					m_pAccountIni = new CIniReader(str2);
					tmpSec.m_SectionName = "Info";
					CString  strtmp;
					strtmp.Format(L"%d",m_SavingDlg.m_iSavingAmount);
					m_pAccountIni->AddPair(L"name",m_SavingDlg.m_strSavingName,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"amount",strtmp,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"date",m_SavingDlg.m_strSavingBeginTime,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"money_type",m_SavingDlg.m_strMoneyType,tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"type",L"存款",tmpSec.m_SectionName);
					m_pAccountIni->AddPair(L"deal_count",L"0",tmpSec.m_SectionName);
					m_pAccountIni->Store();
					//以下代码将新生成的帐户信息加到已有的 帐户.ini 中
					tmpSec2.m_SectionName.Format(L"%d",MAX_ACCOUNT);
					MAX_ACCOUNT++;
					tmpStr.Format(L"%d",MAX_ACCOUNT);
					m_pAccountIni2->AddPair(L"account_count",tmpStr,L"Info"); //将帐户数自增1
					m_pAccountIni2->AddPair(L"name",m_SavingDlg.m_strSavingName,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"amount",strtmp,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"date",m_SavingDlg.m_strSavingBeginTime,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"money_type",m_SavingDlg.m_strMoneyType,tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"type",L"存款",tmpSec2.m_SectionName);
					m_pAccountIni2->AddPair(L"deal_count",L"0",tmpSec2.m_SectionName);
					m_pAccountIni2->Store();
			
				}
			}

		else if(iType == 4) //选择物品
		{
			if(m_MakeGoodsDlg.DoModal()==IDOK)
			{
				//str.Format(L"现金帐户名为%s,币种为%s,金额为%d",m_MakeDlg.m_strCashName,m_MakeDlg.m_strMoneyType,m_MakeDlg.m_iCashAmount);
		
				//以下代码生成以帐户名称为文件名的INI文件
				str2 = m_MakeGoodsDlg.m_strGoodsName +".ini";

					//For Test add by Tony
			//	str2 = "\\Program Files\\理财能手\\Data\\"+str2;
				m_pAccountIni = new CIniReader(str2);
				tmpSec.m_SectionName = "Info";
				CString  strtmp;
				strtmp.Format(L"%d",m_MakeGoodsDlg.m_iAmount);
				m_pAccountIni->AddPair(L"name",m_MakeGoodsDlg.m_strGoodsName,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"amount",strtmp,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"date",m_MakeGoodsDlg.m_strGoodsBeginTime,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"money_type",m_MakeGoodsDlg.m_strMoneyType,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"type",L"物品",tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"deal_count",L"0",tmpSec.m_SectionName);
				m_pAccountIni->Store();
				//以下代码将新生成的帐户信息加到已有的 帐户.ini 中
				tmpSec2.m_SectionName.Format(L"%d",MAX_ACCOUNT);
				MAX_ACCOUNT++;
				tmpStr.Format(L"%d",MAX_ACCOUNT);
				m_pAccountIni2->AddPair(L"account_count",tmpStr,L"Info"); //将帐户数自增1
				m_pAccountIni2->AddPair(L"name",m_MakeGoodsDlg.m_strGoodsName,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"amount",strtmp,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"date",m_MakeGoodsDlg.m_strGoodsBeginTime,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"money_type",m_MakeGoodsDlg.m_strMoneyType,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"type",L"物品",tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"deal_count",L"0",tmpSec2.m_SectionName);
				m_pAccountIni2->Store();

				
			}
		}

		else if(iType == 5) //选择债务
		{
			if(m_MakeAssetDlg.DoModal()==IDOK)
			{
				//str.Format(L"现金帐户名为%s,币种为%s,金额为%d",m_MakeDlg.m_strCashName,m_MakeDlg.m_strMoneyType,m_MakeDlg.m_iCashAmount);
		
				//以下代码生成以帐户名称为文件名的INI文件
				str2 = m_MakeAssetDlg.m_strAssetName +".ini";

					//For Test add by Tony
			//	str2 = "\\Program Files\\理财能手\\Data\\"+str2;
				m_pAccountIni = new CIniReader(str2);
				tmpSec.m_SectionName = "Info";
				CString  strtmp;
				strtmp.Format(L"%d",m_MakeAssetDlg.m_iAssetAmount);
				m_pAccountIni->AddPair(L"name",m_MakeAssetDlg.m_strAssetName,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"amount",strtmp,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"date",m_MakeAssetDlg.m_strAssetBeginTime,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"money_type",m_MakeAssetDlg.m_strMoneyType,tmpSec.m_SectionName);
				m_pAccountIni->AddPair(L"type",L"债权债务",tmpSec.m_SectionName);

⌨️ 快捷键说明

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