📄 financing_master_handdoc.cpp
字号:
// Financing_Master_HandDoc.cpp : implementation of the CFinancing_Master_HandDoc class
//
#include "stdafx.h"
#include "Financing_Master_Hand.h"
#include "Financing_Master_HandView.h" //要包含此头文件,在串行化函数中要用
#include "Financing_Master_HandDoc.h"
#include "AccountManagement.h" //包含帐号管理类
#include <wchar.h>
#include <stdlib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandDoc
IMPLEMENT_DYNCREATE(CFinancing_Master_HandDoc, CDocument)
BEGIN_MESSAGE_MAP(CFinancing_Master_HandDoc, CDocument)
//{{AFX_MSG_MAP(CFinancing_Master_HandDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandDoc construction/destruction
CFinancing_Master_HandDoc::CFinancing_Master_HandDoc()
{
// TODO: add one-time construction code here
m_nTypeFlag = 0; //初始化文件类型
}
CFinancing_Master_HandDoc::~CFinancing_Master_HandDoc()
{
}
BOOL CFinancing_Master_HandDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandDoc serialization
void CFinancing_Master_HandDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
CFinancing_Master_HandApp *TheApp=(CFinancing_Master_HandApp*)AfxGetApp();
int i,n;
CString s;
float money;
switch(m_nTypeFlag)
{
case 1:
CAccountManagement * pAnotherView;
pAnotherView =(CAccountManagement *) TheApp->m_pAnotherView;
n = pAnotherView->m_nAccountNum;
ar<<n;
for(i=0;i<n;i++)
{
s=pAnotherView->GetListCtrl().GetItemText(i,0); //帐号
ar<<s;
// AfxMessageBox(_T("account=")+s);
s=pAnotherView->GetListCtrl().GetItemText(i,1); //户主姓名
ar<<s;
// AfxMessageBox(_T("name=")+s);
s=pAnotherView->GetListCtrl().GetItemText(i,2); //余额
money = (float)wcstod(s,NULL);
// AfxMessageBox(_T("remainMoney=")+s);
ar<<money;
s=pAnotherView->GetListCtrl().GetItemText(i,3); //开户日期
// AfxMessageBox(_T("Date=")+s);
ar<<s;
s=pAnotherView->GetListCtrl().GetItemText(i,4); //备注
// AfxMessageBox(_T("remark=")+s);
ar<<s;
s=pAnotherView->GetListCtrl().GetItemText(i,5);
// AfxMessageBox(_T("type=")+s);
if(s=="In/Outcome") //收入支出类型
{
// AfxMessageBox(_T("type=")+s);
ar<<2;
}
else if(s=="Invest")
ar<<3; //投资管理
else if(s=="Loan") //借贷管理
ar<<4;
else ar<<5; //证券管理
}//end for
break;
case 2:
CFinancing_Master_HandView * pFirstView;
pFirstView = (CFinancing_Master_HandView*)TheApp->m_pFirstView;
ar<<pFirstView->m_nNum<<pFirstView->m_fAllMoney;
n = pFirstView->m_nNum;
for(i=0;i<n;i++)
{
s=pFirstView->GetListCtrl().GetItemText(i,0); //相关帐号
ar<<s;
s=pFirstView->GetListCtrl().GetItemText(i,1); //记录日期
ar<<s;
s=pFirstView->GetListCtrl().GetItemText(i,2);
if(s=="") //支出
{
ar<<TRUE;
s=pFirstView->GetListCtrl().GetItemText(i,3);
AfxMessageBox(_T("store outcome ")+s);
//s.Format(_T("%.2f"),money);
money =(float) wcstod(s,NULL);
ar<<money;
}
else //收入
{
ar<<FALSE;
AfxMessageBox(_T("store income ")+s);
//s.Format(_T("%.2f"),money);
money =(float) wcstod(s,NULL);
ar<<money;
s=pFirstView->GetListCtrl().GetItemText(i,3);
}
s=pFirstView->GetListCtrl().GetItemText(i,4);
//s.Format(_T("%2f"),money); //rmainMoney
money =(float) wcstod(s,NULL);
ar<<money;
s=pFirstView->GetListCtrl().GetItemText(i,5);
ar<<s;
}
break;
default:
return; //是否正确在此return
}//end switch
}
else
{
// TODO: add loading code here
CFinancing_Master_HandApp *TheApp=(CFinancing_Master_HandApp*)AfxGetApp();
int i,n;
CAccounts temp;
CString s;
switch(m_nTypeFlag)
{
case 1: //并行化 帐号信息
CAccountManagement * pAnotherView;
pAnotherView =(CAccountManagement *) TheApp->m_pAnotherView;
ar>>n;
pAnotherView->m_nAccountNum=n;
for(i=0;i<n;i++)
{
ar>>temp.m_account.m_sAccount>>temp.m_account.m_sName
>>temp.m_account.m_fRemainMoney>>temp.m_account.m_sDate
>>temp.m_account.m_sRemark>>temp.m_nNum;
pAnotherView->addItem(i,temp);
}
break;
case 2: //并行化 收入支出信息
CFinancing_Master_HandView * pFirstView;
pFirstView = (CFinancing_Master_HandView*)(TheApp->m_pFirstView);
ar>>pFirstView->m_nNum>>pFirstView->m_fAllMoney;
n = pFirstView->m_nNum;
for(i=0;i<n;i++)
{
ar>>pFirstView->m_sAccount>>pFirstView->m_sDate>>pFirstView->m_bFlag
>>pFirstView->m_fMoney>>pFirstView->m_fRemainMoney>>pFirstView->m_sRemark;
pFirstView->GetListCtrl().InsertItem(i,(LPCTSTR)pFirstView->m_sAccount,i);
pFirstView->GetListCtrl().SetItemText(i,1,(LPCTSTR)pFirstView->m_sDate);
if(pFirstView->m_bFlag)
{
pFirstView->GetListCtrl().SetItemText(i,2,(LPCTSTR)_T(""));
s.Format(_T("%.2f"),pFirstView->m_fMoney);
// AfxMessageBox(_T("load outcome ")+s); //
pFirstView->GetListCtrl().SetItemText(i,3,(LPCTSTR)s);
}
else
{
s.Format(_T("%.2f"),pFirstView->m_fMoney);
// AfxMessageBox(_T("load income ")+s); //
pFirstView->GetListCtrl().SetItemText(i,2,(LPCTSTR)s);
pFirstView->GetListCtrl().SetItemText(i,3,(LPCTSTR)_T(""));
}
s.Format(_T("%.2f"),pFirstView->m_fRemainMoney);
pFirstView->GetListCtrl().SetItemText(i,4,(LPCTSTR)s);
pFirstView->GetListCtrl().SetItemText(i,5,(LPCTSTR)pFirstView->m_sRemark);
}
break;
default:
return; //在此return是否正确?
} //end switch
}
}
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandDoc diagnostics
#ifdef _DEBUG
void CFinancing_Master_HandDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CFinancing_Master_HandDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandDoc commands
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -