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

📄 module1dlg.cpp

📁 该项目是为PPC(PocketPc)使用者提供方便的理财事务.如,现金的借贷,债务处理,证券买卖,以及物品管 理等等。该项目的主要用户群是:PPC使用者.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				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_MakeAssetDlg.m_strAssetName,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"amount",strtmp,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"date",m_MakeAssetDlg.m_strAssetBeginTime,tmpSec2.m_SectionName);
				m_pAccountIni2->AddPair(L"money_type",m_MakeAssetDlg.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
			return;
		Init();
	}	
	else
		return;
	
	
	
}
/*************************************************
函数功能:对选定帐户,进行删除

-------------------------------------------------
修改时间:2005-3-9
修改人:  宋雷
修改内容:只是模拟操作,并没有实际删除

修改时间:2005-3-10
修改人:  宋雷
修改内容:完成了对INI和文件的删除
备注:删除一个帐户是一个很重大的决定,因为该帐户的所有交易将同时被删除
*************************************************/

void CModule1Dlg::OnDelete() 
{	
	if(::MessageBox(NULL,L"注意,你将删除一个帐户,该帐户的所有交易将同时被删除!",L"警告!",MB_OKCANCEL) != IDOK )
		return ;
	POSITION	pos;
	pos = m_ctrAccountList.GetFirstSelectedItemPosition();

	int Select= m_ctrAccountList.GetNextSelectedItem(pos);
	//如果双击空白处
	if(Select==-1)
		return;



	CIniReader * pAccounttmp; //临时变量,用来LOAD 帐户.ini

//	pAccounttmp = new CIniReader(L"\\Program Files\\理财能手\\Data\\帐户.ini");
	pAccounttmp = new CIniReader(L"帐户.ini");	

	//装载和解析INI文件
	if(! pAccounttmp->Load())
	{
		::AfxMessageBox(L"Can not load ini");
		delete pAccounttmp;
		pAccounttmp = NULL;
		return ;
	}

	if(! pAccounttmp->Parse())
	{
		::AfxMessageBox(L"Invalid format ini");
		delete pAccounttmp;
		pAccounttmp = NULL;
		return ;
	}
	for(int i=1;i<pAccounttmp->m_Sections.GetSize();i++)
	{
		CString value;
		pAccounttmp->m_Sections[i].m_item.Lookup(L"name",value);
		if(value==m_ctrAccountList.GetItemText(Select,0))
		{
			pAccounttmp->m_Sections.RemoveAt(i);
			if(i<MAX_ACCOUNT) //不是删除最后一项
			{
				CString tmp;
				//AfxMessageBox(L"不是删除最后一项");
				for(int j=i;j<MAX_ACCOUNT+1;j++)
				{
					tmp.Format(L"%d",j-1);
					pAccounttmp->m_Sections[j].m_SectionName = tmp;
				}
			}
		//else
			//	AfxMessageBox(L"删除最后一项");
			MAX_ACCOUNT--;
		}

	}
	CString tmpStr;
	tmpStr.Format(L"%d",MAX_ACCOUNT);
	pAccounttmp->AddPair(L"account_count",tmpStr,L"Info"); //将帐户数自减1
	pAccounttmp->Store();
	//同时删除同名文件
	CString  filename = m_ctrAccountList.GetItemText(Select,0)+".ini";
	
    CFile::Remove( filename );
	AfxMessageBox(L"删除了文件");
	//初始化列表
	Init();

}
/*************************************************
函数功能:对选定帐户,进行修改

-------------------------------------------------
修改时间:2005-3-9
修改人:  宋雷
修改内容:只是模拟操作,并没有实际修改
*************************************************/
void CModule1Dlg::OnModify()
{
	POSITION	pos;
	pos = m_ctrAccountList.GetFirstSelectedItemPosition();

	int Select= m_ctrAccountList.GetNextSelectedItem(pos);
	//如果双击空白处
	if(Select==-1)
		return;
	CString	Info;

	Info = L"将要修改";
	Info+= m_ctrAccountList.GetItemText(Select,0);
	
	//((CMoneyAnyWhereView*)m_pPa rent)->DisplayDlgCash();
	AfxMessageBox(Info);	

}



/*************************************************
函数功能:在程序退出时的一些处理

-------------------------------------------------
修改时间:2005-3-6
修改人:  宋雷
修改内容:对指针变量进行一下处理

*************************************************/

void CModule1Dlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	if(m_pAccountIni)
	{
		delete m_pAccountIni;
	}
	if(m_pAccountIni2)
	{
		delete m_pAccountIni2;
	}		
}
/*************************************************
函数功能:根据帐户INI信息中的key 和 value

-------------------------------------------------
修改时间:2005-3-10
修改人:  宋雷
修改内容:根据key把value的信息填充到成员变量pAccount中。
备注:删除一个帐户是一个很重大的决定,因为该帐户的所有交易将同时被删除,需要提醒用户!!
*************************************************/
void CModule1Dlg::SetAccount(CString key,CString value)
{
	if(key=="name")
		pAccount->Account_Name = value;
	else
		if(key=="money_type")
			pAccount->Account_MoneyType = value;
	else
		if(key=="date")
			pAccount->Account_Date = value;
	else
		if(key=="amount")
		{
			pAccount->Account_Amount= value;
			int amount=_wtoi(value);
			g_iSum +=amount ;
		}
	else
		if(key=="type")
			pAccount->Account_Type = value;
}
/*************************************************
函数功能:响应用户对列表中某行的双击事件

-------------------------------------------------
修改时间:2005-3-6
修改人:  宋雷
修改内容:根据key把value的信息填充到成员变量pAccount中。
*************************************************/
void CModule1Dlg::OnDblclkListCash(NMHDR* pNMHDR, LRESULT* pResult) 
{
	
	POSITION	pos;
	pos = m_ctrAccountList.GetFirstSelectedItemPosition();

	int Select= m_ctrAccountList.GetNextSelectedItem(pos);
	//如果单击空白处
	if(Select==-1)
		return;
	//测试一下
	CString	str,Info;
	str.Format(L"%d",Select );
	Info = L"You Choose the "+str;
	Info+= m_ctrAccountList.GetItemText(Select,0);
	Info+= m_ctrAccountList.GetItemText(Select,1);
	Info+= m_ctrAccountList.GetItemText(Select,2);
	//AfxMessageBox(m_ctrAccountList.GetItemText(Select,0));
	//跳转,同时将该列的信息传过去
	if(m_ctrAccountList.GetItemText(Select,1) == L"现金")  //modify by Tony
		((CMoneyAnyWhereView*)m_pParent)->DisplayDlgCash(m_ctrAccountList.GetItemText(Select,0));
	else if(m_ctrAccountList.GetItemText(Select,1) == L"债权债务")
		((CMoneyAnyWhereView*)m_pParent)->DisplayDlgAsset(m_ctrAccountList.GetItemText(Select,0));
	else if(m_ctrAccountList.GetItemText(Select,1) == L"存款")
		((CMoneyAnyWhereView*)m_pParent)->DisplayDlgSaving(m_ctrAccountList.GetItemText(Select,0));
	else if(m_ctrAccountList.GetItemText(Select,1) == L"证券")
		((CMoneyAnyWhereView*)m_pParent)->DisplayDlgStock(m_ctrAccountList.GetItemText(Select,0));
	else if(m_ctrAccountList.GetItemText(Select,1) == L"物品")
		((CMoneyAnyWhereView*)m_pParent)->DisplayDlgGoods(m_ctrAccountList.GetItemText(Select,0));
	

	*pResult = 0;
}
/*************************************************
函数功能:初始化INI文件

-------------------------------------------------
修改时间:2005-3-10
修改人:  宋雷
修改内容:m_pAccountIni和m_pAccountIni2的初始化,同时将信息增加到列表中

*************************************************/
BOOL CModule1Dlg::Init()
{
	m_ctrAccountList.DeleteAllItems();	
//	m_pAccountIni  = new CIniReader(L"\\Program Files\\理财能手\\Data\\帐户.ini");
//	m_pAccountIni2 = new CIniReader(L"\\Program Files\\理财能手\\Data\\帐户.ini");

	m_pAccountIni  = new CIniReader(L"帐户.ini");
	m_pAccountIni2 = new CIniReader(L"帐户.ini");
	pAccount = new CAccount();



	//装载和解析INI文件
	if(! m_pAccountIni2->Load())
	{
		::AfxMessageBox(L"Can not load ini");
		delete m_pAccountIni2;
		m_pAccountIni2 = NULL;
		return FALSE;
	}
	
	if(! m_pAccountIni2->Parse())
	{
		::AfxMessageBox(L"Invalid format  ");
		delete m_pAccountIni2;
		m_pAccountIni2 = NULL;
		return FALSE;
	}
	CSection	AccountInfo= (*m_pAccountIni2)[L"Info"];
	POSITION _pos = AccountInfo.m_item.GetStartPosition();

	while( _pos != NULL)
	{
		String _key;
		String _value;

		AccountInfo.m_item.GetNextAssoc(_pos, _key, _value);
		if((CString)_key==(CString)"account_count") //获得该现金帐户一共有多少笔交易
		{
			MAX_ACCOUNT = _wtoi(_value);
		}	
	}


	//CSection Info[MAX_ACCOUNT];
	//装载和解析INI文件
	if(! m_pAccountIni->Load())
	{
		::AfxMessageBox(L"Can not load Account.ini");
		delete m_pAccountIni;
		m_pAccountIni = NULL;
		return FALSE;
	}

	if(! m_pAccountIni->Parse())
	{
		::AfxMessageBox(L"Invalid format :Account.ini");
		delete m_pAccountIni;
		m_pAccountIni = NULL;
		return FALSE;
	}
	//AfxMessageBox(m_pAccountIni->GetFilePath());

	for(int i=0;i<MAX_ACCOUNT;i++)
	{
		CString	str;
		str.Format(L"%d",i);
		CSection	Info= (*m_pAccountIni)[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);
			//AfxMessageBox((CString)key);
			SetAccount((CString)key,(CString)value);
			
		}
		m_ctrAccountList.AddItem(pAccount->Account_Name,pAccount->Account_Type,pAccount->Account_MoneyType,pAccount->Account_Amount);
	}

}

⌨️ 快捷键说明

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